TextSweep

Check-in [2da27e0597]
Login

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

Overview
Comment:Version bump to 2.2
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2da27e0597ee0b036bc094bfdaf68e4f7706cc8f
User & Date: kevin 2016-07-17 19:31:50
Context
2016-08-01
01:10
More tweaks check-in: db09f011c6 user: kevin tags: trunk
2016-07-17
19:31
Version bump to 2.2 check-in: 2da27e0597 user: kevin tags: trunk
2016-07-02
03:07
Initial commit check-in: a7af6d5c8e user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Info-cbk.plist.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>TextSweep</string>
	<key>CFBundleGetInfoString</key>
	<string>TextSweep 2.1.0 (c) 2014 WordTech Communications LLC</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>
<key>NSHighResolutionCapable</key>
	<true/>
	<key>LSMinimumSystemVersionByArchitecture</key>
	<dict>
	<key>i386</key>









|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>TextSweep</string>
	<key>CFBundleGetInfoString</key>
	<string>TextSweep 2.2.0 (c) 2014 WordTech Communications LLC</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>
<key>NSHighResolutionCapable</key>
	<true/>
	<key>LSMinimumSystemVersionByArchitecture</key>
	<dict>
	<key>i386</key>
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	<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>2.1.0</string>
	<key>CFBundleVersion</key>
	<string>2.1.0</string>
	<key>LSMinimumSystemVersion</key>
	<string>10.9</string>
	<key>LSRequiresCarbon</key>
	<true/>	
	<key>NSSupportsAutomaticTermination</key>
	<string>YES</string>
	<key>NSSupportsSuddenTermination</key>







|

|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	<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>2.2.0</string>
	<key>CFBundleVersion</key>
	<string>2.2.0</string>
	<key>LSMinimumSystemVersion</key>
	<string>10.9</string>
	<key>LSRequiresCarbon</key>
	<true/>	
	<key>NSSupportsAutomaticTermination</key>
	<string>YES</string>
	<key>NSSupportsSuddenTermination</key>

Changes to TextSweep.app/Contents/Info.plist.

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
			<key>CFBundleTypeRole</key>
			<string>Viewer</string>
		</dict>
	</array>
	<key>CFBundleExecutable</key>
	<string>Wish</string>
	<key>CFBundleGetInfoString</key>
	<string>Wish Shell 8.5.15,

Copyright © 1989-2014 Tcl Core Team,



Copyright © 2002-2014 Daniel A. Steffen,
Copyright © 2001-2009 Apple Inc.,
Copyright © 2001-2002 Jim Ingham &amp; Ian Reid</string>
	<key>CFBundleIconFile</key>
	<string>Wish.icns</string>
	<key>CFBundleIdentifier</key>
	<string>com.tcltk.wish</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleLocalizations</key>
	<array>
		<string>cs</string><string>da</string><string>de</string><string>el</string><string>en</string><string>en_gb</string><string>eo</string><string>es</string><string>fr</string><string>hu</string><string>it</string><string>nl</string><string>pl</string><string>pt</string><string>ru</string><string>sv</string>
	</array>
	<key>CFBundleName</key>
	<string>Wish</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>8.5.15</string>
	<key>CFBundleSignature</key>
	<string>WiSH</string>
	<key>CFBundleVersion</key>
	<string>8.5.15</string>
	<key>LSMinimumSystemVersion</key>
	<string>10.5.0</string>
	<key>LSRequiresCarbon</key>
	<true/>
	<key>NSAppleScriptEnabled</key>
	<true/>
	<key>OSAScriptingDefinition</key>
	<string>Wish.sdef</string>
	<key>NSHighResolutionCapable</key>
	<string>True</string>
</dict>
</plist>







|
>
|
>
>
>
|
|
|















|



|












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
			<key>CFBundleTypeRole</key>
			<string>Viewer</string>
		</dict>
	</array>
	<key>CFBundleExecutable</key>
	<string>Wish</string>
	<key>CFBundleGetInfoString</key>
	<string>Wish Shell 8.6.5,
	Copyright © 1989-2016 Tcl Core Team,
	Copyright © 1989-2016 Contributors,
	Copyright © 2011-2016 Kevin Walzer/WordTech
	Communications LLC,
	Copyright © 2014-2016 Marc Culler,
	Copyright © 2002-2016 Daniel A. Steffen,
	Copyright © 2001-2009 Apple Inc.,
	Copyright © 2001-2002 Jim Ingham &amp; Ian Reid</string>
	<key>CFBundleIconFile</key>
	<string>Wish.icns</string>
	<key>CFBundleIdentifier</key>
	<string>com.tcltk.wish</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleLocalizations</key>
	<array>
		<string>cs</string><string>da</string><string>de</string><string>el</string><string>en</string><string>en_gb</string><string>eo</string><string>es</string><string>fr</string><string>hu</string><string>it</string><string>nl</string><string>pl</string><string>pt</string><string>ru</string><string>sv</string>
	</array>
	<key>CFBundleName</key>
	<string>Wish</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>8.6.5</string>
	<key>CFBundleSignature</key>
	<string>WiSH</string>
	<key>CFBundleVersion</key>
	<string>8.6.5</string>
	<key>LSMinimumSystemVersion</key>
	<string>10.5.0</string>
	<key>LSRequiresCarbon</key>
	<true/>
	<key>NSAppleScriptEnabled</key>
	<true/>
	<key>OSAScriptingDefinition</key>
	<string>Wish.sdef</string>
	<key>NSHighResolutionCapable</key>
	<string>True</string>
</dict>
</plist>

Changes to TextSweep.app/Contents/MacOS/TextSweep.

cannot compute difference between binary files

Changes to TextSweep.app/Contents/lib/regproc/pkgIndex.tcl.

1
2
3
4
5
6
7
8
9
10
11
# Tcl package index file, version 1.1
# This file is generated by the "pkg_mkIndex" command
# and sourced either when an application starts up or
# by a "package unknown" script.  It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands.  When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.

package ifneeded regproc 1.3 [list source [file join $dir regproc.tcl]]










|
1
2
3
4
5
6
7
8
9
10
11
# Tcl package index file, version 1.1
# This file is generated by the "pkg_mkIndex" command
# and sourced either when an application starts up or
# by a "package unknown" script.  It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands.  When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.

package ifneeded regproc 1.4 [list source [file join $dir regproc.tcl]]

Changes to TextSweep.app/Contents/lib/regproc/regproc.tcl.

1
2
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
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
#regproc.tcl  routines to register serial numbers

#  Copyright (C) 2008  WordTech Communications LLC

#Proprietary to WordTech Communications LLC. Redistribution prohibited.

package provide regproc 1.3
package require http

















namespace eval regproc {

    if {![info exists library]} {
	variable library [file dirname [info script]]
    }





    #set the 30-day clock for application/version
    proc setClock {} {
	variable datadir 
	variable appname
	variable appversion
	variable appstore


	set launchTime [clock seconds]
	set saveTime [open $datadir/.$appname$appversion.rc w]
	puts $saveTime $launchTime
	close $saveTime
    }

    #read the time set
    proc readClock {} {
	variable datadir 
	variable appstatus 
	variable expstatus 
	variable appname
	variable appversion
	variable appstore


	set curTime [clock seconds]
	set oldTime [read [open $datadir/.$appname$appversion.rc r]]
	set expDate [clock scan "30 days" -base $oldTime]
	if {$curTime < $expDate } {

	    regproc::makePitch	
	} else {

	    regproc::expiredPitch
	}
    }
    
    #check to see if a time has been set
    proc checkClock {} {
	variable datadir 
	variable appname
	variable appversion
	variable appstore


	if {![file exists  $datadir/.$appname$appversion.rc]} {







	    regproc::setClock 
	    regproc::readClock
	} else {
	    regproc::readClock
	}
    }


    #dialog before demo has expired
    proc makePitch {} {
	variable version 
	variable appname
	variable appstore
	



	set buyanswer [tk_messageBox -title "Get the Full Version" -icon info -message "Get the Full Version" -detail "You are currently using a 30-day demo of $appname. This version will give you the chance to try $appname free of charge for 30 days. At the conclusion of the demo period, $appname will no longer function. Would you like to buy $appname now?" -type yesno -parent .]


	switch -- $buyanswer {

	    yes {



		exec open http://www.codebykevin.com/$appname.html

	    }


	    no {


		destroy $buyanswer
		


	    }



	}




    }








    #dialog after demo has expired
    proc expiredPitch {} {
	variable version  
	variable appname
	variable appstore

	



	#hide main window so users can't force it to run
	wm withdraw .


	set buyanswer [tk_messageBox -title "Get the Full Version" -icon info -message "Get the Full Version" -detail "This demo of $appname has expired. Would you like to buy $appname now? " -type yesno -parent .]
	switch -- $buyanswer {
	    yes {
		exec open http://www.codebykevin.com/$appname.html
		regproc::getReg
	    }
	    no {
		destroy $buyanswer
		exit

	    }

	    


	}


    }







    #check to see if appstore package or regular package

    proc checkAppStore {filename} {
	variable appstore

	
	if {[file exists $filename]} {

	    set appstore 1
	} else {
	    set appstore 0

	}
	return $appstore
    }

    #check for license, validate if found, set demo pitch if not found
    proc readLic {application version} {

	variable serial 
	variable datadir
	variable appname
	variable appversion
	variable appstore

	set appname $application
	set appversion $version


	set datadir [file join $::env(HOME) "Library" "Application Support"  "$appname" "Preferences"]




	if {[file exists $datadir/.lic]} {

	    set licnum [open $datadir/.lic r]
	    set serial [read $licnum]
	    close $licnum
	    return
	} else {
	    set serial "Demo"
	    regproc::checkClock

	}
    }


  

