Tk Text Edit

Check-in [b3204e5606]
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:b3204e560676de4ecc1a99421e5e8397c8641e47
User & Date: dennis2 2002-06-17 16:17:12
Context
2002-06-17
16:33
Delimiters in speedbuttonbar check-in: ae06678230 user: dennis2 tags: trunk
16:17
Cleanup check-in: b3204e5606 user: dennis2 tags: trunk
16:14
Added some space at the end of flist check-in: 818f3c597e user: dennis2 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/exec.tcl.

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

#? 

namespace eval exec {

namespace export execute RunProgram

proc RunProgram { cmd } {
global window current_window
set result ""
set i 0

macro::rec exec::RunProgram "$cmd"

c $cmd

while {$i < [string length $cmd]} {
set cc [string index $cmd $i]

if {$cc=="%"} { 
incr i
set cc "$cc[string index $cmd $i]"

switch "$cc" {
 "%f" {set cc $window($current_window,name)}
 "%F" {set cc $window($current_window,name)}
 "%p" {set cc [file dirname $window($current_window,name)] }
 "%P" {set cc [file dirname $window($current_window,name)] }
 }
set result "$result$cc"

} else {
set result "$result$cc"
}

incr i
}

c $result
update
set a [lindex $result 0]
set b [lrange $result 1 end]



if {$b==""} { eval "exec {$a}" } else { eval "exec {$a} {$b}" }
}


proc execute {} {
global c
variable exec

c 

set ou .ou
catch {destroy $ou}
toplevel $ou
wm title $ou "Execute"

frame $ou.f
frame $ou.f.fr1
frame $ou.fr2
pack $ou.f.fr1  -side top
pack $ou.f $ou.fr2 -side left

label $ou.f.fr1.lab -text "Command:"
xentry $ou.f.fr1.ent -textvariable cmd -width 30
pack $ou.f.fr1.lab $ou.f.fr1.ent -side left -pady 10 -padx 10
$ou.f.fr1.ent selection range 0 end
xbutton $ou.fr2.ok -text Execute -width 10 -command { 
destroy .ou
exec::RunProgram $cmd
}

xbutton $ou.fr2.can -text Cancel -width 10 -command "destroy $ou"
pack $ou.fr2.ok $ou.fr2.can -side top -padx 10 -pady 5

focus $ou.f.fr1.ent

bindtags $ou.f.fr1.ent "Entry $ou.f.fr1.ent $ou . all" 

bind $ou.f.fr1.ent <Return> { 
destroy .ou
exec::RunProgram $cmd
}

bind $ou.f.fr1.ent <KP_Enter> {
exec::RunProgram $cmd 
}

bind $ou.f.fr1.ent <Escape> "destroy $ou"
grab $ou
powin $ou
}                                          
}








|
|
|

|

|

|
|

|
|
|

|
|
|
|
|
|
|
<
|
|
|

|
|

|
|
|
|
>
>
>
|
|
|


|
|

|

|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|

|
|

|

|

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

namespace eval exec {

namespace export execute RunProgram

proc RunProgram { cmd } {
	global window current_window
	set result ""
	set i 0

	macro::rec exec::RunProgram "$cmd"

	c $cmd

	while {$i < [string length $cmd]} {
		set cc [string index $cmd $i]

		if {$cc=="%"} { 
			incr i
			set cc "$cc[string index $cmd $i]"

			switch "$cc" {
				"%f" {set cc $window($current_window,name)}
				"%F" {set cc $window($current_window,name)}
				"%p" {set cc [file dirname $window($current_window,name)] }
				"%P" {set cc [file dirname $window($current_window,name)] }
			}
			set result "$result$cc"

		} else {
			set result "$result$cc"
		}

		incr i
	}

	c $result
	update
	set a [lindex $result 0]
	set b [lrange $result 1 end]
	if {$b==""} {
		eval "exec {$a}"
	} else {
		eval "exec {$a} {$b}"
	}
}

proc execute {} {
	global c
	variable exec

	c 

	set ou .ou
	catch {destroy $ou}
	toplevel $ou
	wm title $ou "Execute"

	frame $ou.f
	frame $ou.f.fr1
	frame $ou.fr2
	pack $ou.f.fr1  -side top
	pack $ou.f $ou.fr2 -side left

	label $ou.f.fr1.lab -text "Command:"
	xentry $ou.f.fr1.ent -textvariable cmd -width 30
	pack $ou.f.fr1.lab $ou.f.fr1.ent -side left -pady 10 -padx 10
	$ou.f.fr1.ent selection range 0 end
	xbutton $ou.fr2.ok -text Execute -width 10 -command { 
		destroy .ou
		exec::RunProgram $cmd
	}

	xbutton $ou.fr2.can -text Cancel -width 10 -command "destroy $ou"
	pack $ou.fr2.ok $ou.fr2.can -side top -padx 10 -pady 5

	focus $ou.f.fr1.ent

	bindtags $ou.f.fr1.ent "Entry $ou.f.fr1.ent $ou . all" 

	bind $ou.f.fr1.ent <Return> { 
		destroy .ou
		exec::RunProgram $cmd
	}

	bind $ou.f.fr1.ent <KP_Enter> {
		exec::RunProgram $cmd 
	}

	bind $ou.f.fr1.ent <Escape> "destroy $ou"
	grab $ou
	powin $ou
}

}

