Newer
Older
Microsoft / ice / ICE_KEYI.C
@tundra tundra on 24 May 2012 7 KB Initial revision
/*  ICE_KEYIN.C -   IceScreen Keystroke Capture & Mapping Routines
                    This Code Captures A Keystroke And Maps It According
                            To The Global Key Value Maps.

                    Last Modified: 06-05-90
                    Copyright (C) 1988, 1989, 1990 by T.A. Daneliuk


*/


#include    <stdio.h>
#include    <ice_defs.h>

#define     K_XLATE     ((unsigned) ((KEYSTR) -1))+1   /* # of unique keyvals */

KEYSTR      key_xlate[K_XLATE] =    {
                                      0,   1,   2,   3,   4,   5,   6,   7,   8,
                                      9,  10,  11,  12,  13,  14,  15,  16,  17,
                                     18,  19,  20,  21,  22,  23,  24,  25,  26,
                                     27,  28,  29,  30,  31,  32,  33,  34,  35,
                                     36,  37,  38,  39,  40,  41,  42,  43,  44,
                                     45,  46,  47,  48,  49,  50,  51,  52,  53,
                                     54,  55,  56,  57,  58,  59,  60,  61,  62,
                                     63,  64,  65,  66,  67,  68,  69,  70,  71,
                                     72,  73,  74,  75,  76,  77,  78,  79,  80,
                                     81,  82,  83,  84,  85,  86,  87,  88,  89,
                                     90,  91,  92,  93,  94,  95,  96,  97,  98,
                                     99, 100, 101, 102, 103, 104, 105, 106, 107,
                                    108, 109, 110, 111, 112, 113, 114, 115, 116,
                                    117, 118, 119, 120, 121, 122, 123, 124, 125,
                                    126, 127, 128, 129, 130, 131, 132, 133, 134,
                                    135, 136, 137, 138, 139, 140, 141, 142, 143,
                                    144, 145, 146, 147, 148, 149, 150, 151, 152,
                                    153, 154, 155, 156, 157, 158, 159, 160, 161,
                                    162, 163, 164, 165, 166, 167, 168, 169, 170,
                                    171, 172, 173, 174, 175, 176, 177, 178, 179,
                                    180, 181, 182, 183, 184, 185, 186, 187, 188,
                                    189, 190, 191, 192, 193, 194, 195, 196, 197,
                                    198, 199, 200, 201, 202, 203, 204, 205, 206,
                                    207, 208, 209, 210, 211, 212, 213, 214, 215,
                                    216, 217, 218, 219, 220, 221, 222, 223, 224,
                                    225, 226, 227, 228, 229, 230, 231, 232, 233,
                                    234, 235, 236, 237, 238, 239, 240, 241, 242,
                                    243, 244, 245, 246, 247, 248, 249, 250, 251,
                                    252, 253, 254, 255
                                    };

/*====================== Get And Map Keyboard Input ==========================*/

KEYSTR  ice_keyin()

{

    static  char progname[] = PROGNAME;
    static  char  version[] = VERSION;
    static  char   module[] = "ice_keyin()";

    KEYSTR  key, retval;
    BOOL    validkey;

    validkey = FALSE;
    while(!validkey)
        {
        key = ice_getc();
        switch (key)
            {
            case 0:                     /* Control Sequence Introducer */
                key = ice_getc();
                switch (key)
                    {
                    case 15:            /* BACKTAB */
                        retval = (KEYSTR) PRV_FLD;
                        validkey = TRUE;
                        break;

                    case 117:           /* Ctrl-END */
                        retval = (KEYSTR) CUR_END_FLD;
                        validkey = TRUE;
                        break;

                    case 119:           /* Ctrl-HOME */
                        retval = (KEYSTR) CUR_BGN_FLD;
                        validkey = TRUE;
                        break;

                    case 83:            /* DEL */
                        retval = (KEYSTR) DELETE;
                        validkey = TRUE;
                        break;

                    case 80:            /* DOWN ARROW */
                        retval = (KEYSTR) CUR_DOWN;
                        validkey = TRUE;
                        break;

                    case 79:            /* END */
                        retval = (KEYSTR) CUR_END_LIN;
                        validkey = TRUE;
                        break;

                    case 71:            /* HOME */
                        retval = (KEYSTR) CUR_BGN_LIN;
                        validkey = TRUE;
                        break;

                    case 82:            /* INS */
                        retval = (KEYSTR) INSERT;
                        validkey = TRUE;
                        break;

                    case 75:            /* LEFT ARROW */
                        retval = (KEYSTR) CUR_LEFT;
                        validkey = TRUE;
                        break;

                    case 59:            /* PF 1 */
                        retval = (KEYSTR) HELP;
                        validkey = TRUE;
                        break;

                    case 81:            /* PgDn */
                        retval = (KEYSTR) CUR_PG_DOWN;
                        validkey = TRUE;
                        break;

                    case 73:            /* PgUp */
                        retval = (KEYSTR) CUR_PG_UP;
                        validkey = TRUE;
                        break;

                    case 77:            /* RIGHT ARROW */
                        retval = (KEYSTR) CUR_RIGHT;
                        validkey = TRUE;
                        break;

                    case 72:            /* UP ARROW */
                        retval = (KEYSTR) CUR_UP;
                        validkey = TRUE;
                        break;

                    case 132:            /* Ctrl-PgUp */
                        retval = (KEYSTR) FST_FLD;
                        validkey = TRUE;
                        break;

                    case 118:            /* Ctrl-PgDn */
                        retval = (KEYSTR) LST_FLD;
                        validkey = TRUE;
                        break;
                    }
                break;

            case 9:                     /* TAB */
                retval = (KEYSTR) NXT_FLD;
                validkey = TRUE;
                break;

            case 8:                     /* BACKSPACE */
                retval = (KEYSTR) BS;
                validkey = TRUE;
                break;

            case 10:                    /* Ctrl-ENTER */
                retval = (KEYSTR) CLR_FLD;
                validkey = TRUE;
                break;

            case 13:                    /* ENTER */
                retval = (KEYSTR) FLD_DONE;
                validkey = TRUE;
                break;

            case 27:                    /* ESCAPE */
                retval = (KEYSTR) SCR_DONE;
                validkey = TRUE;
                break;

            case 03:                    /* Ctrl-C */
                retval = (KEYSTR) CANCEL_EDIT;
                validkey = TRUE;
                break;

            case 11:                    /* Ctrl-K */
                retval = (KEYSTR) CLR_TO_END;
                validkey = TRUE;
                break;

            default:
                retval = (KEYSTR) key_xlate[key];
                validkey = TRUE;
                break;
            }
        }

    return(retval);

}