Tk Text Edit

Check-in [8f29553668]
Login

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

Overview
Comment:Cleanup
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8f295536684d565fe4bb5c814c6cdba1319cd5b1
User & Date: dennis2 2002-06-15 20:07:09
Context
2002-06-15
22:07
Changed homepage, removed e-mail check-in: 5556035502 user: dennis2 tags: trunk
20:07
Cleanup check-in: 8f29553668 user: dennis2 tags: trunk
19:47
Cleanup check-in: 13a5f0c2ec user: dennis2 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/edit.tcl.

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
...
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
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
#? If you have any problems or if you have any ideas, dont hesitate to
#? Send me a mail message.
#? 
#? You can find my mail address here %lAbout%
#?

proc bgerror {s} {
global rr debug_messages errorInfo errorCode installdir
set info $errorInfo

set ou .ou
catch {destroy $ou}
toplevel $ou
wm title $ou "Message"
wm resizable $ou false false
wm protocol  $ou WM_DELETE_WINDOW "set rr 1"
set rr 0

if {[info exist installdir]} {
 if {[file exist [file join $installdir/stop.gif] ]} {
  image create photo warn -file [file join $installdir/stop.gif]
  label $ou.img -image warn -borderwidth 0
  pack $ou.img -side left
 } 
}

frame $ou.f 

label $ou.f.label -text "$s !"
button $ou.f.ok -text "Ok"       -command "set rr 1" -width 5 -borderwidth 1
pack $ou.f.label
pack $ou.f.ok  

if {$debug_messages>0} {
label $ou.f.d1 -text "Info: $info" -foreground red
label $ou.f.d2 -text "Code: $errorCode" -foreground blue
pack  $ou.f.d2 $ou.f.d1
}

pack $ou.f -side left
bind $ou <Escape> "set rr 1"
bind $ou <Return> "set rr 1"
grab $ou
focus $ou.f.ok
if {[info exist powin]} { powin $ou }


vwait rr
destroy $ou
}


#------------------------------------------------------------------------------+

proc setup {} {
global env installdir tk_version tcl_version c home numw tcl_platform argv0 helpdir

if {$tcl_platform(platform)!="windows"} {

if {![info exist env(DISPLAY)]} {
puts stdout "Are you sure yo're running X ?"
exit
}
}

#Check tk/tcl versions
if {$tk_version<8} { 
puts stdout "You need to upgrade to tk/tcl 8.0 or higer!"
exit
}
if {$tcl_version<8} { 
puts stdout "You need to upgrade to tk/tcl 8.0 or higer!"
exit
}

set cfg::file "$home/rc"
cfg::load

# Load images
image create photo warn -file [file join $installdir/stop.gif]
image create photo i_folder -file [file join $installdir/folder.gif]
image create photo i_openfile -file [file join $installdir/openfile.gif]
image create photo i_savedfile -file [file join $installdir/savedfile.gif]
image create photo i_file -file [file join $installdir/file.gif]
image create photo bar -file [file join $installdir/bar.gif]

tk_setPalette background $c(color-background)
}


#------------------------------------------------------------------------------+


if {$tcl_platform(platform)!="windows"} {
#Unix
set installdir [file dirname $argv0]
set home "$env(HOME)/.tcltextedit"
set helpdir "$installdir/help"

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

} else {
#Windows
set installdir [file dirname $argv0]
set home $installdir
set helpdir "$installdir/help"
}

set numw 99

set op [pwd]
cd $installdir
source cfg.tcl
cd $op

setup

for {set i 1} {$i <100 } {incr i } {
set window($i,name) "Untitled #$i"
set window($i,info) ""
set window($i,change) "0"
set window($i,pos) "1.0"
set window($i,echange) "0"
set window($i,extra) ""
set window($i,temp) ""
}
set i 100
set window($i,name) "ClipBoard"
set window($i,info) ""
set window($i,change) "0"
set window($i,pos) "1.0"
set window($i,echange) "0"
set window($i,extra) ""
set window($i,temp) "NoFile"


set i 200
set window($i,name) "FileList"
set window($i,info) ""
set window($i,change) "0"
set window($i,pos) "1.0"
set window($i,echange) "0"
................................................................................
set window($i,name) "Help"
set window($i,info) ""
set window($i,change) "0"
set window($i,pos) "1.0"
set window($i,echange) "0"
set window($i,extra) ""
set window($i,temp) "NoFile"



