Tk Text Edit

Check-in [b9e97f721a]
Login

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

Overview
Comment:Made special char interactive+ improvements
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b9e97f721af74afe45e2e05aba0b087a226e10fd
User & Date: dennis 2001-02-04 00:22:25
Context
2001-02-04
01:04
Modifications to support wrapping check-in: 3176c54f0b user: dennis tags: trunk
00:22
Made special char interactive+ improvements check-in: b9e97f721a user: dennis tags: trunk
2001-01-25
23:39
Add special char dialog and speedbutton with icon check-in: 6fb2d79ec9 user: dennis tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/SpecChar.mac.

1
.text insert end [format "%c" [specc::specc]]
|
1
specc::specc -win .text

Changes to lib/gui.tcl.

509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
$menu add command -label "Copy" -accelerator [gbn key-copy] -underline 0 -command "txt::copy .text"
$menu add command -label "Copy from..." -accelerator [gbn key-copyfromclip ] -underline 5 -command "txt::copyfrom_clip .text"
$menu add command -label "Cut" -accelerator [gbn key-delete ] -underline 1 -command "txt::cut .text"
$menu add command -label "CopyCut" -accelerator [gbn key-copycut ] -command "txt::copycut .text"
$menu add command -label "Paste" -accelerator [gbn key-paste ] -underline 0 -command "txt::paste .text"
$menu add command -label "Select all" -accelerator [gbn key-tagall ] -underline 0 -command "txt::tagall .text"
$menu add command -label "Evaluate" -accelerator [gbn key-texteval ] -underline 0 -command "txt::texteval .text"
$menu add command -label "Special Char..." -accelerator [gbn key-specc ] -underline 0 -command { .text insert end [format "%c" [specc::specc]] }

$menu add separator
$menu add checkbutton -label "Wrap lines" -variable wraping -offvalue "none" -onvalue "word" -command { .text configure -wrap $wraping }   

set menu .menu.searchmenu
xmenu $menu 
.menu add cascade -label "Search" -underline 0 -menu $menu 







|







509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
$menu add command -label "Copy" -accelerator [gbn key-copy] -underline 0 -command "txt::copy .text"
$menu add command -label "Copy from..." -accelerator [gbn key-copyfromclip ] -underline 5 -command "txt::copyfrom_clip .text"
$menu add command -label "Cut" -accelerator [gbn key-delete ] -underline 1 -command "txt::cut .text"
$menu add command -label "CopyCut" -accelerator [gbn key-copycut ] -command "txt::copycut .text"
$menu add command -label "Paste" -accelerator [gbn key-paste ] -underline 0 -command "txt::paste .text"
$menu add command -label "Select all" -accelerator [gbn key-tagall ] -underline 0 -command "txt::tagall .text"
$menu add command -label "Evaluate" -accelerator [gbn key-texteval ] -underline 0 -command "txt::texteval .text"
$menu add command -label "Special Char..." -accelerator [gbn key-specc ] -underline 0 -command {specc::specc -win ".text"}

$menu add separator
$menu add checkbutton -label "Wrap lines" -variable wraping -offvalue "none" -onvalue "word" -command { .text configure -wrap $wraping }   

set menu .menu.searchmenu
xmenu $menu 
.menu add cascade -label "Search" -underline 0 -menu $menu 

Changes to lib/specc.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



namespace eval  specc {

namespace export specc

proc enter {w p} {

$w.l config -text [format "Dec: %d Hex: %x  Oct: %o" $p $p $p]
$w.c itemconfigure "t$p" -fill green

}

proc leave {w p} {
$w.c itemconfigure "t$p" -fill black






}

proc specc {args} {

global result1 c
set result1 "<None>"
set w .wdlgc

if {$args==""} {



	set font $c(font-editor)



} else {
	set font $args
}

set font "[lindex $font 0] $c(specc-fontsize) [lindex $font 2] [lindex $font 3] [lindex $font 4] [lindex $font 5] [lindex $font 6]"
set cellsize [lindex [font metrics $font] 5]

catch {destroy $w}
toplevel $w

wm title $w "Select special char"
wm resizable $w false false
wm transient $w .


wm protocol  $w WM_DELETE_WINDOW "set result1 <None>" 

canvas  $w.c -width [expr $cellsize*17] -height [expr $cellsize*17] -borderwidth 1 -relief raised


label $w.l 
set p 0


for {set y 1} {$y <17 } {incr y } {

	for {set x 0} {$x <16 } {incr x } {
		$w.c create text  [expr $x*$cellsize+$cellsize] [expr $y*$cellsize]  -text  [format "%c" $p] -font $font -tag "t$p"









		$w.c bind "t$p" <Motion>  "specc::enter $w $p"
		$w.c bind "t$p" <Enter>   "specc::enter $w $p"
		$w.c bind "t$p" <Leave>  "specc::leave $w $p"


		$w.c bind "t$p" <Button-1>  "set result1 $p"







		incr p
	}
}

grid $w.c -column 0 -row 0
grid $w.l


vwait result1
destroy $w
return $result1


}

}








