C pointer principle (65)-Ncurses-text terminal graphics

Source: Internet
Author: User

Then look at the hidden and display panel

Dp @ dp :~ /Cursestest % cat x. c

# Include

Int main ()

{

WINDOW * my_wins [3];

PANEL * my_panels [3];

Int lines = 10, cols = 40, y = 2, x = 4, I;

Int ch;

Initscr ();

Cbreak ();

Noecho ();

/* Create a window for each panel */

My_wins [0] = newwin (lines, cols, y, x );

My_wins [1] = newwin (lines, cols, y + 1, x + 5 );

My_wins [2] = newwin (lines, cols, y + 2, x + 10 );

/* Add a border for the window so that you can see the effect of the Panel */

For (I = 0; I <3; ++ I)

Box (my_wins [I], 0, 0 );

/* Associate a window for each panel in the order of bottom-up */

My_panels [0] = new_panel (my_wins [0]);

/* Press the Panel 0 into the stack and stack it in sequence: stdscr0

*/

My_panels [1] = new_panel (my_wins [1]);

/* Press panel 1 into the stack, stacked in sequence: stdscr01

*/

My_panels [2] = new_panel (my_wins [2]);

/* Press panel 2 into the stack and stack it in sequence: stdscr012 */

/* Update the stack sequence. Place panel 2 on the top of the stack */

Update_panels ();

/* Display on screen */

Doupdate ();

// Exit q. Press the 1-3 key to display and hide the corresponding panel.

Int isshow [3] = {1, 1 };

While (ch = getch ())! = 'Q ')

{Switch (ch)

{

Case '1 ':

If (++ isshow [0]) % 2) show_panel (my_panels [0]);

Else hide_panel (my_panels [0]);

Break;

Case '2 ':

If (++ isshow [1]) % 2) show_panel (my_panels [1]);

Else hide_panel (my_panels [1]);

Break;

Case '3 ':

If (++ isshow [2]) % 2) show_panel (my_panels [2]);

Else hide_panel (my_panels [2]);

Break;

}

Update_panels ();

Doupdate ();

}

Getch ();

Endwin ();

}

All contents of the good AI Park blog is original, if reproduced please indicate the source http://blog.csdn.net/myhaspl/

After execution

Dp @ dp :~ /Cursestest % gcc-lncursesw-lpanel x. c-o mytest

Dp @ dp :~ /Cursestest %./mytest

For example, to hide panel 2, the effect is as follows:


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.