    #write license to file
    proc setLic {} {
	variable serial
	variable serialbase
	variable datadir
	variable appname
	variable regwindow
	variable appstore
	    





	    set count 20000

	    for {set i 1} {$i < $count} {incr i 1} {

		lappend serialbase [string toupper $appname]-[expr $i * 5]-[expr $i/11]-[expr $i - 1]-[string toupper [string trim [string range $appname 0 1]]]
	    }
	    

	    set output [lsearch  -inline $serialbase $serial]
	    puts $serial
	    puts $output
	    
	    if {$output >= 0} {
		    cd $datadir
		    set lic [open $datadir/.lic w]
		    puts $lic "$serial"
		    close $lic
		#  destroy .number
		tk_messageBox -icon info -title "Thank You" -message "Thank You" -detail "Thank you for registering $appname." -parent $regwindow
		destroy $regwindow
		#display window that was hidden
		catch {wm deiconify .}

	    } else {




		#  destroy .number
		tk_messageBox -icon warning -title "Incorrect Serial Number" -message "Incorrect Serial Number" -detail "Incorrect serial number. Please try again." -parent $regwindow
		regproc::getReg
	    }
	}



    #generate license numbers
    proc genList {application} {

	variable appname


|

|

|

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







>
>
>
>







>


|












>


|


>


>










>

|
>
>
>
>
>
>
>







<





|
>
>
>
|
>
>
|
>
|
>
>
>
|
>
|
>
>
|
>
>
|
|
>
>
|
>
>
>
|
>

>
>
|
>
>

>
>
>
>



|


>
|
>
>
>
|
|
>

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

>
>

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

<














>
|
>
>
|

|
>
|






>




<
<








|
>
>
>
>
>
|

|

|
|
|

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

|
>
>
>
>
|
|
|
|
|







1
2
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
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
#regproc.tcl  routines to register serial numbers

#Copyright 2015 WordTech Communications LLC

#MIT license

package provide regproc 1.4
package require http
package require xplat

image create photo _unlock -data  {
    R0lGODlhGAAgAIABAAAAAP///yH+GkNyZWF0ZWQgd2l0aCBHSU1QIG9uIGEgTWFj
    ACH5BAEKAAEALAAAAAAYACAAAAJRjI+gq+jO4npQWmqsBvQenzBYVE1YQH7imWbm
    ib5xA89cPcp4uPX+DwwKh7SdbWXUGF2S5VHn6oBURWrL+lBmb6UrTpucfsE14u85
    tKZ5wkMBADs=
}

image create photo _check -data {
    R0lGODlhIAAaAIABAAQHB////yH+GkNyZWF0ZWQgd2l0aCBHSU1QIG9uIGEgTWFj
    ACH5BAEKAAEALAAAAAAgABoAAAJMjI+pCeuvgIR0yVtzuFxDDnoWGIoHWZobikUV
    2zLTA89yfLNjetY7iag1Ir4VzCFMfpI6ChOYeeJeTxVTZRBie6htEOrl2sJcsmVb
    AAA7
}


namespace eval regproc {

    if {![info exists library]} {
	variable library [file dirname [info script]]
    }
    variable datadir
    variable expired
    set expired 0


    #set the 30-day clock for application/version
    proc setClock {} {
	variable datadir 
	variable appname
	variable appversion
	variable appstore
	puts "datadir is $datadir"

	set launchTime [clock seconds]
	set saveTime [open $datadir/$appname$appversion.dat w]
	puts $saveTime $launchTime
	close $saveTime
    }

    #read the time set
    proc readClock {} {
	variable datadir 
	variable appstatus 
	variable expstatus 
	variable appname
	variable appversion
	variable appstore
	variable expired

	set curTime [clock seconds]
	set oldTime [read [open $datadir/$appname$appversion.dat r]]
	set expDate [clock scan "30 days" -base $oldTime]
	if {$curTime < $expDate } {
	    set expired 0
	    regproc::makePitch	
	} else {
	    set expired 1
	    regproc::expiredPitch
	}
    }
    
    #check to see if a time has been set
    proc checkClock {} {
	variable datadir 
	variable appname
	variable appversion
	variable appstore
	variable expired

	if {[file exists $datadir/.$appname$appversion.rc]} {
	    
	    catch "file rename $datadir/.$appname$appversion.rc $datadir/$appname$appversion.dat"
	    regproc::readClock
	    return
	}

	if  {![file exists  $datadir/$appname$appversion.dat]} {
	    regproc::setClock 
	    regproc::readClock
	} else {
	    regproc::readClock
	}
    }


    #dialog before demo has expired
    proc makePitch {} {
	variable version 
	variable appname
	variable appstore

	toplevel .purchase
	wm title .purchase "Purchase $appname"
	wm resizable .purchase 0 0

	wm withdraw .purchase
	wm transient .purchase .

	wm protocol .purchase WM_DELETE_WINDOW {}

	ttk::frame .purchase.top -padding 10
	pack .purchase.top -side top -fill both -expand yes
	ttk::label .purchase.top.label -text "You are currently using a demo of $appname. This version will give you the chance to try \n$appname free of charge for 30 days. Would you like to buy $appname now?" -image _unlock -compound left -anchor n 

	pack .purchase.top.label  -side top -fill x -expand yes

	ttk::frame .purchase.bottom -padding 5
	pack .purchase.bottom -side bottom -fill both -expand yes

	ttk::frame .purchase.bottom.upper
	pack .purchase.bottom.upper -side top -fill both -expand no


	ttk::frame .purchase.bottom.lower -padding 5
	pack .purchase.bottom.lower -side bottom -fill both -expand no

	ttk::button .purchase.bottom.lower.install -text "Purchase" -default active -command "xplat::launch  http://www.codebykevin.com/$appname.html; regproc::getReg; destroy .purchase"
	ttk::button .purchase.bottom.lower.cancel -text "Cancel" -command " destroy .purchase; raise ."
	pack  .purchase.bottom.lower.install .purchase.bottom.lower.cancel  -side right -fill both -expand no
	
	::tk::PlaceWindow .purchase widget .

	wm deiconify .purchase
	focus .purchase.bottom.lower.install

	if {[tk windowingsystem] eq "aqua"} {
	    after idle [list after 0 wm attributes .purchase -notify 1]

	    bind all <FocusIn> [list add [list  wm attributes . -notify 0]]
	}

    }

    #dialog after demo has expired
    proc expiredPitch {} {
	variable version 
	variable appname
	variable appstore
	variable expired

	toplevel .expired
	wm title .expired "Purchase $appname"
	wm resizable .expired 0 0

	wm withdraw .expired
	wm transient .expired .





	wm protocol .expired WM_DELETE_WINDOW {}


	ttk::frame .expired.top -padding 10
	pack .expired.top -side top -fill both -expand yes
	ttk::label .expired.top.label -text "This demo of $appname is now expired. Would you like to buy $appname now?" -image _unlock -compound left -anchor n 

	pack .expired.top.label  -side top -fill x -expand yes

	ttk::frame .expired.bottom -padding 5
	pack .expired.bottom -side bottom -fill both -expand yes

	ttk::frame .expired.bottom.upper
	pack .expired.bottom.upper -side top -fill both -expand no


	ttk::frame .expired.bottom.lower -padding 5
	pack .expired.bottom.lower -side bottom -fill both -expand no

	ttk::button .expired.bottom.lower.install -text "Purchase" -default active -command "xplat::launch http://www.codebykevin.com/$appname.html; regproc::getReg; destroy .expired"
	ttk::button .expired.bottom.lower.cancel -text "Cancel" -command " destroy .expired; exit"
	pack  .expired.bottom.lower.install .expired.bottom.lower.cancel  -side right -fill both -expand no
	
	::tk::PlaceWindow .expired widget .

	wm deiconify .expired
	focus .expired.bottom.lower.install

	if {[tk windowingsystem] eq "aqua"} {
	    after idle [list after 0 wm attributes .expired -notify 1]



	    bind all <FocusIn> [list add [list  wm attributes . -notify 0]]
	}

    }

    #check for license, validate if found, set demo pitch if not found
    proc readLic {application version} {

	variable serial 
	variable datadir
	variable appname
	variable appversion
	variable appstore

	set appname $application
	set appversion $version

	set datadir [xplat::appconfig $appname]

	if {[file exists $datadir/.lic] } {
	    file rename $datadir/.lic $datadir/lic.dat
	}

	if {[file exists $datadir/lic.dat]} {
	    
	    set licnum [open $datadir/lic.dat r]
	    set serial [read $licnum]
	    close $licnum
	    return
	} else {
	    set serial "Demo"
	    regproc::checkClock
	    
	}
    }




    #write license to file
    proc setLic {} {
	variable serial
	variable serialbase
	variable datadir
	variable appname
	variable regwindow
	variable appstore

	if {$serial == ""} {
	    tk_messageBox -icon warning -title "Incorrect Serial Number" -message "Incorrect Serial Number" -detail "Incorrect serial number. The application will exit now." -parent .number
	    exit
	}

	set count 20000

	for {set i 1} {$i < $count} {incr i 1} {

	    lappend serialbase [string toupper $appname]-[expr $i * 5]-[expr $i/11]-[expr $i - 1]-[string toupper [string trim [string range $appname 0 1]]]
	}
	

	set output [lsearch  -inline $serialbase $serial]
	puts $serial
	puts $output
	
	if {$output >= 0} {
	    cd $datadir
	    set lic [open $datadir/lic.dat w]
	    puts $lic "$serial"
	    close $lic

	    tk_messageBox -icon info -title "Thank You" -message "Thank You" -detail "Thank you for registering $appname." -parent .number
	    destroy .number
	    #display window that was hidden
	    catch {wm deiconify .}

	} else {
	    if {$expired == 1} {
		tk_messageBox -icon warning -title "Incorrect Serial Number" -message "Incorrect Serial Number" -detail "Incorrect serial number. The application will exit now." -parent .number
		exit
	    }
	    
	    tk_messageBox -icon warning -title "Incorrect Serial Number" -message "Incorrect Serial Number" -detail "Incorrect serial number. Please try again." -parent .number
	    regproc::getReg
	}
    }



    #generate license numbers
    proc genList {application} {

	variable appname
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

	    close $keylist
	}
    }

    #dialog to input registration number from demo prompt
    proc getReg {} {

	catch {destroy .number}

	variable serial
	variable regwindow
	variable appstore



	toplevel .number

	set regwindow .number

	::tk::unsupported::MacWindowStyle style $regwindow floating {closeBox hideOnSuspen}



	wm title $regwindow "License Information"


	frame $regwindow.topframe -padx 10 -pady 10 -bg gray95
	pack $regwindow.topframe -side top -fill both -expand yes

	label $regwindow.topframe.prompt -text "License Number:" -padx 5 -pady 5 -background gray95



	entry $regwindow.topframe.entry -textvariable [namespace current]::serial



	pack  $regwindow.topframe.prompt $regwindow.topframe.entry -side top -fill x -expand yes



	frame $regwindow.bottomframe  -padx 10 -pady 10 -bg gray95
	pack $regwindow.bottomframe -side bottom -fill both -expand yes



	button $regwindow.bottomframe.cancel   -text "Cancel" -command {destroy .number} -highlightbackground gray95
	label $regwindow.bottomframe.label -text "" -width 2 -background gray95
	button $regwindow.bottomframe.run -text "Register" -command " regproc::setLic" -default active -highlightbackground gray95


	

	pack  $regwindow.bottomframe.run  $regwindow.bottomframe.cancel -side right -fill both -expand no

	focus -force $regwindow.topframe.entry
	bind $regwindow <Return> "regproc::setLic"



	focus -force $regwindow.topframe.entry
	$regwindow.topframe.entry icursor end

	bind $regwindow <Command-W> [list wm withdraw $regwindow]

	bind $regwindow <Command-w> [list wm withdraw $regwindow]



    }



    namespace export *
}








<




>
>


>
|

<
>
>

<
>

|
|

|
>
>

|
>

>
|

>
>
|
|
>
>

|
<
|
>
>

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

>



>
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
	    close $keylist
	}
    }

    #dialog to input registration number from demo prompt
    proc getReg {} {



	variable serial
	variable regwindow
	variable appstore
	variable expired
	variable appname

	toplevel .number
	wm title .number "License"
	wm resizable .number 0 0


	wm withdraw .number
	wm transient .number .


	wm protocol .number WM_DELETE_WINDOW {}

	ttk::frame .number.top -padding 10
	pack .number.top -side top -fill both -expand yes

	
	ttk::label .number.top.label -text "Please enter your serial number for $appname\nin the field below:" -image _check -compound left -anchor n -padding 10
	pack .number.top.label -side top -fill both -expand yes

	ttk::entry .number.top.entry -textvariable [namespace current]::serial
	pack .number.top.entry -side bottom -fill both -expand yes

	ttk::frame .number.bottom -padding 5
	pack .number.bottom -side bottom -fill both -expand yes

	ttk::frame .number.bottom.upper
	pack .number.bottom.upper -side top -fill both -expand no


	ttk::frame .number.bottom.lower -padding 5
	pack .number.bottom.lower -side bottom -fill both -expand no

	bind .number <Return> {regproc::setLic; destroy .number; raise .}

	ttk::button .number.bottom.lower.install -text "Register" -default active -command {regproc::setLic; destroy .number; raise .}
	ttk::button .number.bottom.lower.cancel -text "Cancel" -command "regproc::exitIfExpired; destroy .number; raise ."
	pack  .number.bottom.lower.install .number.bottom.lower.cancel  -side right -fill both -expand no
	
	::tk::PlaceWindow .number widget .

	wm deiconify .number
	focus .number.bottom.lower.install
	if {[tk windowingsystem] eq "aqua"} {
	    after idle [list after 0 wm attributes .number -notify 1]
	    bind all <FocusIn>  [list  wm attributes . -notify 0]
	}


    }

    proc exitIfExpired {} {

	variable expired
	if {$expired == 1} {
	    exit
	} 

    }

    namespace export *
}

