cmdr
Check-in [e250dbed44]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tweaked options for "operation" command, extended a bit, plus slider & larson animation classes.
Timelines: family | ancestors | descendants | both | say-more
Files: files | file ages | folders
SHA1: e250dbed44acd0811bdf3a15d876a43b07ddb433
User & Date: andreask 2015-05-01 00:06:56
Context
2015-05-01
22:55
New command for output to stderr, plus two higher-level helpers for headers and banners. check-in: 64bb90174f user: andreask tags: say-more
00:06
Tweaked options for "operation" command, extended a bit, plus slider & larson animation classes. check-in: e250dbed44 user: andreask tags: say-more
2015-04-30
22:00
More animations, extended the "operation" command with easy integration of animations, added examples. Added helper script "local" for easier execution of the examples without having cmdr::say installed. check-in: de4974db8f user: andreask tags: say-more
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to say.tcl.

    36     36   namespace eval ::cmdr::say {
    37     37       namespace export \
    38     38   	up down forw back \
    39     39   	erase-screen erase-up erase-down \
    40     40   	erase-line erase-back erase-forw \
    41     41   	goto home line add line rewind lock-prefix clear-prefix \
    42     42   	next next* animate barberpole percent progress-counter progress \
    43         -	ping pulse turn operation \
           43  +	ping pulse turn larson slider operation \
    44     44   	\
    45     45   	auto-width barber-phases progress-phases larson-phases \
    46     46   	slider-phases pulse-phases turn-phases \
    47     47   	\
    48     48   	to
    49     49   
    50     50       namespace ensemble create
................................................................................
   231    231   }
   232    232   
   233    233   # # ## ### ##### ######## ############# #####################
   234    234   
   235    235   proc ::cmdr::say::operation {lead script args} {
   236    236       debug.cmdr/say {}
   237    237   
   238         -    set cmd {}
   239         -    set delay 100
          238  +    set cmd     {}  ;# -play
          239  +    set delay   100 ;# -every
          240  +    set trailer OK  ;# -trailer, -no-trailer
          241  +
   240    242       while {1} {
   241    243   	set o [lindex $args 0]
   242    244   	switch -glob -- $o {
   243         -	    -every {
          245  +	    -every { ;# int number argument
   244    246   		set delay [lindex $args 1]
   245    247   		set args  [lrange $args 2 end]
   246    248   	    }
   247         -	    -play {
          249  +	    -play { ;# cmd prefix argument
   248    250   		set cmd  [lindex $args 1]
   249    251   		set args [lrange $args 2 end]
   250    252   	    }
          253  +	    -no-trailer { ;# no argument
          254  +		set trailer {}
          255  +		set args    [lrange $args 1 end]
          256  +	    }
          257  +	    -trailer { ;# string argument
          258  +		set trailer [lindex $args 1]
          259  +		set args    [lrange $args 2 end]
          260  +	    }
   251    261   	    -* {
   252    262   		return -code error \
   253    263   		    -errorcode {CMD SAY BAD-OPTION} \
   254         -		    "Unknown option $o, expected -a, or -d"
          264  +		    "Unknown option $o, expected -every, -play, or -(no-)trailer"
   255    265   	    }
   256    266   	    default break
   257    267   	}
   258    268       }
   259    269   
   260    270       add $lead
   261    271       lock-prefix
................................................................................
   269    279   	uplevel 1 $script
   270    280       } {*}$args on error {e o} {
   271    281   	# General error => close line, and pass.
   272    282   	line ""
   273    283   	return {*}$o $e
   274    284       } on ok {e o} {
   275    285   	rewind ; # remove animation output, leave only the lead
   276         -	line [color good OK]
          286  +	if {$trailer ne {}} {
          287  +	    line [color good $trailer]
          288  +	}
   277    289       } finally {
   278    290   	# Stop ongoing animation, if any
   279    291   	if {[llength $cmd]} {
   280    292   	    $animation done
   281    293   	}
   282    294       }
   283    295       return $e
................................................................................
   413    425   
   414    426   # # ## ### ##### ######## ############# #####################
   415    427   ## turn animation
   416    428   
   417    429   proc ::cmdr::say::turn {} {
   418    430       debug.cmdr/say {}
   419    431       set phases [turn-phases]
          432  +    # Run the animation via the general class.
          433  +    return [animate::Im new -phases $phases]
          434  +}
          435  +
          436  +# # ## ### ##### ######## ############# #####################
          437  +## slider animation
          438  +
          439  +proc ::cmdr::say::slider {args} {
          440  +    debug.cmdr/say {}
          441  +
          442  +    array set config {
          443  +	-width   {}
          444  +	-pattern ***
          445  +    }
          446  +    array set config $args
          447  +
          448  +    set phases [slider-phases \
          449  +		    [auto-width $config(-width)] \
          450  +		    $config(-pattern)]
          451  +
          452  +    # Run the animation via the general class.
          453  +    return [animate::Im new -phases $phases]
          454  +}
          455  +
          456  +# # ## ### ##### ######## ############# #####################
          457  +## larson scanner animation
          458  +
          459  +proc ::cmdr::say::larson {args} {
          460  +    debug.cmdr/say {}
          461  +
          462  +    array set config {
          463  +	-width   {}
          464  +	-pattern ***
          465  +    }
          466  +    array set config $args
          467  +
          468  +    set phases [larson-phases \
          469  +		    [auto-width $config(-width)] \
          470  +		    $config(-pattern)]
          471  +
   420    472       # Run the animation via the general class.
   421    473       return [animate::Im new -phases $phases]
   422    474   }
   423    475   
   424    476   # # ## ### ##### ######## ############# #####################
   425    477   ## progress counter, n of max.
   426    478