#
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
# 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
set count 0
set lit 0 ;# 1 means literal (ASCII) entry mode
+set echo 1
proc p {s} {
puts -nonewline $s
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
}
}
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 {} {
}
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 {} {
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}]