annotate lisp/language/tv-util.el @ 111861:869f03cdb254

Fix bug #1077 with popping new frames from a minibuffer-only frame. menu-bar.el (menu-bar-frame-for-menubar, menu-bar-positive-p): New functions. (menu-bar-showhide-menu) <menu-bar-mode, showhide-tool-bar>: Use them instead of `nil' and `>', respectively. (menu-bar-showhide-tool-bar-menu): Use menu-bar-frame-for-menubar instead of `nil'. (toggle-menu-bar-mode-from-frame): Use menu-bar-frame-for-menubar and menu-bar-positive-p instead of `nil' and `>', respectively.
author Eli Zaretskii <eliz@gnu.org>
date Thu, 09 Dec 2010 21:07:53 +0200
parents 5b6eec51e45e
children 417b1e4d63cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 ;;; tv-util.el --- support for Tai Viet -*- coding: utf-8 -*-
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
3 ;; Copyright (C) 2007, 2008, 2009, 2010
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 ;; National Institute of Advanced Industrial Science and Technology (AIST)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5 ;; Registration Number H13PRO009
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7 ;; Keywords: multilingual, Tai Viet, i18n
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
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
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
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
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
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
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24 ;;; Code
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26 ;; Regexp matching with a sequence of Tai Viet characters.
109365
5b6eec51e45e * language/tv-util.el (tai-viet-re): Remove format.
Andreas Schwab <schwab@linux-m68k.org>
parents: 106815
diff changeset
27 (defconst tai-viet-re "[\xaa80-\xaac2\xaadb-\xaadf]+")
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 ;; Char-table of information about glyph type of Tai Viet characters.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 (defconst tai-viet-glyph-info
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 (let ((table (make-char-table nil))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 (specials '((right-overhang . "ꪊꪋꪌꪍꪏꪓꪖꪜꪞꪡꪤꪨ")
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 (left-overhang . "ꫂ")
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 (combining-vowel . "ꪴꪰꪲꪳꪷꪸꪾ")
91217
9cf3b1c148b9 (tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents: 90950
diff changeset
35 (combining-tone . "꪿꫁")
9cf3b1c148b9 (tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents: 90950
diff changeset
36 (misc . "-"))))
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 ;; Set all TaiViet characters to `t'.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38 (set-char-table-range table (cons #xaa80 #xaac2) t)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 (set-char-table-range table (cons #xaadb #xaadf) t)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 ;; Overwrite it for special characters.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 (dolist (elt specials)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42 (let ((category (car elt))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43 (chars (cdr elt)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 (dotimes (i (length chars))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 (aset table (aref chars i) category))))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 table))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 (defun tai-viet-compose-string (from to string)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 "Compose Tai Viet characters in STRING between indices FROM and TO."
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50 (let* ((ch (aref string from))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 (info (aref tai-viet-glyph-info ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 prev-info)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53 (if (eq info 'non-spacing)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54 (compose-string string from (1+ from) (string ch ?\t)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
55 (setq from (1+ from) prev-info info)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56 (while (and (< from to)
90949
bba587c2b334 *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 90938
diff changeset
57 (>= #xaa80 (setq ch (aref string from)))
bba587c2b334 *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 90938
diff changeset
58 (<= #xaaDF ch))
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59 (setq info (aref tai-viet-glyph-info ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 (if (and (eq info 'non-spacing)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61 (eq prev-info 'non-spacing))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 (compose-string from (1+ from) (string ?\t ch)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63 (setq from (1+ from) prev-info info))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64 (if (eq info 'right-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65 (compose-string string (1- from) from (string ch ?\t)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 from))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68 (defun tai-viet-compose-region (from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 "Compose Tai Viet characters in the region between FROM and TO."
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70 (decompose-region from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71 (let ((normal-rule '(Br . Bl))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 (tone-rule '(tr . bl))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73 (prev-viet nil)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 ch info pos components overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75 (while (< from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76 (or ch
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 (setq ch (char-after from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 info (aref tai-viet-glyph-info ch)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 (setq from (1+ from))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 (if (not info)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 (setq prev-viet nil
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 ch nil)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 (if (memq info '(combining-vowel combining-tone))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 (progn
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85 ;; Display this as a spacing glyph.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 (compose-region (1- from) from (string ?\t ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 (setq prev-viet t
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 ch nil))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 (setq pos (1- from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 components ch
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 overhang (if (eq info 'right-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 'right-overhang
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 (if (and (not prev-viet) (eq info 'left-overhang))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 'left-overhang))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 prev-viet t
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 ch nil)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 (if (and (< from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 (setq ch (char-after from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 info (aref tai-viet-glyph-info ch)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 (if (memq info '(combining-vowel combining-tone))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 (progn
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 (setq components
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103 (list components normal-rule ch)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
104 from (1+ from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 ch nil)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
106 (if (and (< from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107 (setq ch (char-after from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
108 info (aref tai-viet-glyph-info ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
109 (eq info 'combining-tone))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
110 (setq components (nconc components
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
111 (list tone-rule ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112 from (1+ from)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
113 (if (eq overhang 'left-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
114 (setq components (cons ?\t
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
115 (cons normal-rule components)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116 (if (and (eq overhang 'right-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117 (>= from to))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
118 (setq components (nconc components
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 (list normal-rule ?\t)))))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120 (compose-region pos from components))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121 (if (eq overhang 'left-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
122 (compose-region pos from (string ?\t components))))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
123 (if (eq overhang 'left-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
124 (compose-region pos from (string ?\t components))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
125 (if (and (eq overhang 'right-overhang) (>= from to))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
126 (compose-region pos from (string components ?\t))))))))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
127 from))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
128
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
129
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
130 ;;;###autoload
91277
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
131 (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
132 (if string
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
133 (if (string-match tai-viet-re string from)
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
134 (tai-viet-compose-string from (match-end 0) string))
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
135 (goto-char from)
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
136 (if (looking-at tai-viet-re)
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
137 (tai-viet-compose-region from (match-end 0)))))
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
138
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
139 ;;
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
140 (provide 'tai-viet-util)
90950
8568c29985a3 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90949
diff changeset
141
8568c29985a3 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90949
diff changeset
142 ;; arch-tag: a45ac3fc-07d0-44d5-8841-2ebea7e11f5b