programlibs/Hex1000/demos/terminal.xtl

source · imports hx: libs/Hex1000/src/Hex1000.xtl; rx: libs/Radix/src/Radix.xtl; s: work/libs/Strings/src/Strings.xtl

ᵘk̲ey : Any a => a -> Key

function · line 15
ᵘk̲ey ← { u → '{ v → ⎕K̲EY v } ⎕T̲RAP '{ e → ⎕R̲ECOVER ⎕K̲NAMED 6 } }
Used in: ᵘp̲ress

ᵘc̲ode : Key -> Int

function · line 17
ᵘ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

function · line 22
ᵘ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
}
Used in: ᵘp̲ress, shown

ᵘ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)

function · line 29
ᵘ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)

value · line 39
(t0, d0, done, took) ← ʰˣCalcRom ʰˣt̲ype (ʰˣReset, 0 r̲eshape 0, 2000)

t0 : Int

value · line 39
(t0, d0, done, took) ← ʰˣCalcRom ʰˣt̲ype (ʰˣReset, 0 r̲eshape 0, 2000)
Used in: %42, %43

d0 : Bool

value · line 39
(t0, d0, done, took) ← ʰˣCalcRom ʰˣt̲ype (ʰˣReset, 0 r̲eshape 0, 2000)
Used in: %42, shown, %43

done : Int

value · line 39
(t0, d0, done, took) ← ʰˣCalcRom ʰˣt̲ype (ʰˣReset, 0 r̲eshape 0, 2000)
Used in: ᵘp̲ress, %42

took : Char

value · line 39
(t0, d0, done, took) ← ʰˣCalcRom ʰˣt̲ype (ʰˣReset, 0 r̲eshape 0, 2000)

shown : (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)

value · line 40
shown ← ᵘd̲raw (d0, "reset", took)

%43 : Int

value · line 41
(t, digits, quit) ← 10000 'ᵘp̲ress p̲ower (t0, d0, 0 = 1)

t : Bool

value · line 41
(t, digits, quit) ← 10000 'ᵘp̲ress p̲ower (t0, d0, 0 = 1)
Used in: ᵘp̲ress, %43