Tk Text Edit

Check-in [59de1ec366]
Login

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

Overview
Comment:Added textshell + cleaned up gui.tcl
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:59de1ec3665094553478ec309c72fa7f0dbd4b24
User & Date: dennis 2000-08-05 00:49:22
Context
2000-08-18
23:51
Added macro manager and ability to exec sh macros check-in: e7ac87b7c4 user: dennis tags: trunk
2000-08-05
00:49
Added textshell + cleaned up gui.tcl check-in: 59de1ec366 user: dennis tags: trunk
2000-07-27
23:18
Remove unecessary wrap check check-in: 6dd5738330 user: dennis tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/bindings.tcl.

146
147
148
149
150
151
152













153
154
155
156
157
158
159
doflist 1
set c(flist) 1
} else {
doflist 0
set c(flist) 0
}
}














#Alt-F key bindings
xbind  Text $c(key-lastmacro)   { macro::play $last_macro }
xbind  Text $c(key-saveas)	{ file::Save $window($current_window,info) }
xbind  Text $c(key-searchagain) { global SearchString
			  	  if {$SearchString==""} {Find find } else { FindIt } 
				}







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







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
doflist 1
set c(flist) 1
} else {
doflist 0
set c(flist) 0
}
}
xbind .text $c(key-textshell)           {
global c
if {$c(textshell)==0} {
dotextshell 1
set c(textshell) 1
} else {
dotextshell 0
set c(textshell) 0
}
}




#Alt-F key bindings
xbind  Text $c(key-lastmacro)   { macro::play $last_macro }
xbind  Text $c(key-saveas)	{ file::Save $window($current_window,info) }
xbind  Text $c(key-searchagain) { global SearchString
			  	  if {$SearchString==""} {Find find } else { FindIt } 
				}

Changes to lib/cfg.tcl.

28
29
30
31
32
33
34



35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
..
58
59
60
61
62
63
64

