aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testtext.tcl
diff options
context:
space:
mode:
authorlecoanet2000-05-26 08:16:52 +0000
committerlecoanet2000-05-26 08:16:52 +0000
commit7461fa650430858e53c2bbaf0f18912b6b376694 (patch)
treeb5cf06d8d7aafcdbf6a1530173b154da8e82a3a7 /sandbox/testtext.tcl
parent626eb0df82d3009ad6a70f6c8edfe340c865890f (diff)
downloadtkzinc-7461fa650430858e53c2bbaf0f18912b6b376694.zip
tkzinc-7461fa650430858e53c2bbaf0f18912b6b376694.tar.gz
tkzinc-7461fa650430858e53c2bbaf0f18912b6b376694.tar.bz2
tkzinc-7461fa650430858e53c2bbaf0f18912b6b376694.tar.xz
*** empty log message ***
Diffstat (limited to 'sandbox/testtext.tcl')
-rw-r--r--sandbox/testtext.tcl38
1 files changed, 36 insertions, 2 deletions
diff --git a/sandbox/testtext.tcl b/sandbox/testtext.tcl
index 44df4e8..818d8df 100644
--- a/sandbox/testtext.tcl
+++ b/sandbox/testtext.tcl
@@ -6,10 +6,10 @@ package require Img
set top 1
set mask "/usr/X11R6/include/X11/bitmaps/fvwm.xbm"
-set r [zinc .r -backcolor gray -relief sunken]
+set r [zinc .r -backcolor gray -relief sunken -insertbackground red -insertwidth 10]
pack .r -expand t -fill both
.r configure -width 800 -height 500
-.r configure -drawbboxes t
+# .r configure -drawbboxes t
.r addtag controls withtag $top
.r add rectangle $top "-50 0 +50 1" -composescale 0
@@ -84,6 +84,40 @@ set y 300
.r add rectangle $top [list [expr $x - 3.0] [expr $y - 3.0] \
[expr $x + 3.0] [expr $y + 3.0]] -filled 1 -fillcolor red
+
+.r addtag text withtype text
+.r bind text "<1>" {textB1press %x %y}
+.r bind text "<B1-Motion>" {textB1move %x %y}
+.r bind text "<Shift-B1-Motion>" {textB1move %x %y}
+.r bind text "<Shift-1>" {.r select adjust current @%x,%y}
+.r bind text "<KeyPress>" {.r insert [.r focus] insert %A}
+.r bind text "<Shift-KeyPress>" {.r insert [.r focus] insert %A}
+.r bind text "<Return>" {.r insert [.r focus] insert \n}
+.r bind text "<Control-h>" textBs
+.r bind text "<BackSpace>" textBs
+.r bind text "<Delete>" textBs
+.r bind text "<Control-d>" {.r dchars text sel.first sel.last}
+.r bind text "<Control-v>" {.r insert [.r focus] insert [selection get]}
+
+proc textB1press {x y} {
+ .r cursor current "@$x,$y"
+ .r focus current
+ focus .r
+ .r select from current "@$x,$y"
+}
+
+proc textB1move {x y} {
+ .r select to current "@$x,$y"
+}
+
+proc textBs { } {
+ set item [.r focus]
+ set i [expr [.r index $item insert] - 1]
+ if { $i >= 0 } {
+ .r dchars $item $i
+ }
+}
+
#
# Add controls to the main group
#