Changes to lib/speed.tcl.

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

namespace eval speed {

namespace export Update Button Side Assign Remove Edit selIcon


proc Edit {} {
global current_button c home installdir
c $current_button
macro::edit "[lindex $c(speed) [expr $current_button - 1]]"
.mnu unpost
}


proc Remove {} {
global current_button c
c $current_button

macro::rec global current_button
macro::rec "set current_button $current_button"
macro::rec "speed::Remove"

if {$current_button!=-1} {
speed::removeIcon
set n [expr $current_button - 1]
set c(speed) [ lreplace $c(speed) $n $n]
speed::Update
}
.mnu unpost
}

proc Assign {name} {
global current_button c
c $current_button

macro::rec global current_button
macro::rec "set current_button $current_button"
macro::rec "speed::Assign $name"

if {$current_button==-1} {
set c(speed) "$c(speed) {$name}"
} else {
set n [expr $current_button - 1]
set c(speed) [ lreplace $c(speed) $n $n $name ]
}

speed::Update
.mnu unpost
}

proc selIcon {} {
global current_button c

set file [tk_getOpenFile -title "Select Icon" -filetypes "{{Gif file} {.gif}} {{All Files} {*}}"  ]

if {($current_button!=-1) && ($file!="")}  {
set n [expr $current_button - 1]
set sb [lindex $c(speed) $n]	

set ni [lsearch $c(speed-icon) $sb]
c $ni
if {$ni==-1} {
	set c(speed-icon) "$c(speed-icon) $sb $file"
	} else {
	set ni [expr $ni +1]
	set c(speed-icon) [ lreplace $c(speed-icon) $ni $ni $file ]
	}
}
c $c(speed-icon)
speed::Update
}


proc removeIcon {} {
global current_button c
if {$current_button!=-1}  {
set n [expr $current_button - 1]
set sb [lindex $c(speed) $n]	
set ni [lsearch $c(speed-icon) $sb] 
if {$ni!=-1} {
	set c(speed-icon) [ lreplace $c(speed-icon) $ni $ni]
	set c(speed-icon) [ lreplace $c(speed-icon) $ni $ni]
	c "Remove Icon for: $sb"
	}
}
}

proc Update {} {
global current_button c
c
set menu .mnu
destroy $menu
xmenu $menu 
xmenu $menu.macros

$menu add command -label "Never mind" -command "$menu unpost"
$menu add command -label "Remove this." -command "speed::Remove"
$menu add command -label "Edit this." -command "speed::Edit"
$menu add cascade -label "Icon" -menu $menu.icon
$menu add cascade -label "Assign" -menu $menu.list
xmenu $menu.icon
$menu.icon add command -label "Select icon..." -command "speed::selIcon"
$menu.icon add command -label "Remove icon" -command {
speed::removeIcon
speed::Update
}

xmenu $menu.list 

$menu configure -background $c(color-menubg) -foreground $c(color-menutxt) -activebackground $c(color-menuactive) -activeforeground $c(color-menuactivetext)

foreach n [macro::names] {
$menu.list add command -label $n -command "speed::Assign {$n}"
}

set current_button -1


#Delete all buttons within frame .wl
foreach n [winfo children .wl] {
destroy $n
}

#Add all relevant buttons to frame
set i 1
foreach n $c(speed) {

set ni [lsearch $c(speed-icon) $n]
if {$ni==-1} {
xbutton  .wl.t$i -text "$n" -command "macro::play {$n}"
} else {
image create photo "icon.$n" -file [lindex $c(speed-icon) [expr $ni+1]]
xbutton  .wl.t$i -image "icon.$n" -command "macro::play {$n}"
}

pack .wl.t$i -side left
bind .wl.t$i <Button-3> "speed::Button $i"
bind .wl.t$i <Enter> ".status.filler config -text $n"
bind .wl.t$i <Leave> {.status.filler config -text ""}

incr i
}

if {[llength $c(speed)]==0} {
label .wl.t -text "Right click here to add macro buttons" 
pack .wl.t
bind .wl.t <Button-3> speed::Side
}

}

proc Button {n} {
global current_button
set current_button $n
.mnu post [winfo pointerx . ] [winfo pointery .]
}

proc Side {} {
global current_button
set current_button -1
.mnu post [winfo pointerx . ] [winfo pointery .]
}


}

#Initialize
speed::Update










|
|
|
|


<

|
|

|
|
|

|
|
|
|
|
|
|



|
|

|
|
|

|
|
|
|
|
|