65
66
67
68
69
70
71
{color-menuactivetext}	  {White}
{color-menubg}	 	  {Gray76}
{color-menutxt}		  {Black}
{color-menuactive}        {#008080}
{color-statustext}	  {Blue}
{color-statustextchanged} {Red}
{color-cursor}            {Black}



{filetypes}		  { {{All Files} {*} } {{Text Files} {.txt}} {{TCL Scripts} {.tcl}} {{HTML Scripts} {.html}} }
{geometry}		  {=76x26}
{numrecent}		  {6}
{recent1}		  {}
{recent2}		  {}
{recent3}		  {}
{recent4}		  {}
{recent5}		  {}
{recent6}		  {}
{flist}                   {1}

{speed}                   {HelloWorld TCL-Exec}
{tearoff}		  {0}
{key-paste}		{Shift-Insert}
{key-copy}		{Control-Insert}
{key-copycut}		{Control-Delete}
{key-delline}		{Control-y|Control-Y}
{key-texteval}		{Control-e|Control-E}
................................................................................
{key-clipboard}		{Alt-b|Alt-B}
{key-exit}		{Alt-x|Alt-X}
{key-save}              {F2}
{key-saveall}           {Control-F2}
{key-load}              {F3}
{key-dupline}           {F4}
{key-newmacro}          {F5}

{key-find}              {F7}
{key-searchsel}         {F9}
{key-flist}             {F11}
{key-goto}		{F12}
{key-saveas}            {Alt-F2}
{key-searchagain}       {Alt-F7}
{key-closefile}         {Alt-F3}







>
>
>










>







 







>







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
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{color-menuactivetext}	  {White}
{color-menubg}	 	  {Gray76}
{color-menutxt}		  {Black}
{color-menuactive}        {#008080}
{color-statustext}	  {Blue}
{color-statustextchanged} {Red}
{color-cursor}            {Black}
{color-textshellbg}	  {White}
{color-textshellfg}	  {Black}
{color-textshellcursor}	  {Blue}
{filetypes}		  { {{All Files} {*} } {{Text Files} {.txt}} {{TCL Scripts} {.tcl}} {{HTML Scripts} {.html}} }
{geometry}		  {=76x26}
{numrecent}		  {6}
{recent1}		  {}
{recent2}		  {}
{recent3}		  {}
{recent4}		  {}
{recent5}		  {}
{recent6}		  {}
{flist}                   {1}
{textshell}		  {0}
{speed}                   {HelloWorld TCL-Exec}
{tearoff}		  {0}
{key-paste}		{Shift-Insert}
{key-copy}		{Control-Insert}
{key-copycut}		{Control-Delete}
{key-delline}		{Control-y|Control-Y}
{key-texteval}		{Control-e|Control-E}
................................................................................
{key-clipboard}		{Alt-b|Alt-B}
{key-exit}		{Alt-x|Alt-X}
{key-save}              {F2}
{key-saveall}           {Control-F2}
{key-load}              {F3}
{key-dupline}           {F4}
{key-newmacro}          {F5}
{key-textshell}         {F6}
{key-find}              {F7}
{key-searchsel}         {F9}
{key-flist}             {F11}
{key-goto}		{F12}
{key-saveas}            {Alt-F2}
{key-searchagain}       {Alt-F7}
{key-closefile}         {Alt-F3}

Changes to lib/edit.tcl.

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
...
287
288
289
290
291
292
293
294
295
296
297
298

wm iconbitmap . @$installdir/mini-textedit.xbm
wm iconname   . $prgname
wm title      . $prgname
wm minsize    .  56 1
wm protocol   . WM_DELETE_WINDOW { file::eexit }
wm geometry   . $c(geometry)


source $installdir/supertext.tcl
source $installdir/mclistbox.tcl
source $installdir/window.tcl
source $installdir/help.tcl
source $installdir/macro.tcl
source $installdir/findreplace.tcl
source $installdir/file.tcl
source $installdir/ftp_lib.tcl
source $installdir/cmds.tcl
source $installdir/exec.tcl
source $installdir/flist.tcl

source $installdir/gui.tcl
source $installdir/txt.tcl
source $installdir/bindings.tcl
source $installdir/speed.tcl


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

#Check if user supplied anything at the command line

set i 1
set fil [lindex $argv 0]
................................................................................

#Focus on text

updaterecent
macro::update

grab .


focus .text









>












>




>







 







<




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
...
290
291
292
293
294
295
296

297
298
299
300

wm iconbitmap . @$installdir/mini-textedit.xbm
wm iconname   . $prgname
wm title      . $prgname
wm minsize    .  56 1
wm protocol   . WM_DELETE_WINDOW { file::eexit }
wm geometry   . $c(geometry)


source $installdir/supertext.tcl
source $installdir/mclistbox.tcl
source $installdir/window.tcl
source $installdir/help.tcl
source $installdir/macro.tcl
source $installdir/findreplace.tcl
source $installdir/file.tcl
source $installdir/ftp_lib.tcl
source $installdir/cmds.tcl
source $installdir/exec.tcl
source $installdir/flist.tcl
source $installdir/textsh.tcl
source $installdir/gui.tcl
source $installdir/txt.tcl
source $installdir/bindings.tcl
source $installdir/speed.tcl


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

#Check if user supplied anything at the command line

set i 1
set fil [lindex $argv 0]
................................................................................

#Focus on text

updaterecent
macro::update

grab .


focus .text


Changes to lib/gui.tcl.

135
136
137
138
139
140
141



























142
143
144
145
146
147
148
...
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
destroy .fscrolly
destroy .fscrollx
destroy .path
grid .scrollx -column 0 -row 3 -sticky ew -columnspan 3
grid .text    -column 0 -row 1 -sticky nsew -columnspan 3
}
}



























#----------------------------------------------------------

proc gbn {n} {
global c
return "([lindex [split $c($n) "|"] 0])"
}

................................................................................
global dbutton
set dbutton 0
}
bind .status.c <FocusOut> {
global dbutton
set dbutton 0
}

