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