Changes to TextSweep.app/Contents/lib/softwareupdate/softwareupdate.tcl.

1
2
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
39
40
41
42
#softwareupdate.tcl  routines to manage spoftware updates

#  Copyright (C) 2014  WordTech Communications LLC

#Proprietary to WordTech Communications LLC. Redistribution prohibited.

package provide softwareupdate 1.4
package require http
package require tdom

namespace eval softwareupdate {

    if {![info exists library]} {
	variable library [file dirname [info script]]
    }


    variable icon



































    #check version of installed software
    proc checkVersion {app version} {
	variable appversion
	variable appname
	variable currentversion
	variable versionnumber
	variable appcast
	variable sparkledata
	variable changedata


	set appname $app

	set iconfile [file join [softwareupdate::findCurrentInstallation] "Contents" "Resources" $app.icns]

	tk::mac::iconBitmap myicon 64 64 -imageFile $iconfile

	softwareupdate::checkingForUpdates

	set appcast http://www.codebykevin.com/[string tolower $appname].xml
	http::config -useragent "$appname Update Check"

	set xml [http::data [http::geturl $appcast]]




|













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














<
<
<







1
2
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
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
#softwareupdate.tcl  routines to manage spoftware updates

#  Copyright (C) 2014  WordTech Communications LLC

#MIT license

package provide softwareupdate 1.4
package require http
package require tdom

namespace eval softwareupdate {

    if {![info exists library]} {
	variable library [file dirname [info script]]
    }


    variable icon
	variable appname
    variable tmpdir
    variable currentinstall
    
    switch [tk windowingsystem] {
	"aqua" {
	    set tmpdir $::env(TMPDIR)

	}
	
	"win32" {
	    set tmpdir $::env(TMP)
	}
	
	"x11" {
	    set tmpdir $::env(TMP)
	}
    }
    
   proc setIcon {appicon} {
	
	variable icon
	set icon $appicon
	return $icon
    }

    proc setAppName {name} {

	variable appname
	set appname $name
	return $appname

    }
    

    #check version of installed software
    proc checkVersion {app version} {
	variable appversion
	variable appname
	variable currentversion
	variable versionnumber
	variable appcast
	variable sparkledata
	variable changedata


	set appname $app





	softwareupdate::checkingForUpdates

	set appcast http://www.codebykevin.com/[string tolower $appname].xml
	http::config -useragent "$appname Update Check"

	set xml [http::data [http::geturl $appcast]]
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
	variable appname
	set currentversion $number
	set appname $app
	
    }
    

    #get the current installation path
    proc findCurrentInstallation {} {
	variable currentinstall




	set approot [info nameofexecutable]
	set apppath [split $approot /]
	set currentinstall [join [lrange $apppath 0 [lsearch $apppath "*.app"]] / ]












	return $currentinstall

    }

    #prompt user to update
    proc updatePitch {} {
	variable appname
	variable myicon
	variable changedata
	variable currentversion
	variable versionnumber

	catch {destroy .updateprogress}

	catch {destroy .update}
	

	toplevel .update
	wm title .update "Software Update"

	wm withdraw .update

	frame .update.f -bg gray95
	pack .update.f -fill both -expand yes

	frame .update.f.top -bg gray95
	pack .update.f.top -fill both -expand yes

	label .update.f.top.i -bitmap myicon -bg gray95 -relief flat -highlightthickness 0
	pack .update.f.top.i -side left -fill both -expand yes

	frame .update.f.top.r -bg gray95
	pack .update.f.top.r -side right -fill both -expand yes

	label .update.f.top.r.title -text "A new version of $appname is available!" -font {-weight bold} -bg gray95 -relief flat -highlightthickness 0
	pack .update.f.top.r.title -fill both -expand yes -side top







|


>
>
>
>
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>







|




















|







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
	variable appname
	set currentversion $number
	set appname $app
	
    }
    

   #get the current installation path
    proc findCurrentInstallation {} {
	variable currentinstall
	variable appname 
	switch [tk windowingsystem] {

	    "aqua" {
		set approot [info nameofexecutable]
		set apppath [split $approot /]
		set currentinstall [join [lrange $apppath 0 [lsearch $apppath "*.app"]] / ]
	    }
	    
	    "win32" {
		set currentinstall [file join $::env(APPDATA)  CodebyKevin $appname]
		
	    }
	    
	    "x11" {
		return
	    }
	}
	
	return $currentinstall

    }

    #prompt user to update
    proc updatePitch {} {
	variable appname
	variable icon
	variable changedata
	variable currentversion
	variable versionnumber

	catch {destroy .updateprogress}

	catch {destroy .update}
	

	toplevel .update
	wm title .update "Software Update"

	wm withdraw .update

	frame .update.f -bg gray95
	pack .update.f -fill both -expand yes

	frame .update.f.top -bg gray95
	pack .update.f.top -fill both -expand yes

	label .update.f.top.i -image $icon -bg gray95 -relief flat -highlightthickness 0
	pack .update.f.top.i -side left -fill both -expand yes

	frame .update.f.top.r -bg gray95
	pack .update.f.top.r -side right -fill both -expand yes

	label .update.f.top.r.title -text "A new version of $appname is available!" -font {-weight bold} -bg gray95 -relief flat -highlightthickness 0
	pack .update.f.top.r.title -fill both -expand yes -side top
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
    }


    #"busy" dialog
    proc checkingForUpdates {} {

	variable appname


	catch {destroy .updateprogress}

	toplevel .updateprogress 
	wm title .updateprogress "Updating $appname"

	wm withdraw .updateprogress
	update idletasks

	ttk::frame .updateprogress.f -padding 5
	pack .updateprogress.f -fill both -expand yes

	label .updateprogress.f.l -bg gray95 -bitmap myicon -bd 0 -relief flat -highlightthickness 0
	pack .updateprogress.f.l -side left -fill both -expand yes

	frame .updateprogress.f.r -bg gray95 -bd 0 -highlightcolor gray95
	pack .updateprogress.f.r -side right -fill both -expand yes
	
	
	ttk::label .updateprogress.f.r.t -text "Checking for updates..." -padding 5







>












|







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
    }


    #"busy" dialog
    proc checkingForUpdates {} {

	variable appname
	variable icon

	catch {destroy .updateprogress}

	toplevel .updateprogress 
	wm title .updateprogress "Updating $appname"

	wm withdraw .updateprogress
	update idletasks

	ttk::frame .updateprogress.f -padding 5
	pack .updateprogress.f -fill both -expand yes

	label .updateprogress.f.l -bg gray95 -image $icon -bd 0 -relief flat -highlightthickness 0
	pack .updateprogress.f.l -side left -fill both -expand yes

	frame .updateprogress.f.r -bg gray95 -bd 0 -highlightcolor gray95
	pack .updateprogress.f.r -side right -fill both -expand yes
	
	
	ttk::label .updateprogress.f.r.t -text "Checking for updates..." -padding 5
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
    }

    #download and install the update
    proc installUpdate {} {
	variable currentinstall
	variable status
	variable appname


	catch {destroy .update}

	softwareupdate::findCurrentInstallation

	variable appname
	variable status



        softwareupdate::progressDialog
	set status "Downloading update for $appname"
	http::geturl http://www.codebykevin.com/updates/[list $appname].tgz -channel [open /tmp/$appname.tgz w] 
	update
	after 1000
	cd /tmp
	set status "Unpacking update for $appname"
	update
	after 1000
	catch {exec tar xvfz [list $appname].tgz}















	set status "Ready to install"
	.downloadprogress.frame.bar configure -mode determinate
	.downloadprogress.frame.bar configure -value 100
	.downloadprogress.frame.bar stop
	destroy .downloadprogress.frame.b 
	pack [	ttk::button .downloadprogress.frame.b -text "Install and Relaunch" -command softwareupdate::launchUpdate] -side right -fill both -expand no
	return
    }


    #launch the update
    proc launchUpdate {}  {

	variable currentinstall
	variable appname


	catch {destroy .downloadprogress}


	if {[catch {exec codesign -v /tmp/$appname.app} msg]} {
	    bgerror $msg
	    tk_messageBox -icon warning -message "Error!" -detail "An error occurred in the installation of $appname. Please try again later."
	    return
	} else {

	    file rename -force $currentinstall [file join /Users [exec whoami] .Trash [file tail $currentinstall]]

	    file rename -force /tmp/$appname.app $currentinstall

	    exec $currentinstall/Contents/MacOS/$appname &

	    exit
	}

    }






    













    namespace export *

}







>





|
|
|
>

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





|









>
|
|

>
|
|
|
|
|

|

|

|

|
|
|
|
>
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>




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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
    }

