1 ;;; mule-charset.el --- Charset functions for Mule.
3 ;; Copyright (C) 1992 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995 Amdahl Corporation.
5 ;; Copyright (C) 1996 Sun Microsystems.
6 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
7 ;; 2009, 2010, 2011, 2012 MORIOKA Tomohiko
10 ;; Keywords: i18n, mule, internal
12 ;; This file is part of XEmacs.
14 ;; XEmacs is free software; you can redistribute it and/or modify it
15 ;; under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
19 ;; XEmacs is distributed in the hope that it will be useful, but
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 ;; General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with XEmacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
29 ;;; Synched up with: Not synched. API at source level synched with FSF 20.3.9.
33 ;; These functions are not compatible at the bytecode level with Emacs/Mule,
34 ;; and they never will be. -sb [1999-05-26]
38 ;;;; Classifying text according to charsets
40 (defun charsets-in-region (start end &optional buffer)
41 "Return a list of the charsets in the region between START and END.
42 BUFFER defaults to the current buffer if omitted."
48 (narrow-to-region start end)
49 (goto-char (point-min))
52 (ch (char-after (point)))
53 (charset (char-charset ch)))
54 (if (not (eq prev-charset charset))
56 (setq prev-charset charset)
57 (or (memq charset list)
58 (setq list (cons charset list))))))
62 (defun charsets-in-string (string)
63 "Return a list of the charsets in STRING."
66 prev-charset charset list)
68 (setq charset (char-charset (aref string i)))
69 (if (not (eq prev-charset charset))
71 (setq prev-charset charset)
72 (or (memq charset list)
73 (setq list (cons charset list)))))
78 ;;;; Charset accessors
80 (defun charset-iso-graphic-plane (charset)
81 "Return the `graphic' property of CHARSET.
83 (charset-property charset 'graphic))
85 (defun charset-iso-final-char (charset)
86 "Return the final byte of the ISO 2022 escape sequence designating CHARSET."
87 (charset-property charset 'final))
89 (defun charset-chars (charset)
90 "Return the number of characters per dimension of CHARSET."
91 (charset-property charset 'chars))
93 (defun charset-width (charset)
94 "Return the number of display columns per character of CHARSET.
95 This only applies to TTY mode (under X, the actual display width can
96 be automatically determined)."
97 (charset-property charset 'columns))
99 ;; #### FSFmacs returns 0
100 (defun charset-direction (charset)
101 "Return the display direction (0 for `l2r' or 1 for `r2l') of CHARSET.
102 Only left-to-right is currently implemented."
103 (if (eq (charset-property charset 'direction) 'l2r)
108 (defun charset-registry (charset)
109 "Return the registry of CHARSET.
110 This is a regular expression matching the registry field of fonts
111 that can display the characters in CHARSET."
112 (charset-property charset 'registry))
114 (defun charset-ccl-program (charset)
115 "Return the CCL program of CHARSET.
117 (charset-property charset 'ccl-program))
119 (defun charset-bytes (charset)
120 "Useless in XEmacs, returns 1."
123 (define-obsolete-function-alias 'charset-columns 'charset-width) ;; 19990409
124 (define-obsolete-function-alias 'charset-final 'charset-iso-final-char) ;; 19990409
125 (define-obsolete-function-alias 'charset-graphic 'charset-iso-graphic-plane) ;; 19990409
126 (define-obsolete-function-alias 'charset-doc-string 'charset-description) ;; 19990409
128 ;;;; Define setf methods for all settable Charset properties
130 (defsetf charset-registry set-charset-registry)
131 (defsetf charset-ccl-program set-charset-ccl-program)
133 ;;; FSF compatibility functions
134 (defun charset-after (&optional pos)
135 "Return charset of a character in current buffer at position POS.
136 If POS is nil, it defauls to the current point.
137 If POS is out of range, the value is nil."
140 (check-argument-type 'integerp pos)
141 (unless (or (< pos (point-min))
143 (char-charset (char-after pos))))
146 ;; We're not going to support this.
147 ;(defun charset-info (charset)
148 ; "Return a vector of information of CHARSET.
149 ;The elements of the vector are:
150 ; CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
151 ; LEADING-CODE-BASE, LEADING-CODE-EXT,
152 ; ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
153 ; REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
156 ;CHARSET-ID (integer) is the identification number of the charset.
157 ;BYTES (integer) is the length of multi-byte form of a character in
158 ; the charset: one of 1, 2, 3, and 4.
159 ;DIMENSION (integer) is the number of bytes to represent a character of
160 ;the charset: 1 or 2.
161 ;CHARS (integer) is the number of characters in a dimension: 94 or 96.
162 ;WIDTH (integer) is the number of columns a character in the charset
163 ; occupies on the screen: one of 0, 1, and 2.
164 ;DIRECTION (integer) is the rendering direction of characters in the
165 ; charset when rendering. If 0, render from left to right, else
166 ; render from right to left.
167 ;LEADING-CODE-BASE (integer) is the base leading-code for the
169 ;LEADING-CODE-EXT (integer) is the extended leading-code for the
170 ; charset. All charsets of less than 0xA0 has the value 0.
171 ;ISO-FINAL-CHAR (character) is the final character of the
172 ; corresponding ISO 2022 charset.
173 ;ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
174 ; while encoding to variants of ISO 2022 coding system, one of the
175 ; following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
176 ;REVERSE-CHARSET (integer) is the charset which differs only in
177 ; LEFT-TO-RIGHT value from the charset. If there's no such a
178 ; charset, the value is -1.
179 ;SHORT-NAME (string) is the short name to refer to the charset.
180 ;LONG-NAME (string) is the long name to refer to the charset
181 ;DESCRIPTION (string) is the description string of the charset.
182 ;PLIST (property list) may contain any type of information a user
183 ; want to put and get by functions `put-charset-property' and
184 ; `get-charset-property' respectively."
186 ; (charset-id charset)
188 ; (charset-dimension charset)
189 ; (charset-chars charset)
190 ; (charset-width charset)
191 ; (charset-direction charset)
192 ; nil ;; (charset-leading-code-base (charset))
193 ; nil ;; (charset-leading-code-ext (charset))
194 ; (charset-iso-final-char charset)
195 ; (charset-iso-graphic-plane charset)
197 ; (charset-short-name charset)
198 ; (charset-long-name charset)
199 ; (charset-description charset)
200 ; (charset-plist charset)))
202 ;(make-compatible 'charset-info "Don't use this if you can help it.")
204 (defun define-charset (charset-id charset property-vector)
205 "Define CHARSET-ID as the identification number of CHARSET with INFO-VECTOR.
206 If CHARSET-ID is nil, it is decided automatically, which means CHARSET is
207 treated as a private charset.
208 INFO-VECTOR is a vector of the format:
209 [DIMENSION CHARS WIDTH DIRECTION ISO-FINAL-CHAR ISO-GRAPHIC-PLANE
210 SHORT-NAME LONG-NAME DESCRIPTION]
211 The meanings of each elements is as follows:
212 DIMENSION (integer) is the number of bytes to represent a character: 1 or 2.
213 CHARS (integer) is the number of characters in a dimension: 94 or 96.
214 WIDTH (integer) is the number of columns a character in the charset
215 occupies on the screen: one of 0, 1, and 2.
217 DIRECTION (integer) is the rendering direction of characters in the
218 charset when rendering. If 0, render from left to right, else
219 render from right to left.
221 ISO-FINAL-CHAR (character) is the final character of the
222 corresponding ISO 2022 charset.
224 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
225 while encoding to variants of ISO 2022 coding system, one of the
226 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
229 SHORT-NAME (string) is the short name to refer to the charset.
231 LONG-NAME (string) is the long name to refer to the charset.
233 DESCRIPTION (string) is the description string of the charset."
234 (make-charset charset (aref property-vector 8)
236 'short-name (aref property-vector 6)
237 'long-name (aref property-vector 7)
238 'dimension (aref property-vector 0)
239 'columns (aref property-vector 2)
240 'chars (aref property-vector 1)
241 'final (aref property-vector 4)
242 'graphic (aref property-vector 5)
243 'direction (aref property-vector 3))))
245 (make-compatible 'define-charset "")
249 (defalias 'get-charset-property 'get)
250 (defalias 'put-charset-property 'put)
251 (defalias 'charset-plist 'object-plist)
252 (defalias 'set-charset-plist 'setplist)
254 ;; Setup auto-fill-chars for charsets that should invoke auto-filling.
255 ;; SPACE and NEWLIE are already set.
256 ;; (let ((l '(katakana-jisx0201
257 ;; japanese-jisx0208 japanese-jisx0212
258 ;; chinese-gb2312 chinese-big5-1 chinese-big5-2)))
260 ;; (put-char-table (car l) t auto-fill-chars)
261 ;; (setq l (cdr l))))
264 ;;; @ Coded character set
267 (when (featurep 'utf-2000)
268 (setq default-coded-charset-priority-list
285 =ucs-radicals@unicode
288 =ucs-bmp-cjk@JP/hanazono
290 =ucs-bmp-cjk-compat@unicode
291 japanese-jisx0208-1978
378 =>ucs-bmp-cjk@unicode
379 =+>ucs-bmp-cjk@unicode
389 ;;; mule-charset.el ends here