>

|
>



|
>
>
>
>
>
>



>




<
>
>
>
|
>
>
>
|
<
|










>
>
|
|
<
>
>


>

<
>

<
>
>
>
>
>
>
>
>
>



>
>
|
>
>
>
>
>
>
>







>
|
|
|
>
>



>
>
>
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
namespace eval  specc {

namespace export specc

proc enter {w p} {
set tag "t$p"
$w.l config -text [format "Dec: %d Hex: %x  Oct: %o" $p $p $p]
$w.c itemconfigure $tag -fill [$w.c cget -background]
$w.c itemconfigure "r$p" -fill  [$w.c cget -highlightcolor] -outline [$w.c cget -highlightcolor]
}

proc leave {w p} {
$w.c itemconfigure "t$p" -fill [$w.c cget -highlightcolor]
$w.c itemconfigure "r$p" -fill [$w.c cget -background] -outline [$w.c cget -background]
}

proc place_text {win p} {
macro::rec specc::place_text $win $p
$win insert insert "[format {%c} $p]"
}

proc specc {args} {
c
global result1 c
set result1 "<None>"
set w .wdlgc



if {[set i [lsearch -exact $args "-font"]] >= 0} {
	set default [lindex $args [expr $i+1]]
} else { set font $c(font-editor) }

if {[set i [lsearch -exact $args "-win"]] >= 0} {
	set win [lindex $args [expr $i+1]]
} else { set win ""}



set font "[lindex $font 0] $c(specc-fontsize) [lindex $font 2] [lindex $font 3] [lindex $font 4] [lindex $font 5] [lindex $font 6]"
set cellsize [lindex [font metrics $font] 5]

catch {destroy $w}
toplevel $w

wm title $w "Select special char"
wm resizable $w false false
wm transient $w .

if {$win==""} {
	wm protocol  $w WM_DELETE_WINDOW "set result1 <None>" 
}


canvas  $w.c -width [expr $cellsize*16] -height [expr $cellsize*16] -borderwidth 1 -relief raised -background  $c(color-listbg) -relief sunken -highlightcolor $c(color-listtext)
label $w.l 
set p 0
set co [$w.c cget -background]


for {set y 0} {$y <16 } {incr y } {
	for {set x 0} {$x <16 } {incr x } {

		set xx [expr $x*$cellsize+5]
		set yy  [expr $y*$cellsize+2]
		$w.c create rectangle $xx $yy [expr "$xx+$cellsize"] [expr "$yy+$cellsize"] -fill $co -outline $co -tag "r$p"
		$w.c create text  $xx $yy   -text [string range  [format "%c" $p] 0 1] -font $font -anchor nw -tag "t$p" -fill $c(color-listtext)

		$w.c bind "r$p" <Motion>  "specc::enter $w $p"
		$w.c bind "r$p" <Enter>   "specc::enter $w $p"
		$w.c bind "r$p" <Leave>  "specc::leave $w $p"

		$w.c bind "t$p" <Motion>  "specc::enter $w $p"
		$w.c bind "t$p" <Enter>   "specc::enter $w $p"
		$w.c bind "t$p" <Leave>  "specc::leave $w $p"

		if {$win==""} {
			$w.c bind "t$p" <Button-1>  "set result1 $p"
			$w.c bind "r$p" <Button-1>  "set result1 $p"
		} else { 
			$w.c bind "t$p" <Button-1>  "specc::place_text $win $p"
			$w.c bind "r$p" <Button-1>  "specc::place_text $win $p"
		}


		incr p
	}
}

grid $w.c -column 0 -row 0
grid $w.l

if {$win==""} {
	vwait result1
	destroy $w
	return $result1
}

}

}