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