diff options
| author | Kenichi Handa | 2000-10-31 04:17:17 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-10-31 04:17:17 +0000 |
| commit | dfc064f2b58b50b4c77f6c68b0f2ad8e2d51dc7f (patch) | |
| tree | de90329b2ee7114526938df2fb3d27a9fe9bf78e | |
| parent | d7a0fd0086f99da6a74c1d7b85dcb21cd1282627 (diff) | |
| download | emacs-dfc064f2b58b50b4c77f6c68b0f2ad8e2d51dc7f.tar.gz emacs-dfc064f2b58b50b4c77f6c68b0f2ad8e2d51dc7f.zip | |
(decode-mac-roman, encode-mac-roman, mac-roman): Moved to european.el.
(ccl-encode-mac-roman-font, fontset-mac): Modified for
mule-unicode-2500-33ff and mule-unicode-e000-ffff.
(mac-roman-kbd-insert, mac-roman-kbd-mode): These functions deleted.
(mac-roman-kbd-mode, mac-roman-kbd-mode-map): These variables deleted.
| -rw-r--r-- | lisp/term/mac-win.el | 134 |
1 files changed, 21 insertions, 113 deletions
diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el index c214b5f5336..9164d162f62 100644 --- a/lisp/term/mac-win.el +++ b/lisp/term/mac-win.el | |||
| @@ -170,77 +170,39 @@ Switch to a buffer editing the last file dropped." | |||
| 170 | (defconst kTextEncodingISOLatin1 513 "0x201") | 170 | (defconst kTextEncodingISOLatin1 513 "0x201") |
| 171 | (defconst kTextEncodingISOLatin2 514 "0x202") | 171 | (defconst kTextEncodingISOLatin2 514 "0x202") |
| 172 | 172 | ||
| 173 | ;; Definitions for the Mac Roman character sets and coding system. | ||
| 174 | ;; The Mac Roman encoding uses all 128 code points in the range 128 to | ||
| 175 | ;; 255 for actual characters. Since Emacs cannot handle this many | ||
| 176 | ;; code points as one character set, we divide it into two: | ||
| 177 | ;; mac-roman-lower for code points 128 to 159 and mac-roman-upper for | ||
| 178 | ;; code points 160 to 255. | ||
| 179 | |||
| 180 | ;; Since Mac Roman does not follow the ISO 2022 standard and uses code | ||
| 181 | ;; points in the range 128-159, it is necessary to define it as a | ||
| 182 | ;; type-4 charset, with CCL programs and all. | ||
| 183 | |||
| 184 | (define-ccl-program decode-mac-roman | ||
| 185 | `(2 | ||
| 186 | ((loop | ||
| 187 | (read r0) | ||
| 188 | (if (r0 < 128) ;; ASCII | ||
| 189 | (if (r0 == ?\r) ;; assume such a file uses Mac EOL's | ||
| 190 | (write-repeat ?\n) | ||
| 191 | (write-repeat r0)) | ||
| 192 | (if (r0 < 160) ;; lower | ||
| 193 | ((r0 += 32) | ||
| 194 | (r1 = ,(charset-id 'mac-roman-lower)) | ||
| 195 | (write-multibyte-character r1 r0) | ||
| 196 | (repeat)) | ||
| 197 | ((r1 = ,(charset-id 'mac-roman-upper)) ;; upper | ||
| 198 | (write-multibyte-character r1 r0) | ||
| 199 | (repeat))))))) | ||
| 200 | "CCL program to decode Mac Roman") | ||
| 201 | |||
| 202 | (define-ccl-program encode-mac-roman | ||
| 203 | `(1 | ||
| 204 | ((loop | ||
| 205 | (read-multibyte-character r0 r1) | ||
| 206 | (if (r0 == ,(charset-id 'ascii)) | ||
| 207 | (if (r1 == ?\n) | ||
| 208 | (write-repeat ?\r) | ||
| 209 | (write-repeat r1)) | ||
| 210 | (if (r0 == ,(charset-id 'mac-roman-lower)) | ||
| 211 | ((r1 += 96) | ||
| 212 | (write-repeat r1)) | ||
| 213 | (if (r0 == ,(charset-id 'mac-roman-upper)) | ||
| 214 | ((r1 += 128) | ||
| 215 | (write-repeat r1)))))))) | ||
| 216 | "CCL program to encode Mac Roman") | ||
| 217 | |||
| 218 | (make-coding-system | ||
| 219 | 'mac-roman 4 ?M "Mac Roman Encoding" | ||
| 220 | '(decode-mac-roman . encode-mac-roman) | ||
| 221 | '((safe-charsets ascii mac-roman-lower mac-roman-upper) | ||
| 222 | (valid codes (0 . 255)))) | ||
| 223 | |||
| 224 | ;; This doesn't seem to do anything for type-4 charsets: | ||
| 225 | ;; (put 'mac-roman 'eol-type (make-subsidiary-coding-system 'mac-roman)) | ||
| 226 | 173 | ||
| 227 | (define-ccl-program ccl-encode-mac-roman-font | 174 | (define-ccl-program ccl-encode-mac-roman-font |
| 228 | `(0 | 175 | `(0 |
| 229 | (if (r0 == ,(charset-id 'mac-roman-lower)) | 176 | (if (r0 != ,(charset-id 'ascii)) |
| 230 | (r1 += 96) | 177 | (if (r0 == ,(charset-id 'latin-iso8859-1)) |
| 231 | (r1 += 128)))) | 178 | (translate-character mac-roman-encoder r0 r1) |
| 179 | ((r1 <<= 7) | ||
| 180 | (r1 |= r2) | ||
| 181 | (translate-character mac-roman-encoder r0 r1))))) | ||
| 182 | "CCL program for Mac Roman font") | ||
| 232 | 183 | ||
| 233 | (setq font-ccl-encoder-alist | 184 | (setq font-ccl-encoder-alist |
| 234 | (cons '("mac-roman" . ccl-encode-mac-roman-font) | 185 | (cons '("mac-roman" . ccl-encode-mac-roman-font) |
| 235 | font-ccl-encoder-alist)) | 186 | font-ccl-encoder-alist)) |
| 236 | 187 | ||
| 188 | ;; Create a fontset that uses mac-roman font. With this fontset, | ||
| 189 | ;; characters decoded from mac-roman encoding (ascii, latin-iso8859-1, | ||
| 190 | ;; and mule-unicode-xxxx-yyyy) are displayed by a mac-roman font. | ||
| 191 | |||
| 237 | (if (fboundp 'new-fontset) | 192 | (if (fboundp 'new-fontset) |
| 238 | (progn | 193 | (progn |
| 239 | (create-fontset-from-fontset-spec | 194 | (create-fontset-from-fontset-spec |
| 240 | "-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-mac, | 195 | "-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-mac, |
| 241 | mac-roman-lower:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman, | 196 | ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman") |
| 242 | mac-roman-upper:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman" | 197 | (let ((monaco-font '("monaco" . "mac-roman"))) |
| 243 | t))) | 198 | (map-char-table |
| 199 | (function | ||
| 200 | (lambda (key val) | ||
| 201 | (or (generic-char-p key) | ||
| 202 | (memq (char-charset key) | ||
| 203 | '(ascii eight-bit-control eight-bit-graphic)) | ||
| 204 | (set-fontset-font "fontset-mac" key monaco-font)))) | ||
| 205 | (get 'mac-roman-encoder 'translation-table))))) | ||
| 244 | 206 | ||
| 245 | ;; To display filenames in Chinese or Japanese, replace mac-roman with | 207 | ;; To display filenames in Chinese or Japanese, replace mac-roman with |
| 246 | ;; big5 or sjis | 208 | ;; big5 or sjis |
| @@ -248,60 +210,6 @@ Switch to a buffer editing the last file dropped." | |||
| 248 | 210 | ||
| 249 | ;; (prefer-coding-system 'mac-roman) | 211 | ;; (prefer-coding-system 'mac-roman) |
| 250 | 212 | ||
| 251 | (defun mac-roman-kbd-insert () | ||
| 252 | "Insert a character in Mac Roman encoding at point.\n\ | ||
| 253 | Called by keymap of Mac-kbd minor mode." | ||
| 254 | (interactive "*") | ||
| 255 | (let ((ch last-command-char)) | ||
| 256 | (if (< ch 160) | ||
| 257 | (insert | ||
| 258 | (make-char 'mac-roman-lower | ||
| 259 | (- last-command-char 96))) | ||
| 260 | (insert | ||
| 261 | (make-char 'mac-roman-upper | ||
| 262 | (- last-command-char 128)))))) | ||
| 263 | |||
| 264 | (defvar mac-roman-kbd-mode nil | ||
| 265 | "Non-nil if in Mac-kbd minor mode.") | ||
| 266 | |||
| 267 | (put 'mac-roman-kbd-mode 'permanent-local t) | ||
| 268 | |||
| 269 | (or (assq 'mac-roman-kbd-mode minor-mode-alist) | ||
| 270 | (setq minor-mode-alist | ||
| 271 | (cons '(mac-roman-kbd-mode " Mac-kbd") minor-mode-alist))) | ||
| 272 | |||
| 273 | (defvar mac-roman-kbd-mode-map | ||
| 274 | (let ((map (make-keymap)) | ||
| 275 | (i 128)) | ||
| 276 | (while (< i 256) | ||
| 277 | (define-key map (vector i) 'mac-roman-kbd-insert) | ||
| 278 | (setq i (1+ i))) | ||
| 279 | map) | ||
| 280 | "Keymap for Mac-kbd minor mode.") | ||
| 281 | |||
| 282 | (or (assq 'mac-roman-kbd-mode minor-mode-map-alist) | ||
| 283 | (setq minor-mode-map-alist | ||
| 284 | (cons (cons 'mac-roman-kbd-mode mac-roman-kbd-mode-map) | ||
| 285 | minor-mode-map-alist))) | ||
| 286 | |||
| 287 | (defun mac-roman-kbd-mode (&optional arg) | ||
| 288 | "Toggle Mac Roman Keyboard (Mac-kbd) minor mode.\n\ | ||
| 289 | In this minor mode, characters in the range 128 to 255 generated by\n\ | ||
| 290 | the Mac keyboard are inserted as mac-roman-lower or mac-roman-upper\n\ | ||
| 291 | characters, in the mac-roman encoding.\n\ | ||
| 292 | \n\ | ||
| 293 | With an argument, a positive argument enables Mac Roman Keyboard mode,\n\ | ||
| 294 | and a negative argument disables it." | ||
| 295 | (interactive "P") | ||
| 296 | (if (if arg | ||
| 297 | ;; Negative arg means switch it off. | ||
| 298 | (<= (prefix-numeric-value arg) 0) | ||
| 299 | ;; No arg means toggle. | ||
| 300 | mac-roman-kbd-mode) | ||
| 301 | (setq mac-roman-kbd-mode nil) | ||
| 302 | ;; Enable mode. | ||
| 303 | (setq mac-roman-kbd-mode t))) | ||
| 304 | |||
| 305 | ;; | 213 | ;; |
| 306 | ;; Available colors | 214 | ;; Available colors |
| 307 | ;; | 215 | ;; |