Commit 92a607bd authored by YAMAMOTO Mitsuharu's avatar YAMAMOTO Mitsuharu
Browse files

(kTextEncodingMacRoman, kTextEncodingISOLatin1)

(kTextEncodingISOLatin2): Remove constants.
(mac-script-code-coding-systems): New constant.
(mac-handle-language-change): New function.
(special-event-map): Bind it to `language-change' event.
(mac-centraleurroman, mac-cyrillic): New coding systems.
(mac-font-encoder-list, ccl-encode-mac-centraleurroman-font)
(ccl-encode-mac-cyrillic-font): Rename mac-centraleurroman-encoder and
mac-cyrillic-encoder to encode-mac-centraleurroman and
encode-mac-cyrillic, respectively.
parent 9c5501d9
......@@ -1085,13 +1085,29 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
(put 'escape 'ascii-character ?\e)
;;;; Keysyms
;; Define constant values to be set to mac-keyboard-text-encoding
(defconst kTextEncodingMacRoman 0)
(defconst kTextEncodingISOLatin1 513 "0x201")
(defconst kTextEncodingISOLatin2 514 "0x202")
;;;; Keyboard layout/language change events
(defconst mac-script-code-coding-systems
'((0 . mac-roman) ; smRoman
(1 . japanese-shift-jis) ; smJapanese
(2 . chinese-big5) ; smTradChinese
(3 . korean-iso-8bit) ; smKorean
(7 . mac-cyrillic) ; smCyrillic
(25 . chinese-iso-8bit) ; smSimpChinese
(29 . mac-centraleurroman) ; smCentralEuroRoman
)
"Alist of Mac script codes vs Emacs coding systems.")
;;;; Keyboard layout/language change events
(defun mac-handle-language-change (event)
(interactive "e")
(let ((coding-system
(cdr (assq (car (cadr event)) mac-script-code-coding-systems))))
(set-keyboard-coding-system (or coding-system 'mac-roman))
;; MacJapanese maps reverse solidus to ?\x80.
(if (eq coding-system 'japanese-shift-jis)
(define-key key-translation-map [?\x80] "\\"))))
(define-key special-event-map [language-change] 'mac-handle-language-change)
;;;; Selections and cut buffers
......@@ -1139,21 +1155,14 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
(setq frame-creation-function 'x-create-frame-with-faces)
(define-ccl-program ccl-encode-mac-roman-font
`(0
(if (r0 != ,(charset-id 'ascii))
(if (r0 <= ?\x8f)
(translate-character mac-roman-encoder r0 r1)
((r1 <<= 7)
(r1 |= r2)
(translate-character mac-roman-encoder r0 r1)))))
"CCL program for Mac Roman font")
(let
((encoding-vector (make-vector 256 nil))
(i 0)
(vec ;; mac-centraleurroman (128..255) -> UCS mapping
[ #x00C4 ;; 128:LATIN CAPITAL LETTER A WITH DIAERESIS
(cp-make-coding-system
mac-centraleurroman
(apply
'vector
(mapcar
(lambda (c) (decode-char 'ucs c))
;; mac-centraleurroman (128..255) -> UCS mapping
[ #x00C4 ;; 128:LATIN CAPITAL LETTER A WITH DIAERESIS
#x0100 ;; 129:LATIN CAPITAL LETTER A WITH MACRON
#x0101 ;; 130:LATIN SMALL LETTER A WITH MACRON
#x00C9 ;; 131:LATIN CAPITAL LETTER E WITH ACUTE
......@@ -1281,26 +1290,18 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
#x017C ;; 253:LATIN SMALL LETTER Z WITH DOT ABOVE
#x0122 ;; 254:LATIN CAPITAL LETTER G WITH CEDILLA
#x02C7 ;; 255:CARON
])
translation-table)
(while (< i 128)
(aset encoding-vector i i)
(setq i (1+ i)))
(while (< i 256)
(aset encoding-vector i
(decode-char 'ucs (aref vec (- i 128))))
(setq i (1+ i)))
(setq translation-table
(make-translation-table-from-vector encoding-vector))
;; (define-translation-table 'mac-centraleurroman-decoder translation-table)
(define-translation-table 'mac-centraleurroman-encoder
(char-table-extra-slot translation-table 0)))
(let
((encoding-vector (make-vector 256 nil))
(i 0)
(vec ;; mac-cyrillic (128..255) -> UCS mapping
[ #x0410 ;; 128:CYRILLIC CAPITAL LETTER A
]))
"Mac Central European Roman Encoding (MIME:x-mac-centraleurroman).")
(coding-system-put 'mac-centraleurroman 'mime-charset 'x-mac-centraleurroman)
(cp-make-coding-system
mac-cyrillic
(apply
'vector
(mapcar
(lambda (c) (decode-char 'ucs c))
;; mac-cyrillic (128..255) -> UCS mapping
[ #x0410 ;; 128:CYRILLIC CAPITAL LETTER A
#x0411 ;; 129:CYRILLIC CAPITAL LETTER BE
#x0412 ;; 130:CYRILLIC CAPITAL LETTER VE
#x0413 ;; 131:CYRILLIC CAPITAL LETTER GHE
......@@ -1428,27 +1429,16 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
#x044D ;; 253:CYRILLIC SMALL LETTER E
#x044E ;; 254:CYRILLIC SMALL LETTER YU
#x20AC ;; 255:EURO SIGN
])
translation-table)
(while (< i 128)
(aset encoding-vector i i)
(setq i (1+ i)))
(while (< i 256)
(aset encoding-vector i
(decode-char 'ucs (aref vec (- i 128))))
(setq i (1+ i)))
(setq translation-table
(make-translation-table-from-vector encoding-vector))
;; (define-translation-table 'mac-cyrillic-decoder translation-table)
(define-translation-table 'mac-cyrillic-encoder
(char-table-extra-slot translation-table 0)))
]))
"Mac Cyrillic Encoding (MIME:x-mac-cyrillic).")
(coding-system-put 'mac-cyrillic 'mime-charset 'x-mac-cyrillic)
(defvar mac-font-encoder-list
'(("mac-roman" mac-roman-encoder
ccl-encode-mac-roman-font "%s")
("mac-centraleurroman" mac-centraleurroman-encoder
("mac-centraleurroman" encode-mac-centraleurroman
ccl-encode-mac-centraleurroman-font "%s ce")
("mac-cyrillic" mac-cyrillic-encoder
("mac-cyrillic" encode-mac-cyrillic
ccl-encode-mac-cyrillic-font "%s cy")))
(let ((encoder-list
......@@ -1468,24 +1458,34 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
(if mac-encoded
(aset table c mac-encoded))))))))
(define-ccl-program ccl-encode-mac-roman-font
`(0
(if (r0 != ,(charset-id 'ascii))
(if (r0 <= ?\x8f)
(translate-character mac-roman-encoder r0 r1)
((r1 <<= 7)
(r1 |= r2)
(translate-character mac-roman-encoder r0 r1)))))
"CCL program for Mac Roman font")
(define-ccl-program ccl-encode-mac-centraleurroman-font
`(0
(if (r0 != ,(charset-id 'ascii))
(if (r0 <= ?\x8f)
(translate-character mac-centraleurroman-encoder r0 r1)
(translate-character encode-mac-centraleurroman r0 r1)
((r1 <<= 7)
(r1 |= r2)
(translate-character mac-centraleurroman-encoder r0 r1)))))
(translate-character encode-mac-centraleurroman r0 r1)))))
"CCL program for Mac Central European Roman font")
(define-ccl-program ccl-encode-mac-cyrillic-font
`(0
(if (r0 != ,(charset-id 'ascii))
(if (r0 <= ?\x8f)
(translate-character mac-cyrillic-encoder r0 r1)
(translate-character encode-mac-cyrillic r0 r1)
((r1 <<= 7)
(r1 |= r2)
(translate-character mac-cyrillic-encoder r0 r1)))))
(translate-character encode-mac-cyrillic r0 r1)))))
"CCL program for Mac Cyrillic font")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment