* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
+ * Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
#include <config.h>
-#include <cstring>
+//#include <cstring>
#include <X11/Xlib.h>
#include "gettext.h"
int kb_sequence::addkey(unsigned int key,
unsigned int mod, unsigned int nmod /*= 0*/)
{
-#if 0
- if (length < 0) length = 0;
-
- if (length + 1 >= size) {
- unsigned int * nseq = new unsigned int[size + KB_PREALLOC];
- size += KB_PREALLOC;
- memcpy(nseq, sequence, length * sizeof(unsigned int));
- if (sequence != staticseq) delete sequence;
- sequence = nseq;
- nseq = new unsigned int[size];
- memcpy(nseq, modifiers, length * sizeof(unsigned int));
- if (modifiers != staticmod) delete modifiers;
- modifiers = nseq;
- }
-#else
- if (length < 0) {
+ //lyxerr << "kb_sequence::addkey: length is [" << length << "]\n"
+ // << "kb_sequence::addkey::key == [" << key << "]\n"
+ // << "kb_sequence::addkey::mod == [" << mod << "]" << endl;
+
+ if (length <= 0) {
length = 0;
sequence.clear();
modifiers.clear();
- //sequence.resize(0);
- //modifiers.resize(0);
}
-#endif
-
-#if 0
- modifiers[length] = mod + (nmod << 16);
- sequence[length++] = key;
-#else
+
modifiers.push_back(mod + (nmod << 16));
sequence.push_back(key);
++length;
-#endif
+
if (curmap)
return curmap->lookup(key, mod, this);
if (s[i] && (s[i]) <= ' ') ++i;
if (i >= s.length()) break;
- if (s[i + 1] == '-') { // is implicit that s[i] == true
+ if (i + 1 < s.length() && s[i + 1] == '-') {
switch (s[i]) {
case 's': case 'S':
mod |= ShiftMask;
default:
return i + 1;
}
- } else if (s[i] == '~' && s[i + 1] && s[i + 2] == '-') {
+ } else if (i + 2 < s.length() && s[i] == '~'
+ && s[i + 2] == '-') {
switch (s[i + 1]) {
case 's': case 'S':
nmod |= ShiftMask;
Called by : [user]
Purpose : print the currently defined sequence into a string
Parameters: buf - string where the result goes
- maxlen - length of string (including '\0')
when_defined - only print when sequence is real: length > 0.
Returns : 0, if ok, -1 if string too long
\* ---F------------------------------------------------------------------- */
int kb_sequence::print(string & buf, bool when_defined) const
{
+ //lyxerr << "kb_sequence::print: length is [" << length << "]" << endl;
+
KeySym key;
unsigned int mod;
int l = length;
for (int i = 0; i < l; ++i) {
key = sequence[i];
mod = modifiers[i] & 0xffff;
+ //lyxerr << "kb_sequence::sequence[" << i << "] == [" << key << "]\n"
+ // << "kb_sequence::modifiers[" << i << "] == [" << mod << "]"
+ // << endl;
printKeysym(key, mod, buf); // RVDK_PATCH_5
char kb_sequence::getiso() const
{
- int c = getsym();
+ unsigned int const c = getsym();
+
+ lyxerr[Debug::KBMAP] << "Raw keysym: "
+ << std::hex << c << std::dec << endl;
+ lyxerr[Debug::KBMAP] << "byte 3: "
+ << std::hex << (c & 0x0000FF00) << std::dec
+ << endl;
- if (c > 0xff)
+ switch (c & 0x0000FF00) {
+ // latin 1 byte 3 = 0
+ case 0x00000000:
+ return c;
+ // latin 2 byte 3 = 1
+ case 0x00000100:
+ // latin 3 byte 3 = 2
+ case 0x00000200:
+ // latin 4 byte 3 = 3
+ case 0x00000300:
+ // latin 8 byte 3 = 18 (0x12)
+ case 0x00001200:
+ // latin 9 byte 3 = 19 (0x13)
+ case 0x00001300:
+ return c & 0x000000FF;
+ default:
return '\0';
- return c;
+ }
+
+ // not a latin char we know of
+ // Yes but this is already handled above (JMarc)
+ //return '\0';
}