Mercurial > hg > xemacs-beta
annotate lisp/mule/thai-xtis.el @ 5412:6a8c6c6f6c8e
Convert to GPLv3 or later from plain text GPLv2 or later.
author | Mats Lidell <matsl@xemacs.org> |
---|---|
date | Sun, 24 Oct 2010 00:24:04 +0200 |
parents | 308d34e9f07d |
children |
rev | line source |
---|---|
398 | 1 ;;; thai-xtis.el --- Support for Thai (XTIS) -*- coding: iso-2022-7bit; -*- |
2 | |
3 ;; Copyright (C) 1999 Electrotechnical Laboratory, JAPAN. | |
4 ;; Licensed to the Free Software Foundation. | |
5 | |
6 ;; Author: TAKAHASHI Naoto <ntakahas@etl.go.jp> | |
7 ;; MORIOKA Tomohiko <tomo@etl.go.jp> | |
8 ;; Created: 1998-03-27 for Emacs-20.3 by TAKAHASHI Naoto | |
9 ;; 1999-03-29 imported and modified for XEmacs by MORIOKA Tomohiko | |
10 | |
11 ;; Keywords: mule, multilingual, Thai, XTIS | |
12 | |
13 ;; This file is part of XEmacs. | |
14 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
15 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
16 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
17 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
18 ;; option) any later version. |
398 | 19 |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
20 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
21 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
22 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
23 ;; for more details. |
398 | 24 |
25 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
26 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
398 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;; For Thai, the pre-composed character set proposed by | |
31 ;; Virach Sornlertlamvanich <virach@links.nectec.or.th> is supported. | |
32 | |
33 ;;; Code: | |
34 | |
780 | 35 (make-charset 'thai-xtis "Precomposed Thai (XTIS by Virach)." |
3659 | 36 '(registries ["xtis-0"] |
37 dimension 2 | |
38 columns 1 | |
39 chars 94 | |
40 final ?? | |
41 graphic 0)) | |
780 | 42 |
43 (define-category ?x "Precomposed Thai character.") | |
44 (modify-category-entry 'thai-xtis ?x) | |
45 | |
398 | 46 (when (featurep 'xemacs) |
47 (let ((deflist '(;; chars syntax | |
48 ("$(?!0(B-$(?NxP0R0S0`0(B-$(?e0(B" "w") | |
49 ("$(?p0(B-$(?y0(B" "w") | |
50 ("$(?O0f0_0o0z0{0(B" "_") | |
51 )) | |
52 elm chars len syntax to ch i) | |
53 (while deflist | |
54 (setq elm (car deflist)) | |
55 (setq chars (car elm) | |
56 len (length chars) | |
57 syntax (nth 1 elm) | |
58 i 0) | |
59 (while (< i len) | |
60 (if (= (aref chars i) ?-) | |
61 (setq i (1+ i) | |
62 to (nth 1 (split-char (aref chars i)))) | |
63 (setq ch (nth 1 (split-char (aref chars i))) | |
64 to ch)) | |
65 (while (<= ch to) | |
66 (modify-syntax-entry (vector 'thai-xtis ch) syntax) | |
67 (setq ch (1+ ch))) | |
68 (setq i (1+ i))) | |
69 (setq deflist (cdr deflist)))) | |
70 | |
71 (put-charset-property 'thai-xtis 'preferred-coding-system 'tis-620) | |
72 ) | |
73 | |
74 ;; This is the ccl-decode-thai-xtis automaton. | |
75 ;; | |
76 ;; "WRITE x y" == (insert (make-char 'thai-xtis x y)) | |
77 ;; "write x" == (insert x) | |
78 ;; rx' == (tis620-to-thai-xtis-second-byte-bitpattern rx) | |
79 ;; r3 == "no vower nor tone" | |
80 ;; r4 == (charset-id 'thai-xtis) | |
81 ;; | |
82 ;; | input (= r0) | |
83 ;; state |-------------------------------------------- | |
84 ;; | consonant | vowel | tone | |
85 ;; ---------+-------------+-------------+---------------- | |
86 ;; r1 == 0 | r1 = r0 | WRITE r0,r3 | WRITE r0,r3 | |
87 ;; r2 == 0 | | | | |
88 ;; ---------+-------------+-------------+---------------- | |
89 ;; r1 == C | WRITE r1,r3 | r2 = r0' | WRITE r1,r3|r0' | |
90 ;; r2 == 0 | r1 = r0 | | r1 = 0 | |
91 ;; ---------+-------------+-------------+---------------- | |
92 ;; r1 == C | WRITE r1,r2 | WRITE r1,r2 | WRITE r1,r2|r0' | |
93 ;; r2 == V | r1 = r0 | WRITE r0,r3 | r1 = r2 = 0 | |
94 ;; | r2 = 0 | r1 = r2 = 0 | | |
95 ;; | |
96 ;; | |
97 ;; | input (= r0) | |
98 ;; state |----------------------------------------- | |
99 ;; | symbol | ASCII | EOF | |
100 ;; ---------+-------------+-------------+------------- | |
101 ;; r1 == 0 | WRITE r0,r3 | write r0 | | |
102 ;; r2 == 0 | | | | |
103 ;; ---------+-------------+-------------+------------- | |
104 ;; r1 == C | WRITE r1,r3 | WRITE r1,r3 | WRITE r1,r3 | |
105 ;; r2 == 0 | WRITE r0,r3 | write r0 | | |
106 ;; | r1 = 0 | r1 = 0 | | |
107 ;; ---------+-------------+-------------+------------- | |
108 ;; r1 == C | WRITE r1,r2 | WRITE r1,r2 | WRITE r1,r2 | |
109 ;; r2 == V | WRITE r0,r3 | write r0 | | |
110 ;; | r1 = r2 = 0 | r1 = r2 = 0 | | |
111 | |
112 | |
113 (eval-and-compile | |
114 | |
115 ;; input : r5 = 1st byte, r6 = 2nd byte | |
116 ;; Their values will be destroyed. | |
117 (define-ccl-program ccl-thai-xtis-write | |
118 '(0 | |
119 ((r5 = ((r5 & #x7F) << 7)) | |
120 (r6 = ((r6 & #x7F) | r5)) | |
121 (write-multibyte-character r4 r6)))) | |
122 | |
123 (define-ccl-program ccl-thai-xtis-consonant | |
124 '(0 | |
125 (if (r1 == 0) | |
126 (r1 = r0) | |
127 (if (r2 == 0) | |
128 ((r5 = r1) (r6 = r3) (call ccl-thai-xtis-write) | |
129 (r1 = r0)) | |
130 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write) | |
131 (r1 = r0) | |
132 (r2 = 0)))))) | |
133 | |
134 (define-ccl-program ccl-thai-xtis-vowel | |
135 '(0 | |
136 ((if (r1 == 0) | |
137 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)) | |
138 ((if (r2 == 0) | |
139 (r2 = ((r0 - 204) << 3)) | |
140 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write) | |
141 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write) | |
142 (r1 = 0) | |
143 (r2 = 0)))))))) | |
144 | |
145 (define-ccl-program ccl-thai-xtis-vowel-d1 | |
146 '(0 | |
147 ((if (r1 == 0) | |
148 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)) | |
149 ((if (r2 == 0) | |
150 (r2 = #x38) | |
151 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write) | |
152 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write) | |
153 (r1 = 0) | |
154 (r2 = 0)))))))) | |
155 | |
156 (define-ccl-program ccl-thai-xtis-vowel-ee | |
157 '(0 | |
158 ((if (r1 == 0) | |
159 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)) | |
160 ((if (r2 == 0) | |
161 (r2 = #x78) | |
162 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write) | |
163 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write) | |
164 (r1 = 0) | |
165 (r2 = 0)))))))) | |
166 | |
167 (define-ccl-program ccl-thai-xtis-tone | |
168 '(0 | |
169 (if (r1 == 0) | |
170 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)) | |
171 (if (r2 == 0) | |
172 ((r5 = r1) (r6 = ((r0 - #xE6) | r3)) (call ccl-thai-xtis-write) | |
173 (r1 = 0)) | |
174 ((r5 = r1) (r6 = ((r0 - #xE6) | r2)) (call ccl-thai-xtis-write) | |
175 (r1 = 0) | |
176 (r2 = 0)))))) | |
177 | |
178 (define-ccl-program ccl-thai-xtis-symbol | |
179 '(0 | |
180 (if (r1 == 0) | |
181 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)) | |
182 (if (r2 == 0) | |
183 ((r5 = r1) (r6 = r3) (call ccl-thai-xtis-write) | |
184 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write) | |
185 (r1 = 0)) | |
186 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write) | |
187 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write) | |
188 (r1 = 0) | |
189 (r2 = 0)))))) | |
190 | |
191 (define-ccl-program ccl-thai-xtis-ascii | |
192 '(0 | |
193 (if (r1 == 0) | |
194 (write r0) | |
195 (if (r2 == 0) | |
196 ((r5 = r1) (r6 = r3) (call ccl-thai-xtis-write) | |
197 (write r0) | |
198 (r1 = 0)) | |
199 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write) | |
200 (write r0) | |
201 (r1 = 0) | |
202 (r2 = 0)))))) | |
203 | |
204 (define-ccl-program ccl-thai-xtis-eof | |
205 '(0 | |
206 (if (r1 != 0) | |
207 (if (r2 == 0) | |
208 ((r5 = r1) (r6 = r3) (call ccl-thai-xtis-write)) | |
209 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write)))))) | |
210 | |
211 (define-ccl-program ccl-decode-thai-xtis | |
212 `(4 | |
213 ((read r0) | |
214 (r1 = 0) | |
215 (r2 = 0) | |
216 (r3 = #x30) | |
217 (r4 = ,(charset-id 'thai-xtis)) | |
218 (loop | |
219 (if (r0 < 161) | |
220 (call ccl-thai-xtis-ascii) | |
221 (branch (r0 - 161) | |
222 (call ccl-thai-xtis-consonant) | |
223 (call ccl-thai-xtis-consonant) | |
224 (call ccl-thai-xtis-consonant) | |
225 (call ccl-thai-xtis-consonant) | |
226 (call ccl-thai-xtis-consonant) | |
227 (call ccl-thai-xtis-consonant) | |
228 (call ccl-thai-xtis-consonant) | |
229 (call ccl-thai-xtis-consonant) | |
230 (call ccl-thai-xtis-consonant) | |
231 (call ccl-thai-xtis-consonant) | |
232 (call ccl-thai-xtis-consonant) | |
233 (call ccl-thai-xtis-consonant) | |
234 (call ccl-thai-xtis-consonant) | |
235 (call ccl-thai-xtis-consonant) | |
236 (call ccl-thai-xtis-consonant) | |
237 (call ccl-thai-xtis-consonant) | |
238 (call ccl-thai-xtis-consonant) | |
239 (call ccl-thai-xtis-consonant) | |
240 (call ccl-thai-xtis-consonant) | |
241 (call ccl-thai-xtis-consonant) | |
242 (call ccl-thai-xtis-consonant) | |
243 (call ccl-thai-xtis-consonant) | |
244 (call ccl-thai-xtis-consonant) | |
245 (call ccl-thai-xtis-consonant) | |
246 (call ccl-thai-xtis-consonant) | |
247 (call ccl-thai-xtis-consonant) | |
248 (call ccl-thai-xtis-consonant) | |
249 (call ccl-thai-xtis-consonant) | |
250 (call ccl-thai-xtis-consonant) | |
251 (call ccl-thai-xtis-consonant) | |
252 (call ccl-thai-xtis-consonant) | |
253 (call ccl-thai-xtis-consonant) | |
254 (call ccl-thai-xtis-consonant) | |
255 (call ccl-thai-xtis-consonant) | |
256 (call ccl-thai-xtis-consonant) | |
257 (call ccl-thai-xtis-symbol) | |
258 (call ccl-thai-xtis-consonant) | |
259 (call ccl-thai-xtis-symbol) | |
260 (call ccl-thai-xtis-consonant) | |
261 (call ccl-thai-xtis-consonant) | |
262 (call ccl-thai-xtis-consonant) | |
263 (call ccl-thai-xtis-consonant) | |
264 (call ccl-thai-xtis-consonant) | |
265 (call ccl-thai-xtis-consonant) | |
266 (call ccl-thai-xtis-consonant) | |
267 (call ccl-thai-xtis-consonant) | |
268 (call ccl-thai-xtis-symbol) | |
269 (call ccl-thai-xtis-symbol) | |
270 (call ccl-thai-xtis-vowel-d1) | |
271 (call ccl-thai-xtis-symbol) | |
272 (call ccl-thai-xtis-symbol) | |
273 (call ccl-thai-xtis-vowel) | |
274 (call ccl-thai-xtis-vowel) | |
275 (call ccl-thai-xtis-vowel) | |
276 (call ccl-thai-xtis-vowel) | |
277 (call ccl-thai-xtis-vowel) | |
278 (call ccl-thai-xtis-vowel) | |
279 (call ccl-thai-xtis-vowel) | |
280 nil | |
281 nil | |
282 nil | |
283 nil | |
284 (call ccl-thai-xtis-symbol) | |
285 (call ccl-thai-xtis-symbol) | |
286 (call ccl-thai-xtis-symbol) | |
287 (call ccl-thai-xtis-symbol) | |
288 (call ccl-thai-xtis-symbol) | |
289 (call ccl-thai-xtis-symbol) | |
290 (call ccl-thai-xtis-symbol) | |
291 (call ccl-thai-xtis-symbol) | |
292 (call ccl-thai-xtis-tone) | |
293 (call ccl-thai-xtis-tone) | |
294 (call ccl-thai-xtis-tone) | |
295 (call ccl-thai-xtis-tone) | |
296 (call ccl-thai-xtis-tone) | |
297 (call ccl-thai-xtis-tone) | |
298 (call ccl-thai-xtis-tone) | |
299 (call ccl-thai-xtis-vowel-ee) | |
300 (call ccl-thai-xtis-symbol) | |
301 (call ccl-thai-xtis-symbol) | |
302 (call ccl-thai-xtis-symbol) | |
303 (call ccl-thai-xtis-symbol) | |
304 (call ccl-thai-xtis-symbol) | |
305 (call ccl-thai-xtis-symbol) | |
306 (call ccl-thai-xtis-symbol) | |
307 (call ccl-thai-xtis-symbol) | |
308 (call ccl-thai-xtis-symbol) | |
309 (call ccl-thai-xtis-symbol) | |
310 (call ccl-thai-xtis-symbol) | |
311 (call ccl-thai-xtis-symbol) | |
312 (call ccl-thai-xtis-symbol) | |
313 nil | |
314 nil | |
315 nil)) | |
316 (read r0) | |
317 (repeat))) | |
318 | |
319 (call ccl-thai-xtis-eof))) | |
320 | |
321 ) | |
322 | |
323 (defconst leading-code-private-21 #x9F) | |
324 | |
325 (define-ccl-program ccl-encode-thai-xtis | |
326 `(1 | |
327 ((read r0) | |
328 (loop | |
329 (if (r0 == ,leading-code-private-21) | |
330 ((read r1) | |
331 (if (r1 == ,(charset-id 'thai-xtis)) | |
332 ((read r0) | |
333 (write r0) | |
334 (read r0) | |
335 (r1 = (r0 & 7)) | |
336 (r0 = ((r0 - #xB0) >> 3)) | |
337 (if (r0 != 0) | |
338 (write r0 [0 209 212 213 214 215 216 217 218 238])) | |
339 (if (r1 != 0) | |
340 (write r1 [0 231 232 233 234 235 236 237])) | |
341 (read r0) | |
342 (repeat)) | |
343 ((write r0 r1) | |
344 (read r0) | |
345 (repeat)))) | |
346 (write-read-repeat r0)))))) | |
347 | |
4690
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
348 (make-coding-system |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
349 'tis-620 'ccl |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
350 "TIS620 (Thai)" |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
351 `(mnemonic "TIS620" |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
352 decode ccl-decode-thai-xtis |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
353 encode ccl-encode-thai-xtis |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
354 safe-charsets (ascii thai-xtis) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
355 documentation "external=tis620, internal=thai-xtis")) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4568
diff
changeset
|
356 (coding-system-put 'tis-620 'category 'iso-8-1) |
398 | 357 |
358 (set-language-info-alist | |
359 "Thai-XTIS" | |
360 '((charset thai-xtis) | |
361 (coding-system tis-620 iso-2022-7bit) | |
362 (tutorial . "TUTORIAL.th") | |
363 (tutorial-coding-system . tis-620) | |
364 (coding-priority tis-620 iso-2022-7bit) | |
365 (sample-text . "$(?!:(B") | |
366 (documentation . t))) | |
367 | |
368 ;; thai-xtis.el ends here. |