X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=sim%2Fucsim%2Fgui.src%2Fa.cc;fp=sim%2Fucsim%2Fgui.src%2Fa.cc;h=81d62c3fe00bfbdbf42d6fbaa069e0577d6e9320;hb=1854d0ec377d6032617c09d2bd31fa0866764744;hp=0000000000000000000000000000000000000000;hpb=9a50653645c82b879939a5da8ce9fdd18c643622;p=fw%2Fsdcc diff --git a/sim/ucsim/gui.src/a.cc b/sim/ucsim/gui.src/a.cc new file mode 100644 index 00000000..81d62c3f --- /dev/null +++ b/sim/ucsim/gui.src/a.cc @@ -0,0 +1,87 @@ +#include +#include + +int sfr[4]; +int port[4]; + +void +init_panel(PANEL *p) +{ + int mask, x, y; + int na, ha; + int cursor= 2; + WINDOW *w= panel_window(p); + + if (has_colors()) + { + na= COLOR_PAIR(1); + ha= COLOR_PAIR(2); + } + else + { + na= A_NORMAL; + ha= A_STANDOUT; + } + //wattron(w, COLOR_PAIR); + x= 0; + for (mask= 1, y= 0; mask < 0x100; mask<<= 1,y++) + { + wattrset(w, (y==cursor)?ha:na); + mvwprintw(w, y,x, "%s", (sfr[0]&mask)?"High":" Low"); + } +} + +wchar_t +wait_input(PANEL *p) +{ + WINDOW *w= panel_window(p); + wchar_t c; + + c= wgetch(w); + printw("%d 0x%x\n",c,c); + return(c); +} + +int +main(int argc, char *argv[]) +{ + wchar_t c; + + initscr(); /* initialize the curses library */ + keypad(stdscr, TRUE); /* enable keyboard mapping */ + nonl(); /* tell curses not to do NL->CR/NL on output */ + cbreak(); /* take input chars one at a time, no wait for \n */ + noecho(); /* don't echo input */ + if (has_colors()) + { + start_color(); + printw("has %d colors and %d pairs\n", COLORS, COLOR_PAIRS); + init_pair(1, COLOR_WHITE, COLOR_BLUE); + init_pair(2, COLOR_WHITE, COLOR_RED); + } + if (has_key(KEY_UP)) + printw("has UP KEY_UP=0x%x\n",KEY_UP); + else + printf("has no UP\n"); + c= getch(); + printw("got %d %x\n",c,c); + + WINDOW *w= newwin(10,10, 3,3); + keypad(w, TRUE); + PANEL *p= new_panel(w); + + sfr[0]= 0x5a; + init_panel(p); + update_panels(); + doupdate(); + c= wait_input(p); + //c= getch(); + + endwin(); + if (c==KEY_UP) + printf("got UP\n"); + else if (c==KEY_DOWN) + printf("got DOWN\n"); + else + printf("got \"%d\"\n", c); +}