#include "ksyms.h"
#include "nls.h"
+#include "loadkeys.keymap.h"
+
/* Keysyms whose KTYP is KT_LATIN or KT_LETTER and whose KVAL is 0..127. */
static const char *iso646_syms[] = {
/* Functions for loadkeys. */
int
-ksymtocode(int try_unicode, const char *s, int direction) {
+ksymtocode(struct keymap *kmap, const char *s, int direction) {
unsigned int i;
int j, jmax;
int keycode;
sym *p;
if (direction == TO_AUTO)
- direction = try_unicode ? TO_UNICODE : TO_8BIT;
+ direction = kmap->prefer_unicode ? TO_UNICODE : TO_8BIT;
if (!strncmp(s, "Meta_", 5)) {
- keycode = ksymtocode(try_unicode, s+5, TO_8BIT);
+ keycode = ksymtocode(kmap, s+5, TO_8BIT);
if (KTYP(keycode) == KT_LATIN)
return K(KT_META, KVAL(keycode));
for (i = 0; i < syn_size; i++)
if (!strcmp(s, synonyms[i].synonym))
- return ksymtocode(try_unicode, synonyms[i].official_name, direction);
+ return ksymtocode(kmap, synonyms[i].official_name, direction);
if (direction == TO_UNICODE) {
for (i = 0; i < sizeof(charsets)/sizeof(charsets[0]); i++) {
}
int
-convert_code(int try_unicode, int code, int direction)
+convert_code(struct keymap *kmap, int code, int direction)
{
const char *ksym;
int unicode_forced = (direction == TO_UNICODE);
int result;
if (direction == TO_AUTO)
- direction = try_unicode ? TO_UNICODE : TO_8BIT;
+ direction = kmap->prefer_unicode ? TO_UNICODE : TO_8BIT;
if (KTYP(code) == KT_META)
return code;
* K(KTYP, KVAL) or a Unicode keysym xor 0xf000 */
ksym = codetoksym(code);
if (ksym)
- result = ksymtocode(try_unicode, ksym, direction);
+ result = ksymtocode(kmap, ksym, direction);
else
result = code;
}
}
int
-add_capslock(int try_unicode, int code)
+add_capslock(struct keymap *kmap, int code)
{
- if (KTYP(code) == KT_LATIN && (!try_unicode || code < 0x80))
+ if (KTYP(code) == KT_LATIN && (!(kmap->prefer_unicode) || code < 0x80))
return K(KT_LETTER, KVAL(code));
else if ((code ^ 0xf000) < 0x100)
/* Unicode Latin-1 Supplement */
/* a bit dirty to use KT_LETTER here, but it should work */
return K(KT_LETTER, code ^ 0xf000);
else
- return convert_code(try_unicode, code, TO_AUTO);
+ return convert_code(kmap, code, TO_AUTO);
}
#ifndef KSYMS_H
#define KSYMS_H
+#include "loadkeys.keymap.h"
+
typedef struct {
unsigned short uni;
const char *name;
extern int set_charset(const char *name);
extern const char *codetoksym(int code);
extern void list_charsets(FILE *f);
-extern int ksymtocode(int try_unicode, const char *s, int direction);
-extern int convert_code(int try_unicode, int code, int direction);
-extern int add_capslock(int try_unicode, int code);
+extern int ksymtocode(struct keymap *kmap, const char *s, int direction);
+extern int convert_code(struct keymap *kmap, int code, int direction);
+extern int add_capslock(struct keymap *kmap, int code);
#endif
}
ptr = &(kmap->accent_table[kmap->accent_table_size++]);
- ptr->diacr = convert_code(kmap->prefer_unicode, diacr, direction);
- ptr->base = convert_code(kmap->prefer_unicode, base, direction);
- ptr->result = convert_code(kmap->prefer_unicode, res, direction);
+ ptr->diacr = convert_code(kmap, diacr, direction);
+ ptr->base = convert_code(kmap, base, direction);
+ ptr->result = convert_code(kmap, res, direction);
return 0;
}
kmap->key_buf[kmap->rvalct++] = $1;
}
;
-rvalue : NUMBER { $$ = convert_code(kmap->prefer_unicode, $1, TO_AUTO); }
- | PLUS NUMBER { $$ = add_capslock(kmap->prefer_unicode, $2); }
- | UNUMBER { $$ = convert_code(kmap->prefer_unicode, $1^0xf000, TO_AUTO); }
- | PLUS UNUMBER { $$ = add_capslock(kmap->prefer_unicode, $2^0xf000); }
+rvalue : NUMBER { $$ = convert_code(kmap, $1, TO_AUTO); }
+ | PLUS NUMBER { $$ = add_capslock(kmap, $2); }
+ | UNUMBER { $$ = convert_code(kmap, $1^0xf000, TO_AUTO); }
+ | PLUS UNUMBER { $$ = add_capslock(kmap, $2^0xf000); }
| LITERAL { $$ = $1; }
- | PLUS LITERAL { $$ = add_capslock(kmap->prefer_unicode, $2); }
+ | PLUS LITERAL { $$ = add_capslock(kmap, $2); }
;
%%