nx_input.nx
buildroot/runtime/nx_input.nx
about
nx_input.nx -- terminal input primitives (line + byte read from stdin).
The user-interaction layer's INPUT side. Reads bytes from stdin
(fd=0) via sys_read; decodes basic escape sequences when in raw
mode (see nx_termios.nx for raw-mode entry).
Companion to nx_tty.nx (output side). Together they close the
substrate-to-user gap.
Why this exists (per user 2026-05-13):
user said "if not build it" when the layer audit showed UI was
the missing tier. This is the foundation; widgets / event loop
can build on these primitives.
Standard usage:
- nx_input_read_line(buf, max) -- cooked-mode line read
- nx_input_read_byte() -- single byte (works in any mode)
- nx_input_read_key() -- decode arrow keys etc. (raw mode)
genealogy_id: ecma_48_1976_ansi_escape + readline_lineage
lineage_id: stdin_byte_stream + escape_sequence_decode
axioms: NX_AX_LOGIC_EXCLUDED_MIDDLE (each byte is or isn't a
key event prefix; no third state)
dependencies 3 imports · 0 importers
imports: syscalls.nxruntime.nxnx_axioms.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 37 | const NX_KEY_NONE: i64 = 0 |
| 38 | const NX_KEY_BACKSPACE: i64 = 127 |
| 39 | const NX_KEY_ENTER: i64 = 10 |
| 40 | const NX_KEY_ESC: i64 = 27 |
| 41 | const NX_KEY_UP: i64 = 1001 |
| 42 | const NX_KEY_DOWN: i64 = 1002 |
| 43 | const NX_KEY_RIGHT: i64 = 1003 |
| 44 | const NX_KEY_LEFT: i64 = 1004 |
| 45 | const NX_KEY_HOME: i64 = 1005 |
| 46 | const NX_KEY_END: i64 = 1006 |
| 47 | const NX_KEY_PGUP: i64 = 1007 |
| 48 | const NX_KEY_PGDN: i64 = 1008 |
| 49 | const NX_KEY_DEL: i64 = 1009 |
| 50 | const NX_KEY_INS: i64 = 1010 |
functions
| 54 | func nx_input_read_byte() -> i64 |
| 65 | func nx_input_read_line(buf: *u8, max: i64) -> i64 calls 1: nx_input_read_byte |
| 102 | func nx_input_read_key() -> i64 calls 1: nx_input_read_byte |