cmdr
Check-in [d1f3c1d5ee]
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:Split the example file into many, and moved into the proper section.
Timelines: family | ancestors | descendants | both | say-more
Files: files | file ages | folders
SHA1: d1f3c1d5eef02009eab39f25df970550d080bf63
User & Date: andreask 2015-04-22 20:42:41
Context
2015-04-22
21:42
say - Start on tests, and extended package to support output redirection, making the tests easier. check-in: 2cc0a755b9 user: andreask tags: say-more
20:42
Split the example file into many, and moved into the proper section. check-in: d1f3c1d5ee user: andreask tags: say-more
20:19
Fix small issue, clear header in a multi-line prompt, this is a fixed part we must not redraw on retry under this new scheme. check-in: defa6f6ead user: andreask tags: say-more
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added examples/say-barber-phases.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +puts |[join [cmdr say barber-phases 16 {**  }] |\n|]|
            7  +
            8  +exit

Added examples/say-barberpole-1.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# infinite barberpole
            7  +set B [cmdr say barberpole -width 30]
            8  +while {1} {
            9  +    after 100
           10  +    cmdr say rewind
           11  +    $B step
           12  +}
           13  +
           14  +exit

Added examples/say-barberpole-2.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# infinite barberpole with a prefix
            7  +set B [cmdr say barberpole -width 30]
            8  +cmdr say add "download ... "
            9  +cmdr say lock-prefix
           10  +while {1} {
           11  +    #
           12  +    # fake download, unknown size, sync ... actual use:
           13  +    # - fcopy callback,
           14  +    # - http progress-callback
           15  +    # - tcllib transfer callback
           16  +    after 100
           17  +    #
           18  +    cmdr say rewind
           19  +    $B step
           20  +}
           21  +
           22  +exit

Added examples/say-counter.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# progress counter.
            7  +set B [cmdr say progress-counter 100]
            8  +set i 0
            9  +cmdr say add "upload ... "
           10  +cmdr say lock-prefix
           11  +while {$i < 100} {
           12  +    #
           13  +    # fake upload, sync ... actual use:
           14  +    # - fcopy callback,
           15  +    # - http progress-callback
           16  +    # - tcllib transfer callback
           17  +    after 100
           18  +    #
           19  +    cmdr say rewind
           20  +    incr i
           21  +    $B step $i
           22  +}
           23  +
           24  +exit

Added examples/say-general-1.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# scanner
            7  +set B [cmdr say animate -phases {
            8  +    {[***      ]}
            9  +    {[** *     ]}
           10  +    {[ ** *    ]}
           11  +    {[  ** *   ]}
           12  +    {[   ** *  ]}
           13  +    {[    ** * ]}
           14  +    {[     ** *]}
           15  +    {[      ***]}
           16  +    {[     * **]}
           17  +    {[    * ** ]}
           18  +    {[   * **  ]}
           19  +    {[  * **   ]}
           20  +    {[ * **    ]}
           21  +    {[* **     ]}
           22  +}]
           23  +while {1} {
           24  +    after 100
           25  +    cmdr say rewind
           26  +    $B step
           27  +
           28  +    # NOTE: putting the rewind after the step means that we will
           29  +    # see the animation output only for a split second and the
           30  +    # erased/empty line for the 100 milli delay => the terminal
           31  +    # will look empty, with nothing happening.
           32  +}
           33  +
           34  +exit

Added examples/say-general-2.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# infinite slider - semi-barberpole
            7  +set B [cmdr say animate -phases {
            8  +    {[         ]}
            9  +    {[*        ]}
           10  +    {[**       ]}
           11  +    {[***      ]}
           12  +    {[* **     ]}
           13  +    {[ * **    ]}
           14  +    {[  * **   ]}
           15  +    {[   * **  ]}
           16  +    {[    * ** ]}
           17  +    {[     * **]}
           18  +    {[      * *]}
           19  +    {[       * ]}
           20  +    {[        *]}
           21  +}]
           22  +while {1} {
           23  +    after 100
           24  +    cmdr say rewind
           25  +    $B step
           26  +}
           27  +
           28  +exit