#canvas .flist -background $c(color-listbg) -width 100 -borderwidth 2 -relief sunken -xscrollcommand ".fscrollx set" -yscrollcommand ".fscrolly set"
#flist::Show .flist 
#scrollbar .fscrollx -command ".flist xview" -orient horiz -background $c(color-menubg) -activebackground $c(color-menuactive) -troughcolor $c(color-menubg)
#scrollbar .fscrolly -command ".flist yview" -background $c(color-menubg) -activebackground $c(color-menuactive) -troughcolor $c(color-menubg)
#entry .path -borderwidth 1 

text .output -height 5 -background $c(color-editbg)


grid  .wl  -row 0 -column 0 -sticky ew -columnspan 4      
#grid .path -column 0 -row 1 -sticky nsew 
#grid .flist -column 0 -row 2 -sticky nsew
#grid .fscrolly -column 1 -row 1 -sticky ns -rowspan 2
grid .text -column 0 -row 1 -sticky nsew -rowspan 2 -columnspan 3
grid .scrolly -column 3 -row 1 -sticky ns -rowspan 2
#grid .fscrollx -column 0 -row 3 -sticky ew
grid .scrollx -column 0 -row 3 -sticky ew -columnspan 3
grid .status -column 0 -row 5 -sticky ew -columnspan 4

#grid .output -column 0 -row 4 -columnspan 4 -sticky nsew
#grid rowconfigure . 4 -weight 2


grid rowconfigure . 2 -weight 3
grid columnconfigure . 2 -weight 3
grid columnconfigure . 0 -weight 2

if {$c(flist)==1} {doflist 1}


#------------------------------- Make menu --------------------------------
xmenu .menu -borderwidth 0

set menu .menu.file
xmenu $menu
.menu add cascade -label "File" -underline 0 -menu $menu







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







 








<
<
<
<
<
<
<
<
<

<
<
<


<

<

<
<
>






>







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
...
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
destroy .fscrolly
destroy .fscrollx
destroy .path
grid .scrollx -column 0 -row 3 -sticky ew -columnspan 3
grid .text    -column 0 -row 1 -sticky nsew -columnspan 3
}
}
#--------------------------- text shell -------------------
proc dotextshell {act} {
global c

if {$act==1} {
c "Activate textshell"
text .textshell -height 5 -yscrollcommand ".shscrolly set" -xscrollcommand ".shscrollx set" -wrap none -foreground $c(color-textshellfg) -background $c(color-textshellbg) -insertbackground $c(color-textshellcursor) -insertborderwidth 0 -insertwidth 6

scrollbar .shscrolly -command ".textshell yview" -background $c(color-menubg) -activebackground $c(color-menuactive) -troughcolor $c(color-menubg) 
scrollbar .shscrollx -command ".textshell xview" -background $c(color-menubg) -activebackground $c(color-menuactive) -troughcolor $c(color-menubg) -orient horiz
grid .textshell -column 0 -row 5 -sticky ew -columnspan 3
grid .shscrolly -column 3 -row 5 -sticky ns
grid .shscrollx -column 0 -row 6 -sticky ew -columnspan 3

textsh::start .textshell

} else {
c "Deactivate textshell"
textsh::stop
destroy .textshell
destroy .shscrolly
destroy .shscrollx

}

}

#----------------------------------------------------------

proc gbn {n} {
global c
return "([lindex [split $c($n) "|"] 0])"
}

................................................................................
global dbutton
set dbutton 0
}
bind .status.c <FocusOut> {
global dbutton
set dbutton 0
}










grid  .wl  -row 0 -column 0 -sticky ew -columnspan 4      



grid .text -column 0 -row 1 -sticky nsew -rowspan 2 -columnspan 3
grid .scrolly -column 3 -row 1 -sticky ns -rowspan 2

grid .scrollx -column 0 -row 3 -sticky ew -columnspan 3




grid .status -column 0 -row 7 -sticky ew -columnspan 4

grid rowconfigure . 2 -weight 3
grid columnconfigure . 2 -weight 3
grid columnconfigure . 0 -weight 2

if {$c(flist)==1} {doflist 1}
if {$c(textshell)==1} {dotextshell 1}

#------------------------------- Make menu --------------------------------
xmenu .menu -borderwidth 0

