TextSweep

Check-in [c774a344e7]
Login

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

Overview
Comment:Begin implementation of scripting API
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c774a344e7951479c04440c2b6203ae8e1c29be1
User & Date: kevin 2017-12-27 02:11:01
Context
2017-12-27
19:13
Update to help docs check-in: e0e4b8ed66 user: kevin tags: trunk
02:11
Begin implementation of scripting API check-in: c774a344e7 user: kevin tags: trunk
2017-12-26
21:37
First changes for 4.0 check-in: 20268b140c user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Info-cbk.plist.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>TextSweep</string>
	<key>CFBundleGetInfoString</key>
	<string>TextSweep 3.3.0 (c) 2018 WordTech Communications LLC</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>
<key>NSHighResolutionCapable</key>
	<true/>
	<key>LSMinimumSystemVersionByArchitecture</key>
	<dict>
	<key>i386</key>
................................................................................
	<key>CFBundleDisplayName</key>
	<string>TextSweep</string>
	<key>CFBundleIdentifier</key>
	<string>com.codebykevin.com.textsweep-cbk</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>3.3.0</string>
	<key>CFBundleVersion</key>
	<string>3.3.0</string>
	<key>LSMinimumSystemVersion</key>
	<string>10.13</string>
	<key>LSRequiresCarbon</key>
	<true/>	
	<key>NSSupportsAutomaticTermination</key>
	<string>YES</string>
	<key>NSSupportsSuddenTermination</key>
	<string>YES</string>
  <key>SUFeedURL</key>
	<string>http://www.codebykevin.com/textsweep.xml</string>
</dict>
</plist>







|







 







|

|












3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>TextSweep</string>
	<key>CFBundleGetInfoString</key>
	<string>TextSweep 4.0.0 (c) 2018 WordTech Communications LLC</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>
<key>NSHighResolutionCapable</key>
	<true/>
	<key>LSMinimumSystemVersionByArchitecture</key>
	<dict>
	<key>i386</key>
................................................................................
	<key>CFBundleDisplayName</key>
	<string>TextSweep</string>
	<key>CFBundleIdentifier</key>
	<string>com.codebykevin.com.textsweep-cbk</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>4.0.0</string>
	<key>CFBundleVersion</key>
	<string>4.0.0</string>
	<key>LSMinimumSystemVersion</key>
	<string>10.13</string>
	<key>LSRequiresCarbon</key>
	<true/>	
	<key>NSSupportsAutomaticTermination</key>
	<string>YES</string>
	<key>NSSupportsSuddenTermination</key>
	<string>YES</string>
  <key>SUFeedURL</key>
	<string>http://www.codebykevin.com/textsweep.xml</string>
</dict>
</plist>

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

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
...
172
173
174
175
176
177
178
179

180
181
182
183
184
185
186
...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
608
609
610
611
612
613
614
615


























































616
617
set searchvar {}
set patternvar {}
set replacevar {}
set searchterm {}
set filelist {}



#handle errors in Tk
proc bgerror {args} {

    global cachedir
    puts "TextSweep: An error occurred: $args"  
}

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

    source $imagedir/images.tcl
   
    
    image create photo folder -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=
    }
................................................................................
    .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 "aqua"} {
	#window menu
	windowlist::windowMenu .mb

    }

    
    menu .mb.help -tearoff 0
    
    if {[tk windowingsystem] ne "aqua"} {
	
................................................................................
    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 folder -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"

................................................................................
    machelp::setAppName $appname::name $appname::version
    drawGUI
    after 50 
    regproc::readLic $appname::name $appname::version


}



























































trace add variable searchvar write updateSearchTerm
startUp







<







 







|







 







|
>







 







|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


42
43
44
45
46
47
48

49
50
51
52
53
54
55
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
...
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
set searchvar {}
set patternvar {}
set replacevar {}
set searchterm {}
set filelist {}



#handle errors in Tk
proc bgerror {args} {

    global cachedir
    puts "TextSweep: An error occurred: $args"  
}

................................................................................
    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=
    }
................................................................................
    .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 "aqua"} {
	#window menu
	menu .mb.window
	.mb add cascade -label Window -menu .mb.window
    }

    
    menu .mb.help -tearoff 0
    
    if {[tk windowingsystem] ne "aqua"} {
	
................................................................................
    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"

................................................................................
    machelp::setAppName $appname::name $appname::version
    drawGUI
    after 50 
    regproc::readLic $appname::name $appname::version


}

#AppleScript and DDE commands

#set search directory
proc set_search_folder {foldername} {
    global folder
    set folder $foldername
}


#set pattern
proc set_search_pattern {pattern} {
    global patternvar
    set patternvar $pattern
}

#set search string
proc set_search_term {term} {
    global searchvar
    set searchvar $term
}

#set replacement string
proc set_replace_term {term} {
    global replacevar
    set replacevar $term
}

#run the search and replace
proc execute_replace {} {
    global folder
    global filename
    global filelist
    global patternvar
    global searchterm
    global searchvar
    
    catch {.f.text.list.listbox delete 0 end}

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

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

	foreach item $filelist {
	    .f.text.list.listbox insert end [list $item]
	}
    }

    batchReplace

}



trace add variable searchvar write updateSearchTerm
startUp