    #download and install the update
    proc installUpdate {} {
	variable currentinstall
	variable status
	variable appname
	variable tmpdir

	catch {destroy .update}

	softwareupdate::findCurrentInstallation

	softwareupdate::progressDialog
	set status "Downloading update for $appname"
	
	switch [tk windowingsystem] {


	    "aqua" {
		http::geturl http://www.codebykevin.com/updates/[list $appname].tgz -channel [open $tmpdir/[list $appname].tgz w] 
		update
		after 1000
		cd $tmpdir
		set status "Unpacking update for $appname"
		update
		after 1000
		catch {exec tar xvfz [list $appname].tgz}
	    }
	    
	    "win32" {
		
		http::geturl http://www.codebykevin.com/updates/[list $appname].exe -channel [open $tmpdir/[list $appname].exe w] 

	    }
	    
	    "x11" {
		tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
		return
	    }
	}
	
	
	set status "Ready to install"
	.downloadprogress.frame.bar configure -mode determinate
	.downloadprogress.frame.bar configure -value 100
	.downloadprogress.frame.bar stop
	destroy .downloadprogress.frame.b 
	pack [ttk::button .downloadprogress.frame.b -text "Install and Relaunch" -command softwareupdate::launchUpdate] -side right -fill both -expand no
	return
    }


    #launch the update
    proc launchUpdate {}  {

	variable currentinstall
	variable appname
	variable tmpdir
	
	switch [tk windowingsystem] {

	    "aqua" {
		if {[catch {exec codesign -v $tmpdir/$appname.app} msg]} {
		    bgerror $msg
		    tk_messageBox -icon warning -message "Error!" -detail "An error occurred in the installation of $appname. Please try again later."
		    return
		} else {

		    file rename -force $currentinstall [file join /Users [exec whoami] .Trash [file tail $currentinstall]]

		    file rename -force /tmp/$appname.app $currentinstall

		    exec $currentinstall/Contents/MacOS/$appname &

		    exit
		}
	    }
	    
	    "win32" {
		
		file rename -force $currentinstall/[list $appname].exe $tmpdir/[list $appname].exe~
		file copy $tmpdir/[list $appname].exe $currentinstall/[list $appname.exe]
		exec $currentinstall/[list $appname].exe &
		exit
	    }
	    
	    "x11" {
		tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
		return
	    }
	}

	catch {destroy .downloadprogress}

	

    }

    namespace export *

}

Changes to TextSweep.app/Contents/lib/textsweep/textsweep-main.tcl.

1
2
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
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
# TextSweep: batch search-replace tool 

#  Copyright (C) 2014 WordTech Communications LLC

#Proprietary to WordTech Communications LLC. Redistribution prohibited.

#let's get started

#initialize package requirements
package require tablelist_tile
package require fileutil 
package require windowlist
package require Img
package require tkdnd
package require regproc
package require appstorereceipt
package require machelp
package require softwareupdate
package require aquahig
package require appname
package require customfont
package require fullscreen
package require launcher

package require cocoaprint


#initialize variables
global folder
global searchvar
global patternvar
global replacevar
global searchterm
global filelist


set folder {}
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"  2>$cachedir/bgerr
}

#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]
    


    tk::mac::iconBitmap logo 128 128 -imageFile [file join [softwareupdate::findCurrentInstallation] "Contents/Resources/TextSweep.icns"]
    

















}

#display user help
proc tk::mac::ShowHelp {} {
    machelp::userhelp
}

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

proc aboutWindow {} {

    set w .aboutw
    catch {destroy $w}
    toplevel $w 
    ::tk::unsupported::MacWindowStyle style $w floating {closeBox hideOnSuspen}
    wm title $w "About TextSweep"


    frame $w.ftext
    frame $w.fbutton
    label $w.l -bitmap logo -bg gray95

    pack $w.l -in $w -side top -expand no -fill both 
    pack $w.ftext -in $w -side bottom -expand no -fill both 
    pack $w.fbutton -in $w -side bottom

    text $w.ftext.text -yscrollcommand "$w.ftext.sbar set" \
        -wrap word -font {LucidaGrande}
    scrollbar $w.ftext.sbar -takefocus 0 -command "$w.ftext.text yview"
    
    pack $w.ftext.text -in $w.ftext -side left -fill both -expand yes
    pack $w.ftext.sbar -in $w.ftext -side right -fill y

    $w.ftext.text tag configure center -justify center
    $w.ftext.text tag configure bold -font {-weight bold}
    $w.ftext.text tag configure url -foreground blue
    $w.ftext.text tag bind url <ButtonPress-1> {
	launcher::launchurl "http://www.codebykevin.com/TextSweep.html"
    }

    
    $w.ftext.text insert end "TextSweep $appname::version\n" "bold center"
    $w.ftext.text insert end "Powerful Search and Replace\n\n" center
    $w.ftext.text insert end "Copyright (c) 2014 WordTech Communications LLC\n\n" center
    $w.ftext.text insert end "http://www.codebykevin.com/TextSweep.html\n\n" "url center"
    $w.ftext.text insert end "See Acknowledgements in TextSweep Help for additional credits and see History in TextSweep Help for changes in this version" center
    
    $w.ftext.text config -state disabled

    bind $w <Command-W> [list wm withdraw $w]
    bind $w <Command-w> [list wm withdraw $w]

    wm geometry $w 350x340

}

#check file list to ensure existence
proc checkfilelist {} {


|












<




|
|
|
>
|
|








>








>





|










|
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


















<





|
















|





|





|
|







1
2
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
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
# TextSweep: batch search-replace tool 

#  Copyright (C) 2016 WordTech Communications LLC

#Proprietary to WordTech Communications LLC. Redistribution prohibited.

#let's get started

#initialize package requirements
package require tablelist_tile
package require fileutil 
package require windowlist
package require Img
package require tkdnd
package require regproc

package require machelp
package require softwareupdate
package require aquahig
package require appname
package require xplat


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

#initialize variables
global folder
global searchvar
global patternvar
global replacevar
global searchterm
global filelist
global platform_name

set folder {}
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"  
}

