Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15240
Modified Files: Tag: desiredata desire.tk Log Message: new feature: object creation history (think bash history)
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.600.2.260 retrieving revision 1.1.2.600.2.261 diff -C2 -d -r1.1.2.600.2.260 -r1.1.2.600.2.261 *** desire.tk 1 Aug 2007 05:15:48 -0000 1.1.2.600.2.260 --- desire.tk 1 Aug 2007 17:49:10 -0000 1.1.2.600.2.261 *************** *** 1982,1986 **** def Canvas new_wire_callback {wire} {} def Canvas new_object_callback {obj} { ! set @newest $obj set @keynav_last_obj $obj $self selection+= $obj --- 1982,1986 ---- def Canvas new_wire_callback {wire} {} def Canvas new_object_callback {obj} { ! $self add_to_obj_history $obj set @keynav_last_obj $obj $self selection+= $obj *************** *** 1994,2002 **** }
def Canvas insertxy {} {return [list $@insert_x $@insert_y]}
! def Canvas insert_object {} { ! $self do_insert_obj "none" "none" ! }
def Canvas get_canvas {} { --- 1994,2010 ---- }
+ set obj_history {} + def Canvas add_to_obj_history {obj} { + if {![[$obj class] <= ObjectBox]} {return} + set ::obj_history [linsert $::obj_history 0 [$obj text]] + if {[llength $::obj_history] >= 5} {set ::obj_history [lrange $::obj_history 0 4]} + puts "history:::::: $::obj_history" + + } + + def Canvas insertxy {} {return [list $@insert_x $@insert_y]}
! def Canvas insert_object {} {$self do_insert_obj "none" "none"}
def Canvas get_canvas {} { *************** *** 2062,2065 **** --- 2070,2074 ---- } def Canvas new_object_chain_wire {obj} { + $self add_to_obj_history $obj set obj1_idx [$self children_idx [lindex [$self selection] 0]] $self deselect_all *************** *** 2265,2268 **** --- 2274,2278 ---- set @edit 1 set @tab_repeats 0 + set @histi -1 # stores which line is the longest if multiple line set @longline 1 *************** *** 2295,2298 **** --- 2305,2313 ---- bind $t <Return> "$self unedit" bind $t <Escape> "$self unedit 0" + bind $t <Up> "$self scroll_history +1" + bind $t <Down> "$self scroll_history -1" + bind $t <Control-p> "$self scroll_history +1" + bind $t <Control-n> "$self scroll_history -1" + bind $t <Alt-BackSpace> "$self clear" #bind $t <FocusOut> "$self unedit" $@canvas focus= $self *************** *** 2344,2347 **** --- 2359,2386 ---- $self changed } + + def TextBox scroll_history {incr} { + if {![llength $::obj_history]} {return} + set @histi [expr $@histi + $incr] + set mod [expr ([llength $::obj_history]<5) ?[llength $::obj_history]:5] + if {$@histi >=$mod} {set @histi [expr $@histi%$mod]} + if {$@histi < 0} {set @histi [expr ($@histi+$mod)%$mod]} + set c [$self cwidget] + set t $c.${self}text + $t delete 1.0 1.end + set text [lindex $::obj_history $@histi] + $t insert 1.0 [lindex $::obj_history $@histi] + $t configure -width [string length $text] + $self update_size + after 0 $self changed + } + + def TextBox clear {} { + set c [$self cwidget] + set t $c.${self}text + $t delete 1.0 1.end + + } + #checks which line should be used as the width of the objectbox def TextBox long_line {} { *************** *** 2389,2393 **** #set textwidth [expr {[font measure [$self look font] $text]+20}];#+20 hack mset {x1 y1 x2 y2} [[[$self canvas] widget] bbox ${self}text] ! set textwidth [expr $x2-$x1+2] } set iowidth [$self look iowidth] --- 2428,2432 ---- #set textwidth [expr {[font measure [$self look font] $text]+20}];#+20 hack mset {x1 y1 x2 y2} [[[$self canvas] widget] bbox ${self}text] ! set textwidth [expr ($x2-$x1+2)/[$@canvas zoom]] } set iowidth [$self look iowidth] *************** *** 2450,2453 **** --- 2489,2494 ---- set xya [$self bbox] mset {x1 y1 x2 y2} $xya + puts "width::::: [expr $x2-$x1]" + puts "height::::: [expr $y2-$y1]" #set xyb [l+ [list $x2 $y1 $x1 $y1 $x1 $y2] [list -1 +1 +1 +1 +1 -1]] #set xyc [l+ [list $x2 $y1 $x2 $y2 $x1 $y2] [list -1 +1 -1 -1 +1 -1]]