1 .\" $tcsh: eight-bit.me,v 3.2 2006/03/02 18:46:44 christos Exp $
2 How to use 8 bit characters
11 (Disclaimer: This is really a sketch of an approach rather
12 than a "how-to" document.
13 Also, it is mostly relevant to Swedish X Window users...)
16 The way I use this facility at present is to add lines such as the following
21 setenv LC_CTYPE iso_8859_1
22 foreach key ( \\\\304 \\\\305 \\\\326 \\\\344 \\\\345 \\\\366 )
23 bindkey $key self-insert-command
28 Note that if I used a system with a reasonably complete NLS
29 (and a tcsh compiled to use it),
30 all of the above could be replaced with simply setting the LANG environment
31 variable to an appropriate value - the NLS would then indicate exactly which
32 characters should be considered printable, and tcsh would do the rebinding
33 of these automatically. The above works for tcsh's simulated NLS and for
34 the NLS in SunOS 4.1 - without the NOREBIND setting, all of the
35 Meta-<non-control-character> bindings would be undone in these cases.
38 These keybindings are the codes for my national characters, but the bindings
39 (M-d, M-e etc) are not conveniently placed.
40 They are however consistent with what other programs will see.
43 Now: I actually want the character \\304 to be inserted when I press say '{'
44 together with a modifier key. I want the behavior to be the same not only
45 in tcsh but in say cat, an editor and all other programs. I fix this by
46 performing a keyboard remapping with the
48 program (I use X Windows).
51 I give xmodmap an input something like the following:
54 keycode 26 = Mode_switch
55 add mod2 = Mode_switch
56 ! if you want Mode_switch to toggle, at the expense of losing
57 ! Caps- or whatever Lock you currently have, add the two lines below
59 ! add Lock = Mode_switch
60 ! Binds swedish characters on ][\\
62 keycode 71 = bracketleft braceleft adiaeresis Adiaeresis
63 keycode 72 = bracketright braceright aring Aring
64 keycode 95 = backslash bar odiaeresis Odiaeresis
70 keysym Alt_R = Mode_switch
71 add mod2 = Mode_switch
72 keysym bracketleft = bracketleft braceleft Adiaeresis adiaeresis
73 keysym bracketright = bracketright braceright Aring aring
74 keysym backslash = backslash bar Odiaeresis odiaeresis
77 Another, more portable way of doing the same thing is:
81 # Make Alt-] etc produce the "appropriate" Swedish iso8859/1 keysym values
82 # Should handle fairly strange initial mappings
84 xmodmap -pk | sed -e 's/[()]//g' | \\
86 alt["bracketright"] = "Aring"; alt["braceright"] = "aring";
87 alt["bracketleft"] = "Adiaeresis"; alt["braceleft"] = "adiaeresis";
88 alt["backslash"] = "Odiaeresis"; alt["bar"] = "odiaeresis";
90 NF >= 5 && (alt[$3] != "" || alt[$5] != "") {
91 printf "keycode %s = %s %s ", $1, $3, $5;
92 if (alt[$3] != "") printf "%s ", alt[$3];
93 else printf "%s ", $3;
94 printf "%s\\n", alt[$5];
98 printf "keycode %s = %s %s %s\\n", $1, $3, $3, alt[$3];
100 NF >= 5 && ($3 ~ /^Alt_[LR]$/ || $5 ~ /^Alt_[LR]$/) {
101 printf "keycode %s = %s %s Mode_switch\\n", $1, $3, $5;
102 if ($3 ~ /^Alt_[LR]$/) altkeys = altkeys " " $3;
103 else altkeys = altkeys " " $5;
107 printf "keycode %s = %s %s Mode_switch\\n", $1, $3, $3;
108 altkeys = altkeys " " $3;
111 if (altkeys != "") printf "clear mod2\\nadd mod2 =%s\\n", altkeys;
116 Finally, with the binding of the codes of my national characters to
117 self-insert-command, I lost the ability to use the Meta key to call the
118 functions previously bound to M-d, M-e, and M-v (<esc>d etc still works).
119 However, with the assumption that
120 most of my input to tcsh will be through the
122 terminal emulator, I can get that ability back via xterm bindings!
123 Since M-d is the only one of the "lost" key combinations that was
124 actually bound to a function in my case,
125 and it had the same binding as M-D, I can use the following in
129 XTerm*VT100.Translations: #override \\n\\
130 Meta ~Ctrl<Key>d: string(0x1b) string(d)
133 - or, if I really want a complete mapping:
136 XTerm*VT100.Translations: #override \\n\\
137 :Meta ~Ctrl<Key>d: string(0x1b) string(d) \\n\\
138 :Meta ~Ctrl<Key>D: string(0x1b) string(D) \\n\\
139 :Meta ~Ctrl<Key>e: string(0x1b) string(e) \\n\\
140 :Meta ~Ctrl<Key>E: string(0x1b) string(E) \\n\\
141 :Meta ~Ctrl<Key>v: string(0x1b) string(v) \\n\\
142 :Meta ~Ctrl<Key>V: string(0x1b) string(V)