Is there any way to get back the characters outputted into a variable on ncurses ?
let's say I do:
printw("test");
then I want to be able to:
somefunc(strbuffer);
printf("%s",strbuffer); // test
I need a function to get back all characters on the screen into a variable, scr_dump get's close but the output format is unreadable..
Fortunately, ncurses provides printf-like or puts-like functions.
The putchar () function will write its character argument to the screen at the current cursor position.
Window Basicsnewwin(lines, columns, y, x) - creates a new window with the specified dimensions. wresize(window, lines, colums) - resizes an existing window to the specified dimensions. mvwin(window, y, x) - moves a window to the specified location. delwin(window) - frees all memory associated with the specified window.
The clrtobot() and wclrtobot() routines erase from the cursor to the end of screen. That is, they erase all lines below the cursor in the window. Also, the current line to the right of the cursor, inclusive, is erased.
If you put stuff on the screen using curses functions (e.g. addch, mvaddch, addstr) you can use inchstr
) and related functions to read the characters from the screen (extracting them with AND'ing the returned value with A_CHARTEXT
).
However, if you use printf or any other non-curses method of puting text on the screen (including a system call to another program that uses curses) you will not be able to read the content of the screen.
Curses maintains the current screen contents internally and the inchstr functions use the internal representation of the screen to find the current contents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With