#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]
	
	image create photo logo -data {
	iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4AQODiESuncpcAAAGMNJREFUeNrdm3l0XPWV5z+/t9QrVZX2xZblRbJsyxLYgGyZzSYGAgGzBOLukBh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/vepihcDbgolQAgEJpL35E9KpEWr+eAZgrG4ebGxhiw2hjgHyHh4/7bnCoYxGgY9vYrecWK+Mo7/yZ48TWXvndv35GNtZW15ysnHcPNJITyfcontZIaeotgyBglINvyZigqu4aRaDuDx/qpmzkNVFYAzaIWUIr+I3tFVw+/FuCqDyNQFYh0HqQ6QUVTf/Gi6Jgb5aPouFzcsNk78ujTziNNM819YbNnmp8ZmOT5xCIl063ySa2EypowzMkgrOx02oujB2YSCM5m3/t/xHN9Jk1twQomkG4HofIbONa1j8Ge/fKrdydvHXNPNY4GFFYtVeA0NZaEjxsB3phjs7BqKIUP6P/pJ8k/Kni+OEzkqX8q/rlQh5du3/ATSipmq5LKRhEumUGobD5Sevhekt7Ot1U65aGUFMFIOYGQgW5+lkDRdA7t/i3DI/z3nNP8MYBUQcUaS8R4+7/sVdkxEWSM2etj6nPefEBb+3ehK6ZNFp8NBVmiIadIXxEIlmAVVRIbPERsRDwTKZJfmD73Ykoq6giESokNdNG+9UW+8+P09ANd0pkAwBPt5Rl5V/gE5dQoAF1Ye/VxhEgCGaERWvOdovPqqrW5QYupuiZK3/vAfeSic83Vhq6ahFB15BZS40nx91/6YeL+gr9XJwn/k3r9kyBgbFQU1t6xqlyoIXlhEgUgRGGJa23RK69ebFbd/2j6iOsdF+5yTJ6PR4j6RN4W/xjRIcYpQ+IUY1DjfFYnMCYKeOz2fwE2bRiycGlcGgAAAABJRU5ErkJggg==
	
	}
	
	image create photo folder -data {
R0lGODlhFgAWAIABAAAAAP///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAEALAAAAAAWABYAAAIghG+hy4zY4npHSoqz3tD6D4aiwpXmiabqyrbuC8fyXBYAOw==
	
	}
	
	
	image create photo glass -data {
R0lGODlhFgAWAIABAAAAAP///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAEALAAAAAAWABYAAAJAjB+gi90LmTuxqpmg0/tiTnlYBjziKJEjkqZre6KiK5cG/c1xbt+72fP9QkFh0birkCwdi3PCXOJekRUUZGVdCgA7
	}
	
	image create photo reverse -data {
R0lGODlhFgAWAIABAAAAAP///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAEALAAAAAAWABYAAAI8jG+gi90L2VEoWiZDdBek7Gib6IXTBoYXaX5d2ZppXFG0at9Prp9w7wPWfsKZDhIj+nguZfPlXFp601ABADs=	
	
	}
  

}

#display user help
proc tk::mac::ShowHelp {} {
    machelp::userhelp
}

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

proc aboutWindow {} {

    set w .aboutw
    catch {destroy $w}
    toplevel $w 

    wm title $w "About TextSweep"


    frame $w.ftext
    frame $w.fbutton
    label $w.l -image logo -bg gray95

    pack $w.l -in $w -side top -expand no -fill both 
    pack $w.ftext -in $w -side bottom -expand no -fill both 
    pack $w.fbutton -in $w -side bottom

    text $w.ftext.text -yscrollcommand "$w.ftext.sbar set" \
        -wrap word -font {LucidaGrande}
    scrollbar $w.ftext.sbar -takefocus 0 -command "$w.ftext.text yview"
    
    pack $w.ftext.text -in $w.ftext -side left -fill both -expand yes
    pack $w.ftext.sbar -in $w.ftext -side right -fill y

    $w.ftext.text tag configure center -justify center
    $w.ftext.text tag configure bold -font {-weight bold}
    $w.ftext.text tag configure url -foreground blue
    $w.ftext.text tag bind url <ButtonPress-1> {
	xplat::launch "http://www.codebykevin.com/TextSweep.html"
    }

    
    $w.ftext.text insert end "TextSweep $appname::version\n" "bold center"
    $w.ftext.text insert end "Powerful Search and Replace\n\n" center
    $w.ftext.text insert end "Copyright (c) 2016 WordTech Communications LLC\n\n" center
    $w.ftext.text insert end "http://www.codebykevin.com/TextSweep.html\n\n" "url center"
    $w.ftext.text insert end "See Acknowledgements in TextSweep Help for additional credits and see History in TextSweep Help for changes in this version" center
    
    $w.ftext.text config -state disabled

    bind $w <[xplat::controlkey]-W> [list wm withdraw $w]
    bind $w <[xplat::controlkey]-w> [list wm withdraw $w]

    wm geometry $w 350x340

}

#check file list to ensure existence
proc checkfilelist {} {
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
    set wmy [expr [winfo rooty $w]+[winfo height $w]]
    wm geometry $top \
	[winfo reqwidth $top.txt]x[winfo reqheight $top.txt]+$wmx+$wmy
    raise $top
}


#code to make canvas gradient, based on code at http://wiki.tcl.tk/6100
proc + {n1 n2} {
    expr {$n1 + $n2}
}
proc - {n1 n2} {
    expr {$n1 - $n2}
}
proc * {n1 n2} {
    expr {$n1 * $n2}
}
proc / {n1 n2} {
    expr {$n1 / $n2}
}
proc toInt {n} {
    expr int($n)
}

proc drawGradient {win type col1Str col2Str} {
    $win delete gradient
    
    set width [winfo width $win]
    set height [winfo height $win]
    
    foreach {r1 g1 b1} [winfo rgb $win $col1Str] break
    foreach {r2 g2 b2} [winfo rgb $win $col2Str] break
    set rRange [- $r2.0 $r1]
    set gRange [- $g2.0 $g1]
    set bRange [- $b2.0 $b1]
    
    if {$type == "x"} {
	set rRatio [/ $rRange $width]
	set gRatio [/ $gRange $width]
	set bRatio [/ $bRange $width]
	
	for {set x 0} {$x < $width} {incr x} {
	    set nR [toInt [+ $r1 [* $rRatio $x]]]
	    set nG [toInt [+ $g1 [* $gRatio $x]]]
	    set nB [toInt [+ $b1 [* $bRatio $x]]]
	    
	    set col [format {%4.4x} $nR]
	    append col [format {%4.4x} $nG]
	    append col [format {%4.4x} $nB]
	    $win create line $x 0 $x $height -tags gradient -fill #${col}
	}
    } else {
	set rRatio [/ $rRange $height]
	set gRatio [/ $gRange $height]
	set bRatio [/ $bRange $height]
	
	for {set y 0} {$y < $height} {incr y} {
	    set nR [toInt [+ $r1 [* $rRatio $y]]]
	    set nG [toInt [+ $g1 [* $gRatio $y]]]
	    set nB [toInt [+ $b1 [* $bRatio $y]]]
	    
	    set col [format {%4.4x} $nR]
	    append col [format {%4.4x} $nG]
	    append col [format {%4.4x} $nB]
	    $win create line 0 $y $width $y -tags gradient -fill #${col}
	}
    }
    return $win
}


#restore state
proc readState {} {

    global searchvar
    global datadir


    if {[file exists $datadir/.state]} {
	source $datadir/.state
	set searchvar $searchvar
	set replacear $replacevar
	
    }
    
}

