From: ian Date: Fri, 9 Dec 2005 23:08:39 +0000 (+0000) Subject: echo X-Git-Tag: before-protocol-change-2006-01-04 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=32f5154fe45eb7c2dbbac1017dc12133fa1e01e6 echo --- diff --git a/scripts/hexterm b/scripts/hexterm index 5189848..54a1b5e 100755 --- a/scripts/hexterm +++ b/scripts/hexterm @@ -3,10 +3,11 @@ set comment { # Use of the screen: 0 1 2 3 4 5 6 7 -xxx| hh hh hh hh hh hh hh hh hh hh hh hh hh hh hh hh_| abcd e_.. .... ...._| +xxxE hh hh hh hh hh hh hh hh hh hh hh hh hh hh hh hh_| abcd e_.. .... ...._| } # Display: # | is a vertical delimiter +# E is either | to mean echo is on or ' to mean it is off # hh are hex digits of output: # 00-ff actual hex data (bold for stuff we entered) # 0-f under cursor: one digit entered, need the next @@ -25,6 +26,7 @@ xxx| hh hh hh hh hh hh hh hh hh hh hh hh hh hh hh hh_| abcd e_.. .... ...._| # set count to 0 # DEL clear any entered hex digit # SPC send 00 +# ' toggle echo # nyi: # G-Z record last bytes we transmitted and store in memory # if we were halfway through a hex byte, first digit @@ -37,6 +39,7 @@ set port [lindex $argv 0] set count 0 set lit 0 ;# 1 means literal (ASCII) entry mode +set echo 1 proc p {s} { puts -nonewline $s @@ -72,11 +75,16 @@ proc csrs_show {} { csr_this_show } +proc echop {} { + global echo + return [expr {$echo ? "|" : "'"}] +} + proc newline {} { - global x count + global x echo count if {[info exists x]} { csrs_erase; p "\r\n" } set x 0 - p [format "%3x|%*s|%*s|" $count 52 "" 21 ""] + p [format "%3x%s%*s|%*s|" $count [echop] 52 "" 21 ""] csrs_show } @@ -128,9 +136,17 @@ proc onreadp {} { } proc transmit {d} { - global p + global p echo puts -nonewline $p [format %c $d] - ch $d bold + if {$echo} { ch $d bold } +} + +proc k_echo {} { + global echo + set echo [expr {!$echo}] + tput hpa 3 + p [echop] + csr_this } proc k_newline {} { @@ -172,11 +188,12 @@ proc k_noparthex {} { } proc k_hexdigit {c} { - global h1 + global h1 echo if {![info exists h1]} { set h1 $c; p $c; p "\b"; return } set d [expr 0x${h1}${c}] unset h1 transmit $d + if {!$echo} { p " \b" } } proc onreadk {} { @@ -196,8 +213,9 @@ proc onreadk {} { if {$lit} { transmit $d; continue } switch -exact $d { 13 { k_newline; continue } - 127 { k_noparthex; continue } 32 { transmit 0; continue } + 39 { k_echo; continue } + 127 { k_noparthex; continue } } if {$d >= 48 && $d <= 57} { k_hexdigit $c; continue } set kl [expr {$d | 32}]