TextSweep

Check-in [7a78922f68]
Login

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

Overview
Comment:Updates for next release
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7a78922f68faa673ee78a43e69670e1f2af33b85
User & Date: kevin 2019-11-20 03:11:01
Context
2019-11-22
14:18
Tweak images check-in: d1a9e51320 user: kevin tags: trunk
2019-11-20
03:11
Updates for next release check-in: 7a78922f68 user: kevin tags: trunk
2019-11-18
02:56
Tweak icons check-in: fe05cfa61c user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to scriptlibs/textsweep/textsweep-main.tcl.

3
4
5
6
7
8
9
10
11
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
..
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
...
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
...
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
...
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
...
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
...
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
...
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
...
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
...
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
#  Copyright (C) 2018 WordTech Communications LLC

#MIT license

#let's get started

#initialize package requirements
package require tablelist_tile
package require fileutil 
package require tkdnd
package require regproc
package require machelp
package require softwareupdate
package require appname
package require xplat
package require BWidget










if {[tk windowingsystem] eq "aqua"} {
    package require cocoaprint
    package require aem
    #install AppleScript event handlers
    aem::installeventhandler CoKv sFld set_search_folder
    aem::installeventhandler CoKv sPtn set_search_pattern
    aem::installeventhandler CoKv sStm set_search_term
    aem::installeventhandler CoKv sRtm set_replace_term
    aem::installeventhandler CoKv sExr execute_replace
}

if {[tk windowingsystem] eq "win32"} {
    package require dde
    dde servername TextSweep
}


................................................................................
	tk_messageBox -icon warning -title "Error" -message $args
    }
}

#make images for buttons et. al from files
proc makeImage {} {

    global  runsearch 
    global folder_documents 
    global edit_undo
    
    set imagedir [file join [file dirname [info script]] images]



    source $imagedir/images.tcl
    
    
    image create photo dirfolder -data {
	iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAAADFBMVEUEBwcEBwcEBwcEBwcNzGmPAAAAAXRSTlMAQObYZgAAAC1JREFUeAFjYEYABgQgXRhCowAyhNEAfmFMQFiYsJX0F6aa5xmxiTIygMQxRQEtWAMvBVlMnAAAAABJRU5ErkJggg==
    }
    
    
    image create photo glass -data {
	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=
    }
    
    image create photo reverse -data {
	iVBORw0KGgoAAAANSUhEUgAAABIAAAAVCAMAAAB8FU7dAAAAJFBMVEUAAAAEBwcEBwcEBwcEBwcEBwcEBwcEBwcEBwcEBwcEBwcEBwciT4YkAAAAC3RSTlMADy8/T19vn7/P72K50kgAAABxSURBVHgBZZBdDgQhCINl/VHs/e+7aUimMNMX4UvVQkvabq1qAy9mjsRsOSixcSFtkgkpXIPVmZ3eIMZqlh8XSc3lwHlyxCFTKFD/op+6DqBcjIzpeeoAnkOEaaWoQa5poD4Pq1HHll/LuaPVFfoydn8C6Qbq4n8uEwAAAABJRU5ErkJggg==
    }

    softwareupdate::setIcon icon-update
    
}

#display user help



if {[tk windowingsystem] eq "aqua"} {
    proc tk::mac::ShowHelp {} {
	machelp::userhelp
    }















































}

#"about application" command
proc tkAboutDialog {} {
    aboutWindow
}

................................................................................

    
    menu .mb
    
    if {[tk windowingsystem] eq "aqua"} {
	menu .mb.apple
	.mb.apple add command -label "About TextSweep" -command tkAboutDialog
	.mb.apple add command -label "License" -command regproc::getReg
	.mb.apple add command -label "Check for Updates" -command  "softwareupdate::checkVersion $appname::name $appname::version"
	.mb.apple add separator
	.mb add cascade -label "TextSweep" -menu .mb.apple
    }

    menu .mb.search -tearoff -0
    .mb.search add command -label "Select Directory" -command setDir 
    .mb.search add command -label "Replace Text" -command batchReplace -accelerator "[xplat::controlkey]-H"
    .mb.search add command -label "Undo" -command batchUndo -accelerator "[xplat::controlkey]-Z"
    .mb add cascade -label "Search" -menu .mb.search
    if {[tk windowingsystem] eq "win32"} {
	.mb.search add command -label "Exit" -command exit
    }
    
    
    if {[tk windowingsystem] eq "aqua"} {
	#window menu
	menu .mb.window
	.mb add cascade -label Window -menu .mb.window
................................................................................
	.mb.help add command -label "Help" -command machelp::userhelp
    }
    .mb.help add command -label "Contact Code by Kevin" -command machelp::usermail
    .mb.help add command -label "Web Site" -command  machelp::appweb 
    
    if {[tk windowingsystem] ne "aqua"} {
	.mb.help add command -label "About TextSweep" -command tkAboutDialog
	.mb.help add command -label "License" -command regproc::getReg
	.mb.help add command -label "Check for Updates" -command  "softwareupdate::checkVersion $appname::name $appname::version"
    }

    
    .mb add cascade -label "Help" -menu .mb.help

    . configure -menu .mb