#write out state
proc writeState {} {

    global searchvar
    global datadir
    global replacevar
    

    set state [open $datadir/.state w+]
    puts $state [list set searchvar $searchvar]
    puts $state [list set replacevar $replacevar]
    close $state

    after 5000 writeState

}
#draw the GUI
proc drawGUI {} {

    global folder
    global searchvar
    global patternvar
    global replacevar
    global searchterm
    global appname
    global cachedir
    global datadir

    wm title . "TextSweep"

    . configure -height 700 -width 700
    
    ::customfont::addcustomfont iconic_stroke.ttf ;# 24.0
    ::fullscreen::fullscreen .


    set patternvar *

    
    bind . <Command-W> {wm state .  withdrawn}
    bind . <Command-w> {wm state .  withdrawn}


    global runsearch 
    global folder_documents 
    global edit_undo

    
    menu .mb
    

    menu .mb.apple
    .mb.apple add command -label "About TextSweep" -command tkAboutDialog
    if {$regproc::appstore == 0} {
	.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 "Command-H"
    .mb.search add command -label "Undo" -command batchUndo -accelerator "Command-Z"
    .mb add cascade -label "Search" -menu .mb.search
    


    #window menu
    windowlist::windowMenu .mb


    
    menu .mb.help -tearoff 0
    




    .mb.help add command -label "Contact Code by Kevin" -command machelp::usermail
    .mb.help add command -label "Web Site" -command  machelp::appweb 







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

    . configure -menu .mb
    
    ttk::style configure Toolbutton -font {Iconic 22} 

    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 -text \ue065 -style Toolbutton -command setDir -takefocus 0
    pack .f.buttons.folder  -side left  -expand no
    balloon .f.buttons.folder  "Select the directory to search"

    ttk::button .f.buttons.search -text  \ue074 -style Toolbutton -command batchReplace -takefocus 0
    pack .f.buttons.search  -side left  -expand no
    balloon .f.buttons.search "Replace text"

    ttk::button .f.buttons.reload -text \ue031 -style Toolbutton -command batchUndo -takefocus 0
    pack .f.buttons.reload  -side left  -expand no
    balloon .f.buttons.reload  "Undo replace"

    
    ttk::frame .f.foldersearch -padding 5
    pack .f.foldersearch -fill both -expand no -side top
    







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
















|

>




|
|









>


<


<


>



|
|


>
>


>




>
>
>
>


>
>
>
>
>
>





<
<








|



|



|







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
    set wmy [expr [winfo rooty $w]+[winfo height $w]]
    wm geometry $top \
	[winfo reqwidth $top.txt]x[winfo reqheight $top.txt]+$wmx+$wmy
    raise $top
}


































































































#draw the GUI
proc drawGUI {} {

    global folder
    global searchvar
    global patternvar
    global replacevar
    global searchterm
    global appname
    global cachedir
    global datadir

    wm title . "TextSweep"

    . configure -height 700 -width 700
    
    if {[tk windowingsystem] eq "aqua"} {
    ::fullscreen::fullscreen .
	}

    set patternvar *

    
    bind . <[xplat::controlkey]-W> {wm state .  withdrawn}
    bind . <[xplat::controlkey]-w> {wm state .  withdrawn}


    global runsearch 
    global folder_documents 
    global edit_undo

    
    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 "aqua"} {
    #window menu
    windowlist::windowMenu .mb
	}

    
    menu .mb.help -tearoff 0
    
    if {[tk windowingsystem] ne "aqua"} {
	
	    .mb.help add command -label "Help" -command machelp::showhelp
	}
    .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 folder -style Toolbutton -command setDir -takefocus 0
    pack .f.buttons.folder  -side left  -expand no
    balloon .f.buttons.folder  "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
    balloon .f.buttons.search "Replace text"

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

    
    ttk::frame .f.foldersearch -padding 5
    pack .f.foldersearch -fill both -expand no -side top
    
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
    ttk::button .f.bottom.replaceall -text "Replace in All Files" -command  batchReplace -default active
    ttk::button .f.bottom.undo -text "Undo" -command batchUndo
    
    pack  .f.bottom.replaceall .f.bottom.undo -side right -fill x -expand no

    bind .f.text.t <Button-1> {focus .f.text.t} 
    
    canvas .gradient -bd .1 -highlightthickness .01 -height 20
    bind .gradient <Configure> [list drawGradient .gradient y gray90 gray60]

    pack .gradient -fill both  -side bottom ;#-expand 0

    ttk::separator .bottomsep1 -orient vertical 
    pack .bottomsep1 -side bottom -fill both -expand no -side bottom
    
    if {[file exists $datadir/.state]} {
	readState
    } else {
	set searchvar {}
	set replacevar  {}
    }

    bind all <Command-Q> ::tk::mac::Quit
    bind all <Command-q> ::tk::mac::Quit
    bind all <Command-Z> batchUndo
    bind all <Command-z> batchUndo
    
}

#handle program shutdown via command-q
proc ::tk::mac::Quit {} {
    writeState
    saveWindowPosition
    exit
}

proc saveWindowPosition {} {

    global datadir 
    global windowposition

    set saveWindow [wm geometry .]
    set wingeo [open $datadir/.windowposition w+]
    puts $wingeo [list set windowposition $saveWindow]
    close $wingeo

}


#restore last saved window position
proc checkWindowPosition {} {

    global datadir windowposition

    set windowposition ""

    if {[file exists $datadir/.windowposition]} {
	source $datadir/.windowposition
	puts $windowposition
	
	wm geometry . $windowposition
	
    }  else {
	wm geometry . 900x650 
    }
}

#set search directory
proc setDir {} {

    global folder
    global patternvar
    global searchterm







<
<
|
<

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



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







359
360
361
362
363
364
365


366

367


368






369


370
371
372
373
374





375































376
377
378
379
380
381
382
    ttk::button .f.bottom.replaceall -text "Replace in All Files" -command  batchReplace -default active
    ttk::button .f.bottom.undo -text "Undo" -command batchUndo
    
    pack  .f.bottom.replaceall .f.bottom.undo -side right -fill x -expand no

    bind .f.text.t <Button-1> {focus .f.text.t} 
    


   




    bind all <[xplat::controlkey]-Q> exit






    bind all <[xplat::controlkey]-q> exit


    bind all <[xplat::controlkey]-Z> batchUndo
    bind all <[xplat::controlkey]-z> batchUndo
    
}







































#set search directory
proc setDir {} {

    global folder
    global patternvar
    global searchterm
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
#initialize the app
proc startUp {} {
    global appname
    global appversion
    global datadir
    global cachedir
    
    appname::setAppName TextSweep 2.1

    
    #check for app support directory
    set appdir [file join $::env(HOME) "Library" "Application Support" "TextSweep"]
    if {![file exists $appdir]} {
	file mkdir $appdir
    }

    #check for preferences directory
    set olddatadir [file join $::env(HOME) "Library" "Preferences" "TextSweep"]
    set datadir  [file join $::env(HOME) "Library" "Application Support" "TextSweep" "Preferences"]
    set cachedir  [file join $::env(HOME) "Library" "Application Support" "TextSweep" "Cache"]

    if {![file exists $cachedir]} {
	file mkdir $cachedir
    }

    if {[file exists $olddatadir]} {
	file rename -force $olddatadir $datadir
    } else {
	if {![file exists $datadir]} {
	    file mkdir $datadir
	} else {
	    
	}
    }

    set resourcedir [file join [softwareupdate::findCurrentInstallation] "Contents" "Resources"]

    regproc::checkAppStore [file join $resourcedir ".appstore"]
    puts "regproc::appstore is $regproc::appstore"

    if {$regproc::appstore == 1} {
	appstorereceipt::validatereceipt 
    }


    makeImage
    softwareupdate::setVersion $appname::name $appname::version
    machelp::setAppName $appname::name $appname::version
    drawGUI
    checkWindowPosition

    after 50 
    if {$regproc::appstore == 0} {
	regproc::readLic $appname::name $appname::version
    }


}

trace add variable searchvar write updateSearchTerm
startUp







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






<
<

<

<






652
653
654
655
656
657
658
659
660
661

































662
663
664
665
666
667


668

669

670
671
672
673
674
675
#initialize the app
proc startUp {} {
    global appname
    global appversion
    global datadir
    global cachedir
    
    appname::setAppName TextSweep 2.2
	
	set datadir [xplat::appconfig TextSweep]



































    makeImage
    softwareupdate::setVersion $appname::name $appname::version
    machelp::setAppName $appname::name $appname::version
    drawGUI


    after 50 

	regproc::readLic $appname::name $appname::version



}

trace add variable searchvar write updateSearchTerm
startUp

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

1
2
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
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
# TextSweep: batch search-replace tool 

#  Copyright (C) 2014 WordTech Communications LLC

#Proprietary to WordTech Communications LLC. Redistribution prohibited.

#let's get started

#initialize package requirements
package require tablelist_tile
package require fileutil 
package require windowlist
package require Img
package require tkdnd
package require regproc
package require appstorereceipt
package require machelp
package require softwareupdate
package require aquahig
package require appname
package require customfont
package require fullscreen
package require launcher

package require cocoaprint


#initialize variables
global folder
global searchvar
global patternvar
global replacevar
global searchterm
global filelist


set folder {}
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"  2>$cachedir/bgerr
}

#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]
    


    tk::mac::iconBitmap logo 128 128 -imageFile [file join [softwareupdate::findCurrentInstallation] "Contents/Resources/TextSweep.icns"]
    

















}

#display user help
proc tk::mac::ShowHelp {} {
    machelp::userhelp
}

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

proc aboutWindow {} {

    set w .aboutw
    catch {destroy $w}
    toplevel $w 
    ::tk::unsupported::MacWindowStyle style $w floating {closeBox hideOnSuspen}
    wm title $w "About TextSweep"


    frame $w.ftext
    frame $w.fbutton
    label $w.l -bitmap logo -bg gray95

    pack $w.l -in $w -side top -expand no -fill both 
    pack $w.ftext -in $w -side bottom -expand no -fill both 
    pack $w.fbutton -in $w -side bottom

    text $w.ftext.text -yscrollcommand "$w.ftext.sbar set" \
        -wrap word -font {LucidaGrande}
    scrollbar $w.ftext.sbar -takefocus 0 -command "$w.ftext.text yview"
    
    pack $w.ftext.text -in $w.ftext -side left -fill both -expand yes
    pack $w.ftext.sbar -in $w.ftext -side right -fill y

    $w.ftext.text tag configure center -justify center
    $w.ftext.text tag configure bold -font {-weight bold}
    $w.ftext.text tag configure url -foreground blue
    $w.ftext.text tag bind url <ButtonPress-1> {
	launcher::launchurl "http://www.codebykevin.com/TextSweep.html"
    }

    
    $w.ftext.text insert end "TextSweep $appname::version\n" "bold center"
    $w.ftext.text insert end "Powerful Search and Replace\n\n" center
    $w.ftext.text insert end "Copyright (c) 2014 WordTech Communications LLC\n\n" center
    $w.ftext.text insert end "http://www.codebykevin.com/TextSweep.html\n\n" "url center"
    $w.ftext.text insert end "See Acknowledgements in TextSweep Help for additional credits and see History in TextSweep Help for changes in this version" center
    
    $w.ftext.text config -state disabled

    bind $w <Command-W> [list wm withdraw $w]
    bind $w <Command-w> [list wm withdraw $w]

    wm geometry $w 350x340

}

