ihalila / pancurses

A Rust curses library, supports Unix platforms and Windows
MIT License
396 stars 44 forks source link

Moving subwindow leaves behind the old windows #62

Closed WishCow closed 4 years ago

WishCow commented 5 years ago

Sorry if this is a very basic question, this is the first time I'm using ncurses.

When I create a subwindow, and I move it, the window is still visible in its old location, it effectively looks like I have two windows.

fn main() {
    let window = initscr();
    window.keypad(true);
    noecho();
    curs_set(0);
    window.draw_box(0,0);
    let subwin = window.derwin(10, 10, 5, 5).unwrap();)
    subwin.draw_box(0,0);
    subwin.printw("Hello");
    subwin.mvwin(15, 15);
    window.refresh();
    subwin.refresh();
    window.getch();
}

This causes the screen to look like this: tmp hjkbp4y1fa

I was expecting the "hello" window to only show up once, is there something I'm missing?

ratijas commented 4 years ago

It only draws where you tell it to. It has no notion of "window" in the terms of GUI frameworks like X Window System or window managers like KWin. You are not actually "moving a window", just setting other coordinates to count from when drawing.

About the solution, manual .clear() should do.

ratijas commented 4 years ago

As a rule of thumb for pa{n,}curses, it's good to clear your terminal before each iteration of your drawing loop.

This issue should be closed, as this is not a bug.

WishCow commented 4 years ago

Okay, that wasn't clear, thanks.