}
static void
-print_keysym(FILE *fd, int code, char numeric)
+print_keysym(struct keymap *kmap, FILE *fd, int code, char numeric)
{
unsigned int t;
int v;
t = KTYP(code);
v = KVAL(code);
if (t >= syms_size) {
- if (!numeric && (p = codetoksym(code)) != NULL)
+ if (!numeric && (p = codetoksym(kmap, code)) != NULL)
fprintf(fd, "%-16s", p);
else
fprintf(fd, "U+%04x ", code ^ 0xf000);
}
static void
-print_bind(FILE *fd, int bufj, int i, int j, char numeric)
+print_bind(struct keymap *kmap, FILE *fd, int bufj, int i, int j, char numeric)
{
if(j)
fprintf(fd, "\t");
print_mod(fd, j);
fprintf(fd, "keycode %3d =", i);
- print_keysym(fd, bufj, numeric);
+ print_keysym(kmap, fd, bufj, numeric);
fprintf(fd, "\n");
}
fprintf(fd, "keycode %3d =", i);
for (j = 0; j < keymapnr; j++)
- print_keysym(fd, buf[j], numeric);
+ print_keysym(kmap, fd, buf[j], numeric);
fprintf(fd, "\n");
continue;
if (table_shape == SEPARATE_LINES) {
for (j = 0; j < keymapnr; j++) {
//if (buf[j] != K_HOLE)
- print_bind(fd, buf[j], i, kmap->defining[j]-1, numeric);
+ print_bind(kmap, fd, buf[j], i, kmap->defining[j]-1, numeric);
}
fprintf(fd, "\n");
if (isasexpected) {
/* print only a single entry */
/* suppress the + for ordinary a-zA-Z */
- print_keysym(fd, K(KT_LATIN, val), numeric);
+ print_keysym(kmap, fd, K(KT_LATIN, val), numeric);
fprintf(fd, "\n");
} else {
/* choose between single entry line followed by exceptions,
if (bad <= count && bad < keymapnr-1) {
if (buf[0] != K_HOLE) {
- print_keysym(fd, buf[0], numeric);
+ print_keysym(kmap, fd, buf[0], numeric);
}
fprintf(fd, "\n");
for (j = 1; j < keymapnr; j++) {
if (buf[j] != buf[0] && !zapped[j]) {
- print_bind(fd, buf[j], i, kmap->defining[j]-1, numeric);
+ print_bind(kmap, fd, buf[j], i, kmap->defining[j]-1, numeric);
}
}
} else {
(j == 0 || table_shape != UNTIL_HOLE ||
kmap->defining[j]-1 == kmap->defining[j-1]-1+1);
j++) {
- //print_bind(fd, buf[j], i, kmap->defining[j]-1, numeric);
- print_keysym(fd, buf[j], numeric);
+ //print_bind(kmap, fd, buf[j], i, kmap->defining[j]-1, numeric);
+ print_keysym(kmap, fd, buf[j], numeric);
}
fprintf(fd, "\n");
for (; j < keymapnr; j++) {
if (buf[j] != K_HOLE) {
- print_bind(fd, buf[j], i, kmap->defining[j]-1, numeric);
+ print_bind(kmap, fd, buf[j], i, kmap->defining[j]-1, numeric);
}
}
}
};
static unsigned int charsets_size = sizeof(charsets) / sizeof(charsets[0]);
-static unsigned int kmap_charset = 0;
/* Functions for both dumpkeys and loadkeys. */
void
-list_charsets(FILE *f) {
+lk_list_charsets(FILE *f) {
int lth,ct;
unsigned int i, j;
char *mm[] = { "iso-8859-", "koi8-" };
}
int
-set_charset(const char *charset) {
+lk_set_charset(struct keymap *kmap, const char *charset) {
unsigned int i;
for (i = 1; i < charsets_size; i++) {
if (!strcasecmp(charsets[i].charset, charset)) {
- kmap_charset = i;
+ kmap->charset = i;
return 0;
}
}
}
const char *
-codetoksym(int code) {
+codetoksym(struct keymap *kmap, int code) {
unsigned int i;
int j;
sym *p;
if (KTYP(code) > KT_LATIN)
return syms[KTYP(code)].table[KVAL(code)];
- i = kmap_charset;
+ i = kmap->charset;
while (1) {
p = charsets[i].charnames;
if (p) {
if (i == charsets_size)
i = 0;
- if (i == kmap_charset)
+ if (i == kmap->charset)
break;
}
}
if (code < 0x80)
return iso646_syms[code];
- i = kmap_charset;
+ i = kmap->charset;
while (1) {
p = charsets[i].charnames;
if (p) {
if (i == charsets_size)
i = 0;
- if (i == kmap_charset)
+ if (i == kmap->charset)
break;
}
kt_latin(struct keymap *kmap, const char *s, int direction) {
int i, max;
- if (kmap_charset) {
- sym *p = charsets[kmap_charset].charnames;
+ if (kmap->charset) {
+ sym *p = charsets[kmap->charset].charnames;
- for (i = charsets[kmap_charset].start; i < 256; i++, p++) {
+ for (i = charsets[kmap->charset].start; i < 256; i++, p++) {
if(p->name[0] && !strcmp(s, p->name))
return K(KT_LATIN, i);
}
return ksymtocode(kmap, synonyms[i].official_name, direction);
if (direction == TO_UNICODE) {
- i = kmap_charset;
+ i = kmap->charset;
while (1) {
p = charsets[i].charnames;
if (i == charsets_size)
i = 0;
- if (i == kmap_charset)
+ if (i == kmap->charset)
break;
}
} else /* if (!chosen_charset[0]) */ {
else {
/* depending on direction, this will give us either an 8-bit
* K(KTYP, KVAL) or a Unicode keysym xor 0xf000 */
- ksym = codetoksym(code);
+ ksym = codetoksym(kmap, code);
if (ksym)
result = ksymtocode(kmap, ksym, direction);
else