set menu .menu.file
xmenu $menu
.menu add cascade -label "File" -underline 0 -menu $menu

Added lib/textsh.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
set tcl_traceExec 0

namespace eval textsh {

variable pipe ""
variable piperun 0
variable w ""

proc readch {} {
variable piperun 
variable pipe
variable w

if {$piperun} {
	set s [read $pipe]

	if {$s!=""} {
		$w insert end $s
		$w see end
		tkTextSetCursor $w end
		update
		}
	if { [eof $pipe]} {
		set piperun 0
		textsh::startsh
		}
	after 150 "textsh::readch"
	}
}

proc pressed {ch c} {
variable pipe
variable piperun
variable cmds
variable w

#puts stdout $c

if {$piperun} {  
		 
	switch $c {
	BackSpace {
		set cmds [string range $cmds 1 [expr [string length $cmds] -1 ]]
		}
	Return {

		textsh::runcmd $cmds
		}
                default {
		set cmds $cmds$ch
		tkTextSetCursor $w end
		$w see end
         	}
	}
}
}

proc runcmd {cmd} {
variable pipe
variable cmds
variable w

set cmds ""

switch $cmd {
	clear   {
		$w delete 0.0 end
		$w see end
		runcmd ""	
		}
	exit	{
		$w insert end "\ntextsh: unsupported command"
		}

	default {
		puts $pipe $cmd
		flush $pipe
		}
	}

}

proc startsh {} {
variable pipe
variable piperun
variable cmds
variable w

set cmds ""

if {!$piperun} {
	set piperun 1

	set pipe [open "|sh -c {exec sh 2>&1 }" "RDWR"]
	#set pipe [open "|sh 2>&1" "RDWR"]

	fconfigure $pipe -blocking 0
	textsh::readch
	runcmd ""
	}
}

proc start {win} {
variable w
set w $win
bind $w <KeyPress> "textsh::pressed %A %K"
#bind $w <KeyRelease> "tkTextSetCursor %W end"
startsh
}

proc stop {} {
variable pipe
variable piperun

set piperun 0
close $pipe
}

}

#text .cmd  -foreground black -insertbackground orange  -insertborderwidth 0 -insertwidth 6 
#pack .cmd -expand 1 -fill both
#button .b -text "Stop" -command "textsh::stop"
#button .b2 -text "Start" -command "textsh::start .cmd"
#pack .b .b2 -side left


Changes to lib/window.tcl.

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

if {$window($i,echange)==1} {
.menu.windowmenu add command -label "$i. [pton $window($i,name)]"  -command "win::activate $i"
}

}
.menu.windowmenu add separator
#.menu.windowmenu add command -label "Filelist" -underline 5 -command "win::activate 200"
.menu.windowmenu add command -label "Filelist" -underline 5 -command {
global c
if {$c(flist)==0} {
doflist 1

set c(flist) 1
} else {
doflist 0
set c(flist) 0
}

}

.menu.windowmenu add command -label "Help" -underline 0 -command "win::activate 300"
.menu.windowmenu add command -label "View/Edit Clipboard" -underline 5 -command "win::activate 100"



#Make the current window disabled in the menu
set n [lsearch [win::names] $current_window]







<


|
|
>
|
|
|
|


|
>







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

if {$window($i,echange)==1} {
.menu.windowmenu add command -label "$i. [pton $window($i,name)]"  -command "win::activate $i"
}

}
.menu.windowmenu add separator

.menu.windowmenu add command -label "Filelist" -underline 5 -command {
global c
if {$c(flist)==1} {set c(flist) 0} else {set c(flist) 1}
doflist $c(flist)
}
.menu.windowmenu add command -label "TextShell" -underline 5 -command {
global c
if {$c(textshell)==1} {set c(textshell) 0} else {set c(textshell) 1}
dotextshell $c(textshell)
}



.menu.windowmenu add command -label "Help" -underline 0 -command "win::activate 300"
.menu.windowmenu add command -label "View/Edit Clipboard" -underline 5 -command "win::activate 100"



#Make the current window disabled in the menu
set n [lsearch [win::names] $current_window]