Annotation of 43BSD/contrib/X/xterm/input.c, revision 1.1.1.1

1.1       root        1: #include <X/mit-copyright.h>
                      2: 
                      3: /* Copyright    Massachusetts Institute of Technology    1984, 1985    */
                      4: 
                      5: /* input.c */
                      6: 
                      7: #ifndef lint
                      8: static char *rcsid_input_c = "$Header: input.c,v 10.10 86/02/01 16:06:22 tony Rel $";
                      9: #endif lint
                     10: 
                     11: #include <X/Xlib.h>
                     12: #include <X/Xkeyboard.h>
                     13: #include "ptyx.h"
                     14: #include <stdio.h>
                     15: 
                     16: static char *kypd_num = "0x.
123456,789-";
                     17: static char *kypd_apl = "pxnMqrstuvlwxym";
                     18: static char *cur = "DCBA";
                     19: 
                     20: Input (keyboard, screen, event)
                     21: register Keyboard      *keyboard;
                     22: register Screen                *screen;
                     23: register XKeyPressedEvent *event;
                     24: {
                     25:        register int keycode = event->detail;
                     26:        register char *string;
                     27:        int     tx8bit  = screen->tx8bit;
                     28:        int     pty     = screen->respond;
                     29:        int     nbytes;
                     30:        ANSI    reply;
                     31: 
                     32:        string = XLookupMapping (event, &nbytes);
                     33: 
                     34:        keycode &= ValueMask;   /* no longer need shift bits for anything */
                     35: 
                     36:        reply.a_pintro = 0;
                     37:        reply.a_final = 0;
                     38:        reply.a_nparam = 0;
                     39:        reply.a_inters = 0;
                     40: 
                     41:        if (nbytes > 0) {
                     42:                while (nbytes-- > 0)
                     43:                        unparseputc(*string++, pty);
                     44:        }
                     45:        else if (IsKeypadKey(keycode)) {
                     46:                if (keyboard->flags & KYPD_APL) {
                     47:                        reply.a_type   = SS3;
                     48:                        unparseseq(&reply, tx8bit, pty);
                     49:                        unparseputc(kypd_apl[keycode-KC_KEYPAD_0], pty);
                     50:                }
                     51:                else
                     52:                        unparseputc(kypd_num[keycode-KC_KEYPAD_0], pty);
                     53:        }
                     54:        else if (IsCursorKey(keycode)) {
                     55:                        if (keyboard->flags & CURSOR_APL) {
                     56:                        reply.a_type = SS3;
                     57:                        unparseseq(&reply, tx8bit, pty);
                     58:                        unparseputc(cur[keycode-KC_CURSOR_LEFT], pty);
                     59:                }
                     60:                else {
                     61:                        reply.a_type = CSI;
                     62:                        reply.a_final = cur[keycode-KC_CURSOR_LEFT];
                     63:                        unparseseq(&reply, tx8bit, pty);
                     64:                }
                     65:        }
                     66:        else if (IsPFKey(keycode)) {
                     67:                        reply.a_type = SS3;
                     68:                        unparseseq(&reply, tx8bit, pty);
                     69:                        unparseputc((char)(keycode-KC_PF1+'P'), pty);
                     70:        }
                     71:        else if (IsFunctionKey(keycode)) {
                     72:                        reply.a_type = CSI;
                     73:                        reply.a_nparam = 1;
                     74:                        reply.a_param[0] = funcvalue(keycode);
                     75:                        reply.a_final = '~';
                     76:                        if (reply.a_param[0] > 0)
                     77:                                unparseseq(&reply, tx8bit, pty);
                     78:        }
                     79: #ifdef ENABLE_PRINT
                     80:        if (keycode == KC_F2) TekPrint();
                     81: #endif
                     82:        return;
                     83: }
                     84: 
                     85: funcvalue(keycode)
                     86: {
                     87:        switch (keycode) {
                     88:                case KC_F1:     return(11);
                     89:                case KC_F2:     return(12);
                     90:                case KC_F3:     return(13);
                     91:                case KC_F4:     return(14);
                     92:                case KC_F5:     return(15);
                     93:                case KC_F6:     return(17);
                     94:                case KC_F7:     return(18);
                     95:                case KC_F8:     return(19);
                     96:                case KC_F9:     return(20);
                     97:                case KC_F10:    return(21);
                     98:                case KC_F11:    return(23);
                     99:                case KC_F12:    return(24);
                    100:                case KC_F13:    return(25);
                    101:                case KC_F14:    return(26);
                    102:                case KC_F15:    return(28);
                    103:                case KC_F16:    return(29);
                    104:                case KC_F17:    return(31);
                    105:                case KC_F18:    return(32);
                    106:                case KC_F19:    return(33);
                    107:                case KC_F20:    return(34);
                    108:                case KC_E1 :    return(1);
                    109:                case KC_E2:     return(2);
                    110:                case KC_E3:     return(3);
                    111:                case KC_E4:     return(4);
                    112:                case KC_E5:     return(5);
                    113:                case KC_E6:     return(6);
                    114:                default:        return(-1);
                    115:        }
                    116: }

unix.superglobalmegacorp.com

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