................................................................................
    ttk::frame .f
    pack .f -fill both -expand yes
    
    pack [ttk::frame .f.buttons -padding 5] -side top -fill both -expand no	

    pack [ ttk::separator .f.septop -orient vertical] -side top -fill both -expand no

    ttk::button .f.buttons.folder -image dirfolder -style Toolbutton -command setDir -takefocus 0
    pack .f.buttons.folder  -side left  -expand no
    DynamicHelp::register .f.buttons.folder  balloon "Select the directory to search"

    ttk::button .f.buttons.search -image glass -style Toolbutton -command batchReplace -takefocus 0
    pack .f.buttons.search  -side left  -expand no
    DynamicHelp::register .f.buttons.search balloon "Replace text"

    ttk::button .f.buttons.reload -image reverse -style Toolbutton -command batchUndo -takefocus 0
    pack .f.buttons.reload  -side left  -expand no
    DynamicHelp::register .f.buttons.reload  balloon "Undo replace"

    
    ttk::frame .f.foldersearch -padding 5
    pack .f.foldersearch -fill both -expand no -side top
    
    ttk::label .f.foldersearch.folder -text "Folder:"
    ttk::entry .f.foldersearch.foldervar -textvar folder
................................................................................
    
    ttk::panedwindow .f.text -orient horizontal
    pack .f.text -side top -fill both -expand yes
    
    ttk::frame .f.text.list   
    ttk::frame .f.text.display
    
    #main data display
    tablelist::tablelist .f.text.list.listbox -columns {0 "File" }  -width 40 -yscrollcommand [list .f.text.list.scrollframe.scroll set] -selectbackground   RoyalBlue1 -selectforeground   white -stretch all -stripebackground white -relief flat -border 0 -showseparators yes -takefocus 0 -setfocus 1 -activestyle none -exportselection 0



    
    pack  .f.text.list.listbox -side left -fill both -expand yes
    
    bind .f.text.list.listbox <<ListboxSelect>> highlightText

    tkdnd::drop_target register [.f.text.list.listbox bodypath] *
    bind [.f.text.list.listbox bodypath]  <<Drop:DND_Files>> {selectFileSystem [join %D]}
    
    ttk::frame .f.text.list.scrollframe
    pack .f.text.list.scrollframe -fill y -expand no -side right
    
    ttk::scrollbar .f.text.list.scrollframe.scroll -command [list .f.text.list.listbox yview]
    
    pack .f.text.list.scrollframe.scroll -fill y -expand no -side right

    ttk::frame .f.text.frame
    pack .f.text.frame -fill both -expand yes
    
    text .f.text.frame.t -yscrollcommand [list .f.text.frame.scrollframe.scroll set]  -borderwidth 0 -highlightthickness 3 -background white  -highlightcolor SlateGray3 -state disabled
    pack .f.text.frame.t -fill both -side left -expand yes
    
    ttk::frame .f.text.frame.scrollframe
    pack .f.text.frame.scrollframe -fill y -side right -expand no
    
    ttk::scrollbar .f.text.frame.scrollframe.scroll -command [list .f.text.frame.t yview]
    pack .f.text.frame.scrollframe.scroll -side right -fill y -expand no
................................................................................
    global patternvar
    global searchterm
    global searchvar
    global filelist

    set searchterm $searchvar

    catch {.f.text.list.listbox delete 0 end}
    catch {clearText}


    set folder [tk_chooseDirectory -parent . -initialdir $::env(HOME)]
    if { $folder == ""} {
        return; # they clicked cancel
    } else {
	set filelist  [glob  -type f -nocomplain -directory [join $folder] $patternvar]
	foreach item $filelist {
	    if {[checkTextType $item] >= 0} {
		.f.text.list.listbox insert end [list $item]
	    }
	}

	return [join $folder]
    }
}

