159243SobrienHow to use 8 bit characters 259243Sobrienby 359243SobrienJohan Widen 459243Sobrien(jw@sics.se) 559243Sobrienand 659243SobrienPer Hedeland 759243Sobrien(per@erix.ericsson.se) 859243Sobrien 959243Sobrien.pp 1059243Sobrien(Disclaimer: This is really a sketch of an approach rather 1159243Sobrienthan a "how-to" document. 1259243SobrienAlso, it is mostly relevant to Swedish X Window users...) 1359243Sobrien 1459243Sobrien.pp 1559243SobrienThe way I use this facility at present is to add lines such as the following 1659243Sobriento my .cshrc: 1759243Sobrien 1859243Sobrien.nf 1959243Sobriensetenv NOREBIND 2059243Sobriensetenv LC_CTYPE iso_8859_1 2159243Sobrienforeach key ( \\\\304 \\\\305 \\\\326 \\\\344 \\\\345 \\\\366 ) 2259243Sobrien bindkey $key self-insert-command 2359243Sobrienend 2459243Sobrien.fi 2559243Sobrien 2659243Sobrien.pp 2759243SobrienNote that if I used a system with a reasonably complete NLS 2859243Sobrien(and a tcsh compiled to use it), 2959243Sobrienall of the above could be replaced with simply setting the LANG environment 3059243Sobrienvariable to an appropriate value - the NLS would then indicate exactly which 3159243Sobriencharacters should be considered printable, and tcsh would do the rebinding 3259243Sobrienof these automatically. The above works for tcsh's simulated NLS and for 3359243Sobrienthe NLS in SunOS 4.1 - without the NOREBIND setting, all of the 3459243SobrienMeta-<non-control-character> bindings would be undone in these cases. 3559243Sobrien 3659243Sobrien.pp 3759243SobrienThese keybindings are the codes for my national characters, but the bindings 3859243Sobrien(M-d, M-e etc) are not conveniently placed. 3959243SobrienThey are however consistent with what other programs will see. 4059243Sobrien 4159243Sobrien.pp 4259243SobrienNow: I actually want the character \\304 to be inserted when I press say '{' 4359243Sobrientogether with a modifier key. I want the behavior to be the same not only 4459243Sobrienin tcsh but in say cat, an editor and all other programs. I fix this by 4559243Sobrienperforming a keyboard remapping with the 4659243Sobrien.i xmodmap 4759243Sobrienprogram (I use X Windows). 4859243Sobrien 4959243Sobrien.pp 5059243SobrienI give xmodmap an input something like the following: 5159243Sobrien 5259243Sobrien.nf 5359243Sobrienkeycode 26 = Mode_switch 5459243Sobrienadd mod2 = Mode_switch 5559243Sobrien! if you want Mode_switch to toggle, at the expense of losing 5659243Sobrien! Caps- or whatever Lock you currently have, add the two lines below 5759243Sobrien! clear Lock 5859243Sobrien! add Lock = Mode_switch 5959243Sobrien! Binds swedish characters on ][\\ 6059243Sobrien! 6159243Sobrienkeycode 71 = bracketleft braceleft adiaeresis Adiaeresis 6259243Sobrienkeycode 72 = bracketright braceright aring Aring 6359243Sobrienkeycode 95 = backslash bar odiaeresis Odiaeresis 6459243Sobrien.fi 6559243Sobrien 6659243Sobrienor: 6759243Sobrien 6859243Sobrien.nf 6959243Sobrienkeysym Alt_R = Mode_switch 7059243Sobrienadd mod2 = Mode_switch 7159243Sobrienkeysym bracketleft = bracketleft braceleft Adiaeresis adiaeresis 7259243Sobrienkeysym bracketright = bracketright braceright Aring aring 7359243Sobrienkeysym backslash = backslash bar Odiaeresis odiaeresis 7459243Sobrien.fi 7559243Sobrien 7659243SobrienAnother, more portable way of doing the same thing is: 7759243Sobrien 7859243Sobrien.nf 7959243Sobrien#!/bin/sh 8059243Sobrien# Make Alt-] etc produce the "appropriate" Swedish iso8859/1 keysym values 8159243Sobrien# Should handle fairly strange initial mappings 8259243Sobrien 8359243Sobrienxmodmap -pk | sed -e 's/[()]//g' | \\ 8459243Sobrienawk 'BEGIN { 8559243Sobrien alt["bracketright"] = "Aring"; alt["braceright"] = "aring"; 8659243Sobrien alt["bracketleft"] = "Adiaeresis"; alt["braceleft"] = "adiaeresis"; 8759243Sobrien alt["backslash"] = "Odiaeresis"; alt["bar"] = "odiaeresis"; 8859243Sobrien} 8959243SobrienNF >= 5 && (alt[$3] != "" || alt[$5] != "") { 9059243Sobrien printf "keycode %s = %s %s ", $1, $3, $5; 9159243Sobrien if (alt[$3] != "") printf "%s ", alt[$3]; 9259243Sobrien else printf "%s ", $3; 9359243Sobrien printf "%s\\n", alt[$5]; 9459243Sobrien next; 9559243Sobrien} 9659243Sobrienalt[$3] != "" { 9759243Sobrien printf "keycode %s = %s %s %s\\n", $1, $3, $3, alt[$3]; 9859243Sobrien} 9959243SobrienNF >= 5 && ($3 ~ /^Alt_[LR]$/ || $5 ~ /^Alt_[LR]$/) { 10059243Sobrien printf "keycode %s = %s %s Mode_switch\\n", $1, $3, $5; 10159243Sobrien if ($3 ~ /^Alt_[LR]$/) altkeys = altkeys " " $3; 10259243Sobrien else altkeys = altkeys " " $5; 10359243Sobrien next; 10459243Sobrien} 10559243Sobrien$3 ~ /^Alt_[LR]$/ { 10659243Sobrien printf "keycode %s = %s %s Mode_switch\\n", $1, $3, $3; 10759243Sobrien altkeys = altkeys " " $3; 10859243Sobrien} 10959243SobrienEND { 11059243Sobrien if (altkeys != "") printf "clear mod2\\nadd mod2 =%s\\n", altkeys; 11159243Sobrien}' | xmodmap - 11259243Sobrien.fi 11359243Sobrien 11459243Sobrien.pp 11559243SobrienFinally, with the binding of the codes of my national characters to 11659243Sobrienself-insert-command, I lost the ability to use the Meta key to call the 11759243Sobrienfunctions previously bound to M-d, M-e, and M-v (<esc>d etc still works). 11859243SobrienHowever, with the assumption that 11959243Sobrienmost of my input to tcsh will be through the 12059243Sobrien.i xterm 12159243Sobrienterminal emulator, I can get that ability back via xterm bindings! 12259243SobrienSince M-d is the only one of the "lost" key combinations that was 12359243Sobrienactually bound to a function in my case, 12459243Sobrienand it had the same binding as M-D, I can use the following in 12559243Sobrienmy .Xdefaults file: 12659243Sobrien 12759243Sobrien.nf 12859243SobrienXTerm*VT100.Translations: #override \\n\\ 12959243Sobrien Meta ~Ctrl<Key>d: string(0x1b) string(d) 13059243Sobrien.fi 13159243Sobrien 13259243Sobrien- or, if I really want a complete mapping: 13359243Sobrien 13459243Sobrien.nf 13559243SobrienXTerm*VT100.Translations: #override \\n\\ 13659243Sobrien :Meta ~Ctrl<Key>d: string(0x1b) string(d) \\n\\ 13759243Sobrien :Meta ~Ctrl<Key>D: string(0x1b) string(D) \\n\\ 13859243Sobrien :Meta ~Ctrl<Key>e: string(0x1b) string(e) \\n\\ 13959243Sobrien :Meta ~Ctrl<Key>E: string(0x1b) string(E) \\n\\ 14059243Sobrien :Meta ~Ctrl<Key>v: string(0x1b) string(v) \\n\\ 14159243Sobrien :Meta ~Ctrl<Key>V: string(0x1b) string(V) 14259243Sobrien.fi 143