Next: 8.11 Video Attributes and Up: 8 Character Cell Graphics Previous: 8.9 Clear Window and

# 8.10 Updating the Terminal

As written in the overview, ncurses windows are images in memory. This means that any change to a window is not printed to the physical screen until a refresh is done. This optimizes the output to the screen because you can do a lot of manipulations and then, once, call refresh to print it to screen. Otherwise, every change would be printed to the terminal and decrease the performance of your programs.

- `int refresh()`
  `int wrefresh(win)`
  refresh() copies to the terminal and wrefresh(win) copies the window image to and then makes looks like .
- `int wnoutrefresh(win)`
  `int doupdate()`
  wnoutrefresh(win) copies the window `win` to only. This means that no output to the terminal is done but the virtual screen actually looks like the programmer wanted. doupdate() will do the output to the terminal. A program can change various windows, call wnoutrefresh(win) for every window and then call doupdate() to update the physical screen only once.

  For instance, we have the following program with two windows. We change both windows by altering some lines of text. We can write changewin(win) with wrefresh(win).

  This will cause ncurses to update the terminal twice and slow down our execution. With doupdate() we change changewin(win) and our main function and will get better a performance.

- `int redrawwin(win)`
  `int wredrawln(win, bline, nlines)`
  Use these functions when some lines or the entire screen should thrown away before writing anything new in it (may be when the lines are trashed or so).
- `int touchwin(win)`
  `int touchline(win, start, count)`
  `int wtouchln(win, y, n, changed)`
  `int untouchwin(win)`
  Tells ncurses that the whole window `win` or the lines from `start` up to `start+count` have been manipulated. For instance, when you have some overlapping windows (as in the example .c) a change to one window will not affect the image from the other.

  wtouchln(...) will touch `n` lines starting at `y`. If `change` is TRUE the lines are touched, otherwise untouched (changed or unchanged).

  untouchwin(win) will mark the window `win` as unchanged since the last call to refresh().

- `int is_linetouched(win, line)`
  `int is_wintouched(win)`
  With these functions you can check if the line `line` or the window `win` has been touched since the last call to refresh().

Next: 8.11 Video Attributes and Up: 8 Character Cell Graphics Previous: 8.9 Clear Window and