| 1 |
;;; skk-tutcode.el --- assist TUT-code inputting in SKK environment -*- coding: iso-2022-jp -*- |
| 2 |
|
| 3 |
;; Copyright (C) 1999, 2000, 2001 GUNJI Takao <[email protected]> |
| 4 |
|
| 5 |
;; Author: GUNJI Takao <[email protected]> |
| 6 |
;; Maintainer: SKK Development Team |
| 7 |
;; URL: https://github.com/skk-dev/ddskk |
| 8 |
;; Keywords: japanese, mule, input method, TUT-code |
| 9 |
|
| 10 |
;; This file is part of Daredevil SKK. |
| 11 |
|
| 12 |
;; This program is free software: you can redistribute it and/or |
| 13 |
;; modify it under the terms of the GNU General Public License as |
| 14 |
;; published by the Free Software Foundation, either version 3 of |
| 15 |
;; the License, or (at your option) any later version. |
| 16 |
|
| 17 |
;; This program is distributed in the hope that it will be |
| 18 |
;; useful, but WITHOUT ANY WARRANTY; without even the implied |
| 19 |
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 |
;; PURPOSE. See the GNU General Public License for more details. |
| 21 |
|
| 22 |
;; You should have received a copy of the GNU General Public License |
| 23 |
;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 |
|
| 25 |
;;; Commentary: |
| 26 |
|
| 27 |
;; <INFORMATION> |
| 28 |
|
| 29 |
;; TUT-code was developed by Hajime Ohiwa <[email protected]> and |
| 30 |
;; Takaaki Takashima of Toyohashi University of Technology in 1982. |
| 31 |
;; TUT-code is a kind of direct input method of Japanese with two |
| 32 |
;; strokes. You can pronounce it `Tea You Tea' or `TUT' like |
| 33 |
;; Tutankamen's nickname, king `TUT'. |
| 34 |
|
| 35 |
;; At Mon, 23 Aug 1999 01:13:34 +0900, |
| 36 |
;; Hajime Ohiwa <[email protected]> wrote: |
| 37 |
|
| 38 |
;; > $B;d$O!V$F$#!<$f!<$F$#!<$3!<$I!W$HFI$s$G$$$^$9$,!"$b$&>/$78@$$0W$$J}$,(B |
| 39 |
;; > $B$h$$$H;W$$$^$9!#(BTUT$B$O$3$l$r3+H/$7$?K-665;=Q2J3XBg3X$NN,>N$G$9!#(B |
| 40 |
;; > $BJF9q?M$K8+$;$?$i!"!V$?$C$H!W$HFI$_$^$7$?!#$D$?$s$+!<$a$s2&$N$3$H$r1Q8l(B |
| 41 |
;; > $B$G$O(B king TUT $B$H8F$S!"H/2;$O!V$?$C$H!W$J$N$@$=$&$G$9!#!V$?$C$H$3!<$I!W(B |
| 42 |
;; > $B$NJ}$,$h$$$+$b$7$l$^$;$s!#8f0U8+$r$*J9$+$;2<$5$$!#(B |
| 43 |
|
| 44 |
;; To get more information, access following URL; |
| 45 |
;; http://www.crew.sfc.keio.ac.jp/~chk/ |
| 46 |
|
| 47 |
;; To join TUT-code mailing list, send mail like following; |
| 48 |
;; To: [email protected] |
| 49 |
;; Subject: APPEND |
| 50 |
;; Body: an introduction of yourself (null body is available). |
| 51 |
|
| 52 |
;; <INSTALL> |
| 53 |
|
| 54 |
;; Put the following lines in your .skk. |
| 55 |
|
| 56 |
;; (require 'skk-tutcdef) |
| 57 |
|
| 58 |
;; If you would like to customize some definitions in skk-tutcdef.el, |
| 59 |
;; you could do, for example; |
| 60 |
|
| 61 |
;; (require 'skk-tutcdef) |
| 62 |
;; ;; your customizations... |
| 63 |
;; (setq skk-rom-kana-rule-list |
| 64 |
;; '(...)) |
| 65 |
|
| 66 |
;; <TODO> |
| 67 |
;; - Efficient mazegaki (e.x. provided by T-code driver) support. |
| 68 |
;; - To switch easily okurigana prefix in jisyo buffer. |
| 69 |
|
| 70 |
;;; Code: |
| 71 |
|
| 72 |
(require 'skk) |
| 73 |
|
| 74 |
;;;###autoload |
| 75 |
(defgroup skk-tutcode nil "SKK/TUT-code related customization." |
| 76 |
:prefix "skk-tutcode-" |
| 77 |
:group 'skk-input-enhanced |
| 78 |
:group 'skk) |
| 79 |
|
| 80 |
;; all prefix of functions, variables and constants are |
| 81 |
;; `skk-tutcode-'. |
| 82 |
;;;###autoload |
| 83 |
(defcustom skk-tutcode-use-touch16+ nil |
| 84 |
"*Non-nil $B$G$"$l$P!"(BTouch16+ $B3HD%%3!<%I$rMxMQ$9$k!#(B" |
| 85 |
:type 'boolean |
| 86 |
:group 'skk-tutcode) |
| 87 |
|
| 88 |
;;;###autoload |
| 89 |
(defun skk-tutcode-mode-off (foo) |
| 90 |
(skk-latin-mode t) |
| 91 |
(skk-insert-str "\\")) |
| 92 |
|
| 93 |
;;;###autoload |
| 94 |
(defun skk-tutcode-display-code (&optional arg) |
| 95 |
;; adapted from skk-kcode.el |
| 96 |
"$B%]%$%s%H$K$"$kJ8;z$N(B EUC $B%3!<%I!"(BJIS $B%3!<%I!"(BTUT $B%3!<%I$rI=<($9$k!#(B" |
| 97 |
(interactive "P") |
| 98 |
(if (eobp) |
| 99 |
(skk-error "$B%+!<%=%k$,%P%C%U%!$N=*C<$K$"$j$^$9(B" |
| 100 |
"Cursor is at the end of the buffer") |
| 101 |
(skk-tutcode-display-code-1 |
| 102 |
(buffer-substring-no-properties |
| 103 |
(point) |
| 104 |
(skk-save-point (forward-char 1) (point)))) |
| 105 |
;; $B%(%3!<$7$?J8;zNs$r%+%l%s%H%P%C%U%!$KA^F~$7$J$$$h$&$K!#(B |
| 106 |
t)) |
| 107 |
|
| 108 |
(defun skk-tutcode-display-code-1 (str) |
| 109 |
(let* ((char (string-to-char str)) |
| 110 |
(charset (char-charset char)) |
| 111 |
(charset-list (if (charsetp 'japanese-jisx0213-1) |
| 112 |
'(japanese-jisx0213-1 |
| 113 |
japanese-jisx0213-2 |
| 114 |
japanese-jisx0208 |
| 115 |
japanese-jisx0208-1978) |
| 116 |
'(japanese-jisx0208 |
| 117 |
japanese-jisx0208-1978)))) |
| 118 |
(cond |
| 119 |
((memq charset charset-list) |
| 120 |
(let* ((char1-j (skk-char-octet char 0)) |
| 121 |
(char1-k (- char1-j 32)) |
| 122 |
(char1-e (+ char1-j 128)) |
| 123 |
(char2-j (skk-char-octet char 1)) |
| 124 |
(char2-k (- char2-j 32)) |
| 125 |
(char2-e (+ char2-j 128)) |
| 126 |
(char3 (skk-tutcode-get-code str))) |
| 127 |
(message |
| 128 |
"$B!X(B%s$B!Y(B EUC: %2x%2x (%3d, %3d), JIS: %2x%2x (%3d, %3d), KUTEN: (%2d, %2d), TUT: `%s'" |
| 129 |
str char1-e char2-e char1-e char2-e |
| 130 |
char1-j char2-j char1-j char2-j char1-k char2-k char3))) |
| 131 |
((memq charset '(ascii latin-jisx0201)) |
| 132 |
(message "\"%s\" %2x (%3d)" |
| 133 |
str (skk-char-octet char 0) (skk-char-octet char 0))) |
| 134 |
(t |
| 135 |
(skk-error "$BH=JL$G$-$J$$J8;z$G$9(B" |
| 136 |
"Cannot understand this character"))))) |
| 137 |
|
| 138 |
;; some new stuff |
| 139 |
(defun skk-tutcode-get-code (key) |
| 140 |
(let ((srkr-list skk-rom-kana-rule-list) (cont t) (val nil)) |
| 141 |
(while cont |
| 142 |
(if (null srkr-list) |
| 143 |
(setq cont nil) |
| 144 |
(if (listp (car (cdr (cdr (car srkr-list))))) |
| 145 |
(cond |
| 146 |
((string= key (car (car (cdr (cdr (car srkr-list)))))) |
| 147 |
(setq cont nil |
| 148 |
val (car (car srkr-list)))) |
| 149 |
((string= key (cdr (car (cdr (cdr (car srkr-list)))))) |
| 150 |
(setq cont nil |
| 151 |
val (car (car srkr-list)))) |
| 152 |
(t (setq srkr-list (cdr srkr-list)))) |
| 153 |
(cond |
| 154 |
((string= key (car (cdr (cdr (car srkr-list))))) |
| 155 |
(setq cont nil |
| 156 |
val (car (car srkr-list)))) |
| 157 |
(t (setq srkr-list (cdr srkr-list))))))) |
| 158 |
|
| 159 |
val)) |
| 160 |
|
| 161 |
(provide 'skk-tutcode) |
| 162 |
|
| 163 |
;; Local Variables: |
| 164 |
;; indent-tabs-mode: nil |
| 165 |
;; End: |
| 166 |
|
| 167 |
;;; skk-tutcode.el ends here |