Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11622
Modified Files: Tag: devel_0_39 desire.tk Log Message: class name completions
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.172 retrieving revision 1.1.2.173 diff -C2 -d -r1.1.2.172 -r1.1.2.173 *** desire.tk 21 Apr 2006 09:03:20 -0000 1.1.2.172 --- desire.tk 21 Apr 2006 21:41:07 -0000 1.1.2.173 *************** *** 42,45 **** --- 42,56 ---- }
+ proc luniq {a} { + set r {} + set last "" + set i 0 + foreach x $a { + if {$i && [string compare $last $x]} {lappend r $x} + incr i; set last $x + } + return $r + } + #-----------------------------------------------------------------------------------# # Observer pattern *************** *** 1339,1345 **** --- 1350,1360 ---- def* textbox key {widget x y key iso shift} { after 0 "$self after_key $widget" + switch -- $key { + Tab {$self propose_completions; $widget configure -state disabled} + } }
def* textbox after_key {widget} { + $widget configure -state normal set @text [$widget get 1.0 1.end] $self update_size *************** *** 3167,3174 **** set tooltip(visible) 0 set tooltip(text) ""
! def Canvas show_tooltip {x y text} { global tooltip ! if {$tooltip(visible) && [string compare $text $tooltip(text)==0]} {return} $self hide_tooltip set border 4 --- 3182,3190 ---- set tooltip(visible) 0 set tooltip(text) "" + set tooltip(on_hide) ""
! def* Canvas show_tooltip {x y text {on_hide ""}} { global tooltip ! if {$tooltip(visible) && [string compare $text $tooltip(text)]==0} {return} $self hide_tooltip set border 4 *************** *** 3189,3192 **** --- 3205,3209 ---- set tooltip(visible) 1 set tooltip(text) $text + set tooltip(on_hide) $on_hide }
*************** *** 3196,3199 **** --- 3213,3217 ---- $c delete tooltip_bg tooltip_fg set tooltip(visible) 0 + if {$tooltip(on_hide) != ""} {$self $tooltip(on_hide)} }
*************** *** 3211,3215 **** set n 0 $f.1 delete 0 end ! foreach class [lsort $class_list] { if {[string length $s]==0 || [string first $s $class]>=0} { $f.1 insert end "$class" --- 3229,3233 ---- set n 0 $f.1 delete 0 end ! foreach class [luniq [lsort $class_list]] { if {[string length $s]==0 || [string first $s $class]>=0} { $f.1 insert end "$class" *************** *** 3245,3249 ****
frame $f.5 ! button $f.5.help -text [say help] -command {pd pd help [$f.1 get [$f.1 curselection]]} pack $f.5.help -side top pack $f.5 -side left -fill y -expand no --- 3263,3267 ----
frame $f.5 ! button $f.5.help -text [say help] -command "pd pd help [$f.1 get [$f.1 curselection]]" pack $f.5.help -side top pack $f.5 -side left -fill y -expand no *************** *** 3288,3321 **** ############ completions
! set completion_closure {} ! ! proc propose_completions {self canvas x y text} { ! global class_list completion_closure ! set completion_closure [list $self $canvas $x $y $text] ! pd pd update-class-list propose_completions2 if {![info exists class_list]} { post_to_gui "loading class list..." ! ! } else { ! propose_completions2 } - } - - proc propose_completions2 {} { - global class_list completion_closure - mset {self canvas x y text} $completion_closure set r {} set n 0 ! foreach class [lsort $class_list] { ! if {[string length $text]==0 || [string first $text $class]>=0} { ! lappend r $class incr n } ! if {$n > 20} {lappend r ...; break} } #post_to_gui "$r\n" ! set r [string map {" " "\n"} $r] ! global tooltip ! show_canvas_tooltip $self $canvas $x $y $r }
--- 3306,3334 ---- ############ completions
! def textbox propose_completions {} { ! global class_list if {![info exists class_list]} { + pd pd update-class-list $self propose_completions post_to_gui "loading class list..." ! return } set r {} set n 0 ! set prev "" ! foreach class [luniq [lsort $class_list]] { ! if {[string length $@text]==0 || [string first $@text $class]>=0} { ! if {[string compare [say $class] "{{$class}}"]} { ! lappend r "$class : [say $class]" ! } { ! lappend r $class ! } incr n } ! if {$n > 16} {lappend r ...; break} } #post_to_gui "$r\n" ! set r [join $r "\n"] ! mset {x1 y1 x2 y2} [$self bbox] ! $@canvas show_tooltip $x2 $y1 $r }