Keywords: lpg

Next: 8.7.1 Formated Input Up: 8 Character Cell Graphics Previous: 8.6.5 Background Character

# 8.7 Input

- `int getch()`
  `int wgetch(win)`
  `int mvgetch(y, x)`
  `int mvwgetch(win, y, x)`
  getch() will read input from the terminal in a manner depending on whether delay mode is set or not. If delay is on, getch() will wait until a key is pressed, otherwise it will return the key in the input buffer or ERR if this buffer is empty. mvgetch(...) and mvwgetch(...) will move the cursor to position `y,x` first. The `w` functions read input from the terminal related to the window `win`, getch() and mvgetch(...) from the terminal related to .

  With keypad(...) enabled, getch() will return a code defined in .h as KEY_* macros when a function key is pressed. When ESCAPE is pressed (which can be the beginning of a function key) ncurses will start a one second timer. If the remainder of the keystroke is not finished in this second, the key is returned. Otherwise, the function key value is returned. (If necessary, use notimeout() to disable the second timer).

- `int ungetch(ch)`
  Will put the character `ch` back to the input buffer.
- `int getstr(str)`
  `int wgetstr(win, str)`
  `int mvgetstr(y, x, str)`
  `int mvwgetstr(win, y, x, str)`
  `int wgetnstr(win, str, n)`
  These functions will do a series of calls to getch() until a newline is received. The characters are placed in `str` (so don't forget to allocate memory for your character pointer before calling getstr(...)). If echo is enabled the string is echoed (use noecho() to disable echo) and the user's kill and delete characters will be interpreted.
- `chtype inch()`
  `chtype winch(win)`
  `chtype mvinch(y, x)`
  `chtype mvwinch(win, y, x)`
  These functions return a character from the screen or window. Because the type of the return value is `chtype` attribute information is included. This information can be extracted from the character using the A_* constants (see table 8.4 on page ).
- `int instr(str)`
  `int innstr(str, n)`
  `int winstr(win, str)`
  `int winnstr(win, str, n)`
  `int mvinstr(y, x, str)`
  `int mvinnstr(y, x, str, n)`
  `int mvwinstr(win, y, x, str)`
  `int mvwinnstr(win, y, x, str, n)`
  Return a character string from the screen or a window. (Note: not implemented yet.)
- `int inchstr(chstr)`
  `int inchnstr(chstr, n)`
  `int winchstr(win, chstr)`
  `int winchnstr(win, chstr, n)`
  `int mvinchstr(y, x, chstr)`
  `int mvinchnstr(y, x, chstr, n)`
  `int mvwinchstr(win, y, x, chstr)`
  `int mvwinchnstr(win, y, x, chstr, n)`
  Return a chtype string from the screen or window. In the string, attribute information is included for every character. (Note: not implemented yet, lib_inchstr not included in the ncurses lib.)

- 8.7.1 Formated Input

Next: 8.7.1 Formated Input Up: 8 Character Cell Graphics Previous: 8.6.5 Background Character