Imported Upstream version 2.9.0
[debian/cc1111] / sim / ucsim / gui.src / obsolete / a.cc
1 #include <curses.h>
2 #include <panel.h>
3
4 int sfr[4];
5 int port[4];
6
7 void
8 init_panel(PANEL *p)
9 {
10   int mask, x, y;
11   int na, ha;
12   int cursor= 2;
13   WINDOW *w= panel_window(p);
14   
15   if (has_colors())
16     {
17       na= COLOR_PAIR(1);
18       ha= COLOR_PAIR(2);
19     }
20   else
21     {
22       na= A_NORMAL;
23       ha= A_STANDOUT;
24     }
25   //wattron(w, COLOR_PAIR);
26   x= 0;
27   for (mask= 1, y= 0; mask < 0x100; mask<<= 1,y++)
28     {
29       wattrset(w, (y==cursor)?ha:na);
30       mvwprintw(w, y,x, "%s", (sfr[0]&mask)?"High":" Low");
31     }
32 }
33
34 wchar_t
35 wait_input(PANEL *p)
36 {
37   WINDOW *w= panel_window(p);
38   wchar_t c;
39
40   c= wgetch(w);
41   printw("%d 0x%x\n",c,c);
42   return(c);
43 }
44
45 int
46 main(int argc, char *argv[])
47 {
48   wchar_t c;
49
50   initscr();      /* initialize the curses library */
51   keypad(stdscr, TRUE);  /* enable keyboard mapping */
52   nonl();         /* tell curses not to do NL->CR/NL on output */
53   cbreak();       /* take input chars one at a time, no wait for \n */
54   noecho();       /* don't echo input */
55   if (has_colors())
56     {
57       start_color();
58       printw("has %d colors and %d pairs\n", COLORS, COLOR_PAIRS);
59       init_pair(1, COLOR_WHITE, COLOR_BLUE);
60       init_pair(2, COLOR_WHITE, COLOR_RED);
61     }
62   if (has_key(KEY_UP))
63     printw("has UP KEY_UP=0x%x\n",KEY_UP);
64   else
65     printf("has no UP\n");
66   c= getch();
67   printw("got %d %x\n",c,c);
68
69   WINDOW *w= newwin(10,10, 3,3);
70   keypad(w, TRUE);
71   PANEL *p= new_panel(w);
72
73   sfr[0]= 0x5a;
74   init_panel(p);
75   update_panels();
76   doupdate();
77   c= wait_input(p);
78   //c= getch();
79
80   endwin();
81   if (c==KEY_UP)
82     printf("got UP\n");
83   else if (c==KEY_DOWN)
84     printf("got DOWN\n");
85   else
86     printf("got \"%d\"\n", c);
87 }