Stringscan

Check-in [c7f9249bd0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Code cleanup
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:c7f9249bd0353180c3868f485105da556361373d79ab0c7ce0b81c7c74f28fcc
User & Date: kevin 2017-09-18 02:25:10
Context
2017-09-19
03:13
Update file for 1.1 check-in: d9d50ad502 user: kevin tags: trunk
2017-09-18
02:25
Code cleanup check-in: c7f9249bd0 user: kevin tags: trunk
02:17
More tweaks for version 1.1 check-in: 3d2ce95654 user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to stringscan.rb.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
require 'mime/types'
require 'tkextlib/tkDND'
require 'tkextlib/tkimg'

$platform = Tk.windowingsystem

if $platform == 'aqua'
	TkPackage.require('windowlist')
	TkPackage.require('fullscreen')
	require 'tk/tk_mac'
end
TkPackage.require('regproc')
TkPackage.require('machelp')
TkPackage.require('softwareupdate')
TkPackage.require('xplat')

if $platform == 'aqua'
	$accelkey = 'Command'
else 
	$accelkey = 'Control'
end


class StringscanApp

#here we initialize our app class
def initialize

	$dirname = ""
	$searchterm = ""
	$appname = 'Stringscan'
	$appversion = '1.0'
	Tk.tk_call('machelp::setAppName', $appname, $appversion)
	Tk.tk_call('softwareupdate::setAppName', $appname)
	Tk.tk_call('softwareupdate::setVersion', $appname, $appversion)

	bgerror = Tk.install_cmd(proc{
		|*args|
		puts args
	})
	Tk.ip_eval("proc bgerror {args} {#{bgerror} $args}")

	if $platform == 'aqua'
		##map ruby proc to "odoc" Apple Event
		setDir = Tk.install_cmd(proc{
			|*args|
			filename=(args[0]).delete('{}')
			begin
			        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
			end
		})    
		Tk.ip_eval("proc ::tk::mac::OpenDocument {args} {#{setDir} $args}")
		Tk.ip_eval("proc ::tk::mac::ShowHelp {} {#{Tk.install_cmd(proc{showHelp})}}")
	end        
	drawgui
	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
		#we are only reading text files here, not binary. 
		text =  MIME::Types.type_for(i).first.to_s
		type =  text.split('/')[0]
		if type  =~ /text/
			f = File.open(i, "r:iso-8859-1:utf-8")
			result = f.read
			if result =~ /#{$searchterm}/ then
				$lbox.insert('end', "#{i}")
				f.close
			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

def drawgui 
	begin
		Tk.ip_eval("console hide")
	rescue
		puts "could not hide console.\n"
	end

	#image data
	$folderdata = 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAAADFBMVEUEBwcEBwcEBwcEBwcNzGmPAAAAAXRSTlMAQObYZgAAAC1JREFUeAFjYEYABgQgXRhCowAyhNEAfmFMQFiYsJX0F6aa5xmxiTIygMQxRQEtWAMvBVlMnAAAAABJRU5ErkJggg=='

	$glassdata = 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AcSAg8sJGRWZAAAAXhJREFUOMutlL9LQlEUxz+WGRHllGNEPyAUWnLWsVYhXNpd+ldC6B/QPyDnoMXNtbnFIRAarLAn+bDU13IuHC/vPm/agQuXy/d93veec+4Bv9gGKkAbGAORrAHQBPLAOn+MAtBVMNdqARlfaEk+minAJ/AOvAEjC973gWeAnvpoCNSAfWAX2AKKQN36eWtRWhoK+grkErRXlvO8S7hjuah6pK2uwE2X6BKYiujFsx5FlfPBmkO0B6Rkf+8JfgZC2Wdd4EjtNzzBcwVzgccKfuIJzgJp2X+7RIfAjyrGkQe4pvTtpIcxUcLOgt7MSZ8bfcUFDWOebMfhvCp9btqzK7NlLspW/36ptjPrAbgDbqUVbQOFOKh++wFwLfCk4WNM9OS2scPGrA/gQODmbCIFnQpspm7TsIdPWqCPIkgJ9AZ4Uk97DFyIq3NgU7R9yf0wrliB5fZMxqI+K7FEnIpLe+5GkvMyK8SxoyArQTXcOA+XvX5SWoL/gP4Cdj2n/+OJ36AAAAAASUVORK5CYII='

	$folderimage = TkPhotoImage.new(:data => $folderdata)
	$glassimage = TkPhotoImage.new(:data => $glassdata)

	$icondata = 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAABuvAAAbrwFeGpEcAAAAB3RJTUUH4QcKAhkVOQjHbgAAF1lJREFUeNrNW2l0nNV5fu693zL7opE02uUVLNuSN1kKJhBTKBgTl5QU6pICLQ3tSU+a07RpFuD0pIHDadOVpElP6iyHkzQlKacQ0gCNjUkBEyzkbYwsC9uyFo+kGc2m2edb7u2PmZFGsjZkZbnn3HNn+ea7933uc9/7vO/9hmAZpaNzNwK971S87wKAKgBeAE4ADUKIjQJYAyGaANQKgWpAeADYAVgByAAEgAKADIAECIkQIAhgiBBynhByDkAUQCTQ2xOt7C/Q24NfRCGLGz7TcUdnlwzgnlLtFEI4OOd2zrmNc0GsVguqfVXwej3wuN1wOh1w2OywWG1QVRmSxCAEYBgG8vkCstkskqkU4rE4JiNRTITDKBQ0UEbzjNIkpXQSwPMAvhro7QkDwLbdXTjzTs8vFYAdAPZyLj4mBN8lSRJcTgecTieqfVVoamxAQ10d/H4/nA47uODQNQOGacA0TZimCc4FAAEhBAACSgkopWCMQWIMkixDURQwShGNxTE8OoJLl4YwOjaGeDyOZDINQvA2pfQfABwN9PbEV5MRZBHjGwAMcs7V1uZGbGvfipbmZiiqAouqQpZlTE1NIRKNIBaLIR6PIZ/PQwgBzjmEENMVQkAAIKTYHSFkulJKQQiBzWZDTU0t6uvqUF/fANMUyOWzCIcn8X9vHMPFwSHIshQB8Gigt+fQL5wBHZ1drQAu33n7rWTr5jak0mmkkknEEzFEo1H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O1d4+eWXC9lsVlSKsJtvvvmO+vr6H37sYx9DMBiE0+mEqqoIhUJIp9Pw+/14/vnnE9lsdteRI0cGf1UMIBVB1Lz14Ycftn/0ox9tWrNmzVq3292sqmq9LMteANQwjFQulwtPTU0Fh4eHh1555ZUrhw4dSuTzeQ4g193dffP69eufufvuu33ZbBaUUlgsxThhx44dEELg0UcfvfDcc89dd60AsGswnlW0sxSj3W6XHnrooboNGzasc7vd62w220aLxbJJVdUtsiyvJYQ4ACimaZLS/wuN06dPZ6ampggAORgMjmua9l8jIyMPbd++XS4/Ntfd3Q0AsFqtOH36tE9V1W+MjIykf9m7AF2E+gQAzWQy5POf/3zonnvuye/evXu8paXlvMvl8iqKYhNCsFwup8VisfTo6Gj0zJkz0cOHDyfGx8dFhd8wBwYGQolEYgsh5Af79u3ramtrm378jhACTdPQ398fm5vh+WUAwEsD5RWM4HMYIlKpFJ555pn4M888kwRweQ5Yc50jn6PiOACEQqH0T37yk1sNw3jR5XLdsm7dumJ0evYsRkdHvxqJRLRf5S5Al6hkAaPJPLGHqAB3FiCEECGEyO/Zs+fPtm7d+ruMMXb27NnnU6nU3zHGjJMnTwr8ikvZD8gAFAAWFJ8Ot5eqE8UHmN2l6pmnukvXuAA4Sr+zle6jlu47y18dPHjw108IzRM4YZ5Ey6ylskCmZq7O/4XN8v8D9yIPOOfsZU4AAAAASUVORK5CYII='
	$icon = TkPhotoImage.new(:data => $icondata)
	
	#initialize variables for entry
	$dirname = TkVariable.new
	$searchterm = TkVariable.new
	
	#top window and frame
	Tk::TkDND::DND
	$root = TkRoot.new {
		title "Stringscan"
	}
	
	$root.iconphoto_default($icon)
	
	if $platform == 'aqua'
		Tk.tk_call('fullscreen::fullscreen', $root)
	end
	
	#menu
	$menubar = TkMenu.new($root)
	TkOption.add '*tearOff', 0
	if $platform == 'aqua'
		$appmenu = TkSysMenu_Apple.new($menubar)
		$menubar.add :cascade, :menu => $appmenu
		$appmenu.add :command, :label => 'About Stringscan', :command=> proc{aboutWindow}
		$appmenu.add :command, :label => 'License', :command=>proc{getReg}
		$appmenu.add :command, :label=>'Check for Updates', :command=>proc{checkUpdate}
		$appmenu.add :separator
	end
	$searchmenu = TkMenu.new($menubar)
	$menubar.add :cascade, :menu => $searchmenu, :label => 'Search'
	$searchmenu.add :command, :label => 'Choose Directory...', 'accelerator' => "#{$accelkey}+O", :command => proc{choosedir}
	$searchmenu.add :command, :label => 'Run Search', 'accelerator' => "#{$accelkey}+R", :command => proc{stringgrep}
	if $platform == 'win32'
		$searchmenu.add :command, :label => "Exit", :command=>proc{exit}, 'accelerator' => "#{$accelkey}+Q"
	end
	if $platform == 'aqua'
		Tk.tk_call("windowlist::windowMenu",  $menubar)
	end
	$helpmenu = TkSysMenu_Help.new($menubar)
	$menubar.add :cascade, :menu => $helpmenu, :label => 'Help'
	if $platform != 'aqua'
		$helpmenu.add :command, :label=>'Stringscan Help', :command=>proc{
			Tk.tk_call('machelp::userhelp')
		}
	end
	$helpmenu.add :command, :label=>'Contact Code by Kevin', :command=>proc{
		Tk.tk_call('xplat::launch', 'mailto:kw@codebykevin.com?subject=Stringscan')
	}
	$helpmenu.add :command, :label=>'Web Site', :command=>proc{
		Tk.tk_call('xplat::launch', 'https://www.codebykevin.com/stringscan.html')
	}

	if $platform != 'aqua'
		$helpmenu.add :command, :label => 'About Stringscan', :command=> proc{aboutWindow}
		$helpmenu.add :command, :label => 'License', :command=>proc{getReg}
		$helpmenu.add :command, :label=>'Check for Updates', :command=>proc{checkUpdate}
			end
	$root['menu'] = $menubar
	$mainframe = Tk::Tile::Frame.new($root).pack('side' => 'top','fill' => 'both','expand' => 'yes')
	
	#button frame and buttons
	$buttonframe = Tk::Tile::Frame.new($mainframe){padding 2}.pack('side' => 'top','fill' => 'both','expand' => 'no')
	choosedirproc = proc{choosedir}
	$choosebutton = Tk::Tile::Button.new($buttonframe) {
		image $folderimage
		takefocus 0
		padding 5
		command  choosedirproc
	}.pack('side' => 'left','fill' => 'both','expand' => 'no')
	Tk::RbWidget::BalloonHelp.new($choosebutton, 'text'=>'Select Directory', 'background'=>'lightyellow', 'relief'=>'solid', 'borderwidth'=>1)
	stringgrepProc = proc {stringgrep}
	$runbutton = Tk::Tile::Button.new($buttonframe) {
		image $glassimage
		takefocus 0
		padding 5
		command stringgrepProc
	}.pack('side' => 'left','fill' => 'both','expand' => 'no')
	Tk::RbWidget::BalloonHelp.new($runbutton, 'text'=>'Run Search', 'background'=>'lightyellow', 'relief'=>'solid', 'borderwidth'=>1)
	$sep = Tk::Tile::Separator.new($mainframe) { orient 'horizontal' }.pack('side'=> 'top', 'fill'=>'both')
	
	#labels and entries
	$topframe = Tk::Tile::Frame.new($mainframe){padding 5}.pack('side' => 'top','fill' => 'both','expand' => 'no')
	$chooselabel = Tk::Tile::Label.new($topframe) {text "Directory:"}.pack('side' => 'left','fill' => 'both','expand' => 'no')
	$direntry = Tk::Tile::Entry.new($topframe) {textvariable $dirname }.pack('side' => 'left','fill' => 'both','expand' => 'no')
	$termlabel = Tk::Tile::Label.new($topframe) {text "Search Term:"}.pack('side' => 'left','fill' => 'both','expand' => 'no')
	$termentry = Tk::Tile::Entry.new($topframe) {textvariable $searchterm}.pack('side' => 'left','fill' => 'both','expand' => 'no')
	$termentry.bind('Return', proc {stringgrep})
	$nextsep = Tk::Tile::Separator.new($mainframe) {orient 'horizontal'}.pack('side'=>'top', 'fill'=>'both')
	
	#listbox, textbox, scrollbars
	$bottomframe = Tk::Frame.new($mainframe).pack('side'=>'bottom','fill' => 'both', 'expand' => 'yes')
	$bottomleftframe = Tk::Tile::Frame.new($bottomframe).pack('side'=>'left','fill' => 'both', 'expand' => 'yes')
	$listlabel = Tk::Tile::Label.new($bottomleftframe) {
		text 'File Name'
		style 'TablelistHeader.TLabel'
		padding 1
	}.pack('side'=>'top', 'fill'=>'both', 'expand' => 'no')
	$lbox = Tk::Listbox.new($bottomleftframe){
		width 50
		height 30
		borderwidth 0
		takefocus 0
		activestyle "none"
		exportselection 0
		selectbackground "RoyalBlue1"
		selectforeground "white"
		dnd_bindtarget('text/uri-list', '<Drop>', '%D') {|d|
			filename=d.join(' ')
			begin
			  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
			end
		}
	}.pack('side'=>'left','fill' => 'both', 'expand' => 'yes')
	$lbox.bind '<ListboxSelect>', proc {
		begin
			if $lbox.curselection.empty?
				puts "No selection in listbox."
			else
				highlighttext  $lbox.get($lbox.curselection[0])
			end
		rescue
			puts "Cannot get selection in listbox."
		end
	}
	$scrollframe = Tk::Frame.new($bottomleftframe).pack('side'=>'right','fill' => 'y', 'expand' => 'no')
	$listscroll = Tk::Tile::Scrollbar.new($scrollframe).pack('side'=>'right','fill' => 'y', 'expand' => 'no')
	$lbox.yscrollbar($listscroll)
	$bottomrightframe  =Tk::Tile::Frame.new($bottomframe).pack('side'=>'right','fill' => 'both', 'expand' => 'yes')
	$tbox = Tk::Text::new($bottomrightframe){
		borderwidth 0.1
		relief 'sunken'
		wrap 'word'
		highlightcolor 'SlateGray3'
		bg 'white'
		state 'disabled'
	}.pack('side'=>'left','fill' => 'both', 'expand' => 'yes')
	$tscrollframe = Tk::Frame.new($bottomrightframe).pack('side'=>'right','fill' => 'y', 'expand' => 'no')
	$tscroll = Tk::Tile::Scrollbar.new($tscrollframe).pack('side'=>'right','fill' => 'y', 'expand' => 'no')
	$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')
	
  	$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
  	$tbox.configure('state'=>'normal')
	$tbox.delete('1.0', 'end')
        $tbox.configure('state'=>'disabled')
        $lbox.delete(0, 'end')
	$dirname = Tk::chooseDirectory('initialdir'=>Dir.home, 'parent'=>$root)
	$direntry.value = $dirname
end

#read file for display in text widget
def highlighttext(file)
	$tbox.configure('state'=>'normal')
	$tbox.delete('1.0', 'end') 
	f = open(file, 'rb')
	while(!f.eof?)
		$tbox.insert('end', f.read(1000))
	end
	f.close
	$tbox.configure('state'=>'disabled')
	$tbox.tag_configure('search', :background=>'yellow')
	sethighlight
end

#set highlight color for search term
def sethighlight
	$tbox.configure('state'=>'normal')
	$tbox.tag_remove('search', '0.0', 'end')
	return if $searchterm == ""
	cur = '1.0'
	loop {
		cur, len = $tbox.search_with_length("#{$searchterm}", cur, 'end')
		break if cur == ""
		$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',
	:detail  => "Version 1.1\n(c) 2017 WordTech Communications LLC",
	:parent => $root
end

#check version of installed software
def checkUpdate 
	Tk.tk_call('softwareupdate::setIcon', $icon)
	Tk.tk_call('softwareupdate::checkVersion', $appname, $appversion)
end

#check version of installed software
def getReg
	Tk.tk_call('regproc::getReg')
end

#user help
def showHelp
	Tk.tk_call('machelp::userhelp')
end
 
          
#end of app class
end

#run app
app = StringscanApp.new
Tk.mainloop








|
|
|







|

|





|
|

|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|

|
|


|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|




|

|
|



|
|
|
|
|

|
|

|

|
|

|
|
<
|
|
|
<
|
|
|
|
|
<
|
<
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
|
|
|
|
<
|
|
|
|
|
|

|






|
|
|
|
|
|




|
|
|
|
|
|
|
|
|
|




|
|
|
|
|
|
|
|
|
|
|




|
|
|
|
|




|
|




|




|

<
<







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

134
135
136

137
138
139
140
141

142

143
144
145

146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

207
208
209
210
211
212
213
214

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273


274
275
276
277

278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352


353
354
355
356
357
358
359
require 'mime/types'
require 'tkextlib/tkDND'
require 'tkextlib/tkimg'

$platform = Tk.windowingsystem

if $platform == 'aqua'
    TkPackage.require('windowlist')
    TkPackage.require('fullscreen')
    require 'tk/tk_mac'
end
TkPackage.require('regproc')
TkPackage.require('machelp')
TkPackage.require('softwareupdate')
TkPackage.require('xplat')

if $platform == 'aqua'
    $accelkey = 'Command'
else 
    $accelkey = 'Control'
end


class StringscanApp

    #here we initialize our app class
    def initialize

        $dirname = ""
        $searchterm = ""
        $appname = 'Stringscan'
        $appversion = '1.0'
        Tk.tk_call('machelp::setAppName', $appname, $appversion)
        Tk.tk_call('softwareupdate::setAppName', $appname)
        Tk.tk_call('softwareupdate::setVersion', $appname, $appversion)

        bgerror = Tk.install_cmd(proc{
            |*args|
            puts args
        })
        Tk.ip_eval("proc bgerror {args} {#{bgerror} $args}")

        if $platform == 'aqua'
            ##map ruby proc to "odoc" Apple Event
            setDir = Tk.install_cmd(proc{
                |*args|
                filename=(args[0]).delete('{}')
                begin
                    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
                end
            })    
            Tk.ip_eval("proc ::tk::mac::OpenDocument {args} {#{setDir} $args}")
            Tk.ip_eval("proc ::tk::mac::ShowHelp {} {#{Tk.install_cmd(proc{showHelp})}}")
        end        
        drawgui
        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
            #we are only reading text files here, not binary. 
            text =  MIME::Types.type_for(i).first.to_s
            type =  text.split('/')[0]
            if type  =~ /text/
                f = File.open(i, "r:iso-8859-1:utf-8")
                result = f.read
                if result =~ /#{$searchterm}/ then
                    $lbox.insert('end', "#{i}")
                    f.close
                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

def drawgui 
    begin
        Tk.ip_eval("console hide")
    rescue
        puts "could not hide console.\n"
    end

    #image data
    $folderdata = 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAAADFBMVEUEBwcEBwcEBwcEBwcNzGmPAAAAAXRSTlMAQObYZgAAAC1JREFUeAFjYEYABgQgXRhCowAyhNEAfmFMQFiYsJX0F6aa5xmxiTIygMQxRQEtWAMvBVlMnAAAAABJRU5ErkJggg=='

    $glassdata = 'iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AcSAg8sJGRWZAAAAXhJREFUOMutlL9LQlEUxz+WGRHllGNEPyAUWnLWsVYhXNpd+ldC6B/QPyDnoMXNtbnFIRAarLAn+bDU13IuHC/vPm/agQuXy/d93veec+4Bv9gGKkAbGAORrAHQBPLAOn+MAtBVMNdqARlfaEk+minAJ/AOvAEjC973gWeAnvpoCNSAfWAX2AKKQN36eWtRWhoK+grkErRXlvO8S7hjuah6pK2uwE2X6BKYiujFsx5FlfPBmkO0B6Rkf+8JfgZC2Wdd4EjtNzzBcwVzgccKfuIJzgJp2X+7RIfAjyrGkQe4pvTtpIcxUcLOgt7MSZ8bfcUFDWOebMfhvCp9btqzK7NlLspW/36ptjPrAbgDbqUVbQOFOKh++wFwLfCk4WNM9OS2scPGrA/gQODmbCIFnQpspm7TsIdPWqCPIkgJ9AZ4Uk97DFyIq3NgU7R9yf0wrliB5fZMxqI+K7FEnIpLe+5GkvMyK8SxoyArQTXcOA+XvX5SWoL/gP4Cdj2n/+OJ36AAAAAASUVORK5CYII='

    $folderimage = TkPhotoImage.new(:data => $folderdata)
    $glassimage = TkPhotoImage.new(:data => $glassdata)

    $icondata = 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAABuvAAAbrwFeGpEcAAAAB3RJTUUH4QcKAhkVOQjHbgAAF1lJREFUeNrNW2l0nNV5fu693zL7opE02uUVLNuSN1kKJhBTKBgTl5QU6pICLQ3tSU+a07RpFuD0pIHDadOVpElP6iyHkzQlKacQ0gCNjUkBEyzkbYwsC9uyFo+kGc2m2edb7u2PmZFGsjZkZbnn3HNn+ea7933uc9/7vO/9hmAZpaNzNwK971S87wKAKgBeAE4ADUKIjQJYAyGaANQKgWpAeADYAVgByAAEgAKADIAECIkQIAhgiBBynhByDkAUQCTQ2xOt7C/Q24NfRCGLGz7TcUdnlwzgnlLtFEI4OOd2zrmNc0GsVguqfVXwej3wuN1wOh1w2OywWG1QVRmSxCAEYBgG8vkCstkskqkU4rE4JiNRTITDKBQ0UEbzjNIkpXQSwPMAvhro7QkDwLbdXTjzTs8vFYAdAPZyLj4mBN8lSRJcTgecTieqfVVoamxAQ10d/H4/nA47uODQNQOGacA0TZimCc4FAAEhBAACSgkopWCMQWIMkixDURQwShGNxTE8OoJLl4YwOjaGeDyOZDINQvA2pfQfABwN9PbEV5MRZBHjGwAM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Ooqqqirouo6JiQkwxmAYBl566aV3VVXtEkLkCCF4+eWXf70AmCOgaEUrKiToVYlGSqngnBf27t37pW3btj1+yy23kEgkAofDASEEJiYmoCgKhBA4fPjwu+l0+sCrr746tG/fPrzyyiu/UgBIxa4wX0sA0LvuukvZtm2bWl1drQghSCKRMM+dO1d4+eWXC9lsVlSKsJtvvvmO+vr6H37sYx9DMBiE0+mEqqoIhUJIp9Pw+/14/vnnE9lsdteRI0cGf1UMIBVB1Lz14Ycftn/0ox9tWrNmzVq3292sqmq9LMteANQwjFQulwtPTU0Fh4eHh1555ZUrhw4dSuTzeQ4g193dffP69eufufvuu33ZbBaUUlgsxThhx44dEELg0UcfvfDcc89dd60AsGswnlW0sxSj3W6XHnrooboNGzasc7vd62w220aLxbJJVdUtsiyvJYQ4ACimaZLS/wuN06dPZ6ampggAORgMjmua9l8jIyMPbd++XS4/Ntfd3Q0AsFqtOH36tE9V1W+MjIykf9m7AF2E+gQAzWQy5POf/3zonnvuye/evXu8paXlvMvl8iqKYhNCsFwup8VisfTo6Gj0zJkz0cOHDyfGx8dFhd8wBwYGQolEYgsh5Af79u3ramtrm378jhACTdPQ398fm5vh+WUAwEsD5RWM4HMYIlKpFJ555pn4M888kwRweQ5Yc50jn6PiOACEQqH0T37yk1sNw3jR5XLdsm7dumJ0evYsRkdHvxqJRLRf5S5Al6hkAaPJPLGHqAB3FiCEECGEyO/Zs+fPtm7d+ruMMXb27NnnU6nU3zHGjJMnTwr8ikvZD8gAFAAWFJ8Ot5eqE8UHmN2l6pmnukvXuAA4Sr+zle6jlu47y18dPHjw108IzRM4YZ5Ey6ylskCmZq7O/4XN8v8D9yIPOOfsZU4AAAAASUVORK5CYII='
    $icon = TkPhotoImage.new(:data => $icondata)

        #initialize variables for entry
    $dirname = TkVariable.new
    $searchterm = TkVariable.new

        #top window and frame
    Tk::TkDND::DND
    $root = TkRoot.new {
        title "Stringscan"
    }

        $root.iconphoto_default($icon)

        if $platform == 'aqua'
        Tk.tk_call('fullscreen::fullscreen', $root)
    end

        #menu
    $menubar = TkMenu.new($root)
    TkOption.add '*tearOff', 0
    if $platform == 'aqua'
        $appmenu = TkSysMenu_Apple.new($menubar)
        $menubar.add :cascade, :menu => $appmenu
        $appmenu.add :command, :label => 'About Stringscan', :command=> proc{aboutWindow}
        $appmenu.add :command, :label => 'License', :command=>proc{getReg}
        $appmenu.add :command, :label=>'Check for Updates', :command=>proc{checkUpdate}
        $appmenu.add :separator
    end
    $searchmenu = TkMenu.new($menubar)
    $menubar.add :cascade, :menu => $searchmenu, :label => 'Search'
    $searchmenu.add :command, :label => 'Choose Directory...', 'accelerator' => "#{$accelkey}+O", :command => proc{choosedir}
    $searchmenu.add :command, :label => 'Run Search', 'accelerator' => "#{$accelkey}+R", :command => proc{stringgrep}
    if $platform == 'win32'
        $searchmenu.add :command, :label => "Exit", :command=>proc{exit}, 'accelerator' => "#{$accelkey}+Q"
    end
    if $platform == 'aqua'
        Tk.tk_call("windowlist::windowMenu",  $menubar)
    end
    $helpmenu = TkSysMenu_Help.new($menubar)
    $menubar.add :cascade, :menu => $helpmenu, :label => 'Help'
    if $platform != 'aqua'
        $helpmenu.add :command, :label=>'Stringscan Help', :command=>proc{
            Tk.tk_call('machelp::userhelp')
        }
    end
    $helpmenu.add :command, :label=>'Contact Code by Kevin', :command=>proc{
        Tk.tk_call('xplat::launch', 'mailto:kw@codebykevin.com?subject=Stringscan')
    }
    $helpmenu.add :command, :label=>'Web Site', :command=>proc{
        Tk.tk_call('xplat::launch', 'https://www.codebykevin.com/stringscan.html')
    }

    if $platform != 'aqua'
        $helpmenu.add :command, :label => 'About Stringscan', :command=> proc{aboutWindow}
        $helpmenu.add :command, :label => 'License', :command=>proc{getReg}
        $helpmenu.add :command, :label=>'Check for Updates', :command=>proc{checkUpdate}
    end
    $root['menu'] = $menubar
    $mainframe = Tk::Tile::Frame.new($root).pack('side' => 'top','fill' => 'both','expand' => 'yes')

        #button frame and buttons
    $buttonframe = Tk::Tile::Frame.new($mainframe){padding 2}.pack('side' => 'top','fill' => 'both','expand' => 'no')
    choosedirproc = proc{choosedir}
    $choosebutton = Tk::Tile::Button.new($buttonframe) {
        image $folderimage
        takefocus 0
        padding 5
        command  choosedirproc
    }.pack('side' => 'left','fill' => 'both','expand' => 'no')
    Tk::RbWidget::BalloonHelp.new($choosebutton, 'text'=>'Select Directory', 'background'=>'lightyellow', 'relief'=>'solid', 'borderwidth'=>1)
    stringgrepProc = proc {stringgrep}
    $runbutton = Tk::Tile::Button.new($buttonframe) {
        image $glassimage
        takefocus 0
        padding 5
        command stringgrepProc
    }.pack('side' => 'left','fill' => 'both','expand' => 'no')
    Tk::RbWidget::BalloonHelp.new($runbutton, 'text'=>'Run Search', 'background'=>'lightyellow', 'relief'=>'solid', 'borderwidth'=>1)
    $sep = Tk::Tile::Separator.new($mainframe) { orient 'horizontal' }.pack('side'=> 'top', 'fill'=>'both')

        #labels and entries
    $topframe = Tk::Tile::Frame.new($mainframe){padding 5}.pack('side' => 'top','fill' => 'both','expand' => 'no')
    $chooselabel = Tk::Tile::Label.new($topframe) {text "Directory:"}.pack('side' => 'left','fill' => 'both','expand' => 'no')
    $direntry = Tk::Tile::Entry.new($topframe) {textvariable $dirname }.pack('side' => 'left','fill' => 'both','expand' => 'no')
    $termlabel = Tk::Tile::Label.new($topframe) {text "Search Term:"}.pack('side' => 'left','fill' => 'both','expand' => 'no')
    $termentry = Tk::Tile::Entry.new($topframe) {textvariable $searchterm}.pack('side' => 'left','fill' => 'both','expand' => 'no')
    $termentry.bind('Return', proc {stringgrep})
    $nextsep = Tk::Tile::Separator.new($mainframe) {orient 'horizontal'}.pack('side'=>'top', 'fill'=>'both')

        #listbox, textbox, scrollbars
    $bottomframe = Tk::Frame.new($mainframe).pack('side'=>'bottom','fill' => 'both', 'expand' => 'yes')
    $bottomleftframe = Tk::Tile::Frame.new($bottomframe).pack('side'=>'left','fill' => 'both', 'expand' => 'yes')
    $listlabel = Tk::Tile::Label.new($bottomleftframe) {
        text 'File Name'
        style 'TablelistHeader.TLabel'
        padding 1
    }.pack('side'=>'top', 'fill'=>'both', 'expand' => 'no')
    $lbox = Tk::Listbox.new($bottomleftframe){
        width 50
        height 30
        borderwidth 0
        takefocus 0
        activestyle "none"
        exportselection 0
        selectbackground "RoyalBlue1"
        selectforeground "white"
        dnd_bindtarget('text/uri-list', '<Drop>', '%D') {|d|
            filename=d.join(' ')
            begin
                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
            end
        }
    }.pack('side'=>'left','fill' => 'both', 'expand' => 'yes')
    $lbox.bind '<ListboxSelect>', proc {
        begin
            if $lbox.curselection.empty?
                puts "No selection in listbox."
            else
                highlighttext  $lbox.get($lbox.curselection[0])
            end
        rescue
            puts "Cannot get selection in listbox."
        end
    }
    $scrollframe = Tk::Frame.new($bottomleftframe).pack('side'=>'right','fill' => 'y', 'expand' => 'no')
    $listscroll = Tk::Tile::Scrollbar.new($scrollframe).pack('side'=>'right','fill' => 'y', 'expand' => 'no')
    $lbox.yscrollbar($listscroll)
    $bottomrightframe  =Tk::Tile::Frame.new($bottomframe).pack('side'=>'right','fill' => 'both', 'expand' => 'yes')
    $tbox = Tk::Text::new($bottomrightframe){
        borderwidth 0.1
        relief 'sunken'
        wrap 'word'
        highlightcolor 'SlateGray3'
        bg 'white'
        state 'disabled'
    }.pack('side'=>'left','fill' => 'both', 'expand' => 'yes')
    $tscrollframe = Tk::Frame.new($bottomrightframe).pack('side'=>'right','fill' => 'y', 'expand' => 'no')
    $tscroll = Tk::Tile::Scrollbar.new($tscrollframe).pack('side'=>'right','fill' => 'y', 'expand' => 'no')
    $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')

        $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
    $tbox.configure('state'=>'normal')
    $tbox.delete('1.0', 'end')
    $tbox.configure('state'=>'disabled')
    $lbox.delete(0, 'end')
    $dirname = Tk::chooseDirectory('initialdir'=>Dir.home, 'parent'=>$root)
    $direntry.value = $dirname
end

#read file for display in text widget
def highlighttext(file)
    $tbox.configure('state'=>'normal')
    $tbox.delete('1.0', 'end') 
    f = open(file, 'rb')
    while(!f.eof?)
        $tbox.insert('end', f.read(1000))
    end
    f.close
    $tbox.configure('state'=>'disabled')
    $tbox.tag_configure('search', :background=>'yellow')
    sethighlight
end

#set highlight color for search term
def sethighlight
    $tbox.configure('state'=>'normal')
    $tbox.tag_remove('search', '0.0', 'end')
    return if $searchterm == ""
    cur = '1.0'
    loop {
        cur, len = $tbox.search_with_length("#{$searchterm}", cur, 'end')
        break if cur == ""
        $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',
    :detail  => "Version 1.1\n(c) 2017 WordTech Communications LLC",
    :parent => $root
end

#check version of installed software
def checkUpdate 
    Tk.tk_call('softwareupdate::setIcon', $icon)
    Tk.tk_call('softwareupdate::checkVersion', $appname, $appversion)
end

#check version of installed software
def getReg
    Tk.tk_call('regproc::getReg')
end

#user help
def showHelp
    Tk.tk_call('machelp::userhelp')
end


#end of app class
end

#run app
app = StringscanApp.new
Tk.mainloop