From ef5402943619c843981fb5f36abfb828fd3fe981 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sat, 17 Feb 2024 08:16:54 +1000 Subject: examples/tip.tcl: No need for output-on-writable Now that the I/O subsystem does auto-flush on write we no longer need to manually set up a writable handler. --- examples/tip.tcl | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/examples/tip.tcl b/examples/tip.tcl index ff8b2fc..fc6990c 100755 --- a/examples/tip.tcl +++ b/examples/tip.tcl @@ -107,34 +107,6 @@ stdout buffering none set status "" set tilde 0 -set tosend {} - -# To avoid sending too much data and blocking, -# this sends str in chunks of 1000 bytes via writable -proc output-on-writable {fh str} { - # Add it to the buffer to send - append ::tosend($fh) $str - - if {[string length [$fh writable]] == 0} { - # Start the writable event handler - $fh writable [list output-is-writable $fh] - } -} - -# This is the writable callback -proc output-is-writable {fh} { - global tosend - set buf $tosend($fh) - if {[string bytelength $buf] >= 1000} { - set tosend($fh) [string byterange $buf 1000 end] - set buf [string byterange $buf 0 999] - } else { - set tosend($fh) {} - # All sent, so cancel the writable event handler - $fh writable {} - } - $fh puts -nonewline $buf -} proc bgerror {args} { set status $args @@ -145,18 +117,19 @@ proc bgerror {args} { $f readable { set c [$f read] + #stdout puts "" + #stdout flush if {[$f eof]} { set status "$device: disconnected" incr done - break } - output-on-writable stdout $c + stdout puts -nonewline $c } proc tilde_timeout {} { global tilde f if {$tilde} { - output-on-writable $f ~ + $f puts -nonewline ~ set tilde 0 } } @@ -177,9 +150,9 @@ stdin readable { incr done return } - output-on-writable $f ~ + $f puts -nonewline ~ } - output-on-writable $f $c + $f puts -nonewline $c } } -- cgit v1.1