Mercurial > hg > xemacs-beta
comparison lisp/mule/mule-charset.el @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | 2f8bb876ab1d |
children | da8ed4261e83 |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
1 ;;; mule-charset.el --- Charset functions for Mule. | 1 ;;; mule-charset.el --- Charset functions for Mule. |
2 | |
3 ;; Copyright (C) 1992 Free Software Foundation, Inc. | 2 ;; Copyright (C) 1992 Free Software Foundation, Inc. |
4 ;; Copyright (C) 1995 Amdahl Corporation. | 3 ;; Copyright (C) 1995 Amdahl Corporation. |
5 ;; Copyright (C) 1996 Sun Microsystems. | 4 ;; Copyright (C) 1996 Sun Microsystems. |
6 | |
7 ;; Author: Unknown | |
8 ;; Keywords: i18n, mule, internal | |
9 | 5 |
10 ;; This file is part of XEmacs. | 6 ;; This file is part of XEmacs. |
11 | 7 |
12 ;; XEmacs is free software; you can redistribute it and/or modify it | 8 ;; 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 | 9 ;; under the terms of the GNU General Public License as published by |
22 ;; You should have received a copy of the GNU General Public License | 18 ;; 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 | 19 ;; along with XEmacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
25 ;; Boston, MA 02111-1307, USA. | 21 ;; Boston, MA 02111-1307, USA. |
26 | 22 |
27 ;;; Synched up with: Not synched. API at source level synched with FSF 20.3.9. | 23 |
24 ;;;; Composite character support | |
28 | 25 |
29 ;;; Commentary: | 26 (defun compose-region (start end &optional buffer) |
27 "Compose characters in the current region into one composite character. | |
28 From a Lisp program, pass two arguments, START to END. | |
29 The composite character replaces the composed characters. | |
30 BUFFER defaults to the current buffer if omitted." | |
31 (interactive "r") | |
32 (let ((ch (make-composite-char (buffer-substring start end buffer)))) | |
33 (delete-region start end buffer) | |
34 (insert-char ch nil nil buffer))) | |
30 | 35 |
31 ;; These functions are not compatible at the bytecode level with Emacs/Mule, | 36 (defun decompose-region (start end &optional buffer) |
32 ;; and they never will be. -sb [1999-05-26] | 37 "Decompose any composite characters in the current region. |
38 From a Lisp program, pass two arguments, START to END. | |
39 This converts each composite character into one or more characters, | |
40 the individual characters out of which the composite character was formed. | |
41 Non-composite characters are left as-is. BUFFER defaults to the current | |
42 buffer if omitted." | |
43 (interactive "r") | |
44 (save-excursion | |
45 (set-buffer buffer) | |
46 (save-restriction | |
47 (narrow-to-region start end) | |
48 (goto-char (point-min)) | |
49 (let ((compcharset (get-charset 'composite))) | |
50 (while (< (point) (point-max)) | |
51 (let ((ch (char-after (point)))) | |
52 (if (eq compcharset (char-charset ch)) | |
53 (progn | |
54 (delete-char 1) | |
55 (insert (composite-char-string ch)))))))))) | |
33 | 56 |
34 ;;; Code: | |
35 | 57 |
36 ;;;; Classifying text according to charsets | 58 ;;;; Classifying text according to charsets |
37 | 59 |
38 (defun charsets-in-region (start end &optional buffer) | 60 (defun charsets-in-region (start end &optional buffer) |
39 "Return a list of the charsets in the region between START and END. | 61 "Return a list of the charsets in the region between START and END. |
92 "Return the number of display columns per character of CHARSET. | 114 "Return the number of display columns per character of CHARSET. |
93 This only applies to TTY mode (under X, the actual display width can | 115 This only applies to TTY mode (under X, the actual display width can |
94 be automatically determined)." | 116 be automatically determined)." |
95 (charset-property charset 'columns)) | 117 (charset-property charset 'columns)) |
96 | 118 |
97 ;; #### FSFmacs returns 0 | |
98 (defun charset-direction (charset) | 119 (defun charset-direction (charset) |
99 "Return the display direction (0 for `l2r' or 1 for `r2l') of CHARSET. | 120 "Return the display direction (`l2r' or `r2l') of CHARSET." |
100 Only left-to-right is currently implemented." | 121 (charset-property charset 'direction)) |
101 (if (eq (charset-property charset 'direction) 'l2r) | |
102 0 | |
103 1)) | |
104 | 122 |
105 ;; Not in Emacs/Mule | |
106 (defun charset-registry (charset) | 123 (defun charset-registry (charset) |
107 "Return the registry of CHARSET. | 124 "Return the registry of CHARSET. |
108 This is a regular expression matching the registry field of fonts | 125 This is a regular expression matching the registry field of fonts |
109 that can display the characters in CHARSET." | 126 that can display the characters in CHARSET." |
110 (charset-property charset 'registry)) | 127 (charset-property charset 'registry)) |
125 | 142 |
126 ;;;; Define setf methods for all settable Charset properties | 143 ;;;; Define setf methods for all settable Charset properties |
127 | 144 |
128 (defsetf charset-registry set-charset-registry) | 145 (defsetf charset-registry set-charset-registry) |
129 (defsetf charset-ccl-program set-charset-ccl-program) | 146 (defsetf charset-ccl-program set-charset-ccl-program) |
130 | |
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." | |
136 (when (null pos) | |
137 (setq pos (point))) | |
138 (check-argument-type 'integerp pos) | |
139 (unless (or (< pos (point-min)) | |
140 (> pos (point-max))) | |
141 (char-charset (char-after pos)))) | |
142 | |
143 ;; Yuck! | |
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, | |
152 ; PLIST, | |
153 ;where | |
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 | |
166 ; charset. | |
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." | |
183 ; (vector | |
184 ; (charset-id charset) | |
185 ; 1 | |
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) | |
194 ; -1 | |
195 ; (charset-short-name charset) | |
196 ; (charset-long-name charset) | |
197 ; (charset-description charset) | |
198 ; (charset-plist charset))) | |
199 | |
200 ;(make-compatible 'charset-info "Don't use this if you can help it.") | |
201 | |
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. | |
214 | |
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. | |
218 | |
219 ISO-FINAL-CHAR (character) is the final character of the | |
220 corresponding ISO 2022 charset. | |
221 | |
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). | |
225 | |
226 | |
227 SHORT-NAME (string) is the short name to refer to the charset. | |
228 | |
229 LONG-NAME (string) is the long name to refer to the charset. | |
230 | |
231 DESCRIPTION (string) is the description string of the charset." | |
232 (make-charset charset (aref property-vector 8) | |
233 (list | |
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)))) | |
242 | |
243 (make-compatible 'define-charset "") | |
244 | |
245 ;;; Charset property | |
246 | |
247 (defalias 'get-charset-property 'get) | |
248 (defalias 'put-charset-property 'put) | |
249 (defalias 'charset-plist 'object-plist) | |
250 (defalias 'set-charset-plist 'setplist) | |
251 | |
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))) | |
257 (while l | |
258 (put-char-table (car l) t auto-fill-chars) | |
259 (setq l (cdr l)))) | |
260 | |
261 ;;; mule-charset.el ends here |