Search code examples
c++panelncursestui

NCurses: Insert panel in the middle of stacking order


I've read the following at [ 1 ] and I'm sorry if this has an obvious answer, but how do you insert a panel into the middle of a stacking order with regard to NCurses? Do you delete them all using del_panel() and re-add them with new_panel(), before doing a update_panels() and doupdate()? Any solutions to this will be greatly appreciated, thank you.

[ 1 ] - http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/panels.html


Solution

  • Reviewing the manual page is a good first step:

    • you can use hide_panel to remove a panel from the panel-stack without deleting (and re-creating it),
    • you can use show_panel to add a panel back — on top of the stack,
    • so removing all of the panels and re-adding them in the order that you want to display them will let you "insert" a new panel in the middle.

    The del_panel function would not only hide the panel, but deallocate it, so you would have to create a new panel (with whatever contents) to get one that looked like the original.