|
|



|

|

|
|
|

|
|
|
|
|
|
|
|
|
|
|


<

|
|
|
|
|
|
|
|
|
|
|



|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|

|

|

|
|
|

|

<
|
|
|
|

|
|
|
<
|
|
|
|
|
|
|

|
|
|
|

|
|

|
|
|
|
|
|
|
<

|
|
|



|
|
|










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

namespace eval speed {

namespace export Update Button Side Assign Remove Edit selIcon


proc Edit {} {
	global current_button c home installdir
	c $current_button
	macro::edit "[lindex $c(speed) [expr $current_button - 1]]"
	.mnu unpost
}


proc Remove {} {
	global current_button c
	c $current_button

	macro::rec global current_button
	macro::rec "set current_button $current_button"
	macro::rec "speed::Remove"

	if {$current_button!=-1} {
		speed::removeIcon
		set n [expr $current_button - 1]
		set c(speed) [ lreplace $c(speed) $n $n]
		speed::Update
	}
	.mnu unpost
}

proc Assign {name} {
	global current_button c
	c $current_button

	macro::rec global current_button
	macro::rec "set current_button $current_button"
	macro::rec "speed::Assign $name"

	if {$current_button==-1} {
		set c(speed) "$c(speed) {$name}"
	} else {
		set n [expr $current_button - 1]
		set c(speed) [ lreplace $c(speed) $n $n $name ]
	}

	speed::Update
	.mnu unpost
}

proc selIcon {} {
	global current_button c

	set file [tk_getOpenFile -title "Select Icon" -filetypes "{{Gif file} {.gif}} {{All Files} {*}}"  ]

	if {($current_button!=-1) && ($file!="")}  {
		set n [expr $current_button - 1]
		set sb [lindex $c(speed) $n]	

		set ni [lsearch $c(speed-icon) $sb]
		c $ni
		if {$ni==-1} {
			set c(speed-icon) "$c(speed-icon) $sb $file"
		} else {
			set ni [expr $ni +1]
			set c(speed-icon) [ lreplace $c(speed-icon) $ni $ni $file ]
		}
	}
	c $c(speed-icon)
	speed::Update
}


proc removeIcon {} {
	global current_button c
	if {$current_button!=-1} {
		set n [expr $current_button - 1]
		set sb [lindex $c(speed) $n]	
		set ni [lsearch $c(speed-icon) $sb] 
		if {$ni!=-1} {
			set c(speed-icon) [ lreplace $c(speed-icon) $ni $ni]
			set c(speed-icon) [ lreplace $c(speed-icon) $ni $ni]
			c "Remove Icon for: $sb"
		}
	}
}

proc Update {} {
	global current_button c
	c
	set menu .mnu
	destroy $menu
	xmenu $menu 
	xmenu $menu.macros

	$menu add command -label "Never mind" -command "$menu unpost"
	$menu add command -label "Remove this." -command "speed::Remove"
	$menu add command -label "Edit this." -command "speed::Edit"
	$menu add cascade -label "Icon" -menu $menu.icon
	$menu add cascade -label "Assign" -menu $menu.list
	xmenu $menu.icon
	$menu.icon add command -label "Select icon..." -command "speed::selIcon"
	$menu.icon add command -label "Remove icon" -command {
		speed::removeIcon
		speed::Update
	}

	xmenu $menu.list 

	$menu configure -background $c(color-menubg) -foreground $c(color-menutxt) -activebackground $c(color-menuactive) -activeforeground $c(color-menuactivetext)

	foreach n [macro::names] {
		$menu.list add command -label $n -command "speed::Assign {$n}"
	}

	set current_button -1


	#Delete all buttons within frame .wl
	foreach n [winfo children .wl] {
		destroy $n
	}

	#Add all relevant buttons to frame
	set i 1
	foreach n $c(speed) {

		set ni [lsearch $c(speed-icon) $n]
		if {$ni==-1} {
			xbutton  .wl.t$i -text "$n" -command "macro::play {$n}"
		} else {
			image create photo "icon.$n" -file [lindex $c(speed-icon) [expr $ni+1]]
			xbutton  .wl.t$i -image "icon.$n" -command "macro::play {$n}"
		}

		pack .wl.t$i -side left
		bind .wl.t$i <Button-3> "speed::Button $i"
		bind .wl.t$i <Enter> ".status.filler config -text $n"
		bind .wl.t$i <Leave> {.status.filler config -text ""}

		incr i
	}

	if {[llength $c(speed)]==0} {
		label .wl.t -text "Right click here to add macro buttons" 
		pack .wl.t
		bind .wl.t <Button-3> speed::Side
	}
}


proc Button {n} {
	global current_button
	set current_button $n
	.mnu post [winfo pointerx . ] [winfo pointery .]
}

proc Side {} {
	global current_button
	set current_button -1
	.mnu post [winfo pointerx . ] [winfo pointery .]
}


}

#Initialize
speed::Update