xref: /freebsd/contrib/tcsh/eight-bit.me (revision 9122aeeaa60ee2a1381ea935d749194b32940e7a)
1c80476e4SDavid E. O'BrienHow to use 8 bit characters
2c80476e4SDavid E. O'Brienby
3c80476e4SDavid E. O'BrienJohan Widen
4c80476e4SDavid E. O'Brien(jw@sics.se)
5c80476e4SDavid E. O'Brienand
6c80476e4SDavid E. O'BrienPer Hedeland
7c80476e4SDavid E. O'Brien(per@erix.ericsson.se)
8c80476e4SDavid E. O'Brien
9c80476e4SDavid E. O'Brien.pp
10c80476e4SDavid E. O'Brien(Disclaimer: This is really a sketch of an approach rather
11c80476e4SDavid E. O'Brienthan a "how-to" document.
12c80476e4SDavid E. O'BrienAlso, it is mostly relevant to Swedish X Window users...)
13c80476e4SDavid E. O'Brien
14c80476e4SDavid E. O'Brien.pp
15c80476e4SDavid E. O'BrienThe way I use this facility at present is to add lines such as the following
16c80476e4SDavid E. O'Briento my .cshrc:
17c80476e4SDavid E. O'Brien
18c80476e4SDavid E. O'Brien.nf
19c80476e4SDavid E. O'Briensetenv NOREBIND
20c80476e4SDavid E. O'Briensetenv LC_CTYPE iso_8859_1
21c80476e4SDavid E. O'Brienforeach key ( \\\\304 \\\\305 \\\\326 \\\\344 \\\\345 \\\\366 )
22c80476e4SDavid E. O'Brien   bindkey $key self-insert-command
23c80476e4SDavid E. O'Brienend
24c80476e4SDavid E. O'Brien.fi
25c80476e4SDavid E. O'Brien
26c80476e4SDavid E. O'Brien.pp
27c80476e4SDavid E. O'BrienNote that if I used a system with a reasonably complete NLS
28c80476e4SDavid E. O'Brien(and a tcsh compiled to use it),
29c80476e4SDavid E. O'Brienall of the above could be replaced with simply setting the LANG environment
30c80476e4SDavid E. O'Brienvariable to an appropriate value - the NLS would then indicate exactly which
31c80476e4SDavid E. O'Briencharacters should be considered printable, and tcsh would do the rebinding
32c80476e4SDavid E. O'Brienof these automatically. The above works for tcsh's simulated NLS and for
33c80476e4SDavid E. O'Brienthe NLS in SunOS 4.1 - without the NOREBIND setting, all of the
34c80476e4SDavid E. O'BrienMeta-<non-control-character> bindings would be undone in these cases.
35c80476e4SDavid E. O'Brien
36c80476e4SDavid E. O'Brien.pp
37c80476e4SDavid E. O'BrienThese keybindings are the codes for my national characters, but the bindings
38c80476e4SDavid E. O'Brien(M-d, M-e etc) are not conveniently placed.
39c80476e4SDavid E. O'BrienThey are however consistent with what other programs will see.
40c80476e4SDavid E. O'Brien
41c80476e4SDavid E. O'Brien.pp
42c80476e4SDavid E. O'BrienNow: I actually want the character \\304 to be inserted when I press say '{'
43c80476e4SDavid E. O'Brientogether with a modifier key. I want the behavior to be the same not only
44c80476e4SDavid E. O'Brienin tcsh but in say cat, an editor and all other programs. I fix this by
45c80476e4SDavid E. O'Brienperforming a keyboard remapping with the
46c80476e4SDavid E. O'Brien.i xmodmap
47c80476e4SDavid E. O'Brienprogram (I use X Windows).
48c80476e4SDavid E. O'Brien
49c80476e4SDavid E. O'Brien.pp
50c80476e4SDavid E. O'BrienI give xmodmap an input something like the following:
51c80476e4SDavid E. O'Brien
52c80476e4SDavid E. O'Brien.nf
53c80476e4SDavid E. O'Brienkeycode 26 = Mode_switch
54c80476e4SDavid E. O'Brienadd mod2 = Mode_switch
55c80476e4SDavid E. O'Brien! if you want Mode_switch to toggle, at the expense of losing
56c80476e4SDavid E. O'Brien! Caps- or whatever Lock you currently have, add the two lines below
57c80476e4SDavid E. O'Brien! clear Lock
58c80476e4SDavid E. O'Brien! add Lock = Mode_switch
59c80476e4SDavid E. O'Brien! 	Binds swedish characters on ][\\
60c80476e4SDavid E. O'Brien!
61c80476e4SDavid E. O'Brienkeycode 71 = bracketleft braceleft adiaeresis Adiaeresis
62c80476e4SDavid E. O'Brienkeycode 72 = bracketright braceright aring Aring
63c80476e4SDavid E. O'Brienkeycode 95 = backslash bar odiaeresis Odiaeresis
64c80476e4SDavid E. O'Brien.fi
65c80476e4SDavid E. O'Brien
66c80476e4SDavid E. O'Brienor:
67c80476e4SDavid E. O'Brien
68c80476e4SDavid E. O'Brien.nf
69c80476e4SDavid E. O'Brienkeysym Alt_R = Mode_switch
70c80476e4SDavid E. O'Brienadd mod2 = Mode_switch
71c80476e4SDavid E. O'Brienkeysym bracketleft = bracketleft braceleft Adiaeresis adiaeresis
72c80476e4SDavid E. O'Brienkeysym bracketright = bracketright braceright Aring aring
73c80476e4SDavid E. O'Brienkeysym backslash = backslash bar Odiaeresis odiaeresis
74c80476e4SDavid E. O'Brien.fi
75c80476e4SDavid E. O'Brien
76c80476e4SDavid E. O'BrienAnother, more portable way of doing the same thing is:
77c80476e4SDavid E. O'Brien
78c80476e4SDavid E. O'Brien.nf
79c80476e4SDavid E. O'Brien#!/bin/sh
80c80476e4SDavid E. O'Brien# Make Alt-] etc produce the "appropriate" Swedish iso8859/1 keysym values
81c80476e4SDavid E. O'Brien# Should handle fairly strange initial mappings
82c80476e4SDavid E. O'Brien
83c80476e4SDavid E. O'Brienxmodmap -pk | sed -e 's/[()]//g' | \\
84c80476e4SDavid E. O'Brienawk 'BEGIN {
85c80476e4SDavid E. O'Brien	alt["bracketright"] = "Aring"; alt["braceright"] = "aring";
86c80476e4SDavid E. O'Brien	alt["bracketleft"] = "Adiaeresis"; alt["braceleft"] = "adiaeresis";
87c80476e4SDavid E. O'Brien	alt["backslash"] = "Odiaeresis"; alt["bar"] = "odiaeresis";
88c80476e4SDavid E. O'Brien}
89c80476e4SDavid E. O'BrienNF >= 5 && (alt[$3] != "" || alt[$5] != "") {
90c80476e4SDavid E. O'Brien	printf "keycode %s = %s %s ", $1, $3, $5;
91c80476e4SDavid E. O'Brien	if (alt[$3] != "") printf "%s ", alt[$3];
92c80476e4SDavid E. O'Brien	else printf "%s ", $3;
93c80476e4SDavid E. O'Brien	printf "%s\\n", alt[$5];
94c80476e4SDavid E. O'Brien	next;
95c80476e4SDavid E. O'Brien}
96c80476e4SDavid E. O'Brienalt[$3] != "" {
97c80476e4SDavid E. O'Brien	printf "keycode %s = %s %s %s\\n", $1, $3, $3, alt[$3];
98c80476e4SDavid E. O'Brien}
99c80476e4SDavid E. O'BrienNF >= 5 && ($3 ~ /^Alt_[LR]$/ || $5 ~ /^Alt_[LR]$/) {
100c80476e4SDavid E. O'Brien	printf "keycode %s = %s %s Mode_switch\\n", $1, $3, $5;
101c80476e4SDavid E. O'Brien	if ($3 ~ /^Alt_[LR]$/) altkeys = altkeys " " $3;
102c80476e4SDavid E. O'Brien	else altkeys = altkeys " " $5;
103c80476e4SDavid E. O'Brien	next;
104c80476e4SDavid E. O'Brien}
105c80476e4SDavid E. O'Brien$3 ~ /^Alt_[LR]$/ {
106c80476e4SDavid E. O'Brien	printf "keycode %s = %s %s Mode_switch\\n", $1, $3, $3;
107c80476e4SDavid E. O'Brien	altkeys = altkeys " " $3;
108c80476e4SDavid E. O'Brien}
109c80476e4SDavid E. O'BrienEND {
110c80476e4SDavid E. O'Brien	if (altkeys != "") printf "clear mod2\\nadd mod2 =%s\\n", altkeys;
111c80476e4SDavid E. O'Brien}' | xmodmap -
112c80476e4SDavid E. O'Brien.fi
113c80476e4SDavid E. O'Brien
114c80476e4SDavid E. O'Brien.pp
115c80476e4SDavid E. O'BrienFinally, with the binding of the codes of my national characters to
116c80476e4SDavid E. O'Brienself-insert-command, I lost the ability to use the Meta key to call the
117c80476e4SDavid E. O'Brienfunctions previously bound to M-d, M-e, and M-v (<esc>d etc still works).
118c80476e4SDavid E. O'BrienHowever, with the assumption that
119c80476e4SDavid E. O'Brienmost of my input to tcsh will be through the
120c80476e4SDavid E. O'Brien.i xterm
121c80476e4SDavid E. O'Brienterminal emulator, I can get that ability back via xterm bindings!
122c80476e4SDavid E. O'BrienSince M-d is the only one of the "lost" key combinations that was
123c80476e4SDavid E. O'Brienactually bound to a function in my case,
124c80476e4SDavid E. O'Brienand it had the same binding as M-D, I can use the following in
125c80476e4SDavid E. O'Brienmy .Xdefaults file:
126c80476e4SDavid E. O'Brien
127c80476e4SDavid E. O'Brien.nf
128c80476e4SDavid E. O'BrienXTerm*VT100.Translations:	#override \\n\\
129c80476e4SDavid E. O'Brien			Meta ~Ctrl<Key>d:	string(0x1b) string(d)
130c80476e4SDavid E. O'Brien.fi
131c80476e4SDavid E. O'Brien
132c80476e4SDavid E. O'Brien- or, if I really want a complete mapping:
133c80476e4SDavid E. O'Brien
134c80476e4SDavid E. O'Brien.nf
135c80476e4SDavid E. O'BrienXTerm*VT100.Translations:	#override \\n\\
136c80476e4SDavid E. O'Brien			:Meta ~Ctrl<Key>d:	string(0x1b) string(d) \\n\\
137c80476e4SDavid E. O'Brien			:Meta ~Ctrl<Key>D:	string(0x1b) string(D) \\n\\
138c80476e4SDavid E. O'Brien			:Meta ~Ctrl<Key>e:	string(0x1b) string(e) \\n\\
139c80476e4SDavid E. O'Brien			:Meta ~Ctrl<Key>E:	string(0x1b) string(E) \\n\\
140c80476e4SDavid E. O'Brien			:Meta ~Ctrl<Key>v:	string(0x1b) string(v) \\n\\
141c80476e4SDavid E. O'Brien			:Meta ~Ctrl<Key>V:	string(0x1b) string(V)
142c80476e4SDavid E. O'Brien.fi
143