DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Ncurses

02.09.2006
| 267 views |
  • submit to reddit
        
#include <curses.h>

int main() {

   int c;
   WINDOW *config_win;

   initscr();
   cbreak();
   noecho();

   config_win = newwin(10,20,1,1);
   mvwaddstr(config_win, 1,1, "test");

   while (c = wgetch(config_win)) {
      switch(c) {
         case 'a':
         delwin(config_win);
         config_win = newwin(10,20,1,1);
         mvwaddstr(config_win, 1,1, "print this");
         wrefresh(config_win);
         break;

         default:
         delwin(config_win);
         config_win = newwin(10,20,1,1);
         mvwaddstr(config_win, 1,1, "hello");
         wrefresh(config_win);
         break;
      }
   }

   endwin();
}

    
    Tags:
  • C