set ftypes {
{{All Files}       {*}         }
{{Text Files}      {.txt}      } 
{{TCL Script}      {.tcl}      }
{{C Source}        {.c}        }
{{Pascal Source}   {.pas}      }
................................................................................
cd $op



#------------------------------------------------------------------------------+

proc fixname {f} {
set r ""
for {set i 0} {$i <[string length $f] } {incr i } {
set c [string index $f $i]
if {$c=="\134"} {set c "/"}
set r "$r$c"
}
return $r
}

#------------------------------------------------------------------------------+

#Check if user supplied anything at the command line

set i 1
set fil [lindex $argv 0]

while {$fil!=""} {

set fil [fixname $fil]

set tmp [string toupper $fil]
if {[string first "HTTP://" $tmp]=="0"} {
file::Load "http $fil" -force
} else {
	#textLoadFile .text $fil
        file::Load "file $fil" -force
	}

set fil [lindex $argv $i]
incr i
if {$i>$numw} {set fil ""}
}


if {$i==1} { file::NewFile }


win::activate 1
win::update
win::status_change

#Set up update procedure for status line
trace variable window w win::status_change







|
|

|
|
|
|
|
|
|

|
|
|
|
|
|
|

|

|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
>
>
|
|






|

|
<
|
|
|
|
|

|
|
|
|
|
|
|
|
|

|
|

|
|
|
|
|
|
|

|







|
|
|
|

|
|
|


|
|
|
|












|
|
|
|
|
|
|









<







 







<
<







 







|
|
|
|
|
|
|










<
|

|
|
|
|
<
|


|
|
|


>
|
>







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
...
202
203
204
205
206
207
208


209
210
211
212
213
214
215
...
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
#? If you have any problems or if you have any ideas, dont hesitate to
#? Send me a mail message.
#? 
#? You can find my mail address here %lAbout%
#?

proc bgerror {s} {
	global rr debug_messages errorInfo errorCode installdir
	set info $errorInfo

	set ou .ou
	catch {destroy $ou}
	toplevel $ou
	wm title $ou "Message"
	wm resizable $ou false false
	wm protocol  $ou WM_DELETE_WINDOW "set rr 1"
	set rr 0

	if {[info exist installdir]} {
		if {[file exist [file join $installdir/stop.gif] ]} {
			image create photo warn -file [file join $installdir/stop.gif]
			label $ou.img -image warn -borderwidth 0
			pack $ou.img -side left
		} 
	}

	frame $ou.f 

	label $ou.f.label -text "$s !"
	button $ou.f.ok -text "Ok"       -command "set rr 1" -width 5 -borderwidth 1
	pack $ou.f.label
	pack $ou.f.ok  

	if {$debug_messages>0} {
		label $ou.f.d1 -text "Info: $info" -foreground red
		label $ou.f.d2 -text "Code: $errorCode" -foreground blue
		pack  $ou.f.d2 $ou.f.d1
	}

	pack $ou.f -side left
	bind $ou <Escape> "set rr 1"
	bind $ou <Return> "set rr 1"
	grab $ou
	focus $ou.f.ok
	if {[info exist powin]} { 
		powin $ou
	}
	vwait rr
	destroy $ou
}


#------------------------------------------------------------------------------+

proc setup {} {
	global env installdir tk_version tcl_version c home numw tcl_platform argv0 helpdir

	if {$tcl_platform(platform)!="windows"} {

		if {![info exist env(DISPLAY)]} {
			puts stdout "Are you sure yo're running X ?"
			exit
		}
	}

	#Check tk/tcl versions
	if {$tk_version<8} { 
		puts stdout "You need to upgrade to tk/tcl 8.0 or higer!"
		exit
	}
	if {$tcl_version<8} { 
		puts stdout "You need to upgrade to tk/tcl 8.0 or higer!"
		exit
	}

	set cfg::file "$home/rc"
	cfg::load

	# Load images
	image create photo warn -file [file join $installdir/stop.gif]
	image create photo i_folder -file [file join $installdir/folder.gif]
	image create photo i_openfile -file [file join $installdir/openfile.gif]
	image create photo i_savedfile -file [file join $installdir/savedfile.gif]
	image create photo i_file -file [file join $installdir/file.gif]
	image create photo bar -file [file join $installdir/bar.gif]

	tk_setPalette background $c(color-background)
}


#------------------------------------------------------------------------------+


if {$tcl_platform(platform)!="windows"} {
	#Unix
	set installdir [file dirname $argv0]
	set home "$env(HOME)/.tcltextedit"
	set helpdir "$installdir/help"

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

} else {
	#Windows
	set installdir [file dirname $argv0]
	set home $installdir
	set helpdir "$installdir/help"
}

set numw 99

set op [pwd]
cd $installdir
source cfg.tcl
cd $op

setup

for {set i 1} {$i <100 } {incr i } {
	set window($i,name) "Untitled #$i"
	set window($i,info) ""
	set window($i,change) "0"
	set window($i,pos) "1.0"
	set window($i,echange) "0"
	set window($i,extra) ""
	set window($i,temp) ""
}
set i 100
set window($i,name) "ClipBoard"
set window($i,info) ""
set window($i,change) "0"
set window($i,pos) "1.0"
set window($i,echange) "0"
set window($i,extra) ""
set window($i,temp) "NoFile"


set i 200
set window($i,name) "FileList"
set window($i,info) ""
set window($i,change) "0"
set window($i,pos) "1.0"
set window($i,echange) "0"
................................................................................
set window($i,name) "Help"
set window($i,info) ""
set window($i,change) "0"
set window($i,pos) "1.0"
set window($i,echange) "0"
set window($i,extra) ""
set window($i,temp) "NoFile"



set ftypes {
{{All Files}       {*}         }
{{Text Files}      {.txt}      } 
{{TCL Script}      {.tcl}      }
{{C Source}        {.c}        }
{{Pascal Source}   {.pas}      }
................................................................................
cd $op



#------------------------------------------------------------------------------+

proc fixname {f} {
	set r ""
	for {set i 0} {$i <[string length $f] } {incr i } {
		set c [string index $f $i]
		if {$c=="\134"} {set c "/"}
		set r "$r$c"
	}
	return $r
}

#------------------------------------------------------------------------------+

#Check if user supplied anything at the command line

set i 1
set fil [lindex $argv 0]

while {$fil!=""} {

	set fil [fixname $fil]

	set tmp [string toupper $fil]
	if {[string first "HTTP://" $tmp]=="0"} {
		file::Load "http $fil" -force
	} else {

 	       file::Load "file $fil" -force
	}

	set fil [lindex $argv $i]
	incr i
	if {$i>$numw} {set fil ""}
}

if {$i==1} {
	file::NewFile
}

win::activate 1
win::update
win::status_change

#Set up update procedure for status line
trace variable window w win::status_change