|
|
@ -18,10 +18,25 @@ set ms [expr {1000 / $persec}] |
|
|
|
set nl_every [expr {$persec * $newline_every_x_seconds}] |
|
|
|
set nl_every [expr {$persec * $newline_every_x_seconds}] |
|
|
|
|
|
|
|
|
|
|
|
proc schedule {} { |
|
|
|
proc schedule {} { |
|
|
|
|
|
|
|
if {$::forever_ansi_count_per_second} { |
|
|
|
after idle [list after 0 ::emit] |
|
|
|
after idle [list after 0 ::emit] |
|
|
|
tailcall after $::ms ::schedule |
|
|
|
tailcall after $::ms ::schedule |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
after idle [list ::the_end] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set ::forever_ansi_count_per_second 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc the_end {} { |
|
|
|
|
|
|
|
puts stderr "-done-" |
|
|
|
|
|
|
|
flush stderr |
|
|
|
|
|
|
|
flush stdout |
|
|
|
|
|
|
|
set ::done_ansi_count_per_second 1 |
|
|
|
|
|
|
|
rename ::emit "" |
|
|
|
|
|
|
|
rename ::schedule "" |
|
|
|
|
|
|
|
rename ::the_end "" |
|
|
|
|
|
|
|
} |
|
|
|
proc emit {} { |
|
|
|
proc emit {} { |
|
|
|
upvar ::counter c |
|
|
|
upvar ::counter c |
|
|
|
puts -nonewline "\x1b\[1000D$c" |
|
|
|
puts -nonewline "\x1b\[1000D$c" |
|
|
@ -39,8 +54,10 @@ chan configure stdin -blocking 0 -buffering none |
|
|
|
chan event stdin readable [list apply {{chan} { |
|
|
|
chan event stdin readable [list apply {{chan} { |
|
|
|
set chunk [chan read $chan] |
|
|
|
set chunk [chan read $chan] |
|
|
|
if {[string length $chunk]} { |
|
|
|
if {[string length $chunk]} { |
|
|
|
if {[string match "q*" [string tolower $chunk]]} { |
|
|
|
if {[string match "*q*" [string tolower $chunk]]} { |
|
|
|
set ::forever 0 |
|
|
|
set ::forever_ansi_count_per_second 0 |
|
|
|
|
|
|
|
chan event $chan readable {} |
|
|
|
|
|
|
|
puts stderr "cancelling" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if {[chan eof $chan]} { |
|
|
|
if {[chan eof $chan]} { |
|
|
@ -49,6 +66,6 @@ chan event stdin readable [list apply {{chan} { |
|
|
|
}} stdin] |
|
|
|
}} stdin] |
|
|
|
|
|
|
|
|
|
|
|
schedule |
|
|
|
schedule |
|
|
|
vwait ::forever |
|
|
|
vwait ::forever_ansi_count_per_second |
|
|
|
|
|
|
|
vwait ::done_ansi_count_per_second |
|
|
|
|
|
|
|
|
|
|
|
puts "-done-" |
|
|
|
|
|
|
|