nx_tty_test.nx source
↩ module page · 34 lines · 1129 B
1// nx_tty_test.nx -- smoke for the user-interaction output layer.
2//
3// Non-interactive: writes a known sequence of ANSI escapes + text
4// to stdout, verifies via byte-count return values that each
5// sys_write succeeded. A real interactive smoke would need a TTY.
6
7import "syscalls.nx"
8import "runtime.nx"
9import "nx_tty.nx"
10
11func main() -> i64 {
12 // Each operation must return a positive byte count.
13
14 if nx_tty_clear() <= 0 { return 1 }
15 if nx_tty_cursor_home() <= 0 { return 2 }
16 if nx_tty_reset() <= 0 { return 3 }
17
18 if nx_tty_fg(NX_TTY_FG_GREEN) <= 0 { return 10 }
19 if nx_tty_bg(NX_TTY_FG_BLUE) <= 0 { return 11 }
20 if nx_tty_bold() <= 0 { return 12 }
21 if nx_tty_underline() <= 0 { return 13 }
22 if nx_tty_inverse() <= 0 { return 14 }
23 nx_tty_reset()
24
25 // Cursor positioning.
26 if nx_tty_cursor_at(5, 10) <= 0 { return 20 }
27 if nx_tty_cursor_at(100, 200) <= 0 { return 21 }
28
29 // High-level helpers.
30 nx_tty_say(NX_TTY_FG_CYAN, "cyan text\n" as *u8)
31 nx_tty_announce(NX_TTY_FG_MAGENTA, "magenta bold + reset + newline" as *u8)
32
33 return 0
34}