................................................................................
    global patternvar
    global searchterm
    global searchvar
    global filelist

    set selectedfile [ .f.text.list.listbox get [ .f.text.list.listbox curselection]]

    .f.text.list.listbox delete 0 end
    clearText
    
    set filelist  [glob -type f -nocomplain -directory [join $folder] $patternvar]
    foreach item $filelist {
	if {[checkTextType $item] >= 0} {
	    .f.text.list.listbox insert end [list $item]
	}
    }

    set newselectedfile [ .f.text.list.listbox searchcolumn 0 [join $selectedfile] -start 0 ]
    .f.text.list.listbox see  $newselectedfile
    .f.text.list.listbox selection set $newselectedfile
    .f.text.list.listbox selection anchor  $newselectedfile
................................................................................
    global filelist
    global patternvar
    global searchterm
    global searchvar

    set searchterm $searchvar

    catch {.f.text.list.listbox delete 0 end}
    catch {clearText}

    if {[file isfile $fname]} {
	return
    }

    if {[file isdir $fname]} {
	set folder $fname
	.f.text.list.listbox delete 0 end
	clearText
	set filelist  [glob -type f -nocomplain -directory [join $folder] $patternvar]

	foreach item $filelist {
	    if {[checkTextType $item] >= 0} {
		.f.text.list.listbox insert end [list $item]
	    }
	}
	return [join $folder]
    }
}


#proc to determine if filetype is text
proc checkTextType {file} {
    lsearch [fileutil::fileType $file] "text"
}


#Mac-specific procedures
if {[tk windowingsystem] eq "aqua"} {
    proc ::tk::mac::OpenDocument {fname} {
	selectFileSystem $fname
    }

    #raise window if closed--dock click
    proc ::tk::mac::ReopenApplication {} {
	if { [wm state .] == "withdrawn"} {
	    wm state . normal
	    raise .
	} else {
	    wm deiconify .
	    raise .
	}
    }
}


#initialize the app
proc startUp {} {
    global appname
    global appversion
    global datadir
................................................................................
    global folder
    global filename
    global filelist
    global patternvar
    global searchterm
    global searchvar
    
    catch {.f.text.list.listbox delete 0 end}
    catch {clearText}

    if {[file isfile $folder]} {
	return
    }

    if {[file isdir $folder]} {
	.f.text.list.listbox delete 0 end
	clearText
	set filelist  [glob -type f -nocomplain -directory [join $folder] $patternvar]

	foreach item $filelist {
	    if {[checkTextType $item] >= 0} {
		.f.text.list.listbox insert end [list $item]
	    }
	}
    }

    batchReplace

}



trace add variable searchvar write updateSearchTerm
startUp







<







|

>
>
>
>
>
>
>




<
<
<
<
<
<
<
|







 







|
<
<
<

|
>
>
|
<
<
<
<
<
<
<
<
<
<
<
<
<






<
>
>
>

<
<
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<











|







 







<







 







|

|

|

|

|

|







 







|
|
>
>
>



|


|











|







 







|










|







 







|





|







 







|








|





|













<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|







|





|












3
4
5
6
7
8
9

10
11
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
..
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
...
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
...
235
236
237
238
239
240
241

242
243
244
245
246
247
248
...
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
...
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
...
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
...
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
...
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656

















657
658
659
660
661
662
663
...
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
#  Copyright (C) 2018 WordTech Communications LLC

#MIT license

#let's get started

#initialize package requirements

package require fileutil 
package require tkdnd
package require regproc
package require machelp
package require softwareupdate
package require appname
package require xplat
package require tooltip

image create photo upArrow -data {
    R0lGODlhDgAOAJEAANnZ2YCAgPz8/P///yH5BAEAAAAALAAAAAAOAA4AAAImhI+
    py+1LIsJHiBAh+BgmiEAJQITgW6DgUQIAECH4JN8IPqYuNxUAOw==}
image create photo downArrow -data {
    R0lGODlhDgAOAJEAANnZ2YCAgPz8/P///yH5BAEAAAAALAAAAAAOAA4AAAInhI+
    py+1I4ocQ/IgDEYIPgYJICUCE4F+YIBolEoKPEJKZmVJK6ZACADs=}
image create photo noArrow -height 14 -width 14


if {[tk windowingsystem] eq "aqua"} {
    package require cocoaprint







   }

if {[tk windowingsystem] eq "win32"} {
    package require dde
    dde servername TextSweep
}


................................................................................
	tk_messageBox -icon warning -title "Error" -message $args
    }
}

#make images for buttons et. al from files
proc makeImage {} {

  #create the images



    set imagedir [file join [file dirname [info script]] images]
    
    set imagefiles [glob -directory $imagedir *.tcl]
    foreach item $imagefiles {
	source $item













    }

    softwareupdate::setIcon icon-update
    
}




