Annotation of researchv10no/ncurses/screen/initkeypad.c, revision 1.1.1.1

1.1       root        1: #include "curses.ext"
                      2: /*     @(#) initkeypad.c: 1.1 10/15/83 (1.13   8/20/82)        */
                      3: 
                      4: #ifdef         KEYPAD
                      5: static struct map *_addone();
                      6: /*
                      7:  * Make up the needed array of map structures for dealing with the keypad.
                      8:  */
                      9: #define MAXKEYS 50     /* number of keys we understand */
                     10: 
                     11: struct map *
                     12: _init_keypad()
                     13: {
                     14:        struct map *r, *p;
                     15: 
                     16:        r = (struct map *) calloc(MAXKEYS, sizeof (struct map));
                     17:        p = r;
                     18: 
                     19:        /* If down arrow key sends \n, don't map it. */
                     20:        if (key_down && strcmp(key_down, "\n"))
                     21:                p = _addone(p, key_down,        KEY_DOWN,       "down");
                     22:        p = _addone(p, key_up,          KEY_UP,         "up");
                     23:        /* If left arrow key sends \b, don't map it. */
                     24:        if (key_left && strcmp(key_left, "\b"))
                     25:                p = _addone(p, key_left,        KEY_LEFT,       "left");
                     26:        p = _addone(p, key_right,       KEY_RIGHT,      "right");
                     27:        p = _addone(p, key_home,        KEY_HOME,       "home");
                     28:        /* If backspace key sends \b, don't map it. */
                     29:        if (key_backspace && strcmp(key_backspace, "\b"))
                     30:                p = _addone(p, key_backspace,   KEY_BACKSPACE,  "backspace");
                     31:        p = _addone(p, key_f0,          KEY_F(0),       lab_f0?lab_f0:"f0");
                     32:        p = _addone(p, key_f1,          KEY_F(1),       lab_f1?lab_f1:"f1");
                     33:        p = _addone(p, key_f2,          KEY_F(2),       lab_f2?lab_f2:"f2");
                     34:        p = _addone(p, key_f3,          KEY_F(3),       lab_f3?lab_f3:"f3");
                     35:        p = _addone(p, key_f4,          KEY_F(4),       lab_f4?lab_f4:"f4");
                     36:        p = _addone(p, key_f5,          KEY_F(5),       lab_f5?lab_f5:"f5");
                     37:        p = _addone(p, key_f6,          KEY_F(6),       lab_f6?lab_f6:"f6");
                     38:        p = _addone(p, key_f7,          KEY_F(7),       lab_f7?lab_f7:"f7");
                     39:        p = _addone(p, key_f8,          KEY_F(8),       lab_f8?lab_f8:"f8");
                     40:        p = _addone(p, key_f9,          KEY_F(9),       lab_f9?lab_f9:"f9");
                     41:        p = _addone(p, key_dl,          KEY_DL,         "dl");
                     42:        p = _addone(p, key_il,          KEY_IL,         "il");
                     43:        p = _addone(p, key_dc,          KEY_DC,         "dc");
                     44:        p = _addone(p, key_ic,          KEY_IC,         "ic");
                     45:        p = _addone(p, key_eic,         KEY_EIC,        "eic");
                     46:        p = _addone(p, key_clear,       KEY_CLEAR,      "clear");
                     47:        p = _addone(p, key_eos,         KEY_EOS,        "eos");
                     48:        p = _addone(p, key_eol,         KEY_EOL,        "eol");
                     49:        p = _addone(p, key_sf,          KEY_SF,         "sf");
                     50:        p = _addone(p, key_sr,          KEY_SR,         "sr");
                     51:        p = _addone(p, key_npage,       KEY_NPAGE,      "npage");
                     52:        p = _addone(p, key_ppage,       KEY_PPAGE,      "ppage");
                     53:        p = _addone(p, key_stab,        KEY_STAB,       "stab");
                     54:        p = _addone(p, key_ctab,        KEY_CTAB,       "ctab");
                     55:        p = _addone(p, key_catab,       KEY_CATAB,      "catab");
                     56:        p = _addone(p, key_ll,          KEY_LL,         "ll");
                     57:        p = _addone(p, key_a1,          KEY_A1,         "a1");
                     58:        p = _addone(p, key_a3,          KEY_A3,         "a3");
                     59:        p = _addone(p, key_b2,          KEY_B2,         "b2");
                     60:        p = _addone(p, key_c1,          KEY_C1,         "c1");
                     61:        p = _addone(p, key_c3,          KEY_C3,         "c3");
                     62:        p -> keynum = 0;                /* termination convention */
                     63: #ifdef DEBUG
                     64:        if(outf) fprintf(outf, "return key structure %x, ending at %x\n", r, p);
                     65: #endif
                     66:        return r;
                     67: }
                     68: 
                     69: /*
                     70:  * Map text into num, updating the map structure p.
                     71:  * label is currently unused, but is an English description
                     72:  * of what the key is labelled, similar to the name in vi.
                     73:  */
                     74: static
                     75: struct map *
                     76: _addone(p, text, num, label)
                     77: struct map *p;
                     78: char *text;
                     79: int num;
                     80: char *label;
                     81: {
                     82:        if (text) {
                     83:                strcpy(p->label, label);
                     84:                strcpy(p->sends, text);
                     85:                p->keynum = num;
                     86: #ifdef DEBUG
                     87:                if(outf) fprintf(outf, "have key label %s, sends '%s', value %o\n", p->label, p->sends, p->keynum);
                     88: #endif
                     89:                p++;
                     90:        }
                     91:        return p;
                     92: }
                     93: 
                     94: #endif         KEYPAD

unix.superglobalmegacorp.com

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