programlibs/Hex1000/demos/terminal.xtl
ᵘk̲ey : Any a => a -> Key
ᵘk̲ey ← { u → '{ v → ⎕K̲EY v } ⎕T̲RAP '{ e → ⎕R̲ECOVER ⎕K̲NAMED 6 } }
Used in: ᵘp̲ress
ᵘc̲ode : Key -> Int
ᵘc̲ode ← { k → k = ⎕K̲NAMED 5 ? 19 f̲irst (ʳˣk̲eys ˢu̲pper ⎕K̲CHAR k) c̲at 21 }
Used in: ᵘp̲ress
ᵘd̲raw : (Int, Char, Int) -> Char
ᵘd̲raw ← { (digits, key, took) → face ← " +----------+\n | " c̲at (ʰˣs̲creen r̲ev digits) c̲at " |\n +----------+" cost ← " key " c̲at key c̲at ": " c̲at (f̲ormat took) c̲at " instructions, " c̲at (f̲ormat (2 × took) d̲iv 27) c̲at " microseconds on a Tang Nano" help ← " keys: 0-9 A-F + - * = Enter (=) X (clear) q (quit)" p̲rint! (⎕C̲LS @) c̲at " HEX1000, a 4-bit machine, computing in X_eTaL\n\n" c̲at face c̲at "\n\n" c̲at cost c̲at "\n" c̲at help }
ᵘp̲ress : Truthy a => ((Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int), Int, a) -> ((Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int), Int, a)
ᵘp̲ress ← { (t, digits, quit) → quit ? (t, digits, quit) k ← ᵘk̲ey @ (k = ⎕K̲NAMED 6) ∨ "q" m̲atch ⎕K̲CHAR k ? (t, digits, 1 = 1) c ← ᵘc̲ode k c = 21 ? (t, digits, quit) (t1, d1, done, took) ← ʰˣCalcRom ʰˣt̲ypeOn (t, digits, 1 r̲eshape c, 1500 + 15000 × c ≥ 16) shown ← ᵘd̲raw (d1, d̲isclose (1 + c) s̲elect ˢw̲ords "0 1 2 3 4 5 6 7 8 9 A B C D E F + - * = X", took) (t1, d1, quit) }
Used in: %43
%42 : (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
(t0, d0, done, took) ← ʰˣCalcRom ʰˣt̲ype (ʰˣReset, 0 r̲eshape 0, 2000)