I am running into a problem with ncurses.
I have a window (the main window) and it has a child derived window. The problem my use-case requires me to move and resize the child window, this works fine using the `wresize` and `mvderwin` functions; except if I perform a `wgetch` on that child window, in which case it places the cursor in the right if the frame hadn't moved, and depending on whether or not I refresh the parent on not, it also print the whole of the window at the old position as well.
int main() {
WINDOW *win=initscr();
int y,x,i=3;
getmaxyx(win, y, x);
//creates a sub windows 1 col high
WINDOW *child=derwin(win, i, x, y-i, 0);
//doc says to touch before referesh
touchwin(win);
mvwaddstr(child, 1, 1, "hello");
wrefresh(win); //is this the correct order?
wrefresh(child);
box(child, '|', '-');
while(wgetch(child)!='q') {
++i;
mvderwin(child, y-i, 0);
wresize(child, i, x);
touchwin(win); //is this the right place?
wclear(child); //redraw content
mvwaddstr(child, 1, 1,"hello");
box(child, '|', '-');
wmove(child, 1, 1);
wrefresh(win);
wrefresh(child);
}
delwin(child);
delwin(win);
endwin();
}
The only "fix" I have come across with is to destroy the old derived window and create a new one in the desired position, but this is an immense faff for nested structures.