Added examples/say-larson.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# larson scanner
            7  +set B [cmdr say animate -phases [cmdr say larson-phases 9 ***]]
            8  +while {1} {
            9  +    after 100
           10  +    cmdr say rewind
           11  +    $B step
           12  +
           13  +    # NOTE: putting the rewind after the step means that we will
           14  +    # see the animation output only for a split second and the
           15  +    # erased/empty line for the 100 milli delay => the terminal
           16  +    # will look empty, with nothing happening.
           17  +}
           18  +
           19  +exit

Added examples/say-larson-phases.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +puts |[join [cmdr say larson-phases 23 ***] |\n|]|
            7  +
            8  +exit

Added examples/say-percent.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# percent progress counter
            7  +set B [cmdr say percent -max 10000 -digits 2]
            8  +set i 0
            9  +cmdr say add "upload ... "
           10  +cmdr say lock-prefix
           11  +while {$i < 10000} {
           12  +    #
           13  +    # fake upload, sync ... actual use:
           14  +    # - fcopy callback,
           15  +    # - http progress-callback
           16  +    # - tcllib transfer callback
           17  +    after 10
           18  +    #
           19  +    cmdr say rewind
           20  +    incr i
           21  +    $B step $i
           22  +}
           23  +
           24  +exit

Added examples/say-progress-1.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# percent progress bar
            7  +set B [cmdr say progress -max 1000 -width 50]
            8  +set C [cmdr say percent  -max 1000]
            9  +set i 0
           10  +cmdr say add "upload ... "
           11  +cmdr say lock-prefix
           12  +while {$i < 1000} {
           13  +    #
           14  +    # fake upload, sync ... actual use:
           15  +    # - fcopy callback,
           16  +    # - http progress-callback
           17  +    # - tcllib transfer callback
           18  +    after 10
           19  +    #
           20  +    cmdr say rewind
           21  +    incr i
           22  +    cmdr say add \[
           23  +    $B step $i
           24  +    cmdr say add \]
           25  +
           26  +    cmdr say add { }
           27  +    $C step $i
           28  +}
           29  +#after 10
           30  +#cmdr say rewind
           31  +cmdr say line { OK}
           32  +
           33  +exit

Added examples/say-progress-2.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# percent progress bar, full width
            7  +set C [cmdr say percent -max 1000]
            8  +
            9  +set  n [string length "upload ... \[\] "]
           10  +incr n [$C width]
           11  +
           12  +set B [cmdr say progress -max 1000 -width -$n]
           13  +set i 0
           14  +cmdr say add "upload ... "
           15  +cmdr say lock-prefix
           16  +while {$i < 1000} {
           17  +    #
           18  +    # fake upload, sync ... actual use:
           19  +    # - fcopy callback,
           20  +    # - http progress-callback
           21  +    # - tcllib transfer callback
           22  +    after 10
           23  +    #
           24  +    cmdr say rewind
           25  +    incr i
           26  +    $C step $i
           27  +    cmdr say add { }
           28  +
           29  +    cmdr say add \[
           30  +    $B step $i
           31  +    cmdr say add \]
           32  +}
           33  +after 1000
           34  +cmdr say rewind
           35  +cmdr say line { OK}
           36  +
           37  +exit

Added examples/say-progress-phases.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +puts |[join [cmdr say progress-phases 6 * ^] |\n|]|
            7  +
            8  +exit

Added examples/say-pulse.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# infinite pulse - semi-barberpole
            7  +set B [cmdr say animate \
            8  +	   -phases [cmdr say pulse-phases 3 [cmdr color {bg-blue white} *]]]
            9  +while {1} {
           10  +    after 100
           11  +    cmdr say rewind
           12  +    $B step
           13  +}
           14  +
           15  +exit

Added examples/say-pulse-phases-1.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +puts |[join [cmdr say pulse-phases 6 *] |\n|]|
            7  +
            8  +exit

Added examples/say-pulse-phases-2.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +puts |[join [cmdr say pulse-phases 3 [cmdr color red .]] |\n|]|
            7  +
            8  +exit

Added examples/say-slider.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +# infinite slider - semi-barberpole
            7  +set B [cmdr say animate -phases [cmdr say slider-phases 9 ***]]
            8  +while {1} {
            9  +    after 100
           10  +    cmdr say rewind
           11  +    $B step
           12  +}
           13  +
           14  +exit

