Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get the text in the display with ncurses

Tags:

c

ncurses

curses

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..

like image 202
Anon Avatar asked Jun 17 '10 19:06

Anon


People also ask

Does printf work in ncurses?

Fortunately, ncurses provides printf-like or puts-like functions.

Which function is used for printing a character on to the screen at the current cursor location?

The putchar () function will write its character argument to the screen at the current cursor position.

How do you make a window in ncurses?

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.

How do I clear my ncurses screen?

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.


1 Answers

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.

like image 104
Craig Avatar answered Sep 18 '22 23:09

Craig