#check file list to ensure existence
proc checkfilelist {} {


|












<




|
|
|
>
|
|








>








>





|










|
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


















<





|
















|





|





|
|







1
2
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
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
# TextSweep: batch search-replace tool 

#  Copyright (C) 2016 WordTech Communications LLC

#Proprietary to WordTech Communications LLC. Redistribution prohibited.

#let's get started

#initialize package requirements
package require tablelist_tile
package require fileutil 
package require windowlist
package require Img
package require tkdnd
package require regproc

package require machelp
package require softwareupdate
package require aquahig
package require appname
package require xplat


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

#initialize variables
global folder
global searchvar
global patternvar
global replacevar
global searchterm
global filelist
global platform_name

set folder {}
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"  
}

#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]
	
	image create photo logo -data {
	iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4AQODiESuncpcAAAGMNJREFUeNrdm3l0XPWV5z+/t9QrVZX2xZblRbJsyxLYgGyZzSYGAgGzBOLukBhyshEz3ZOQk+SEYaCDnzEzSZM0tDtnmM4wMGkGQggJHQINDmExi8EDXoiNd9mybFmWrK1Updre8vvNH1UlykK2ZWKYM/3OuefVq3p67/f93nu/9/5+70nwKW62bV8ItABTAQ3wgQTQC2y1bXsHn/JmfJo3U0q9FAwGI5FIBE3TUErheR6JRALHcd4DFv27JcC2bd113cjy5csJBoMIIRBCoGkaBw8e5MUXX2zh/8GmfYr3agsEAoRCIaLRKNFolOHhYVKpFOXl5SilwrZti3+XBNi2DdBWVlaWT4VR7yulqKqqQkoJMP//KwJywCZ63sKqqiolpcQwDAzDQNd1hBAYhkFpaSnAvIlcs/CciY7hjGqAbdufBx4ALgGOTFAA2yorK4WUEl3X0XUdTdPQtKwPKisr6erqOiUBtm3n7edKqb8BzgU++MQjID8w27bv9n3/9zU1NQ2+73fZtv2tiXhCStlcXV0NcBwBuq4jpaS6uhql1NkTGMqcVatWdUcikW+3trZqruttv2fNT68rPOHBL088sMVpev5nQogfXH311dTU1LBnzx61YcMGoWnaK8CVgCzwELZtVwG3KaW+lEqlzr799tvxPG9UA/IkBINBdu3axQsvvKBM09wghHgCeNi2bb+AeGzbtl3XXdXW1qauufZ6MTJ0hGd/8UPV1/Gu0EcO7EUIKYR4GbgLiH/vSXnmCLBt+x4hxOobbrgBy7JIJBKUlJSQTqdZt26dGhkZSQshltq2/a5t2wuAn7muu7SiooLZs2dTX1/P5MmTSaVSo1GQT4FAIIBpmnR3d9Pe3q62bdsmEokE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0lGODlhFgAWAIABAAAAAP///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAEALAAAAAAWABYAAAIghG+hy4zY4npHSoqz3tD6D4aiwpXmiabqyrbuC8fyXBYAOw==
	
	}
	
	
	image create photo glass -data {
R0lGODlhFgAWAIABAAAAAP///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAEALAAAAAAWABYAAAJAjB+gi90LmTuxqpmg0/tiTnlYBjziKJEjkqZre6KiK5cG/c1xbt+72fP9QkFh0birkCwdi3PCXOJekRUUZGVdCgA7
	}
	
	image create photo reverse -data {
R0lGODlhFgAWAIABAAAAAP///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAEALAAAAAAWABYAAAI8jG+gi90L2VEoWiZDdBek7Gib6IXTBoYXaX5d2ZppXFG0at9Prp9w7wPWfsKZDhIj+nguZfPlXFp601ABADs=	
	
	}
  

}

#display user help
proc tk::mac::ShowHelp {} {
    machelp::userhelp
}

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

proc aboutWindow {} {

    set w .aboutw
    catch {destroy $w}
    toplevel $w 

    wm title $w "About TextSweep"


    frame $w.ftext
    frame $w.fbutton
    label $w.l -image logo -bg gray95

    pack $w.l -in $w -side top -expand no -fill both 
    pack $w.ftext -in $w -side bottom -expand no -fill both 
    pack $w.fbutton -in $w -side bottom

    text $w.ftext.text -yscrollcommand "$w.ftext.sbar set" \
        -wrap word -font {LucidaGrande}
    scrollbar $w.ftext.sbar -takefocus 0 -command "$w.ftext.text yview"
    
    pack $w.ftext.text -in $w.ftext -side left -fill both -expand yes
    pack $w.ftext.sbar -in $w.ftext -side right -fill y

    $w.ftext.text tag configure center -justify center
    $w.ftext.text tag configure bold -font {-weight bold}
    $w.ftext.text tag configure url -foreground blue
    $w.ftext.text tag bind url <ButtonPress-1> {
	xplat::launch "http://www.codebykevin.com/TextSweep.html"
    }

    
    $w.ftext.text insert end "TextSweep $appname::version\n" "bold center"
    $w.ftext.text insert end "Powerful Search and Replace\n\n" center
    $w.ftext.text insert end "Copyright (c) 2016 WordTech Communications LLC\n\n" center
    $w.ftext.text insert end "http://www.codebykevin.com/TextSweep.html\n\n" "url center"
    $w.ftext.text insert end "See Acknowledgements in TextSweep Help for additional credits and see History in TextSweep Help for changes in this version" center
    
    $w.ftext.text config -state disabled

    bind $w <[xplat::controlkey]-W> [list wm withdraw $w]
    bind $w <[xplat::controlkey]-w> [list wm withdraw $w]

    wm geometry $w 350x340

}

#check file list to ensure existence
proc checkfilelist {} {
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
    set wmy [expr [winfo rooty $w]+[winfo height $w]]
    wm geometry $top \
	[winfo reqwidth $top.txt]x[winfo reqheight $top.txt]+$wmx+$wmy
    raise $top
}


#code to make canvas gradient, based on code at http://wiki.tcl.tk/6100
proc + {n1 n2} {
    expr {$n1 + $n2}
}
proc - {n1 n2} {
    expr {$n1 - $n2}
}
proc * {n1 n2} {
    expr {$n1 * $n2}
}
proc / {n1 n2} {
    expr {$n1 / $n2}
}
proc toInt {n} {
    expr int($n)
}

proc drawGradient {win type col1Str col2Str} {
    $win delete gradient
    
    set width [winfo width $win]
    set height [winfo height $win]
    
    foreach {r1 g1 b1} [winfo rgb $win $col1Str] break
    foreach {r2 g2 b2} [winfo rgb $win $col2Str] break
    set rRange [- $r2.0 $r1]
    set gRange [- $g2.0 $g1]
    set bRange [- $b2.0 $b1]
    
    if {$type == "x"} {
	set rRatio [/ $rRange $width]
	set gRatio [/ $gRange $width]
	set bRatio [/ $bRange $width]
	
	for {set x 0} {$x < $width} {incr x} {
	    set nR [toInt [+ $r1 [* $rRatio $x]]]
	    set nG [toInt [+ $g1 [* $gRatio $x]]]
	    set nB [toInt [+ $b1 [* $bRatio $x]]]
	    
	    set col [format {%4.4x} $nR]
	    append col [format {%4.4x} $nG]
	    append col [format {%4.4x} $nB]
	    $win create line $x 0 $x $height -tags gradient -fill #${col}
	}
    } else {
	set rRatio [/ $rRange $height]
	set gRatio [/ $gRange $height]
	set bRatio [/ $bRange $height]
	
	for {set y 0} {$y < $height} {incr y} {
	    set nR [toInt [+ $r1 [* $rRatio $y]]]
	    set nG [toInt [+ $g1 [* $gRatio $y]]]
	    set nB [toInt [+ $b1 [* $bRatio $y]]]
	    
	    set col [format {%4.4x} $nR]
	    append col [format {%4.4x} $nG]
	    append col [format {%4.4x} $nB]
	    $win create line 0 $y $width $y -tags gradient -fill #${col}
	}
    }
    return $win
}


#restore state
proc readState {} {

    global searchvar
    global datadir


    if {[file exists $datadir/.state]} {
	source $datadir/.state
	set searchvar $searchvar
	set replacear $replacevar
	
    }
    
}

