delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/07/24/12:21:44

From: "Mark E." <snowball3 AT bigfoot DOT com>
To: djgpp-workers AT delorie DOT com
Date: Tue, 24 Jul 2001 12:21:40 -0400
MIME-Version: 1.0
Subject: Re: extended keys support
Message-ID: <3B5D6854.19305.A43993@localhost>
References: <3B5C8550 DOT 21789 DOT 243885 AT localhost>
In-reply-to: <Pine.SUN.3.91.1010724134125.1341M-100000@is>
X-mailer: Pegasus Mail for Win32 (v3.12c)
Reply-To: djgpp-workers AT delorie DOT com

> Shouldn't this table be available to other parts of the library, via
> some function that looks up a string given a key?

How's this? The table is still incomplete, but you get the point.

/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */

#define MIN_EXT_SCAN_CODE 0x10

#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))

/* A table that contains the encodings for extended keys.  */
static const unsigned char *
encoding_table[] =
{
  0,        /* 0x10 */
  0,        /* 0x11 */
  0,        /* 0x12 */
  0,        /* 0x13 */
  0,        /* 0x14 */
  0,        /* 0x15 */
  0,        /* 0x16 */
  0,        /* 0x17 */
  0,        /* 0x18 */
  0,        /* 0x19 */
  0,        /* 0x1a */
  0,        /* 0x1b */
  0,        /* 0x1c */
  0,        /* 0x1d */
  0,        /* 0x1e */
  0,        /* 0x1f */
  0,        /* 0x20 */
  0,        /* 0x21 */
  0,        /* 0x22 */
  0,        /* 0x23 */
  0,        /* 0x24 */
  0,        /* 0x25 */
  0,        /* 0x26 */
  0,        /* 0x27 */
  0,        /* 0x28 */
  0,        /* 0x29 */
  0,        /* 0x2a */
  0,        /* 0x2b */
  0,        /* 0x2c */
  0,        /* 0x2d */
  0,        /* 0x2e */
  0,        /* 0x2f */
  0,        /* 0x30 */
  0,        /* 0x31 */
  0,        /* 0x32 */
  0,        /* 0x33 */
  0,        /* 0x34 */
  0,        /* 0x35 */
  0,        /* 0x36 */
  0,        /* 0x37 */
  0,        /* 0x38 */
  0,        /* 0x39 */
  0,        /* 0x3a */
  "\e[[A",  /* 0x3b: F1 */
  "\e[[B",  /* 0x3c: F2 */
  "\e[[C",  /* 0x3d: F3 */
  "\e[[D",  /* 0x3e: F4 */
  "\e[[E",  /* 0x3f: F5 */
  "\e[17",  /* 0x40: F6 */
  "\e[18~", /* 0x41: F7 */
  "\e[19~", /* 0x42: F8 */
  "\e[20~", /* 0x43: F9 */
  "\e[21~", /* 0x44: F10 */
  0,        /* 0x45 */
  0,        /* 0x46 */
  "\e[1~",  /* 0x47: Home */
  "\e[A",   /* 0x48: Up Arrow */
  "\e[5~",  /* 0x49: Page Up */
  0,        /* 0x4a */
  "\e[D",   /* 0x4b: Left Arrow */
  0,        /* 0x4c */
  "\e[C",   /* 0x4d: Right Arrow */
  0,        /* 0x4e */
  "\e[4~",  /* 0x4f: End */
  "\e[B",   /* 0x50: Down Arrow */
  "\e[6~",  /* 0x51: Page Down */
  "\e[2~",  /* 0x52: Insert */
  "\e[3~",  /* 0x53: Delete */
  "\e[25~", /* 0x54: Shift-F1 */
  "\e[26~", /* 0x55: Shift-F2 */
  "\e[27~", /* 0x56: Shift-F3 */
  "\e[28~", /* 0x57: Shift-F4 */
  "\e[29~", /* 0x58: Shift-F5 */
  "\e[30~", /* 0x59: Shift-F6 */
  "\e[31~", /* 0x5a: Shift-F7 */
  "\e[32~", /* 0x5b: Shift-F8 */
  "\e[33~", /* 0x5c: Shift-F9 */
  "\e[34~", /* 0x5d: Shift-F10 */
  "\e[37~", /* 0x5e: Ctrl-F1 */
  "\e[38~", /* 0x5f: Ctrl-F2 */
  0,        /* 0x60 */
  0,        /* 0x61 */
  0,        /* 0x62 */
  0,        /* 0x63 */
  0,        /* 0x64 */
  0,        /* 0x65 */
  0,        /* 0x66 */
  0,        /* 0x67 */
  0,        /* 0x68 */
  0,        /* 0x69 */
  0,        /* 0x6a */
  0,        /* 0x6b */
  0,        /* 0x6c */
  0,        /* 0x6d */
  0,        /* 0x6e */
  0,        /* 0x6f */
  0,        /* 0x70 */
  0,        /* 0x71 */
  0,        /* 0x72 */
  0,        /* 0x73 */
  0,        /* 0x74 */
  0,        /* 0x75 */
  0,        /* 0x76 */
  0,        /* 0x77 */
  0,        /* 0x78 */
  0,        /* 0x79 */
  0,        /* 0x7a */
  0,        /* 0x7b */
  0,        /* 0x7c */
  0,        /* 0x7d */
  0,        /* 0x7e */
  0,        /* 0x7f */
  0,        /* 0x80 */
  0,        /* 0x81 */
  0,        /* 0x82 */
  0,        /* 0x83 */
  0,        /* 0x84 */
  "\e23~",  /* F11: 0x85 */
  "\e24~",  /* F12: 0x86 */
  0,        /* 0x87 */
  0,        /* 0x88 */
  "\e[35~", /* 0x89: Shift-F11 */
  "\e[36~", /* 0x8a: Shift-F12 */
  0,        /* 0x8a */
  0,        /* 0x8b */
  0,        /* 0x8c */
  0,        /* 0x8d */
  0,        /* 0x8e */
  0,        /* 0x8f */
};

const unsigned char *
__get_extended_key_encoding(unsigned long key_code)
{
  unsigned index;

  /* Strip flags added by getxkey.  */
  key_code &= 0xff;
  
  if (key_code < MIN_EXT_SCAN_CODE)
    return NULL;

  index = key_code - MIN_EXT_SCAN_CODE;
  if (index > ARRAY_SIZE(encoding_table))
    return NULL;

  return encoding_table[index];
}


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019