home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / languages / progs / curses / amiga / c / demo < prev    next >
Encoding:
Text File  |  1993-05-15  |  7.3 KB  |  168 lines

  1. /**********************************************************
  2.  *      This is a short demo of the Minix version         *
  3.  *      of curses and is released into the public         *
  4.  *      domain.   Don Cope  900906                        *
  5.  **********************************************************/
  6.  
  7. #include "curses.h"
  8. WINDOW *win1, *win2, *win3, *win4, *win5, *win6, *txwin;
  9. main()
  10. {
  11.         char str[20];
  12.         int d, c;
  13.         if((d = initscr()) == 0)
  14.         {
  15.                 clear();
  16.                 cbreak();
  17.                 noecho();
  18.                 win1 = newwin(10, 80, 0, 0);
  19.                 win2 = newwin(7, 39, 10, 0);
  20.                 win3 = newwin(6, 39, 10, 41);
  21.                 win4 = newwin(3, 20, 17, 0);
  22.                 win5 = newwin(3, 20, 17, 21);
  23.                 win6 = newwin(3, 20, 20, 10);
  24.                 txwin = newwin(24, 80, 0, 0);
  25.                 wsetcolors(win4, A_COLOR(A_BLACK, A_RED));
  26.                 wsetcolors(win3, A_COLOR(A_BLUE, A_WHITE));
  27.                 wsetcolors(win2, A_COLOR(A_RED, A_GREEN));
  28.                 wsetcolors(win5, A_COLOR(A_GREEN, A_RED));
  29.                 wsetcolors(win6, A_COLOR(A_WHITE, A_BLUE));
  30.                 wsetcolors(txwin, A_COLOR(A_BLACK, A_CYAN));
  31.                 wclrtobot(win1);
  32.                 box(win1, 0,0);
  33.                 wstandout(win1);
  34.                 wmove(win1,1,10);
  35.                 wprintw(win1,"Standout   window %d line 1",1);
  36.                 wstandend(win1);
  37.                 mvwaddstr(win1, 2, 10, "Normal   window 1 line 2");
  38.                 wattron(win1,A_UNDERLINE);
  39.                 mvwaddstr(win1,3 ,10, "Underscore        window 1 line 3");
  40.                 wattroff(win1,A_UNDERLINE);
  41.                 mvwaddstr(win1, 4, 10, "Normal   window 1 line 4");
  42.                 wattron(win1,A_REVERSE);
  43.                 mvwaddstr(win1, 5,10, "Reverse   window 1 line 5");
  44.                 wattroff(win1,A_REVERSE);
  45.                 mvwaddstr(win1, 6, 10, "Normal   window 1 line 6");
  46.                 wattron(win1,A_BOLD);
  47.                 mvwaddstr(win1, 7, 10, "Bold             window 1 line 7");
  48.                 wattroff(win1,A_BOLD);
  49.                 mvwaddstr(win1,8,10,"Back to normal window 1 line 8");
  50.                 wrefresh(win1);
  51.                 wclrtobot(win2);
  52.                 box(win2, 0,0);
  53.                 wrefresh(win2);
  54.                 wstandout(win2); 
  55.                 wmove(win2,1,1);
  56.                 wprintw(win2,"Standout window %d line 1",2);
  57.                 wstandend(win2); 
  58.                 mvwaddstr(win2, 2, 1, "Normal window 2 line 2");
  59.                 wattron(win2,A_BLINK); 
  60.                 mvwaddstr(win2,3,1,"Blinking window 2 line 3");
  61.                 wattroff(win2,A_BLINK); 
  62.                 mvwaddstr(win2, 4, 1, "Normal window 2 line 4");
  63.                 mvwaddstr(win2, 5, 1, "Red on Green");
  64.                 wrefresh(win2);
  65.                 wclrtobot(win3);
  66.                 box(win3, 0,0);
  67.                 wrefresh(win3);
  68.                 wstandout(win3);
  69.                 wmove(win3,1,5);
  70.                 wprintw(win3,"Standout window 3 line 1");
  71.                 wstandend(win3); 
  72.                 mvwaddstr(win3, 2, 5, "Normal window 3 line 2");
  73.                 mvwaddstr(win3, 3, 5, "Cursor off window 3 line 3");
  74.                 mvwaddstr(win3, 4, 5, "Blue on White");
  75.                 cursoff();
  76.                 wrefresh(win3);
  77.                 sleep(2);
  78.                 mvwaddstr(win3, 3, 5, "Cursor on  window 3 line 3");
  79.                 curson();
  80.                 wrefresh(win3);
  81.                 wclrtobot(win4);
  82.                 box(win4, 0,0);
  83.                 wrefresh(win4);
  84.                 mvwaddstr(win4, 1, 1, "Black on RED");
  85.                 wrefresh(win4);
  86.                 wclrtobot(win5);
  87.                 box(win5, 0,0);
  88.                 wrefresh(win5);
  89.                 mvwaddstr(win5, 1, 1, "Green on Red");
  90.                 wrefresh(win5);
  91.                 wclrtobot(win6);
  92.                 box(win6, 0,0);
  93.                 wrefresh(win6);
  94.                 mvwaddstr(win6, 1, 1, "White on Blue");
  95.                 wrefresh(win6);
  96.                 sleep(5);
  97.                 wclear(txwin);
  98.                 waddstr(txwin, " This is a test program to insure that MINIX");
  99.                 waddstr(txwin, " can use this curses package and\nthat most ");
  100.                 waddstr(txwin, "functions work properly.");
  101.                 waddstr(txwin, " Not all functions are used in this demo.\n");
  102.                 waddstr(txwin," Those of you with color monitors will notice");
  103.                 waddstr(txwin, " that each window has a different\nforground ");
  104.                 waddstr(txwin, "and background color, however if you have a ");
  105.                 waddstr(txwin, "monocrome monitor every\nthing will be ");
  106.                 waddstr(txwin, "WHITE on BLACK.\n");
  107.                 mvwaddstr(txwin, 12, 0, "Enter 1 to recall window 1.\n");
  108.                 waddstr(txwin, "      2 to recall window 2.\n");
  109.                 waddstr(txwin, "      3 to recall window 3.\n");
  110.                 waddstr(txwin, "      4 to recall window 4.\n");
  111.                 waddstr(txwin, "      5 to recall window 5.\n");
  112.                 waddstr(txwin, "      6 to recall window 6.\n");
  113.                 waddstr(txwin, "      t to recall this text window.\n");
  114.                 waddstr(txwin, "      q to quit.\n");
  115.                 mvwaddstr(txwin, 22, 0, "These are valid KEYS to enter ");
  116.                 waddstr(txwin, "123456tq");
  117.                 while(1)
  118.                 {
  119.                         mvwaddstr(txwin, 23, 5, "ENTER: ");
  120.                         wrefresh(txwin);
  121.                         c = wgetch(txwin);
  122.                         switch(c){
  123.                                 case '1':
  124.                                         touchwin(win1);
  125.                                         wrefresh(win1);
  126.                                         break;
  127.                                 case '2':
  128.                                         touchwin(win2);
  129.                                         wrefresh(win2);
  130.                                         break;
  131.                                 case '3':
  132.                                         touchwin(win3);
  133.                                         wrefresh(win3);
  134.                                         break;
  135.                                 case '4':
  136.                                         touchwin(win4);
  137.                                         wrefresh(win4);
  138.                                         break;
  139.                                 case '5':
  140.                                         touchwin(win5);
  141.                                         wrefresh(win5);
  142.                                         break;
  143.                                 case '6':
  144.                                         touchwin(win6);
  145.                                         wrefresh(win6);
  146.                                         break;
  147.                                 case 't':
  148.                                         touchwin(txwin);
  149.                                         wrefresh(txwin);
  150.                                         break;
  151.                                 case 'q':
  152.                                         goto end;
  153.                                 }
  154.                 }
  155. end:
  156.                 delwin(win1); delwin(win2); delwin(win3); delwin(win4);
  157.                 delwin(win5); delwin(win6); delwin(txwin);
  158.                 endwin();
  159.                 exit(0);
  160.         }
  161.         else
  162.         {
  163.                 printf("Bad return from initscr() %d\n",d);
  164.                 exit(1);
  165.         }
  166.  
  167. }
  168.