#write out state
proc writeState {} {

    global searchvar
    global datadir
    global replacevar
    

    set state [open $datadir/.state w+]
    puts $state [list set searchvar $searchvar]
    puts $state [list set replacevar $replacevar]
    close $state

    after 5000 writeState

}
#draw the GUI
proc drawGUI {} {

    global folder
    global searchvar
    global patternvar
    global replacevar
    global searchterm
    global appname
    global cachedir
    global datadir

    wm title . "TextSweep"

    . configure -height 700 -width 700
    
    ::customfont::addcustomfont iconic_stroke.ttf ;# 24.0
    ::fullscreen::fullscreen .


    set patternvar *

    
    bind . <Command-W> {wm state .  withdrawn}
    bind . <Command-w> {wm state .  withdrawn}


    global runsearch 
    global folder_documents 
    global edit_undo

    
    menu .mb
    

    menu .mb.apple
    .mb.apple add command -label "About TextSweep" -command tkAboutDialog
    if {$regproc::appstore == 0} {
	.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 "Command-H"
    .mb.search add command -label "Undo" -command batchUndo -accelerator "Command-Z"
    .mb add cascade -label "Search" -menu .mb.search
    


    #window menu
    windowlist::windowMenu .mb


    
    menu .mb.help -tearoff 0
    




    .mb.help add command -label "Contact Code by Kevin" -command machelp::usermail
    .mb.help add command -label "Web Site" -command  machelp::appweb 







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

    . configure -menu .mb
    
    ttk::style configure Toolbutton -font {Iconic 22} 

    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 -text \ue065 -style Toolbutton -command setDir -takefocus 0
    pack .f.buttons.folder  -side left  -expand no
    balloon .f.buttons.folder  "Select the directory to search"

    ttk::button .f.buttons.search -text  \ue074 -style Toolbutton -command batchReplace -takefocus 0
    pack .f.buttons.search  -side left  -expand no
    balloon .f.buttons.search "Replace text"

    ttk::button .f.buttons.reload -text \ue031 -style Toolbutton -command batchUndo -takefocus 0
    pack .f.buttons.reload  -side left  -expand no
    balloon .f.buttons.reload  "Undo replace"

    
    ttk::frame .f.foldersearch -padding 5
    pack .f.foldersearch -fill both -expand no -side top
    







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
















|

>




|
|









>


<


<


>



|
|


>
>


>




>
>
>
>


>
>
>
>
>
>





<
<








|



|



|







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
    set wmy [expr [winfo rooty $w]+[winfo height $w]]
    wm geometry $top \
	[winfo reqwidth $top.txt]x[winfo reqheight $top.txt]+$wmx+$wmy
    raise $top
}


































































































#draw the GUI
proc drawGUI {} {

    global folder
    global searchvar
    global patternvar
    global replacevar
    global searchterm
    global appname
    global cachedir
    global datadir

    wm title . "TextSweep"

    . configure -height 700 -width 700
    
    if {[tk windowingsystem] eq "aqua"} {
    ::fullscreen::fullscreen .
	}

    set patternvar *

    
    bind . <[xplat::controlkey]-W> {wm state .  withdrawn}
    bind . <[xplat::controlkey]-w> {wm state .  withdrawn}


    global runsearch 
    global folder_documents 
    global edit_undo

    
    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 "aqua"} {
    #window menu
    windowlist::windowMenu .mb
	}

    
    menu .mb.help -tearoff 0
    
    if {[tk windowingsystem] ne "aqua"} {
	
	    .mb.help add command -label "Help" -command machelp::showhelp
	}
    .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 folder -style Toolbutton -command setDir -takefocus 0
    pack .f.buttons.folder  -side left  -expand no
    balloon .f.buttons.folder  "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
    balloon .f.buttons.search "Replace text"

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

    
    ttk::frame .f.foldersearch -padding 5
    pack .f.foldersearch -fill both -expand no -side top
    
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
    ttk::button .f.bottom.replaceall -text "Replace in All Files" -command  batchReplace -default active
    ttk::button .f.bottom.undo -text "Undo" -command batchUndo
    
    pack  .f.bottom.replaceall .f.bottom.undo -side right -fill x -expand no

    bind .f.text.t <Button-1> {focus .f.text.t} 
    
    canvas .gradient -bd .1 -highlightthickness .01 -height 20
    bind .gradient <Configure> [list drawGradient .gradient y gray90 gray60]

    pack .gradient -fill both  -side bottom ;#-expand 0

    ttk::separator .bottomsep1 -orient vertical 
    pack .bottomsep1 -side bottom -fill both -expand no -side bottom
    
    if {[file exists $datadir/.state]} {
	readState
    } else {
	set searchvar {}
	set replacevar  {}
    }

    bind all <Command-Q> ::tk::mac::Quit
    bind all <Command-q> ::tk::mac::Quit
    bind all <Command-Z> batchUndo
    bind all <Command-z> batchUndo
    
}

#handle program shutdown via command-q
proc ::tk::mac::Quit {} {
    writeState
    saveWindowPosition
    exit
}

proc saveWindowPosition {} {

    global datadir 
    global windowposition

    set saveWindow [wm geometry .]
    set wingeo [open $datadir/.windowposition w+]
    puts $wingeo [list set windowposition $saveWindow]
    close $wingeo

}


#restore last saved window position
proc checkWindowPosition {} {

    global datadir windowposition

    set windowposition ""

    if {[file exists $datadir/.windowposition]} {
	source $datadir/.windowposition
	puts $windowposition
	
	wm geometry . $windowposition
	
    }  else {
	wm geometry . 900x650 
    }
}

#set search directory
proc setDir {} {

    global folder
    global patternvar
    global searchterm







<
<
|
<

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



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







359
360
361
362
363
364
365


366

367


368






369


370
371
372
373
374





375































376
377
378
379
380
381
382
    ttk::button .f.bottom.replaceall -text "Replace in All Files" -command  batchReplace -default active
    ttk::button .f.bottom.undo -text "Undo" -command batchUndo
    
    pack  .f.bottom.replaceall .f.bottom.undo -side right -fill x -expand no

    bind .f.text.t <Button-1> {focus .f.text.t} 
    


   




    bind all <[xplat::controlkey]-Q> exit






    bind all <[xplat::controlkey]-q> exit


    bind all <[xplat::controlkey]-Z> batchUndo
    bind all <[xplat::controlkey]-z> batchUndo
    
}







































#set search directory
proc setDir {} {

    global folder
    global patternvar
    global searchterm
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
#initialize the app
proc startUp {} {
    global appname
    global appversion
    global datadir
    global cachedir
    
    appname::setAppName TextSweep 2.1

    
    #check for app support directory
    set appdir [file join $::env(HOME) "Library" "Application Support" "TextSweep"]
    if {![file exists $appdir]} {
	file mkdir $appdir
    }

    #check for preferences directory
    set olddatadir [file join $::env(HOME) "Library" "Preferences" "TextSweep"]
    set datadir  [file join $::env(HOME) "Library" "Application Support" "TextSweep" "Preferences"]
    set cachedir  [file join $::env(HOME) "Library" "Application Support" "TextSweep" "Cache"]

    if {![file exists $cachedir]} {
	file mkdir $cachedir
    }

    if {[file exists $olddatadir]} {
	file rename -force $olddatadir $datadir
    } else {
	if {![file exists $datadir]} {
	    file mkdir $datadir
	} else {
	    
	}
    }

    set resourcedir [file join [softwareupdate::findCurrentInstallation] "Contents" "Resources"]

    regproc::checkAppStore [file join $resourcedir ".appstore"]
    puts "regproc::appstore is $regproc::appstore"

    if {$regproc::appstore == 1} {
	appstorereceipt::validatereceipt 
    }


    makeImage
    softwareupdate::setVersion $appname::name $appname::version
    machelp::setAppName $appname::name $appname::version
    drawGUI
    checkWindowPosition

    after 50 
    if {$regproc::appstore == 0} {
	regproc::readLic $appname::name $appname::version
    }


}

trace add variable searchvar write updateSearchTerm
startUp







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






<
<

<

<






652
653
654
655
656
657
658
659
660
661

































662
663
664
665
666
667


668

669

670
671
672
673
674
675
#initialize the app
proc startUp {} {
    global appname
    global appversion
    global datadir
    global cachedir
    
    appname::setAppName TextSweep 2.2
	
	set datadir [xplat::appconfig TextSweep]



































    makeImage
    softwareupdate::setVersion $appname::name $appname::version
    machelp::setAppName $appname::name $appname::version
    drawGUI


    after 50 

	regproc::readLic $appname::name $appname::version



}

trace add variable searchvar write updateSearchTerm
startUp

Changes to textsweep.xml.

1
2
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
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" version="2.0">
  <channel>
    <title>TextSweep</title>
    <link>http://www.codebykevin.com/textsweep.html</link>
    <language>en</language>
    <item>

      <title>TextSweep 2.1.0</title>
      <sparkle:minimumSystemVersion>10.9</sparkle:minimumSystemVersion>
      <pubDate>Thu, 12 Jun 2014 17:19:22 -0400</pubDate>
      <author>Code by Kevin</author>
      <description><![CDATA[
This version of TextSweep has the following features and improvements:
* Fix major bug that caused app to hang when selecting file.
* Minor UI improvements.
      ]]></description>
      <link>http://www.codebykevin.com/textsweep.html</link>
     <enclosure
				url="http://www.codebykevin.com/updates/TextSweep.tgz"
				sparkle:version="2.1.0"
				type="application/octet-stream"
				length="7227910"
			/>
    </item>

  </channel>
</rss>








|

|









|

|





1
2
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
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" version="2.0">
  <channel>
    <title>TextSweep</title>
    <link>http://www.codebykevin.com/textsweep.html</link>
    <language>en</language>
    <item>

      <title>TextSweep 2.2.0</title>
      <sparkle:minimumSystemVersion>10.9</sparkle:minimumSystemVersion>
      <pubDate>Sun, 17 Jul 2016 15:26:51 -0400</pubDate>
      <author>Code by Kevin</author>
      <description><![CDATA[
This version of TextSweep has the following features and improvements:
* Fix major bug that caused app to hang when selecting file.
* Minor UI improvements.
      ]]></description>
      <link>http://www.codebykevin.com/textsweep.html</link>
     <enclosure
				url="http://www.codebykevin.com/updates/TextSweep.tgz"
				sparkle:version="2.2.0"
				type="application/octet-stream"
				length="7266128"
			/>
    </item>

  </channel>
</rss>