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 MORIOKA Tomohiko
9 ;; Keywords: i18n, mule, internal
11 ;; This file is part of XEmacs.
13 ;; XEmacs is free software; you can redistribute it and/or modify it
14 ;; under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; XEmacs is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 ;; General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with XEmacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
28 ;;; Synched up with: Not synched. API at source level synched with FSF 20.3.9.
32 ;; These functions are not compatible at the bytecode level with Emacs/Mule,
33 ;; and they never will be. -sb [1999-05-26]
37 ;;;; Classifying text according to charsets
39 (defun charsets-in-region (start end &optional buffer)
40 "Return a list of the charsets in the region between START and END.
41 BUFFER defaults to the current buffer if omitted."
47 (narrow-to-region start end)
48 (goto-char (point-min))
51 (ch (char-after (point)))
52 (charset (char-charset ch)))
53 (if (not (eq prev-charset charset))
55 (setq prev-charset charset)
56 (or (memq charset list)
57 (setq list (cons charset list))))))
61 (defun charsets-in-string (string)
62 "Return a list of the charsets in STRING."
65 prev-charset charset list)
67 (setq charset (char-charset (aref string i)))
68 (if (not (eq prev-charset charset))
70 (setq prev-charset charset)
71 (or (memq charset list)
72 (setq list (cons charset list)))))
77 ;;;; Charset accessors
79 (defun charset-iso-graphic-plane (charset)
80 "Return the `graphic' property of CHARSET.
82 (charset-property charset 'graphic))
84 (defun charset-iso-final-char (charset)
85 "Return the final byte of the ISO 2022 escape sequence designating CHARSET."
86 (charset-property charset 'final))
88 (defun charset-chars (charset)
89 "Return the number of characters per dimension of CHARSET."
90 (charset-property charset 'chars))
92 (defun charset-width (charset)
93 "Return the number of display columns per character of CHARSET.
94 This only applies to TTY mode (under X, the actual display width can
95 be automatically determined)."
96 (charset-property charset 'columns))
98 ;; #### FSFmacs returns 0
99 (defun charset-direction (charset)
100 "Return the display direction (0 for `l2r' or 1 for `r2l') of CHARSET.
101 Only left-to-right is currently implemented."
102 (if (eq (charset-property charset 'direction) 'l2r)
107 (defun charset-registry (charset)
108 "Return the registry of CHARSET.
109 This is a regular expression matching the registry field of fonts
110 that can display the characters in CHARSET."
111 (charset-property charset 'registry))
113 (defun charset-ccl-program (charset)
114 "Return the CCL program of CHARSET.
116 (charset-property charset 'ccl-program))
118 (defun charset-bytes (charset)
119 "Useless in XEmacs, returns 1."
122 (define-obsolete-function-alias 'charset-columns 'charset-width) ;; 19990409
123 (define-obsolete-function-alias 'charset-final 'charset-iso-final-char) ;; 19990409
124 (define-obsolete-function-alias 'charset-graphic 'charset-iso-graphic-plane) ;; 19990409
125 (define-obsolete-function-alias 'charset-doc-string 'charset-description) ;; 19990409
127 ;;;; Define setf methods for all settable Charset properties
129 (defsetf charset-registry set-charset-registry)
130 (defsetf charset-ccl-program set-charset-ccl-program)
132 ;;; FSF compatibility functions
133 (defun charset-after (&optional pos)
134 "Return charset of a character in current buffer at position POS.
135 If POS is nil, it defauls to the current point.
136 If POS is out of range, the value is nil."
139 (check-argument-type 'integerp pos)
140 (unless (or (< pos (point-min))
142 (char-charset (char-after pos))))
145 ;; We're not going to support this.
146 ;(defun charset-info (charset)
147 ; "Return a vector of information of CHARSET.
148 ;The elements of the vector are:
149 ; CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
150 ; LEADING-CODE-BASE, LEADING-CODE-EXT,
151 ; ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
152 ; REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
155 ;CHARSET-ID (integer) is the identification number of the charset.
156 ;BYTES (integer) is the length of multi-byte form of a character in
157 ; the charset: one of 1, 2, 3, and 4.
158 ;DIMENSION (integer) is the number of bytes to represent a character of
159 ;the charset: 1 or 2.
160 ;CHARS (integer) is the number of characters in a dimension: 94 or 96.
161 ;WIDTH (integer) is the number of columns a character in the charset
162 ; occupies on the screen: one of 0, 1, and 2.
163 ;DIRECTION (integer) is the rendering direction of characters in the
164 ; charset when rendering. If 0, render from left to right, else
165 ; render from right to left.
166 ;LEADING-CODE-BASE (integer) is the base leading-code for the
168 ;LEADING-CODE-EXT (integer) is the extended leading-code for the
169 ; charset. All charsets of less than 0xA0 has the value 0.
170 ;ISO-FINAL-CHAR (character) is the final character of the
171 ; corresponding ISO 2022 charset.
172 ;ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
173 ; while encoding to variants of ISO 2022 coding system, one of the
174 ; following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
175 ;REVERSE-CHARSET (integer) is the charset which differs only in
176 ; LEFT-TO-RIGHT value from the charset. If there's no such a
177 ; charset, the value is -1.
178 ;SHORT-NAME (string) is the short name to refer to the charset.
179 ;LONG-NAME (string) is the long name to refer to the charset
180 ;DESCRIPTION (string) is the description string of the charset.
181 ;PLIST (property list) may contain any type of information a user
182 ; want to put and get by functions `put-charset-property' and
183 ; `get-charset-property' respectively."
185 ; (charset-id charset)
187 ; (charset-dimension charset)
188 ; (charset-chars charset)
189 ; (charset-width charset)
190 ; (charset-direction charset)
191 ; nil ;; (charset-leading-code-base (charset))
192 ; nil ;; (charset-leading-code-ext (charset))
193 ; (charset-iso-final-char charset)
194 ; (charset-iso-graphic-plane charset)
196 ; (charset-short-name charset)
197 ; (charset-long-name charset)
198 ; (charset-description charset)
199 ; (charset-plist charset)))
201 ;(make-compatible 'charset-info "Don't use this if you can help it.")
203 (defun define-charset (charset-id charset property-vector)
204 "Define CHARSET-ID as the identification number of CHARSET with INFO-VECTOR.
205 If CHARSET-ID is nil, it is decided automatically, which means CHARSET is
206 treated as a private charset.
207 INFO-VECTOR is a vector of the format:
208 [DIMENSION CHARS WIDTH DIRECTION ISO-FINAL-CHAR ISO-GRAPHIC-PLANE
209 SHORT-NAME LONG-NAME DESCRIPTION]
210 The meanings of each elements is as follows:
211 DIMENSION (integer) is the number of bytes to represent a character: 1 or 2.
212 CHARS (integer) is the number of characters in a dimension: 94 or 96.
213 WIDTH (integer) is the number of columns a character in the charset
214 occupies on the screen: one of 0, 1, and 2.
216 DIRECTION (integer) is the rendering direction of characters in the
217 charset when rendering. If 0, render from left to right, else
218 render from right to left.
220 ISO-FINAL-CHAR (character) is the final character of the
221 corresponding ISO 2022 charset.
223 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
224 while encoding to variants of ISO 2022 coding system, one of the
225 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
228 SHORT-NAME (string) is the short name to refer to the charset.
230 LONG-NAME (string) is the long name to refer to the charset.
232 DESCRIPTION (string) is the description string of the charset."
233 (make-charset charset (aref property-vector 8)
235 'short-name (aref property-vector 6)
236 'long-name (aref property-vector 7)
237 'dimension (aref property-vector 0)
238 'columns (aref property-vector 2)
239 'chars (aref property-vector 1)
240 'final (aref property-vector 4)
241 'graphic (aref property-vector 5)
242 'direction (aref property-vector 3))))
244 (make-compatible 'define-charset "")
248 (defalias 'get-charset-property 'get)
249 (defalias 'put-charset-property 'put)
250 (defalias 'charset-plist 'object-plist)
251 (defalias 'set-charset-plist 'setplist)
253 ;; Setup auto-fill-chars for charsets that should invoke auto-filling.
254 ;; SPACE and NEWLIE are already set.
255 ;; (let ((l '(katakana-jisx0201
256 ;; japanese-jisx0208 japanese-jisx0212
257 ;; chinese-gb2312 chinese-big5-1 chinese-big5-2)))
259 ;; (put-char-table (car l) t auto-fill-chars)
260 ;; (setq l (cdr l))))
263 ;;; @ Coded character set
266 (when (featurep 'utf-2000)
267 (setq default-coded-charset-priority-list
296 japanese-jisx0208-1978
327 =ucs-radicals@unicode
355 ;;; mule-charset.el ends here