-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Summary
Add terminal control functions to naml runtime for building TUI applications and games.
Proposed API
// Clear the terminal screen
fn clear_screen();
// Move cursor to position (0-indexed)
fn set_cursor(x: int, y: int);
// Hide/show cursor
fn hide_cursor();
fn show_cursor();
// Get terminal dimensions
fn terminal_width() -> int;
fn terminal_height() -> int;
Use Cases
- Terminal games (snake, tetris, roguelikes)
- TUI applications
- Progress bars and animations
- Dashboard displays
Implementation Notes
- Use ANSI escape sequences for cross-platform compatibility
- Platform considerations:
- Native: Write ANSI sequences to stdout, use ioctl for dimensions
- Server WASM: Same ANSI sequences via WASI stdout
- Browser: Not applicable
ANSI Reference
- Clear screen:
\x1b[2J - Move cursor:
\x1b[{row};{col}H - Hide cursor:
\x1b[?25l - Show cursor:
\x1b[?25h
Acceptance Criteria
-
clear_screen()clears terminal content -
set_cursor(x, y)positions cursor correctly -
hide_cursor()/show_cursor()work -
terminal_width()/terminal_height()return correct dimensions - Works on native platform with standard terminals
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels