bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

wgetch after wresize and mvderwin wrong behaviour


From: dobson156
Subject: wgetch after wresize and mvderwin wrong behaviour
Date: Sun, 17 Feb 2013 05:11:40 -0800 (PST)

Hello all.

I am running into a problem with ncurses.

I have a window (returned from `initscr`) 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.

I know it is the wgetch that is causing it, because if I `sleep` before the
`wgetch` it only presents the behaviour after the sleep duration.

The code listing demonstrates the problem I am having:

#include <ncurses.h>

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, '|', '-');

                //set where i expect it to prompt me for input
                wmove(child, 1, 1);

                wrefresh(win);
                wrefresh(child);
        }
        delwin(child);
        delwin(win);
        endwin();
}
//end code listing

Ncurses version: 5.9
System: arch linux
Compiler: gcc 4.7.2

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 a bit of a
problem for nested UI structures.

Thanks
-- 
View this message in context: 
http://old.nabble.com/wgetch-after-wresize-and-mvderwin-wrong-behaviour-tp35033018p35033018.html
Sent from the Gnu - Ncurses mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]