Annotation of coherent/d/usr/src/examples/curses.c, revision 1.1.1.1

1.1       root        1: #include <curses.h>
                      2: #include <ctype.h>
                      3: #define        NORMAL 0
                      4: #define        INY  1
                      5: #define        INX  2
                      6: main()
                      7: {
                      8:      int c, y, x, state;
                      9:      initscr();                 /* initialize curses */
                     10:      noecho();
                     11:      raw();
                     12:      clear();
                     13:      move(0, 0);
                     14:      for(state = NORMAL;;) {
                     15:         refresh();
                     16:         c = getch();
                     17:         if(isdigit(c)) {
                     18:                 switch (state) {
                     19:                 case NORMAL:
                     20:                          y = x = 0;
                     21:                          state = INY;
                     22:                 case INY:
                     23:                          y *= 10;
                     24:                          y += c - '0';
                     25:                          break;
                     26:                 case INX:
                     27:                          x *= 10;
                     28:                          x += c - '0';
                     29:                 }
                     30:         } else {
                     31:                 if (3 == c) { /* ctrl-C        */
                     32:                          noraw();
                     33:                          echo();
                     34:                          endwin();
                     35:                          exit(0);
                     36:                 }
                     37:                 switch (state) {
                     38:                 case INX:
                     39:                          state = NORMAL;
                     40:                          move(y, x);
                     41:                 case NORMAL:
                     42:                          addch(c);
                     43:                          break;
                     44:                 case INY:
                     45:                          state = INX;
                     46:                 }
                     47:         }
                     48:      }
                     49: }
                     50: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.