Merge from emacs--rel--22
[bpt/emacs.git] / lisp / term / internal.el
CommitLineData
0a10297a 1;;; internal.el --- support for PC internal terminal -*- coding: raw-text; no-byte-compile: t -*-
c8b836f6 2
5fd6d89f 3;; Copyright (C) 1993, 1994, 1998, 1999, 2001, 2002, 2003, 2004,
12dc447f 4;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
c8b836f6
RS
5
6;; Author: Morten Welinder <terra@diku.dk>
c8b836f6
RS
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
5a9dffec 12;; the Free Software Foundation; either version 3, or (at your option)
c8b836f6
RS
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
2fe590dc 21;; along with GNU Emacs; see the file COPYING. If not, write to the
4fc5845f
LK
22;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23;; Boston, MA 02110-1301, USA.
2fe590dc 24
e8af40ee
PJ
25;;; Commentary:
26
2fe590dc
EN
27;;; Code:
28
c8b836f6
RS
29;; ---------------------------------------------------------------------------
30;; keyboard setup -- that's simple!
31(set-input-mode nil nil 0)
c40bb1ba
KL
32(define-key local-function-key-map [backspace] "\177") ; Normal behaviour for BS
33(define-key local-function-key-map [delete] "\C-d") ; ... and Delete
34(define-key local-function-key-map [tab] [?\t])
35(define-key local-function-key-map [linefeed] [?\n])
36(define-key local-function-key-map [clear] [11])
37(define-key local-function-key-map [return] [13])
38(define-key local-function-key-map [escape] [?\e])
39(define-key local-function-key-map [M-backspace] [?\M-\d])
40(define-key local-function-key-map [M-delete] [?\M-d])
41(define-key local-function-key-map [M-tab] [?\M-\t])
42(define-key local-function-key-map [M-linefeed] [?\M-\n])
43(define-key local-function-key-map [M-clear] [?\M-\013])
44(define-key local-function-key-map [M-return] [?\M-\015])
45(define-key local-function-key-map [M-escape] [?\M-\e]))
c8b836f6
RS
46(put 'backspace 'ascii-character 127)
47(put 'delete 'ascii-character 127)
48(put 'tab 'ascii-character ?\t)
49(put 'linefeed 'ascii-character ?\n)
50(put 'clear 'ascii-character 12)
51(put 'return 'ascii-character 13)
52(put 'escape 'ascii-character ?\e)
0064ab85
EZ
53
54;; ----------------------------------------------------------------------
55;; DOS display setup
56;; =================
57;;
58;; DOS can only support a single font. On most systems (with the
59;; possible exception of Far Eastern DOS versions), this means that
60;; two character sets are available at any given time: the ASCII
61;; charset, and a single national charset, usually mapped to codes
62;; above 128 (i.e., with 8th bit set). Which national charset is
63;; supported depends on the codepage loaded by the system when it
64;; boots; usually, this codepage cannot be changed without
65;; rebooting.
66;;
67;; Since each codepage can usually display character of a single
68;; MULE charset, Emacs can display a single MULE charset with the
69;; glyphs of the current codepage. The mapping from DOS codepages
70;; to MULE charsets is established by the charset property of the
71;; cpNNN-decode-table variables in codepage.el, which also
72;; defines translation tables for each such pair, and a bunch of
73;; functions to generate coding systems that use those translation
74;; tables to convert codepage-encoded text to the appropriate MULE
75;; charset and back. When Emacs starts on DOS, it automatically
76;; sets its default coding systems for file I/O and terminal output
77;; according to the currend DOS codepage, given by the
78;; `dos-codepage' variable.
79;;
80;; This leaves us with the problem of displaying character sets
81;; other than the one which maps directly into the current codepage.
82;; The following functions and variables handle this nuisance by
83;; defining a display table where each character that doesn't have a
84;; glyph in some codepage is mapped to a string which represents it.
85;; For example, a small c with cedilla is mapped to the string
86;; "{,c}" (the braces serve as a sign that this is a single
87;; character). A nice feature of the display tables is that Emacs
88;; knows that the string represents a single character, and thus
89;; cursor motion works as you'd expect: a single `C-f' moves past
90;; the entire string which represents a single character.
91;; ----------------------------------------------------------------------
92
93(defvar IT-character-translations
94 '(
95 (latin-iso8859-1
96 . [255 "!I" "|c" "Pd" "$$" "Ye" "|" "SE" "\"" "(c)"
97 "_a" "<<" "~" "--" "(R)" "'-" "^o" "+-" "^2" "^3"
98 "'" "u" ".P" "^." "'," "^1" "_o" ">>" "1/4" "1/2"
99 "3/4" "?I" "`A" "A'" "A^" "~A" "\"A" "Ao" "AE" ",C"
f3a3ea9a 100 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" "-D" "~N"
0064ab85 101 "`O" "O'" "O^" "~O" "\"O" "*x" "/O" "`U" "U'" "U^"
f3a3ea9a 102 "\"U" "Y'" "-P" "ss" "`a" "a'" "a^" "~a" "\"a" "ao"
0064ab85 103 "ae" ",c" "`e" "e'" "e^" "\"e" "`i" "i'" "i^" "\"i"
f3a3ea9a
EZ
104 "-d" "~n" "`o" "o'" "o^" "~o" "\"o" "-:" "/o" "`u"
105 "u'" "u^" "\"u" "y'" "-p" "\"y"]
0064ab85
EZ
106 )
107 (latin-iso8859-2
108 . [255 "A;" "'(" "/L" "$$" "L<" "S'" "SE" "\"" "S<"
109 ",S" "T<" "Z'" "--" "Z<" "Z^." "^o" "a;" "';" "/l"
110 "'" "l<" "s'" "'<" "'," "s<" ",s" "t<" "z'" "'"
111 "z<" "z^." "R'" "A'" "A^" "A(" "\"A" "L'" "C'" ",C"
112 "C<" "E'" "E;" "E:" "E<" "I'" "I^" "D<" "/D" "N'"
113 "N<" "O'" "O^" "O''" "\"O" "*x" "R<" "U^0" "U'" "U''"
114 "\"U" "Y'" ",T" "ss" "r'" "a'" "a^" "a(" "\"a" "l'"
115 "c'" ",c" "c<" "e'" "e;" "\"e" "e<" "i'" "i^" "d<"
116 "/d" "n'" "n<" "o'" "o^" "o''" "\"o" "-:" "r<" "u^0"
117 "u'" "u''" "\"u" "y'" ",t" "'."]
118 )
119 (latin-iso8859-3
120 . [255 "/H" "'(" "Pd" "$$" " " "H^" "SE" "\"" "I^."
121 ",S" "G(" "J^" "--" " " "Z^." "^o" "/h" "^2" "^3"
122 "'" "u" "h^" "." "'," "i^." ",s" "g(" "j^" "1/2"
123 " " "z^." "`A" "A'" "A^" " " "\"A" "C^." "C^" ",C"
124 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" " " "~N"
125 "`O" "O'" "O^" "G^." "\"O" "*x" "G^" "`U" "U'" "U^"
126 "\"U" "U(" "S^" "ss" "`a" "a'" "a^" " " "\"a" "c^."
127 "c^" ",c" "`e" "e'" "e^" "\"e" "`i" "i'" "i^" "\"i"
128 " " "~n" "`o" "o'" "o^" "g^." "\"o" "-:" "g^" "`u"
129 "u'" "u^" "\"u" "u(" "s^" "^."]
130 )
131 (latin-iso8859-4
132 . [255 "A;" "kk" ",R" "$$" "?I" ",L" "SE" "\"" "S<"
133 "E-" ",G" "/T" "--" "Z<" "'-" "^o" "a;" "';" ",r"
134 "'" "~i" ",l" "'<" "'," "s<" "e-" ",g" "/t" "NG"
135 "z<" "ng" "A-" "A'" "A^" "~A" "\"A" "Ao" "AE" "I;"
136 "C<" "E'" "E;" "\"E" "E^." "I'" "I^" "I-" "/D" ",N"
137 "O-" ",K" "O^" "~O" "\"O" "*x" "/O" "U;" "U'" "U^"
138 "\"U" "~U" "U-" "ss" "a-" "a'" "a^" "~a" "\"a" "ao"
139 "ae" "i;" "c<" "e'" "e;" "\"e" "e^." "i'" "i^" "i-"
140 "/d" ",n" "o-" ",k" "o^" "~o" "\"o" "-:" "/o" "u;"
141 "u'" "u^" "\"u" "~u" "u-" "^."]
142 )
143 (cyrillic-iso8859-5
144 . [255 "\"E" "Dj" "Gj" "IE" "Dz" "Ii" "Ji" "JE" "Lj"
145 "Nj" "Ts" "Kj" 240 "V%" "Dzh" 65 "B=" 66 226
146 68 69 "Z%" 51 85 "J=" 75 "L=" 77 72
147 79 "P=" 80 67 84 89 232 88 "C=" "C%"
148 "S%" "Sc" "=\"" "Y=" "%\"" "Ee" "Yu" "Ya" 97 98
149 "v=" "g=" 103 101 "z%" "z=" 117 "j=" 107 "l="
150 "m=" "n=" 111 110 112 99 "t=" 121 "f=" 120
151 "c=" "c%" "s%" "sc" "='" "y=" "%'" "ee" "yu" "ya"
152 "N0" "\"e" "dj" "gj" "ie" "dz" "ii" "ji" "je" "lj"
153 "nj" "ts" "kj" 21 "v%" "dzh"]
154 )
155 (arabic-iso8859-6
156 . [255 nil nil nil "$$" nil nil nil nil nil
157 nil nil ",+" "--" nil nil nil nil nil nil
158 nil nil nil nil nil nil nil ";+" nil nil
159 nil "?+" nil "H'" "aM" "aH" "wH" "ah" "yH"
160 "a+" "b+" "tm" "t+" "tk" "g+" "hk" "x+" "d+" "dk"
161 "r+" "z+" "s+" "sn" "c+" "dd" "tj" "zH" "e+" "i+"
162 nil nil nil nil nil "++" "f+" "q+" "k+" "l+"
163 "m+" "n+" "h+" "w+" "j+" "y+" ":+" "\"+" "=+" "/+"
164 "'+" "1+" "3+" "0+" nil nil nil nil nil nil
165 nil nil nil nil nil nil nil]
166 )
167 (greek-iso8859-7
168 . [255 "9'" "'9" "Pd" nil nil "|" "SE" "\"" "(c)"
169 nil "<<" "~" "--" nil "-M" "^o" "+-" "^2" "^3"
c35ba278
EZ
170 "'" "'%" "'A" "^." "'E" "'H" "'I" ">>" "'O" "1/2"
171 "'Y" "W%" "i3" 65 66 "G*" "D*" 69 90 72
172 "TH" 73 74 "L*" 77 78 "C*" 79 "P*" 80
173 nil "S*" 84 89 "F*" 88 "Q*" "W*" "\"I" "\"Y"
0064ab85 174 "a%" "e%" "y%" "i%" "u3" "a*" "b*" "g*" "d*" "e*"
c35ba278
EZ
175 "z*" "y*" "h*" "i*" 107 "l*" "m*" "n*" "c*" 111
176 "p*" "r*" "*s" "s*" "t*" 117 "f*" "x*" "q*" "w*"
177 "\"i" "\"u" "'o" "'u" "'w" nil]
0064ab85 178 )
cf8f0b68
EZ
179 ;; Note: some of the characters undefined according to ISO 8859-8
180 ;; in the ranges 190..220 and 250..255 are replaced with SI 1311-1
181 ;; points (Niqud) and bidi formatting characters
0064ab85
EZ
182 (hebrew-iso8859-8
183 . [255 nil "|c" "Pd" "$$" "Ye" "|" "SE" "\"" "(c)"
184 "*x" "<<" "~" "--" "(R)" "'-" "^o" "+-" "^2" "^3"
185 "'" "u" ".P" "^." "'," "^1" "-:" ">>" "1/4" "1/2"
cf8f0b68 186 "3/4" nil ":'" "v:" "-:" "-':" ".'" ".." "v'" "-'"
209695b9 187 "-," "`." nil "\\." "(.)" "|'" "`-" "`=" "||" nil
cf8f0b68
EZ
188 nil "::" nil nil nil nil nil nil nil "LRO"
189 "RLO" "PDF" nil "=2" "A+" "B+" "G+" "D+" "H+" "W+"
0064ab85
EZ
190 "Z+" "X+" "Tj" "J+" "K%" "K+" "L+" "M%" "M+" "N%"
191 "N+" "S+" "E+" "P%" "P+" "Zj" "ZJ" "Q+" "R+" "Sh"
cf8f0b68 192 "T+" "LRE" "RLE" "LRM" "RLM" nil]
0064ab85
EZ
193 )
194 (latin-iso8859-9
195 . [255 "!I" "|c" "Pd" "$$" "Ye" "|" "SE" "\"" "(c)"
196 "_a" "<<" "~" "--" "(R)" "'-" "^o" "+-" "^2" "^3"
197 "'" "u" ".P" "^." "'," "^1" "_o" ">>" "1/4" "1/2"
198 "3/4" "?I" "`A" "A'" "A^" "~A" "\"A" "Ao" "AE" ",C"
199 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" "G(" "~N"
200 "`O" "O'" "O^" "~O" "\"O" "*x" "/O" "`U" "U'" "U^"
201 "\"U" "I^." ",S" "ss" "`a" "a'" "a^" "~a" "\"a" "ao"
c35ba278 202 "ae" ",c" "`e" "e'" "e<" "\"e" "e^." "i'" "i^" "i-"
0064ab85 203 "g(" "~n" "`o" "o'" "o^" "~o" "\"o" "-:" "/o" "`u"
c35ba278
EZ
204 "u'" "u^" "\"u" "i." ",s" "\"y"]
205 )
206 (latin-iso8859-14
bb8aea86
EZ
207 . [255 "B`" "b`" "Pd" "C`" "c`" "D`" "SE" "`W" "(c)"
208 "W'" "d`" "`Y" "--" "(R)" "\"Y" "F`" "f`" "G`" "g`"
209 "M`" "m`" ".P" "P`" "`w" "p`" "w'" "S`" "`y" "\"W"
210 "\"w" "s`" "`A" "A'" "A^" "~A" "\"A" "Ao" "AE" ",C"
c35ba278
EZ
211 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" "W^" "~N"
212 "`O" "O'" "O^" "~O" "\"O" "T`" "/O" "`U" "U'" "U^"
213 "\"U" "Y'" "Y^" "ss" "`a" "a'" "a^" "~a" "\"a" "ao"
214 "ae" ",c" "`e" "e'" "e^" "\"e" "`i" "i'" "i^" "\"i"
bb8aea86 215 "w^" "~n" "`o" "o'" "o^" "~o" "\"o" "t`" "/o" "`u"
c35ba278
EZ
216 "u'" "u^" "\"u" "y'" "y^" "\"y"]
217 )
218 (latin-iso8859-15
f3a3ea9a 219 . [255 "!I" "|c" "Pd" "E=" "Ye" "S<" "SE" "s<" "(c)"
bb8aea86 220 "_a" "<<" "~" "--" "(R)" "'-" "^o" "+-" "^2" "^3"
c35ba278
EZ
221 "Z<" "u" ".P" "^." "z<" "^1" "_o" ">>" "OE" "oe"
222 "\"Y" "?I" "`A" "A'" "A^" "~A" "\"A" "Ao" "AE" ",C"
f3a3ea9a 223 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" "-D" "~N"
c35ba278 224 "`O" "O'" "O^" "~O" "\"O" "*x" "/O" "`U" "U'" "U^"
bb8aea86 225 "\"U" "Y'" "|P" "ss" "`a" "a'" "a^" "~a" "\"a" "ao"
c35ba278 226 "ae" ",c" "`e" "e'" "e^" "\"e" "`i" "i'" "i^" "\"i"
f3a3ea9a 227 "-d" "~n" "`o" "o'" "o^" "~o" "\"o" "-:" "/o" "`u"
bb8aea86 228 "u'" "u^" "\"u" "y'" "|p" "\"y"]
0064ab85
EZ
229 )
230 )
231 "An alist of MULE ISO-8859 character sets and the strings that
232should be used to represent the characters from each set on a DOS
233terminal which does not have corresponding glyphs built into the
234installed codepage.")
235
236(defun IT-display-table-setup (codepage &optional table)
f53c8bb2
EZ
237 "Set up display table TABLE for a DOS terminal which supports
238glyphs built into the codepage CODEPAGE.
0064ab85
EZ
239
240If TABLE is nil or omitted, `standard-display-table' is used."
241 (let* ((surrogates IT-character-translations)
242 (disp-tab (or table standard-display-table))
243 (built-in-set (cp-charset-for-codepage codepage))
244 (offset (cp-offset-for-codepage codepage))
245 (cp-decoder
246 (symbol-value (intern-soft (format "%s-decode-table" codepage))))
247 (cp-decoder-len (length cp-decoder))
248 (c offset)
249 association chset)
250 ;; Undo the effects of previous call (where they may have used
251 ;; a different codepage) by reverting the display table for the
252 ;; built-in charset to its pristine shape.
a88d2801 253 (while (< c 256)
0064ab85
EZ
254 (aset disp-tab (make-char built-in-set c) nil)
255 (setq c (1+ c)))
256 (while surrogates
257 (setq association (car surrogates))
258 (setq chset (car association))
259 (let* ((vector (cdr association))
260 (veclen (length vector))
261 (i 0)
262 glyph)
263 (while (< i veclen)
264 (setq glyph (aref vector i))
cf8f0b68
EZ
265 (or glyph (setq glyph dos-unsupported-char-glyph))
266 (if (or (not (equal chset built-in-set))
267 (>= i cp-decoder-len)
268 (null (aref cp-decoder i)))
0064ab85
EZ
269 (aset disp-tab (make-char chset (+ i (logand offset 127)))
270 (vconcat
271 (if (numberp glyph)
272 (char-to-string glyph)
273 (if (> (length glyph) 1) (concat "{" glyph "}")
274 glyph)))))
275 (setq i (1+ i))))
f53c8bb2 276 (setq surrogates (cdr surrogates)))))
0064ab85 277
8a3d1f8b
EZ
278(defvar IT-unicode-translations
279 '(
280 (mule-unicode-0100-24ff ; charset
281 256 ; base
282 256 563 ; first, last
283 [ "A-" "a-" "A(" "a(" "A;" "a;" "C'" "c'" "C>" "c>" ; Latin Extended-A
284 "C." "c." "C<" "c<" "D<" "d<" "D/" "d/" "E-" "e-"
285 "E(" "e(" "E." "e." "E;" "e;" "E<" "e<" "G>" "g>"
286 "G(" "g(" "G." "g." "G," "g," "H>" "h>" "H/" "h/"
287 "I~" "i~" "I-" "i-" "I(" "i(" "I;" "i;" "I." "i."
288 "IJ" "ij" "J>" "j>" "K," "k," "kk" "L'" "l'" "L,"
289 "l," "L<" "l<" "L." "l." "L/" "l/" "N'" "n'" "N,"
290 "n," "N<" "n<" "'n" "NG" "ng" "O-" "o-" "O(" "o("
291 "O\"" "o\"" "OE" "oe" "R'" "r'" "R," "r," "R<" "r<"
292 "S'" "s'" "S>" "s>" "S," "s," "S<" "s<" "T," "t,"
293 "T<" "t<" "T/" "t/" "U~" "u~" "U-" "u-" "U(" "u("
294 "U0" "u0" "U\"" "u\"" "U;" "u;" "W>" "w>" "Y>" "y>"
295 "Y:" "Z'" "z'" "Z." "z." "Z<" "z<" "s1" ; 017f
296 "b/" "B2" "=B" "=b" "B6" "b6" "!C" "C2" "c2" "-D" ;Lat. Extended-B
297 "D2" "=D" "=d" "!d" "!E" "-E" "Eps" "F2" "f2" "G2"
298 "V0" "hv" "io" "-I" "K2" "k2" "-l" "la-" "!M" "2N"
299 "n_" "-O" "O9" "o9" "OI" "oi" "P2" "p2" "'R" "!S"
300 "!s" "Esh" "!esh" "t~" "T2" "t2" "T~" "U9" "u9" "Ups"
301 "V2" "Y2" "y2" "Z/" "z/" "ED" "!ED" "!ed" "ed;" "2/"
302 "5-" "_5-" "ts" "wn" "|_" "||" "|=" "!_" "DZ<" "Dz<"
303 "dz<" "LJ3" "Lj3" "lj3" "NJ3" "Nj3" "nj3" "A<" "a<" "I<"
304 "i<" "O<" "o<" "U<" "u<" "U:-" "u:-" "U:'" "u:'" "U:<"
305 "u:<" "U:!" "u:!" "e1" "A:-" "a:-" "A.-" "a.-" "AE-" "ae-"
306 "G/" "g/" "G<" "g<" "K<" "k<" "O;" "o;" "O1" "o1"
307 "EZ" "ez" "j<" "DZ3" "Dz3" "dz3" "G'" "g'" "Hv" "Wn"
308 "N`" "n`" "AA'" "aa'" "AE'" "ae'" "O/'" "o/'" "A!!" "a!!"
309 "A)" "a)" "E!!" "e!!" "E)" "e)" "I!!" "i!!" "I)" "i)"
310 "O!!" "o!!" "O)" "o)" "R!!" "r!!" "R)" "r)" "U!!" "u!!"
311 "U)" "u)" ",S" ",s" ",T" ",t" "'3" "'3_" "H<" "h<"
312 nil nil "8" "8_" "Z2" "z2" "A." "a." "E," "e,"
313 "O:-" "o:-" "O~-" "o~-" "O." "o." "O.-" "o.-" "Y-" "y-"] ; 0x233
314
315 )
316
317 (mule-unicode-0100-24ff ; charset
318 256 ; base
319 884 1123 ; first, last
320 [ "'" "," nil nil nil nil "j3" nil nil nil ; Greek
321 "?;" nil nil nil nil nil "'*" "'%" "A%" ".*"
322 "E%" "Y%" "I%" nil "O%" nil "U%" "W%" "i3" "A*"
323 "B*" "G*" "D*" "E*" "Z*" "H*" "Th*" "I*" "K*" "L*"
324 "M*" "N*" "C*" "O*" "P*" "R*" nil "S*" "T*" "U*"
325 "F*" "X*" "Q*" "W*" "J*" "V*" "a%" "e%" "y%" "i%"
326 "u3" "a*" "b*" "g*" "d*" "e*" "z*" "h*" "th*" "i*"
327 "k*" "l*" "m*" "n*" "c*" "o*" "p*" "r*" "*s" "s*"
328 "t*" "u*" "f*" "x*" "q*" "w*" "j*" "v*" "o%" "u%"
329 "w%" nil "b3" "th%" "U2*" "'U2*" "U:2*" "ph*" "pi*" "ka*"
330 nil nil "Sti" "sti" "Dig" "dig" "Kop" "kop" "Sam" "sam"
331 "She" "she" "Fei" "fei" "Khe" "khe" "Hor" "hor" "Gan" "gan"
332 "Shi" "shi" "Dei" "dei" "ka*" "rh*" "ls*" "yo*" nil nil
333 nil nil nil nil nil nil nil nil nil nil
334 "IE'" "E:" "D%" "G%" "IE" "DS" "II" "YI" "J%" "LJ" ; Cyrillic
335 "NJ" "Ts" "KJ" "`I=" "V%" "DZ" 65 "B=" 66 "G="
336 68 69 "Z%" 51 85 "J=" 75 "L=" 77 72
337 79 "P=" 80 67 84 89 "F=" 88 "C=" "C%"
338 "S%" "Sc" "=\"" "Y=" "%\"" "Ee" "JU" "JA" 97 "b="
339 98 "g=" 103 101 "z%" "z=" 117 "j=" 107 "l="
340 109 "n=" 111 "p=" 112 99 "t=" 121 "f=" 120
341 "c=" "c%" "s%" "sc" "='" "y=" "%'" "ee" "ju" "ja"
342 "ie'" "e:" "d%" "g%" "ie" "ds" "ii" "yi" "j%" "lj"
343 "nj" "ts" "kj" "v%" "`i=" "dz" "OM=" "om=" "Y3" "y3"] ; 0x463
344 )
345
346 (mule-unicode-0100-24ff ; charset
347 256 ; base
cf8f0b68
EZ
348 1454 1645 ; first, last
349 [ nil nil ":'" "v:" "-:" "-':" ".'" ".." "v'" "-'"
350 "-," "`." nil "\\." "(.)" "|'" "`-" nil "||" nil
351 nil "::" nil nil nil nil nil nil nil nil
352 nil nil nil nil
353 "A+" "B+" "G+" "D+" "H+" "W+" "Z+" "X+" "Tj" "J+" ; Hebrew
8a3d1f8b
EZ
354 "K%" "K+" "L+" "M%" "M+" "N%" "N+" "S+" "E+" "P%"
355 "P+" "Zj" "ZJ" "Q+" "R+" "Sh" "T+" nil nil nil
356 nil nil "WW+" "WJ+" "JJ+" "'+" "\"+" nil nil nil
357 nil nil nil nil nil nil nil nil nil nil
358 nil nil nil nil nil nil nil nil nil nil
359 ",+" nil nil nil nil nil nil nil nil nil ; Arabic
360 nil nil nil nil nil ";+" nil nil nil "?+"
361 nil "H'" "aM" "aH" "wH" "ah" "yH" "a+" "b+" "tm"
362 "t+" "tk" "g+" "hk" "x+" "d+" "dk" "r+" "z+" "s+"
363 "sn" "c+" "dd" "tj" "zH" "e+" "i+" nil nil nil
364 nil nil "++" "f+" "q+" "k+" "l+" "m+" "n+" "h+"
365 "w+" "j+" "y+" ":+" "\"+" "=+" "/+" "'+" "1+" "3+"
366 "0+" nil nil nil nil nil nil nil nil nil
367 nil nil nil nil "0a" "1a" "2a" "3a" "4a" "5a"
368 "6a" "7a" "8a" "9a" "a%" "a." "a," "a*" ]
369 )
370
371 (mule-unicode-0100-24ff ; charset
372 256 ; base
373 7680 9450 ; first, last
374 [ "A-0" "a-0" "B." "b." "B-." "b-." "B_" "b_" "C,'" "c,'" ; Lat Ext Add
375 "D." "d." "D-." "d-." "D_" "d_" "D," "d," "D->" "d->"
376 "E-!" "e-!" "E-'" "e-'" "E->" "e->" "E-?" "e-?" "E,(" "e,("
377 "F." "f." "G-" "g-" "H." "h." "H-." "h-." "H:" "h:"
378 "H," "h," "H-(" "h-(" "I-?" "i-?" "I:'" "i:'" "K'" "k'"
379 "K-." "k-." "K_" "k_" "L-." "l-." "_L-." "_l-." "L_" "l_"
380 "L->" "l->" "M'" "m'" "M." "m." "M-." "m-." "N." "n."
381 "N-." "n-." "N_" "n_" "N->" "n->" "O?'" "o?'" "O?:" "o?:"
382 "O-!" "o-!" "O-'" "o-'" "P'" "p'" "P." "p." "R." "r."
383 "R-." "r-." "_R-." "_r-." "R_" "r_" "S." "s." "S-." "s-."
384 "S'." "s'." "S<." "s<." ".S-." ".s-." "T." "t." "T-." "t-."
385 "T_" "t_" "T->" "t->" "U_:" "u_:" "U-?" "u-?" "U->" "u->"
386 "U?'" "u?'" "U-:" "u-:" "V?" "v?" "V-." "v-." "W!" "w!"
387 "W'" "w'" "W:" "w:" "W." "w." "W-." "w-." "X." "x."
388 "X:" "x:" "Y." "y." "Z>" "z>" "Z-." "z-." "Z_" "z_"
389 "h_" "t:" "w0" "y0" "a))" "s1." nil nil nil nil
390 "A-." "a-." "A2" "a2" "A>'" "a>'" "A>!" "a>!" "A>2" "a>2"
391 "A>~" "a>~" ".A>" ".a>" "A('" "a('" "A(!" "a(!" "A(2" "a(2"
392 "A(~" "a(~" ".A(" ".a(" "E-." "e-." "E2" "e2" "E~" "e~"
393 "E>'" "e>'" "E>!" "e>!" "E>2" "e>2" "E>~" "e>~" ".E>" ".e>"
394 "I2" "i2" "I-." "i-." "O-." "o-." "O2" "o2" "O>'" "o>'"
395 "O>!" "o>!" "O>2" "o>2" "O>~" "o>~" ".O>" ".o>" "O9'" "o9'"
396 "O9!" "o9!" "O92" "o92" "O9~" "o9~" ".O9" ".o9" "U-." "u-."
397 "U2" "u2" "U9'" "u9'" "U9!" "u9!" "U92" "u92" "U9~" "u9~"
398 ".U9" ".u9" "Y!" "y!" "Y-." "y-." "Y2" "y2" "Y~" "y~"
399 nil nil nil nil nil nil "a*," "a*;" nil nil ; Greek Ext (0x1f00)
400 nil nil nil nil "A*," "A*;" nil nil nil nil
401 nil nil "e*," "e*;" nil nil nil nil nil nil
402 "E*," "E*;" nil nil nil nil nil nil "y*," "y*;"
403 nil nil nil nil nil nil "Y*," "Y*;" nil nil
404 nil nil nil nil "i*," "i*;" nil nil nil nil
405 nil nil "I*," "I*;" nil nil nil nil nil nil
406 "o*," "o*;" nil nil nil nil nil nil "O*," "O*;"
407 nil nil nil nil nil nil "u*," "u*;" nil nil
408 nil nil nil nil nil "U*;" nil nil nil nil
409 nil nil "w*," "w*;" nil nil nil nil nil nil
410 "W*," "W*;" nil nil nil nil nil nil "a*!" "a*'"
411 "e*!" "e*'" "y*!" "y*'" "i*!" "i*'" "o*!" "o*'" "u*!" "u*'"
412 "w*!" "w*'" nil nil nil nil nil nil nil nil
413 nil nil nil nil nil nil nil nil nil nil
414 nil nil nil nil nil nil nil nil nil nil
415 nil nil nil nil nil nil nil nil nil nil
416 nil nil nil nil nil nil nil nil nil nil
417 nil nil "a*(" "a*-" nil "a*j" nil nil "a*~" nil
418 "A*(" "A*-" "A*!" "A*'" "A*J" ")*" "J3" ",," "?*" "?:"
419 nil "y*j" nil nil "y*?" nil "E*!" "E*'" "Y*!" "Y*'"
420 "Y*J" ",!" ",'" "?," "i*(" "i*-" nil nil nil nil
421 "i*?" nil "I*(" "I*-" "I*!" "I*'" nil ";!" ";'" "?;"
422 "u*(" "u*-" nil nil "r*," "r*;" "u*?" nil "U*(" "U*-"
423 "U*!" "U*'" "R*;" "!:" ":'" "!*" nil nil nil "w*j"
424 nil nil "w*?" nil "O*!" "O*'" "W*!" "W*'" "W*J" "/*"
425 ";;" nil nil nil "1N" "1M" "3M" "4M" "6M" nil ; Gen Punct
426 nil "1T" "1H" nil nil nil "LRM" "RLM" "-1" nil
be8cf99e 427 nil "--" "---" "===" "!2" "=2" "6`" "'9" ".9" "9'"
8a3d1f8b
EZ
428 "``" "''" ":9" "9``" "/-" "/=" "sb" "3b" nil ".."
429 "..." ".-" "LSep" "PSep" "LR[" "RL[" "PDF" "LRO" "RLO" 255
430 "%o" "%oo" "'" "''" "\"'" "`" "``" "```" ".^" "<,"
431 ",>" ":X" "!!" "?!" "'-" nil nil nil nil "-b"
432 "/f" nil nil nil nil nil nil nil nil nil
433 nil nil nil nil nil nil nil nil nil nil
434 nil nil nil nil nil nil nil nil nil nil
435 nil nil nil nil nil nil nil nil nil nil
436 nil nil nil nil "^0" nil nil nil "^4" "^5"
437 "^6" "^7" "^8" "^9" "^+" "^-" "^=" "^(" "^)" "^n"
438 "_0" "_1" "_2" "_3" "_4" "_5" "_6" "_7" "_8" "_9"
439 "_+" "_-" "_=" "_(" "_)" nil nil nil nil nil
440 nil nil nil nil nil nil nil nil nil nil
441 nil nil nil nil nil "Ff" "Li" nil nil "Pt"
442 nil "W=" "NIS" nil "E=" nil nil nil nil nil
443 nil nil nil nil nil nil nil nil nil nil
444 nil nil nil nil nil nil nil nil nil nil
445 nil nil nil nil nil nil nil nil nil nil
446 nil nil nil nil nil nil nil nil nil nil
447 nil nil nil nil nil nil nil nil nil nil
448 nil nil nil nil nil nil nil nil nil nil
449 nil nil nil nil nil nil nil nil nil nil
450 nil nil nil nil nil nil nil nil "a/c" "a/s"
451 nil "oC" nil "c/o" "c/u" "=e" nil "oF" nil nil
452 nil nil "-h" "=h" nil nil nil nil nil nil
453 "N0" "PO" nil nil nil nil "Re" nil "Rx" nil
454 "SM" "TEL" "TM" nil nil nil "Om" nil nil nil
455 "oK" "AO" nil nil "Est" nil nil nil nil nil
456 nil "Aleph" "Bet" "Gimel" "Dalet" "=i=" nil nil nil nil
457 nil nil nil nil nil nil nil nil nil nil
458 nil nil nil nil nil nil nil nil nil nil
459 nil "1/3" "2/3" "1/5" "2/5" "3/5" "4/5" "1/6" "5/6" "1/8"
460 "3/8" "5/8" "7/8" "1/" ".I" "II" "III" "IV" ".V" "VI"
461 "VII" "VIII" "IX" "X" "XI" "XII" ".L" ".C" ".D" ".M"
462 ".i" "ii" "iii" "iv" ".v" "vi" "vii" "viii" "ix" ".x"
463 "xi" ".l" ".c" ".d" ".m" "CD" "DD" "CoD" "CI" nil
464 nil nil nil nil nil nil nil nil nil nil
465 nil "<-" "|^" "->" "|v" "<->" "v|^" "^\\" "/^" "\\v"
466 "v/" "<-/" "/->" "<~" "~>" "<<-" "|^^" "->>" "|vv" "<-<"
467 ">->" "<-|" "_|^" "|->" "-|v" "_v|^" "<-?" "?->" "<-o" "o->"
468 "<~>" "<-/>" nil nil nil nil nil nil nil nil
469 nil nil nil nil nil nil nil nil nil nil
470 nil nil nil nil nil nil nil nil nil nil
471 nil nil nil "<=/" "<=/>" "/=>" "<=" "||^" "=>" "||v"
472 "<=>" "v||^" "^\\\\" "//^" "\\\\v" "v//" "<-=" "=->" nil nil
473 nil nil "<.." ":^" "..>" ":v" nil nil "<::" "::^"
474 "::>" "::v" nil nil nil nil nil nil nil nil
475 nil nil nil nil nil nil nil nil nil nil
476 nil nil nil nil "FA" "C." "dP" "TE" "~TE" "/0"
477 "DE" "NB" "(-" "~(-" "e-" "-)" "~-)" "-e" "QED" "*P"
478 nil "+Z" "--" "-+" ".+" "./" ".\\" "*-" "Ob" "Sb"
479 "SQR" "CBR" nil "0(" "00" "-L" "-V" nil nil ".|"
480 "~.|" "||" "/||" "AND" "OR" "(U" ")U" "In" "DI" nil
481 "Io" nil nil nil nil nil ".:" ":." ":R" "::"
482 ".-." "-:" ":-:" ":~:" "?~" "~?" "??" nil nil "/~"
483 "-~" "~-" "/~-" "~=" "~/=" "/~=" "~~" "/~~" nil nil
484 "=?" ")(" "v^" "^_" ".=" "=;" ".=." nil ":=" "=:"
485 nil "=o" "=)" "=^" "=v" "*=" "=<>" "=df" nil "?="
486 "!=" "-=" "!-=" "==" "=<" ">=" nil nil nil nil
487 "<<" ">>" "()" "/)(" "!<" "!>" nil nil nil nil
488 nil nil nil nil nil nil "<'" "`>" "=<'" "`>="
489 "~<'" "`>~" "/<'" "/`>" "(C" ")C" "/(C" "/)C" "(_" ")_"
490 "/(_" "/)_" nil nil nil nil nil nil nil nil
491 nil nil nil "0+" "0-" "0x" "0/" "0." "0o" "0*"
492 "0=" "0_" nil nil nil nil "|T" "T|" "-T" "_T"
493 nil nil nil nil nil nil nil nil nil nil
494 nil nil nil nil nil nil nil nil nil "-,-"
495 nil "XOR" "NAND" "NOR" nil nil nil nil nil nil
496 nil nil nil nil nil nil nil nil nil nil
497 nil nil nil nil nil nil nil nil "<." ".>"
498 "<<<" ">>>" nil nil nil nil nil nil nil nil
499 nil nil nil nil nil nil nil nil nil nil
500 nil nil ":3" "..." nil nil nil nil nil nil
501 nil nil nil nil nil nil nil nil nil nil
502 nil nil "Eh" nil nil nil nil nil "<7" ">7"
503 "7<" "7>" nil nil nil nil "~I" nil "(A" nil
504 nil "TR" nil "=||" "88" nil nil nil nil nil
505 nil nil "Iu" "Il" nil nil "-^-" "-`-" "D->" nil
506 nil "</" "/>" "<-D" nil nil nil nil nil nil
507 nil nil nil nil nil nil nil nil nil nil
508 nil nil nil nil nil nil nil nil nil nil
509 nil nil nil nil nil nil nil nil nil nil
510 nil nil nil nil nil nil nil nil nil nil
511 nil nil nil nil nil nil nil nil nil nil
512 nil nil nil nil nil nil nil nil nil nil
513 nil nil nil nil nil nil nil nil nil nil
514 nil nil nil nil nil nil nil nil nil nil
515 nil nil nil nil nil nil nil nil nil nil
516 nil nil nil nil nil nil nil nil nil nil
517 nil nil nil nil nil nil nil nil nil nil
518 nil nil nil nil nil nil nil nil nil nil
519 nil nil nil nil nil nil nil nil nil nil
520 nil nil nil nil nil nil nil nil nil nil
521 nil nil nil nil nil nil nil nil nil nil
522 nil nil nil nil nil nil nil nil nil nil
523 nil nil nil nil nil nil nil nil nil nil
524 nil nil nil nil nil nil nil nil nil nil
525 nil nil nil nil nil nil nil nil nil nil
526 nil nil nil nil nil nil nil nil nil nil
527 nil nil nil nil nil nil "NUL" "SOH" "STX" "ETX"
528 "EOT" "ENQ" "ACK" "BEL" "BS" "HT" "LF" "VT" "FF" "CR"
529 "SS" "SI" "DLE" "DC1" "DC2" "DC3" "DC4" "NAK" "SYN" "ETB"
530 "CAN" "EM" "SUB" "ESC" "FS" "GS" "RS" "US" "SP" "DEL"
531 "b/" ",_," "NL" nil "?^" nil nil nil nil nil
532 nil nil nil nil nil nil nil nil nil nil
533 nil nil nil nil nil nil nil nil nil nil
534 nil nil nil nil nil nil nil nil nil nil
535 nil nil nil nil nil nil nil nil nil nil
536 nil nil nil nil nil nil nil nil nil nil
537 nil nil "1-o" "2-o" "3-o" "4-o" "5-o" "6-o" "7-o" "8-o"
538 "9-o" "10-o" "11-o" "12-o" "13-o" "14-o" "15-o" "16-o" "17-o" "18-o"
539 "19-o" "20-o" "(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)"
540 "(9)" "(10)" "(11)" "(12)" "(13)" "(14)" "(15)" "(16)" "(17)" "(18)"
541 "(19)" "(20)" "1." "2." "3." "4." "5." "6." "7." "8."
542 "9." "10." "11." "12." "13." "14." "15." "16." "17." "18."
543 "19." "20." "(a)" "(b)" "(c)" "(d)" "(e)" "(f)" "(g)" "(h)"
544 "(i)" "(j)" "(k)" "(l)" "(m)" "(n)" "(o)" "(p)" "(q)" "(r)"
545 "(s)" "(t)" "(u)" "(v)" "(w)" "(x)" "(y)" "(z)" "A-o" "B-o"
546 "C-o" "D-o" "E-o" "F-o" "G-o" "H-o" "I-o" "J-o" "K-o" "L-o"
547 "M-o" "N-o" "O-o" "P-o" "Q-o" "R-o" "S-o" "T-o" "U-o" "V-o"
548 "W-o" "X-o" "Y-o" "Z-o" "a-o" "b-o" "c-o" "d-o" "e-o" "f-o"
549 "g-o" "h-o" "i-o" "j-o" "k-o" "l-o" "m-o" "n-o" "o-o" "p-o"
550 "q-o" "r-o" "s-o" "t-o" "u-o" "v-o" "w-o" "x-o" "y-o" "z-o"
551 "0-o" ]
552 )
553 )
554
555 "A list of mule-unicode-* character sets and the strings that
556should be used to represent the characters from each set on a DOS
557terminal which does not have corresponding glyphs built into the
558installed codepage.")
559
560(defun IT-setup-unicode-display (&optional table)
561 "Set up display table TABLE for displaying mule-unicode-* characters
562on a DOS terminal. If TABLE is nil or omitted, `standard-display-table'
563is used."
564 (interactive)
565 (let ((disp-tab (or table standard-display-table))
566 (tail IT-unicode-translations)
567 translation)
568 (while tail
569 (setq translation (car tail) tail (cdr tail))
570 (let* ((chset (car translation))
571 (base (nth 1 translation))
572 (first (nth 2 translation))
573 (last (nth 3 translation))
574 (table (nth 4 translation))
575 (i 0)
576 (this (- first base))
577 glyph)
578 (while (<= i (- last first))
579 (setq glyph (aref table i))
cf8f0b68
EZ
580 (or glyph (setq glyph dos-unsupported-char-glyph))
581 (aset disp-tab (make-char chset
582 (+ (/ this 96) 32)
583 (+ (% this 96) 32))
584 (vconcat
585 (if (numberp glyph)
586 (char-to-string glyph)
587 (if (> (length glyph) 1) (concat "{" glyph "}")
588 glyph))))
8a3d1f8b
EZ
589 (setq i (1+ i) this (1+ this)))))))
590
08baac3d
EZ
591(defun dos-cpNNN-setup (codepage)
592 "Set up the MULE environment using the DOS codepage CODEPAGE.
0064ab85 593
08baac3d
EZ
594This function creates the coding system cpNNN (where NNN is the value
595of the argument CODEPAGE), and then uses this coding system to set up
596display tables, and the language environment options as appropriate."
597 (let* ((cp (format "cp%s" codepage))
0064ab85
EZ
598 (charset (cp-charset-for-codepage cp))
599 (offset (cp-offset-for-codepage cp)))
600 (cp-make-coding-systems-for-codepage cp charset offset)
601 ;; This is done by set-language-environment.
602 ;;(setq nonascii-translation-table
603 ;; (symbol-value (intern (concat cp "-nonascii-translation-table"))))
604 (set-language-environment (cp-language-for-codepage cp))
605 (set-default-coding-systems (intern (concat cp "-dos")))
4de8f97e 606 (set-selection-coding-system (intern (concat cp "-dos")))
0064ab85
EZ
607 (set-terminal-coding-system
608 (setq default-terminal-coding-system (intern (concat cp
609 "-unix"))))
610 (IT-display-table-setup cp)
a9a9b2e3
EZ
611 ;; It's time: too many input methods in leim/quail produce
612 ;; Unicode characters. Let the user see them.
613 (IT-setup-unicode-display)
3e9c24f6 614 (prefer-coding-system (intern (concat cp "-dos")))
e1b674a1
EZ
615 (if default-enable-multibyte-characters
616 ;; We want this in multibyte version only, since unibyte version
617 ;; should not convert non-ASCII characters at all.
618 (setq unibyte-display-via-language-environment t)
619 ;; Let the unibyte version behave as Emacs 19 did. In particular,
620 ;; let it use and display native codepage-specific glyphs for
621 ;; non-ASCII characters. For this to work correctly, we need to
622 ;; establish the correspondence between lower-case letters and their
623 ;; upper-case brethren, as appropriate for the codepage in use. The
624 ;; code below makes this happen.
625 ;; (In the multibyte mode, the appropriate tables are prepared
626 ;; elsewhere, since multibyte Emacs uses normal MULE character sets,
627 ;; which are supported on all platforms.)
628 (let* ((i 128)
629 (modify (function
db95369b 630 (lambda (ch sy)
e1b674a1
EZ
631 (modify-syntax-entry ch sy text-mode-syntax-table)
632 (if (boundp 'tex-mode-syntax-table)
633 (modify-syntax-entry ch sy tex-mode-syntax-table))
634 (modify-syntax-entry ch sy (standard-syntax-table))
635 )))
636 (table (standard-case-table))
637 ;; The following are strings of letters, first lower then
638 ;; upper case. This will look funny on terminals which
639 ;; display other code pages. In particular, what is
640 ;; displayed as blanks or triangles are not what they
14185565 641 ;; look like at all! (Use `C-x =' to see what they
e1b674a1
EZ
642 ;; really are.)
643 (chars
644 (cond
08baac3d 645 ((= codepage 850)
e1b674a1 646