From 7f84a94b58112e4347cc1f4c932e2adf7eeab579 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 16 Jan 2005 19:20:30 +0000 Subject: [PATCH] *** empty log message *** --- doc/rxvt.1.pod | 69 +++++++++++++++++++++++++++--------- src/keyboard.C | 9 +++-- src/xdefaults.C | 107 ++++++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 141 insertions(+), 44 deletions(-) diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod index 8573362..7396ed2 100644 --- a/doc/rxvt.1.pod +++ b/doc/rxvt.1.pod @@ -112,7 +112,7 @@ B<-tr>; resource B. =item B<-fade> I -Fade the text by the given percentage when focus is lost. +Fade the text by the given percentage when focus is lost. resource B. =item B<-tint> I @@ -138,8 +138,8 @@ Window foreground colour; resource B. =item B<-pixmap> I Compile I: Specify XPM file for the background and also optionally -specify its scaling with a geometry string. Note you may need to add -quotes to avoid special shell interpretation of the `;' in the +specify its scaling with a geometry string. Note you may need to +add quotes to avoid special shell interpretation of the C<;> in the command-line; resource B. =item B<-cr> I @@ -282,8 +282,9 @@ decorations; resource B. =item B<-lsp> I -Compile I: Lines (pixel height) to insert between each row -of the display; resource B. +Compile I: Lines (pixel height) to insert between each row of +the display. Useful to work around font rendering problems; resource +B. =item B<-tn> I @@ -429,7 +430,7 @@ Colours 16-79 form a standard 4x4x4 colour cube (the same as xterm with Use the specified colour to display bold or italic characters when the foreground colour is the default. If font styles are not available -(Compile styles) and this option is unset, reverse video is used instead. +(Compile I) and this option is unset, reverse video is used instead. =item B I @@ -535,7 +536,7 @@ be smaller, but not larger. A reasonable default font list is always appended to it. option B<-fn>. Each font can either be a standard X11 core font (XLFD) name, with -optional prefix C or a Xft font (Compile xft), prefixed with C. +optional prefix C or a Xft font (Compile I), prefixed with C. In addition, each font can be prefixed with additional hints and specifications enclosed in square brackets (C<[]>). The only available @@ -819,14 +820,50 @@ instead scroll the screen up. =item BI: I -Associate I with keysym I (B<0xFF00 - 0xFFFF>). It may -contain escape values (\a: bell, \b: backspace, \e, \E: escape, \n: -newline, \r: return, \t: -tab, \000: octal number) or control characters (^?: delete, ^@: null, -^A ...) and may enclosed with double quotes so that it can start or end -with whitespace. The intervening resource name B cannot be -omitted. This resource is only available when compiled with -KEYSYM_RESOURCE. +Compile I: Associate I with keysym I. The +intervening resource name B cannot be omitted. + +The format of I is "I<(modifiers-)key>", where I can be +any combination of B, B, B, B, +B, B, B, B, B, B, B, B, +and the abbreviated B, B, B, B, B, B, B, B, B<1>, +B<2>, B<3>, B<4>, B<5>. + +The B, B and B modifiers are usually aliased to +whatever modifier the NumLock key, Meta/Alt keys or ISO Level3 Shift/AltGr +keys are being mapped. B is a artificial modifier mapped to the +current application keymap mode state. + +The spellings of I can be obtained by using B(1) command or +searching keysym macros from B and +omitting the prefix B. Alternatively you can specify I by its hex +keysym value (B<0x0000 - 0xFFFF>). Note that the lookup of Is is not +performed in an exact manner; however, the closest match is assured. + +I may contain escape values (C<\a>: bell, C<\b>: backspace, +C<\e>, C<\E>: escape, C<\n>: newline, C<\r>: carriage return, C<\t>: tab, +C<\000>: octal number) or verbatim control characters (C<^?>: delete, +C<^@>: null, C<^A> ...) and may be enclosed with double quotes so that it +can start or end with whitespace. + +You can define a range of keysyms in one shot by providing a I +with pattern B, where the delimeter `/' +should be a character not used by the strings. + +Its usage can be demonstrated by an example: + + URxvt.keysym.M-C-0x61: list|\e + +The above line is equivalent to the following three lines: + + URxvt.keysym.Meta-Control-0x61: \e + URxvt.keysym.Meta-Control-0x62: \e + URxvt.keysym.Meta-Control-0x63: \e + +If I takes the form of C, the specified B is +interpreted and executed as @@RXVT_NAME@@'s control sequence. For example, +C means: change the current locale to +C. =back @@ -870,7 +907,7 @@ double-click to select a word; Left triple-click to select the entire line. Starting a selection while pressing the B key (or B keys) -(Compile: frills) will create a rectangular selection instead of a normal +(Compile: I) will create a rectangular selection instead of a normal one. =item B: diff --git a/src/keyboard.C b/src/keyboard.C index 49a8bbd..45bf19d 100644 --- a/src/keyboard.C +++ b/src/keyboard.C @@ -238,11 +238,9 @@ keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state) { assert (hash[0] == 0 && "register_done() need to be called"); - if (state & term->ModMetaMask) - state |= MetaMask; - - if (state & term->ModNumLockMask) - state |= NumLockMask; + if (state & term->ModMetaMask) state |= MetaMask; + if (state & term->ModNumLockMask) state |= NumLockMask; + if (state & term->ModLevel3Mask) state |= Level3Mask; if (!!(term->priv_modes & PrivMode_aplKP) != !!(state & ShiftMask)) state |= AppKeypadMask; @@ -437,6 +435,7 @@ keyboard_manager::setup_hash () for (int j = 0; j < a->range; ++j) { int index = find_keysym (a->keysym + j, a->state & OtherModMask); + assert (index >= 0); keysym_t *b = keymap [index]; assert (i == (signed) index || // the normally expected result diff --git a/src/xdefaults.C b/src/xdefaults.C index 52737e6..bbfc6e7 100644 --- a/src/xdefaults.C +++ b/src/xdefaults.C @@ -31,6 +31,10 @@ #include "rxvt.h" /* NECESSARY */ #include "version.h" +#ifdef KEYSYM_RESOURCE +#include "keyboard.h" +#endif + /* #define DEBUG_RESOURCES */ static const char *const xnames[2] = { ".Xdefaults", ".Xresources" }; @@ -218,8 +222,6 @@ optList[] = { STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, "borderless window"), -#endif -#ifndef NO_LINESPACE STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"), #endif STRG (Rs_scrollBar_thickness, "thickness", "sbt", "number", "scrollbar thickness/width in pixels"), @@ -360,9 +362,6 @@ static const char optionsstring[] = "options: " #if defined(ENABLE_FRILLS) "frills," #endif -#if !defined(NO_LINESPACE) - "linespace," -#endif #if defined(PREFER_24BIT) "24bit," #endif @@ -627,24 +626,93 @@ rxvt_define_key (XrmDatabase *database __attribute__((unused)), * non-NULL for command-line options (need to allocate) */ #define NEWARGLIM 500 /* `reasonable' size */ + +struct keysym_vocabulary_t +{ + const char *name; + unsigned short len; + unsigned short value; +}; +keysym_vocabulary_t keysym_vocabulary[] = +{ + { "ISOLevel3", 9, Level3Mask }, + { "AppKeypad", 9, AppKeypadMask }, + { "Control", 7, ControlMask }, + { "NumLock", 7, NumLockMask }, + { "Shift", 5, ShiftMask }, + { "Meta", 4, MetaMask }, + { "Lock", 4, LockMask }, + { "Mod1", 4, Mod1Mask }, + { "Mod2", 4, Mod2Mask }, + { "Mod3", 4, Mod3Mask }, + { "Mod4", 4, Mod4Mask }, + { "Mod5", 4, Mod5Mask }, + { "I", 1, Level3Mask }, + { "K", 1, AppKeypadMask }, + { "C", 1, ControlMask }, + { "N", 1, NumLockMask }, + { "S", 1, ShiftMask }, + { "M", 1, MetaMask }, + { "A", 1, MetaMask }, + { "L", 1, LockMask }, + { "1", 1, Mod1Mask }, + { "2", 1, Mod2Mask }, + { "3", 1, Mod3Mask }, + { "4", 1, Mod4Mask }, + { "5", 1, Mod5Mask }, +}; + int rxvt_term::parse_keysym (const char *str, const char *arg) { - int n, sym; - char *key_string, *newarg = NULL; - char newargstr[NEWARGLIM]; + int n, sym; + unsigned int state = 0; + const char *pmodend = NULL; + char *newarg = NULL; + char newargstr[NEWARGLIM]; if (arg == NULL) { if ((n = rxvt_Str_match (str, "keysym.")) == 0) return 0; + str += n; /* skip `keysym.' */ + if ((pmodend = strchr (str, ':')) < str) + return -1; } + else + pmodend = str + strlen(str); + + for (--pmodend; str < pmodend; --pmodend) + if (*pmodend == '-') + break; + + while (str < pmodend) + { + unsigned int i; + + for (i=0; i < sizeof (keysym_vocabulary) / sizeof (keysym_vocabulary_t); ++i) + { + if (strncmp (str, keysym_vocabulary [i].name, keysym_vocabulary [i].len) == 0) + { + state |= keysym_vocabulary[i].value; + str += keysym_vocabulary[i].len; + break; + } + } + + if (i >= sizeof (keysym_vocabulary) / sizeof (keysym_vocabulary_t)) + return -1; + + if (*str == '-') + ++str; + } + /* some scanf () have trouble with a 0x prefix */ - if (isdigit (str[0])) + if (str[0] == '0' && toupper (str[1]) == 'X') { - if (str[0] == '0' && toupper (str[1]) == 'X') - str += 2; + str += 2; + if (arg) { if (sscanf (str, (strchr (str, ':') ? "%x:" : "%x"), &sym) != 1) @@ -668,38 +736,31 @@ rxvt_term::parse_keysym (const char *str, const char *arg) */ strncpy (newargstr, str, NEWARGLIM - 1); newargstr[NEWARGLIM - 1] = '\0'; + if (arg == NULL) { if ((newarg = strchr (newargstr, ':')) == NULL) return -1; + *newarg++ = '\0'; /* terminate keysym name */ } + if ((sym = XStringToKeysym (newargstr)) == None) return -1; } - if (sym < 0xFF00 || sym > 0xFFFF) /* we only do extended keys */ - return -1; - sym &= 0xFF; - if (Keysym_map[sym] != NULL) /* already set ? */ - return -1; - if (newarg == NULL) { strncpy (newargstr, arg, NEWARGLIM - 1); newargstr[NEWARGLIM - 1] = '\0'; newarg = newargstr; } + rxvt_Str_trim (newarg); if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0) return -1; - MIN_IT (n, 255); - key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char)); - - key_string[0] = n; - strncpy (key_string + 1, newarg, n); - Keysym_map[sym] = (unsigned char *)key_string; + keyboard->register_user_translation (sym, state, newarg); return 1; } -- 1.9.1