Index: stringscan.rb ================================================================== --- stringscan.rb +++ stringscan.rb @@ -76,13 +76,17 @@ Tk.tk_call('regproc::readLic', $appname, $appversion) end #core method; here we search for a string in text files within a directory and display a list of matching files in the listbox def stringgrep + $root.update $file_list = [] $grep_list = [] + $p.start + $bottomlabel.configure('text' => "Searching for \"#{$searchterm}\" in #{$dirname}") $lbox.delete(0, 'end') + $root.update Find.find("#{$dirname}") do |path| $file_list << path unless FileTest.directory?(path) end for i in $file_list begin @@ -98,10 +102,14 @@ end end rescue #puts "Search term not found.\n" end + $p.stop + $grep_list = $lbox.get(0, 'end') + num = $grep_list.count.to_s + $bottomlabel.configure('text' => "Found #{num} matches for \"#{$searchterm}\" in #{$dirname}") end rescue puts "Directory not found.\n" puts "Search complete.\n" end @@ -230,11 +238,15 @@ selectbackground "RoyalBlue1" selectforeground "white" dnd_bindtarget('text/uri-list', '', '%D') {|d| filename=d.join(' ') begin - if File.directory?(filename) + if File.directory?(filename) + $tbox.configure('state'=>'normal') + $tbox.delete('1.0', 'end') + $tbox.configure('state'=>'disabled') + $lbox.delete(0, 'end') $dirname = filename $direntry.value = filename end rescue raise @@ -269,22 +281,22 @@ $tbox.yscrollbar($tscroll) $labelframe = Tk::Tile::Frame.new($root).pack('side'=>'bottom', 'fill'=>'both', 'expand' => 'no') $bottomlabel = Tk::Tile::Label.new($labelframe) {text "No data displayed"}.pack('side' => 'left','fill' => 'both','expand' => 'no') + $p = Tk::Tile::Progressbar.new($labelframe) {orient 'horizontal'; length 200; mode 'indeterminate'}.pack('side' => 'left','fill' => 'both','expand' => 'no') $bottomsep = Tk::Tile::Separator.new($root) { orient 'horizontal' }.pack('side'=> 'bottom', 'fill'=>'both') -#p = Tk::Tile::Progressbar.new(parent) {orient 'horizontal'; length 200; mode 'determinate'} - -#Searching for $searchterm in $dirname - - $root.bind("#{$accelkey}-Q", proc{exit}) + $root.bind("#{$accelkey}-Q", proc{exit}) $root.bind("#{$accelkey}-q", proc{exit}) $root.bind("#{$accelkey}-O", proc{choosedir}) $root.bind("#{$accelkey}-o", proc{choosedir}) $root.bind("#{$accelkey}-R", proc{stringgrep}) $root.bind("#{$accelkey}-r", proc{stringgrep}) + + $lbox.focus + end #select search directory def choosedir @@ -322,10 +334,11 @@ $tbox.tag_add('search', cur, "#{cur} + #{len} char") cur = $tbox.index("#{cur} + #{len} char") } $tbox.configure('state'=>'disabled') end + #about window for app def aboutWindow Tk::messageBox :type => 'ok', :message => 'Stringscan: Text Search Tool', :icon => 'info', :title => 'About Stringscan',