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