v / vlib / ncurses / README.md
41 lines · 33 sloc · 921 bytes · 04c09899ccd55ae1caa6b2af1f6a5537f87aae7e
Raw

ncurses

Thin bindings for the system ncurses or curses library.

Supported targets:

Most functions return ncurses.ok on success and ncurses.err on failure. getch() and wgetch() return an int. Compare special keys with ncurses.key_*.

import ncurses

fn main() {
    if !ncurses.is_supported() {
        return
    }
    stdscr := ncurses.initscr()
    defer {
        ncurses.endwin()
    }
    ncurses.cbreak()
    ncurses.noecho()
    ncurses.keypad(stdscr, true)
    ncurses.addstr('Press a key...')
    ncurses.refresh()

    key := ncurses.getch()
    ncurses.mvaddstr(1, 0, 'Key code: ${key}')
    ncurses.refresh()
    ncurses.getch()
}

Use newwin, box, waddstr, wrefresh, and wgetch for additional windows. Use start_color, init_pair, and color_pair for color attributes.