MestreLion
MestreLion

Reputation: 13676

Use data saved with `*inchstr()` to restore screen contents

I needed a way to save screen content to a buffer (as opposed to a FILE as putwin() does) for a quick in-memory save-and-restore, so I looked in Ncurses documentation and found the *inchstr() family of functions, which looks just what I needed.

So I saved data in a function that can be simplified as:

chtype buffer[LINES][COLS+1];
for (int line = 0; line < LINES; line++)
    mvinchnstr(line, 0, buffer[line], COLS);

Question is: how to restore this saved data to screen in an efficient manner?

I know I can use 2 nested loops with addch(), but wouldn't restoring character-per-character defeat the whole purpose of using inchnstr() in the first place? Is there an add*() counterpart of inchnstr() that takes a null-terminated array of chtype chars and print that?

If there isn't, what is the purpose of the *inchnstr() family? Is there a better approach for saving and restoring screen contents to and from memory?

Upvotes: 3

Views: 274

Answers (1)

rici
rici

Reputation: 241671

I think you're looking for addchstr and friends.

Upvotes: 4

Related Questions