* if a dead key sequence does not produce a special character as defined by

the dead key character map - both the dead key itself and the following
  character are being sent. 
  R5 seems to do the same, at least the resulting behaviour in the terminal
  is now identical: e.g. if you press ^ once, you see nothing, if you press ^ a
  second time, you see '^^'.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30765 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe
2009-05-15 10:10:47 +00:00
parent b62daa4867
commit cdea942eea
@@ -21,7 +21,7 @@
#include <string.h> #include <string.h>
static void static void
print_key(char *chars, int32 offset) print_key(char *chars, int32 offset)
{ {
int size = chars[offset++]; int size = chars[offset++];
@@ -62,9 +62,9 @@ print_key(char *chars, int32 offset)
void void
Keymap::DumpKeymap() Keymap::DumpKeymap()
{ {
// Print a chart of the normal, shift, option, and option+shift // Print a chart of the normal, shift, option, and option+shift
// keys. // keys.
printf("Key #\tNormal\tShift\tCaps\tC+S\tOption\tO+S\tO+C\tO+C+S\tControl\n"); printf("Key #\tNormal\tShift\tCaps\tC+S\tOption\tO+S\tO+C\tO+C+S\tControl\n");
for (int i = 0; i < 128; i++) { for (int i = 0; i < 128; i++) {
printf(" 0x%x\t", i); printf(" 0x%x\t", i);
@@ -102,10 +102,10 @@ Keymap::~Keymap()
} }
/* we need to know if a key is a modifier key to choose /* we need to know if a key is a modifier key to choose
a valid key when several are pressed together a valid key when several are pressed together
*/ */
bool bool
Keymap::IsModifierKey(uint32 keyCode) Keymap::IsModifierKey(uint32 keyCode)
{ {
return keyCode == fKeys.caps_key return keyCode == fKeys.caps_key
@@ -124,7 +124,7 @@ Keymap::IsModifierKey(uint32 keyCode)
//! We need to know a modifier for a key //! We need to know a modifier for a key
uint32 uint32
Keymap::Modifier(uint32 keyCode) Keymap::Modifier(uint32 keyCode)
{ {
if (keyCode == fKeys.caps_key) if (keyCode == fKeys.caps_key)
@@ -197,7 +197,7 @@ Keymap::IsDeadKey(uint32 keyCode, uint32 modifiers)
int32 offset; int32 offset;
uint32 tableMask = 0; uint32 tableMask = 0;
switch (modifiers & 0xcf) { switch (modifiers & 0xcf) {
case B_SHIFT_KEY: offset = fKeys.shift_map[keyCode]; tableMask = B_SHIFT_TABLE; break; case B_SHIFT_KEY: offset = fKeys.shift_map[keyCode]; tableMask = B_SHIFT_TABLE; break;
case B_CAPS_LOCK: offset = fKeys.caps_map[keyCode]; tableMask = B_CAPS_TABLE; break; case B_CAPS_LOCK: offset = fKeys.caps_map[keyCode]; tableMask = B_CAPS_TABLE; break;
@@ -217,9 +217,9 @@ Keymap::IsDeadKey(uint32 keyCode, uint32 modifiers)
if (!numBytes) if (!numBytes)
return 0; return 0;
char chars[4]; char chars[4];
strncpy(chars, &(fChars[offset+1]), numBytes ); strncpy(chars, &(fChars[offset+1]), numBytes );
chars[numBytes] = 0; chars[numBytes] = 0;
int32 deadOffsets[] = { int32 deadOffsets[] = {
fKeys.acute_dead_key[1], fKeys.acute_dead_key[1],
@@ -227,7 +227,7 @@ Keymap::IsDeadKey(uint32 keyCode, uint32 modifiers)
fKeys.circumflex_dead_key[1], fKeys.circumflex_dead_key[1],
fKeys.dieresis_dead_key[1], fKeys.dieresis_dead_key[1],
fKeys.tilde_dead_key[1] fKeys.tilde_dead_key[1]
}; };
uint32 deadTables[] = { uint32 deadTables[] = {
fKeys.acute_tables, fKeys.acute_tables,
@@ -277,7 +277,7 @@ Keymap::IsDeadSecondKey(uint32 keyCode, uint32 modifiers, uint8 activeDeadKey)
} }
if (offset <= 0 || offset > fCharsSize) if (offset <= 0 || offset > fCharsSize)
return false; return false;
uint32 numBytes = fChars[offset]; uint32 numBytes = fChars[offset];
if (!numBytes) if (!numBytes)
@@ -291,7 +291,7 @@ Keymap::IsDeadSecondKey(uint32 keyCode, uint32 modifiers, uint8 activeDeadKey)
fKeys.tilde_dead_key fKeys.tilde_dead_key
}; };
int32 *deadOffset = deadOffsets[activeDeadKey-1]; int32 *deadOffset = deadOffsets[activeDeadKey-1];
for (int32 i=0; i<32; i++) { for (int32 i=0; i<32; i++) {
if (offset == deadOffset[i]) if (offset == deadOffset[i])
@@ -414,19 +414,23 @@ Keymap::GetChars(uint32 keyCode, uint32 modifiers, uint8 activeDeadKey,
} }
} }
return; return;
} }
i++; i++;
} }
// if not found we return the current char mapped // if not found we return the whole sequence (the dead key itself plus
*chars = new (std::nothrow) char[*numBytes + 1]; // the following char)
int32 deadKeyNumBytes = fChars[deadKey[1]];
int32 fullNumBytes = deadKeyNumBytes + *numBytes;
*chars = new (std::nothrow) char[fullNumBytes + 1];
if (*chars == NULL) { if (*chars == NULL) {
*numBytes = 0; *numBytes = 0;
return; return;
} }
strncpy(*chars, &fChars[deadKey[1] + 1], deadKeyNumBytes);
strncpy(*chars, &(fChars[offset + 1]), *numBytes ); strncpy(*chars + deadKeyNumBytes, &fChars[offset + 1], *numBytes);
(*chars)[*numBytes] = 0; *numBytes = fullNumBytes;
(*chars)[fullNumBytes] = 0;
} }