#mac-only commands
if {[tk windowingsystem] eq "aqua"} {



  proc ::tk::mac::OpenDocument {fname} {
	selectFileSystem $fname
    }

    #raise window if closed--dock click
    proc ::tk::mac::ReopenApplication {} {
	if { [wm state .] == "withdrawn"} {
	    wm state . normal
	    raise .
	} else {
	    wm deiconify .
	    raise .
	}
    }

proc changeImagesDark {} {

    foreach item [image names]  {
	if {[image type $item] eq "bitmap"} {
	    $item configure -foreground white
	}
    }
}

proc changeImagesLight {} {

    foreach item [image names]  {
	if {[image type $item] eq "bitmap"} {
	    $item configure -foreground black
	}
    }
}

proc checkDarkMode {} {
    set mode [catch {exec defaults read -g AppleInterfaceStyle} msg]
    if {$msg eq "Dark"} {
	event generate . <<DarkAqua>>
    } else {
	event generate . <<LightAqua>>
    }
}

#handle program shutdown via command-q
proc  ::tk::mac::Quit {} {
    regproc::makePitch
}

}

#"about application" command
proc tkAboutDialog {} {
    aboutWindow
}

................................................................................

    
    menu .mb
    
    if {[tk windowingsystem] eq "aqua"} {
	menu .mb.apple
	.mb.apple add command -label "About TextSweep" -command tkAboutDialog

	.mb.apple add command -label "Check for Updates" -command  "softwareupdate::checkVersion $appname::name $appname::version"
	.mb.apple add separator
	.mb add cascade -label "TextSweep" -menu .mb.apple
    }

    menu .mb.search -tearoff -0
    .mb.search add command -label "Select Directory" -command setDir 
    .mb.search add command -label "Replace Text" -command batchReplace -accelerator "[xplat::controlkey]-H"
    .mb.search add command -label "Undo" -command batchUndo -accelerator "[xplat::controlkey]-Z"
    .mb add cascade -label "Search" -menu .mb.search
    if {[tk windowingsystem] eq "win32"} {
	.mb.search add command -label "Exit" -command regproc::makePitch; exit
    }
    
    
    if {[tk windowingsystem] eq "aqua"} {
	#window menu
	menu .mb.window
	.mb add cascade -label Window -menu .mb.window
................................................................................
	.mb.help add command -label "Help" -command machelp::userhelp
    }
    .mb.help add command -label "Contact Code by Kevin" -command machelp::usermail
    .mb.help add command -label "Web Site" -command  machelp::appweb 
    
    if {[tk windowingsystem] ne "aqua"} {
	.mb.help add command -label "About TextSweep" -command tkAboutDialog

	.mb.help add command -label "Check for Updates" -command  "softwareupdate::checkVersion $appname::name $appname::version"
    }

    
    .mb add cascade -label "Help" -menu .mb.help

    . configure -menu .mb
................................................................................
    ttk::frame .f
    pack .f -fill both -expand yes
    
    pack [ttk::frame .f.buttons -padding 5] -side top -fill both -expand no	

    pack [ ttk::separator .f.septop -orient vertical] -side top -fill both -expand no

    ttk::button .f.buttons.folder -image xbm_folder_sans_edit_32 -style Toolbutton -command setDir -takefocus 0
    pack .f.buttons.folder  -side left  -expand no
    tooltip::tooltip .f.buttons.folder "Select the directory to search"

    ttk::button .f.buttons.search -image xbm_search_32 -style Toolbutton -command batchReplace -takefocus 0
    pack .f.buttons.search  -side left  -expand no
    tooltip::tooltip .f.buttons.search  "Replace text"

    ttk::button .f.buttons.reload -image xbm_refresh_32 -style Toolbutton -command batchUndo -takefocus 0
    pack .f.buttons.reload  -side left  -expand no
   tooltip::tooltip .f.buttons.reload   "Undo replace"

    
    ttk::frame .f.foldersearch -padding 5
    pack .f.foldersearch -fill both -expand no -side top
    
    ttk::label .f.foldersearch.folder -text "Folder:"
    ttk::entry .f.foldersearch.foldervar -textvar folder
