Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26069
Modified Files: Tag: desiredata desire.tk Log Message: Keyboard macro part II
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.600.2.294 retrieving revision 1.1.2.600.2.295 diff -C2 -d -r1.1.2.600.2.294 -r1.1.2.600.2.295 *** desire.tk 6 Aug 2007 16:17:12 -0000 1.1.2.600.2.294 --- desire.tk 6 Aug 2007 19:24:21 -0000 1.1.2.600.2.295 *************** *** 342,347 **** set r {} foreach event $@list { ! mset {type W X Y mod K k} $event ! lappend r [format "%-13s %9s %4d %4d %4d %4d %s" $type $K $k $X $Y $mod $W] } return $r --- 342,347 ---- set r {} foreach event $@list { ! mset {type W X Y x y mod K k} $event ! lappend r [format "%-13s %9s %4d %4d %4d %4d %4d %4d %s" $type $K $k $X $Y $x $y $mod $W] } return $r *************** *** 533,542 **** foreach type {KeyPress KeyRelease} { foreach {subtype mod} $mods { ! bind all <$subtype$type> "$::event_history add [list $type %W %X %Y $mod %K %k]" } } foreach type {ButtonPress ButtonRelease} { foreach {subtype mod} $mods { ! bind all <$subtype$type> "$::event_history add [list $type %W %X %Y $mod %b %b]" } } --- 533,542 ---- foreach type {KeyPress KeyRelease} { foreach {subtype mod} $mods { ! bind all <$subtype$type> "$::event_history add [list $type %W %X %Y %x %y $mod %K %k]" } } foreach type {ButtonPress ButtonRelease} { foreach {subtype mod} $mods { ! bind all <$subtype$type> "$::event_history add [list $type %W %X %Y %x %y $mod %b %b]" } } *************** *** 2232,2241 **** --- 2232,2246 ---- def Macro init {} { $::event_history subscribe $self + set @idx 0 set @state 0 set @list {} + set @delay 200 } def Macro state= {val} {set @state $val; if {$val} {set @list {}; puts "start recording macro..."} {puts "end..."}} def Macro state {} {return $@state} def Macro dump {} {set i 0; foreach step $@list {puts "step $i -> $step"; incr i}} + def Macro idx= {val} {set @idx $val} + def Macro idx {} {return $@idx} + def Macro delay {} {return $@delay}
def Macro notice {args} { *************** *** 2249,2282 **** }
! def Macro add {mess} {lappend @list $mess}
! def Macro play {} { set i 0 set focus [string range [focus] 1 [string first . [focus] 2]-1] ! foreach step $@list { ! mset {event widget x y mode k kval} $step ! if {[regexp {^Control_} $k]} {continue} ! if {[regexp {^Alt_} $k]} {continue} ! if {[regexp {^Shift_} $k]} {continue} ! switch $event { ! KeyPress { ! ! set name [modekey $k $mode] ! $self run $name $x $y ! #set w [focus] ! #puts "np::::: $i $name -- $widget $x $y" ! #incr i ! } ! ButtonPress {$self run $event-$k $x $y} ! ButtonRelease {$self run $event-$k $x $y} ! } } }
! def Macro run {name x y} { ! #mset {event widget x y mode k kval} $step set w [focus] ! puts "$w $name" ! event generate $w <$name> }
--- 2254,2288 ---- }
! def Macro add {mess} { ! mset {event widget X Y x y mode k kval} $mess ! if {[regexp {^Control_} $k]} {return} ! if {[regexp {^Alt_} $k]} {return} ! if {[regexp {^Shift_} $k]} {return} ! if {$event == "KeyRelease"} {return} ! lappend @list $mess ! }
! def Macro play {delay} { ! if {$@idx == [llength $@list]} {return} set i 0 set focus [string range [focus] 1 [string first . [focus] 2]-1] ! set step [lindex $@list $@idx] ! mset {event widget X Y x y mode k kval} $step ! switch $event { ! KeyPress {set name [modekey $k $mode]} ! ButtonPress {set name $event-$k} ! ButtonRelease {set name $event-$k} ! default {puts "Error: this event should not have been here.."} ! } ! if {$@idx < [llength $@list]} { ! after $delay [list $self run $event $name $X $Y $x $y] } }
! def Macro run {event name X Y x y} { set w [focus] ! incr @idx ! event generate $w <$name> -x $x -y $y ! $self play $@delay }
*************** *** 2285,2290 **** set ::macro_state 0
! def Canvas macro_toggle {} {if {![$::macro state]} {set ::macro_state 1} {$::macro state= 0}} ! def Canvas macro_play {} {$::macro play} def Canvas keyevent {} { focus [$self widget] --- 2291,2296 ---- set ::macro_state 0
! def Canvas macro_toggle {} {if {![$::macro state]} {set ::macro_state 1} {$::macro state= 0; $::macro dump}} ! def Canvas macro_play {} {$::macro idx= 0; $::macro play [$::macro delay]} def Canvas keyevent {} { focus [$self widget]