Added examples/say-slider-phases.

            1  +#!/usr/bin/env tclsh
            2  +# -*- tcl -*-
            3  +package require Tcl 8.5
            4  +package require cmdr::say
            5  +
            6  +puts |[join [cmdr say slider-phases 9 ***] |\n|]|
            7  +
            8  +exit

Deleted say-ex.tcl.

     1         -
     2         -source color.tcl
     3         -source say.tcl
     4         -
     5         -#debug on cmdr/say
     6         -
     7         -if 0 {
     8         -    puts |[join [cmdr say larson-phases 23 ***] |\n|]|
     9         -    exit
    10         -}
    11         -
    12         -
    13         -if 0 {
    14         -    puts |[join [cmdr say pulse-phases 6 *] |\n|]|
    15         -    exit
    16         -}
    17         -
    18         -if 0 {
    19         -    puts |[join [cmdr say pulse-phases 3 [cmdr color red .]] |\n|]|
    20         -    exit
    21         -}
    22         -
    23         -if 0 {
    24         -    puts |[join [cmdr say progress-phases 6 * ^] |\n|]|
    25         -    exit
    26         -}
    27         -
    28         -if 0 {
    29         -    # larson scanner
    30         -    set B [cmdr say animate -phases [cmdr say larson-phases 9 ***]]
    31         -    while {1} {
    32         -	after 100
    33         -	cmdr say rewind
    34         -	$B step
    35         -
    36         -	# NOTE: putting the rewind after the step means that we will
    37         -	# see the animation output only for a split second and the
    38         -	# erased/empty line for the 100 milli delay => the terminal
    39         -	# will look empty, with nothing happening.
    40         -    }
    41         -}
    42         -
    43         -if 0 {
    44         -    # scanner
    45         -    set B [cmdr say animate -phases {
    46         -	{[***      ]}
    47         -	{[** *     ]}
    48         -	{[ ** *    ]}
    49         -	{[  ** *   ]}
    50         -	{[   ** *  ]}
    51         -	{[    ** * ]}
    52         -	{[     ** *]}
    53         -	{[      ***]}
    54         -	{[     * **]}
    55         -	{[    * ** ]}
    56         -	{[   * **  ]}
    57         -	{[  * **   ]}
    58         -	{[ * **    ]}
    59         -	{[* **     ]}
    60         -    }]
    61         -    while {1} {
    62         -	after 100
    63         -	cmdr say rewind
    64         -	$B step
    65         -
    66         -	# NOTE: putting the rewind after the step means that we will
    67         -	# see the animation output only for a split second and the
    68         -	# erased/empty line for the 100 milli delay => the terminal
    69         -	# will look empty, with nothing happening.
    70         -    }
    71         -}
    72         -
    73         -if 0 {
    74         -    # infinite slider - semi-barberpole
    75         -    set B [cmdr say animate -phases [cmdr say slider-phases 9 ***]]
    76         -    while {1} {
    77         -	after 100
    78         -	cmdr say rewind
    79         -	$B step
    80         -    }
    81         -}
    82         -
    83         -if 1 {
    84         -    # infinite slider - semi-barberpole
    85         -    set B [cmdr say animate -phases {
    86         -	{[         ]}
    87         -	{[*        ]}
    88         -	{[**       ]}
    89         -	{[***      ]}
    90         -	{[* **     ]}
    91         -	{[ * **    ]}
    92         -	{[  * **   ]}
    93         -	{[   * **  ]}
    94         -	{[    * ** ]}
    95         -	{[     * **]}
    96         -	{[      * *]}
    97         -	{[       * ]}
    98         -	{[        *]}
    99         -    }]
   100         -    while {1} {
   101         -	after 100
   102         -	cmdr say rewind
   103         -	$B step
   104         -    }
   105         -}
   106         -
   107         -if 0 {
   108         -    # infinite pulse - semi-barberpole
   109         -    set B [cmdr say animate \
   110         -	       -phases [cmdr say pulse-phases 3 [cmdr color {bg-blue white} *]]]
   111         -    while {1} {
   112         -	after 100
   113         -	cmdr say rewind
   114         -	$B step
   115         -    }
   116         -}
   117         -
   118         -if 0 {
   119         -    # infinite barberpole
   120         -    set B [cmdr say barberpole -width 30]
   121         -    while {1} {
   122         -	after 100
   123         -	cmdr say rewind
   124         -	$B step
   125         -    }
   126         -}
   127         -
   128         -if 0 {
   129         -    # infinite barberpole with a prefix
   130         -    set B [cmdr say barberpole -width 30]
   131         -    cmdr say add "download ... "
   132         -    cmdr say lock-prefix
   133         -    while {1} {
   134         -	#
   135         -	# fake download, unknown size, sync ... actual use:
   136         -	# - fcopy callback,
   137         -	# - http progress-callback
   138         -	# - tcllib transfer callback
   139         -	after 100
   140         -	#
   141         -	cmdr say rewind
   142         -	$B step
   143         -    }
   144         -}
   145         -
   146         -if 0 {
   147         -    # progress counter.
   148         -    set B [cmdr say progress-counter 100]
   149         -    set i 0
   150         -    cmdr say add "upload ... "
   151         -    cmdr say lock-prefix
   152         -    while {$i < 100} {
   153         -	#
   154         -	# fake upload, sync ... actual use:
   155         -	# - fcopy callback,
   156         -	# - http progress-callback
   157         -	# - tcllib transfer callback
   158         -	after 100
   159         -	#
   160         -	cmdr say rewind
   161         -	incr i
   162         -	$B step $i
   163         -    }
   164         -}
   165         -
   166         -if 0 {
   167         -    # percent progress counter
   168         -    set B [cmdr say percent -max 10000 -digits 2]
   169         -    set i 0
   170         -    cmdr say add "upload ... "
   171         -    cmdr say lock-prefix
   172         -    while {$i < 10000} {
   173         -	#
   174         -	# fake upload, sync ... actual use:
   175         -	# - fcopy callback,
   176         -	# - http progress-callback
   177         -	# - tcllib transfer callback
   178         -	after 10
   179         -	#
   180         -	cmdr say rewind
   181         -	incr i
   182         -	$B step $i
   183         -    }
   184         -}
   185         -
   186         -if 0 {
   187         -    # percent progress bar
   188         -    set B [cmdr say progress -max 1000 -width 50]
   189         -    set C [cmdr say percent  -max 1000]
   190         -    set i 0
   191         -    cmdr say add "upload ... "
   192         -    cmdr say lock-prefix
   193         -    while {$i < 1000} {
   194         -	#
   195         -	# fake upload, sync ... actual use:
   196         -	# - fcopy callback,
   197         -	# - http progress-callback
   198         -	# - tcllib transfer callback
   199         -	after 10
   200         -	#
   201         -	cmdr say rewind
   202         -	incr i
   203         -	cmdr say add \[
   204         -	$B step $i
   205         -	cmdr say add \]
   206         -
   207         -	cmdr say add { }
   208         -	$C step $i
   209         -    }
   210         -    #after 10
   211         -    #cmdr say rewind
   212         -    cmdr say line { OK}
   213         -}
   214         -
   215         -if 0 {
   216         -    # percent progress bar, full width
   217         -    set C [cmdr say percent -max 1000]
   218         -
   219         -    set  n [string length "upload ... \[\] "]
   220         -    incr n [$C width]
   221         -
   222         -    set B [cmdr say progress -max 1000 -width -$n]
   223         -    set i 0
   224         -    cmdr say add "upload ... "
   225         -    cmdr say lock-prefix
   226         -    while {$i < 1000} {
   227         -	#
   228         -	# fake upload, sync ... actual use:
   229         -	# - fcopy callback,
   230         -	# - http progress-callback
   231         -	# - tcllib transfer callback
   232         -	after 10
   233         -	#
   234         -	cmdr say rewind
   235         -	incr i
   236         -	$C step $i
   237         -	cmdr say add { }
   238         -
   239         -	cmdr say add \[
   240         -	$B step $i
   241         -	cmdr say add \]
   242         -    }
   243         -    after 1000
   244         -    cmdr say rewind
   245         -    cmdr say line { OK}
   246         -}