................................................................................
    
    ttk::panedwindow .f.text -orient horizontal
    pack .f.text -side top -fill both -expand yes
    
    ttk::frame .f.text.list   
    ttk::frame .f.text.display
    
     #main data display
    ttk::treeview .f.text.list.listbox  -columns {"File"} -show headings -yscrollcommand [list .f.text.list.scrollframe.scroll  set] -displaycolumns #all

	.middle.right.upper.frame.listbox heading "File" -text "File" -anchor w 

    
    pack  .f.text.list.listbox -side left -fill both -expand yes
    
    bind .f.text.list.listbox <<TreeviewSelect>> highlightText

    tkdnd::drop_target register [.f.text.list.listbox bodypath] *
    bind .f.text.list.listbox  <<Drop:DND_Files>> {selectFileSystem [join %D]}
    
    ttk::frame .f.text.list.scrollframe
    pack .f.text.list.scrollframe -fill y -expand no -side right
    
    ttk::scrollbar .f.text.list.scrollframe.scroll -command [list .f.text.list.listbox yview]
    
    pack .f.text.list.scrollframe.scroll -fill y -expand no -side right

    ttk::frame .f.text.frame
    pack .f.text.frame -fill both -expand yes
    
    text .f.text.frame.t -yscrollcommand [list .f.text.frame.scrollframe.scroll set]  -borderwidth 0 -highlightthickness 3  -highlightcolor SlateGray3 -state disabled
    pack .f.text.frame.t -fill both -side left -expand yes
    
    ttk::frame .f.text.frame.scrollframe
    pack .f.text.frame.scrollframe -fill y -side right -expand no
    
    ttk::scrollbar .f.text.frame.scrollframe.scroll -command [list .f.text.frame.t yview]
    pack .f.text.frame.scrollframe.scroll -side right -fill y -expand no
................................................................................
    global patternvar
    global searchterm
    global searchvar
    global filelist

    set searchterm $searchvar

    catch {.f.text.list.listbox delete [.f.text.list.listbox children {}]}
    catch {clearText}


    set folder [tk_chooseDirectory -parent . -initialdir $::env(HOME)]
    if { $folder == ""} {
        return; # they clicked cancel
    } else {
	set filelist  [glob  -type f -nocomplain -directory [join $folder] $patternvar]
	foreach item $filelist {
	    if {[checkTextType $item] >= 0} {
		.f.text.list.listbox insert {} end [list $item]
	    }
	}

	return [join $folder]
    }
}

................................................................................
    global patternvar
    global searchterm
    global searchvar
    global filelist

    set selectedfile [ .f.text.list.listbox get [ .f.text.list.listbox curselection]]

    .f.text.list.listbox delete [.f.text.list.listbox children {}]  
    clearText
    
    set filelist  [glob -type f -nocomplain -directory [join $folder] $patternvar]
    foreach item $filelist {
	if {[checkTextType $item] >= 0} {
	    .f.text.list.listbox insert {} end [list $item]
	}
    }

    set newselectedfile [ .f.text.list.listbox searchcolumn 0 [join $selectedfile] -start 0 ]
    .f.text.list.listbox see  $newselectedfile
    .f.text.list.listbox selection set $newselectedfile
    .f.text.list.listbox selection anchor  $newselectedfile
................................................................................
    global filelist
    global patternvar
    global searchterm
    global searchvar

    set searchterm $searchvar

    catch  [.f.text.list.listbox delete [.f.text.list.listbox children {}] ] 
    catch {clearText}

    if {[file isfile $fname]} {
	return
    }

    if {[file isdir $fname]} {
	set folder $fname
	.f.text.list.listbox delete [.f.text.list.listbox children {}]
	clearText
	set filelist  [glob -type f -nocomplain -directory [join $folder] $patternvar]

	foreach item $filelist {
	    if {[checkTextType $item] >= 0} {
		.f.text.list.listbox insert {} end [list $item]
	    }
	}
	return [join $folder]
    }
}


#proc to determine if filetype is text
proc checkTextType {file} {
    lsearch [fileutil::fileType $file] "text"
}





















#initialize the app
proc startUp {} {
    global appname
    global appversion
    global datadir
................................................................................
    global folder
    global filename
    global filelist
    global patternvar
    global searchterm
    global searchvar
    
    catch [.f.text.list.listbox delete [.f.text.list.listbox children {}]]
    catch {clearText}

    if {[file isfile $folder]} {
	return
    }

    if {[file isdir $folder]} {
	.f.text.list.listbox delete [.f.text.list.listbox children {}]
	clearText
	set filelist  [glob -type f -nocomplain -directory [join $folder] $patternvar]

	foreach item $filelist {
	    if {[checkTextType $item] >= 0} {
		.f.text.list.listbox insert {} end [list $item]
	    }
	}
    }

    batchReplace

}



trace add variable searchvar write updateSearchTerm
startUp