Search code examples
cncurses

ncurses: alternative to mvwprintw


I'm looking for an alternative to the mvwprintw function. My problem is that this function moves the cursor and the puts the text on the screen. Is there an alternative that does the same except it doesn't mess with the cursor position?

Thanks


Solution

  • As noted in another answer, you can always save and restore the cursor position using getyx (or getcurx, getcury) and wmove.

    mvwprintw acts as if it calls wmove and (on success) wprintw, which also moves the cursor:

    The printw, wprintw, mvprintw and mvwprintw routines are analogous to printf [see printf(3)]. In effect, the string that would be output by printf is output instead as though waddstr were used on the given window.

    because waddstr acts as if it calls waddch. There is another set of functions corresponding to waddstr which do not move the cursor, i.e., waddchstr, but there is no counterpart/non-advancing wprintw and waddch for that case. So saving/restoring the cursor is the only way in the curses library for doing what is asked.