Mercurial > emacs
annotate lisp/language/tv-util.el @ 102893:97aebffaf765
* text.texi (Yank Commands): Note that yank uses push-mark.
(Filling): Clarify REGION argument of fill-paragraph. Document
fill-forward-paragraph-function.
(Special Properties): Remove "new in Emacs 22" declaration.
(Clickable Text): Merge with Links and Mouse-1 node.
* display.texi (Button Properties, Button Buffer Commands): Change
xref to Clickable Text.
* tips.texi (Key Binding Conventions): Change xref to Clickable
Text.
* elisp.texi (Top): Update node listing.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Thu, 09 Apr 2009 01:17:08 +0000 |
parents | a9dc0e7c3f2b |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
90938 | 1 ;;; tv-util.el --- support for Tai Viet -*- coding: utf-8 -*- |
2 | |
100908 | 3 ;; Copyright (C) 2007, 2008, 2009 |
90938 | 4 ;; National Institute of Advanced Industrial Science and Technology (AIST) |
5 ;; Registration Number H13PRO009 | |
6 | |
7 ;; Keywords: multilingual, Tai Viet, i18n | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
94665
55b7f25d920a
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91437
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
90938 | 12 ;; it under the terms of the GNU General Public License as published by |
94665
55b7f25d920a
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91437
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
55b7f25d920a
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91437
diff
changeset
|
14 ;; (at your option) any later version. |
90938 | 15 |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
94665
55b7f25d920a
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91437
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
90938 | 23 |
24 ;;; Code | |
25 | |
26 ;; Regexp matching with a sequence of Tai Viet characters. | |
27 (defconst tai-viet-re | |
91217
9cf3b1c148b9
(tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents:
90950
diff
changeset
|
28 (format "[\xaa80-\xaac2\xaadb-\xaadf-]+")) |
90938 | 29 |
30 ;; Char-table of information about glyph type of Tai Viet characters. | |
31 (defconst tai-viet-glyph-info | |
32 (let ((table (make-char-table nil)) | |
33 (specials '((right-overhang . "ꪊꪋꪌꪍꪏꪓꪖꪜꪞꪡꪤꪨ") | |
34 (left-overhang . "ꫂ") | |
35 (combining-vowel . "ꪴꪰꪲꪳꪷꪸꪾ") | |
91217
9cf3b1c148b9
(tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents:
90950
diff
changeset
|
36 (combining-tone . "꪿꫁") |
9cf3b1c148b9
(tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents:
90950
diff
changeset
|
37 (misc . "-")))) |
90938 | 38 ;; Set all TaiViet characters to `t'. |
39 (set-char-table-range table (cons #xaa80 #xaac2) t) | |
40 (set-char-table-range table (cons #xaadb #xaadf) t) | |
41 ;; Overwrite it for special characters. | |
42 (dolist (elt specials) | |
43 (let ((category (car elt)) | |
44 (chars (cdr elt))) | |
45 (dotimes (i (length chars)) | |
46 (aset table (aref chars i) category)))) | |
47 table)) | |
48 | |
49 (defun tai-viet-compose-string (from to string) | |
50 "Compose Tai Viet characters in STRING between indices FROM and TO." | |
51 (let* ((ch (aref string from)) | |
52 (info (aref tai-viet-glyph-info ch)) | |
53 prev-info) | |
54 (if (eq info 'non-spacing) | |
55 (compose-string string from (1+ from) (string ch ?\t))) | |
56 (setq from (1+ from) prev-info info) | |
57 (while (and (< from to) | |
90949 | 58 (>= #xaa80 (setq ch (aref string from))) |
59 (<= #xaaDF ch)) | |
90938 | 60 (setq info (aref tai-viet-glyph-info ch)) |
61 (if (and (eq info 'non-spacing) | |
62 (eq prev-info 'non-spacing)) | |
63 (compose-string from (1+ from) (string ?\t ch))) | |
64 (setq from (1+ from) prev-info info)) | |
65 (if (eq info 'right-overhang) | |
66 (compose-string string (1- from) from (string ch ?\t))) | |
67 from)) | |
68 | |
69 (defun tai-viet-compose-region (from to) | |
70 "Compose Tai Viet characters in the region between FROM and TO." | |
71 (decompose-region from to) | |
72 (let ((normal-rule '(Br . Bl)) | |
73 (tone-rule '(tr . bl)) | |
74 (prev-viet nil) | |
75 ch info pos components overhang) | |
76 (while (< from to) | |
77 (or ch | |
78 (setq ch (char-after from) | |
79 info (aref tai-viet-glyph-info ch))) | |
80 (setq from (1+ from)) | |
81 (if (not info) | |
82 (setq prev-viet nil | |
83 ch nil) | |
84 (if (memq info '(combining-vowel combining-tone)) | |
85 (progn | |
86 ;; Display this as a spacing glyph. | |
87 (compose-region (1- from) from (string ?\t ch)) | |
88 (setq prev-viet t | |
89 ch nil)) | |
90 (setq pos (1- from) | |
91 components ch | |
92 overhang (if (eq info 'right-overhang) | |
93 'right-overhang | |
94 (if (and (not prev-viet) (eq info 'left-overhang)) | |
95 'left-overhang)) | |
96 prev-viet t | |
97 ch nil) | |
98 (if (and (< from to) | |
99 (setq ch (char-after from) | |
100 info (aref tai-viet-glyph-info ch))) | |
101 (if (memq info '(combining-vowel combining-tone)) | |
102 (progn | |
103 (setq components | |
104 (list components normal-rule ch) | |
105 from (1+ from) | |
106 ch nil) | |
107 (if (and (< from to) | |
108 (setq ch (char-after from) | |
109 info (aref tai-viet-glyph-info ch)) | |
110 (eq info 'combining-tone)) | |
111 (setq components (nconc components | |
112 (list tone-rule ch)) | |
113 from (1+ from))) | |
114 (if (eq overhang 'left-overhang) | |
115 (setq components (cons ?\t | |
116 (cons normal-rule components))) | |
117 (if (and (eq overhang 'right-overhang) | |
118 (>= from to)) | |
119 (setq components (nconc components | |
120 (list normal-rule ?\t))))) | |
121 (compose-region pos from components)) | |
122 (if (eq overhang 'left-overhang) | |
123 (compose-region pos from (string ?\t components)))) | |
124 (if (eq overhang 'left-overhang) | |
125 (compose-region pos from (string ?\t components)) | |
126 (if (and (eq overhang 'right-overhang) (>= from to)) | |
127 (compose-region pos from (string components ?\t)))))))) | |
128 from)) | |
129 | |
130 | |
131 ;;;###autoload | |
91277
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
132 (defun tai-viet-composition-function (from to font-object string) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
133 (if string |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
134 (if (string-match tai-viet-re string from) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
135 (tai-viet-compose-string from (match-end 0) string)) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
136 (goto-char from) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
137 (if (looking-at tai-viet-re) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
138 (tai-viet-compose-region from (match-end 0))))) |
90938 | 139 |
140 ;; | |
141 (provide 'tai-viet-util) | |
90950 | 142 |
143 ;; arch-tag: a45ac3fc-07d0-44d5-8841-2ebea7e11f5b |