Skip to content
mrtalley edited this page Oct 17, 2017 · 1 revision
  • To get data types:
    • #include <ncurses.h>
  • To link the library:
    • -lncurses when compiling

Functions

  • WINDOW *initscr(void)
    • Initialize ncurses window
  • int raw(void)
    • Turns off buffered I/O
    • We can read one byte at a time, no need to wait for user to hit enter
  • int noecho(void)
    • Doesn't echo input to the terminal
  • int curs_set(int visibility)
    • Make cursor invisible with visibility of 0
  • int keypad(WINDOW *win, bool bf)
    • Turns on the keypad
  • int endwin(void)
    • Deinitializes the WINDOW
    • returns resources to the system
    • NOTE: If your program crashes and corrupts the terminal, run the reset command.

Reading input

  • int getch(void)
    • Read a single key code
    • Blocking call

Displaying

  • int clear(void)
    • Before redrawing, use this
  • int mvaddch(int y, int x, const chtype ch)
    • Move cursor to (y, x) and write ch to that position
  • int refresh(void)
    • Redraw the terminal
Clone this wiki locally