|
Warning: this is an htmlized version!
The original is across this link, and the conversion rules are here. |
# dragTs.tcl
# By Edrx, 2007feb19
# This is meant to be used in eepitch blocks
# to drag text around
# (find-es "tcl" "dragTs")
# (find-tclbook2page (+ -126 167) "Anchors")
# canvas .c -width 200 -height 200
# pack .c -expand yes -fill both
proc dragx {x} { global oldx; set prevx $oldx; set oldx $x; expr $x-$prevx }
proc dragy {y} { global oldy; set prevy $oldy; set oldy $y; expr $y-$prevy }
set tcl_prompt2 { puts -nonewline "> " } ;# (find-es "tcl" "prompts")
proc T {x y text} {
global n placex placey
if {$x=="_"} { set x $placex }
if {$y=="_"} { set y $placey; incr placey 11 }
incr n
.c delete T${n}
.c create text $x $y -text $text -anchor nw -tags "T${n} dump"
.c bind T${n} <1> {set oldx %x; set oldy %y}
.c bind T${n} <B1-Motion> ".c move T${n}||tagged \[dragx %x\] \[dragy %y\]"
}
proc dumptostring {n} {
foreach {x y} [.c coords T${n}] {}
set x [expr int($x)]
set y [expr int($y)]
set text [.c itemcget T${n} -text]
format "T %3d %3d %s" $x $y [list $text]
}
proc dumpalltostring {} {
global n
set bigstr {}
for {set i 1} {$i<=$n} {incr i} {
append bigstr "[dumptostring $i]\n"
}
return $bigstr
}
source $env(HOME)/TCL/inc.tcl ;# (find-angg "TCL/inc.tcl")
proc writeTs {} { writefile /tmp/Ts [dumpalltostring] }