1 ;;; skk-cursor.el --- SKK cursor control.
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Masatake YAMATO <masata-y@is.aist-nara.ac.jp>
5 ;; Author: Masatake YAMATO <masata-y@is.aist-nara.ac.jp>
6 ;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
7 ;; Version: $Id: skk-cursor.el,v 1.2 2000-11-08 01:51:43 youngs Exp $
9 ;; Last Modified: $Date: 2000-11-08 01:51:43 $
11 ;; This file is part of SKK.
13 ;; SKK is free software; you can redistribute it and/or modify it under
14 ;; the terms of the GNU General Public License as published by the Free
15 ;; Software Foundation; either versions 2, or (at your option) any later
18 ;; SKK is distributed in the hope that it will be useful but WITHOUT
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
21 ;; License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with SKK, see the file COPYING. If not, write to the Free
25 ;; Software Foundation Inc., 59 Temple Place - Suite 330, Boston,
26 ;; MA 02111-1307, USA.
30 ;; [Todo] Use `skk-cursor-' prefix for all variables and functions.
31 ;; skk-default-cursor-color -> skk-cursor-default-color
32 ;; skk-jisx0208-latin-cursor-color -> skk-cursor-jisx0208-latin-color
33 ;; skk-katakana-cursor-color -> skk-cursor-katakana-color
34 ;; skk-hiragana-cursor-color -> skk-cursor-hiragana-color
35 ;; skk-latin-cursor-color -> skk-cursor-latin-color
38 (eval-when-compile (require 'static) (require 'skk-foreword))
41 ;;
\e$BJQ?tL>$N
\e(B prefix
\e$B$r
\e(B skk-cursor-
\e$B$KE}0l$9$l$P$3$N%0%k!<%W$,@8$-$F$/$k$s$@$,
\e(B...
42 ;; 10.x
\e$B$O$3$l0J>eJQ?tL>$rJQ99$7$J$$J}$,NI$$$H;W$&$N$G!"$3$N$^$^$K$7$F$*$/!#
\e(B
43 ;;(defgroup skk-cursor nil "SKK cursor related customization."
47 (defcustom skk-default-cursor-color
48 (if (eq skk-emacs-type 'xemacs)
49 (frame-property (selected-frame) 'cursor-color)
50 (cdr (assq 'cursor-color (frame-parameters (selected-frame)))))
51 "*SKK
\e$B$N%*%U$r<($9%+!<%=%k?'!#
\e(B
52 skk-use-color-cursor
\e$B$,
\e(B non-nil
\e$B$N$H$-$K;HMQ$5$l$k!#
\e(B"
55 (defcustom skk-hiragana-cursor-color (if (eq skk-background-mode 'light)
58 "*
\e$B$+$J%b!<%I$r<($9%+!<%=%k?'!#
\e(B
59 skk-use-color-cursor
\e$B$,
\e(B non-nil
\e$B$N$H$-$K;HMQ$5$l$k!#
\e(B"
63 (defcustom skk-katakana-cursor-color (if (eq skk-background-mode 'light)
66 "*
\e$B%+%?%+%J%b!<%I$r<($9%+!<%=%k?'!#
\e(B
67 skk-use-color-cursor
\e$B$,
\e(B non-nil
\e$B$N$H$-$K;HMQ$5$l$k!#
\e(B"
71 (defcustom skk-jisx0208-latin-cursor-color "gold"
72 "*
\e$BA43Q1Q;z%b!<%I$r<($9%+!<%=%k?'!#
\e(B
73 skk-use-color-cursor
\e$B$,
\e(B non-nil
\e$B$N$H$-$K;HMQ$5$l$k!#
\e(B"
77 (defcustom skk-latin-cursor-color (if (eq skk-background-mode 'light)
80 "*
\e$B%"%9%-!<%b!<%I$r<($9%+!<%=%k?'!#
\e(B
81 skk-use-color-cursor
\e$B$,
\e(B non-nil
\e$B$N$H$-$K;HMQ$5$l$k!#
\e(B"
85 (defcustom skk-abbrev-cursor-color "royalblue"
86 "*abbrev
\e$B%b!<%I$r<($9%+!<%=%k?'!#
\e(B
87 skk-use-color-cursor
\e$B$,
\e(B non-nil
\e$B$N$H$-$K;HMQ$5$l$k!#
\e(B"
91 (defcustom skk-report-set-cursor-error t
92 "*Non-nil
\e$B$G$"$l$P!"%+%i!<%^%C%W@Z$l$,5/$-$?>l9g!"%(%i!<%a%C%;!<%8$rI=<($9$k!#
\e(B
93 nil
\e$B$G$"$l$P!"I=<($7$J$$!#
\e(B"
98 (defun skk-cursor-set-color (color)
99 ;;
\e$B%+!<%=%k$N?'$r
\e(B COLOR
\e$B$KJQ99$9$k!#
\e(B
101 (set-cursor-color color)
103 (set-cursor-color skk-default-cursor-color)
104 (and skk-report-set-cursor-error
106 "
\e$B%+%i!<%^%C%W@Z$l$G$9!#%G%#%U%)%k%H$N%+%i!<$r;H$$$^$9!#
\e(B"
107 "Color map is exhausting, use default cursor color" )))))
109 (defun skk-cursor-change-when-ovwrt ()
111 ((eq skk-emacs-type 'xemacs) (setq bar-cursor overwrite-mode))
112 (t (if overwrite-mode
113 (modify-frame-parameters (selected-frame) '((cursor-type bar . 3)))
114 (modify-frame-parameters (selected-frame) '((cursor-type . box)))))))
116 (defun skk-cursor-set-properly (&optional color)
117 ;;
\e$B%+%l%s%H%P%C%U%!$N
\e(B SKK
\e$B$N%b!<%I$K=>$$!"%+!<%=%k$N?'$rJQ99$9$k!#
\e(B
118 ;;
\e$B%*%W%7%g%J%k0z?t$N
\e(B COLOR
\e$B$,;XDj$5$l$?$H$-$O!"$=$N%+!<%=%k?'$r;H$&!#
\e(B
119 ;; OVWRT
\e$B%b!<%I$N$H$-$O%+!<%=%k$NI}$r>.$5$/$9$k!#
\e(B
120 (if (not (get-buffer-window (current-buffer)))
122 (if skk-use-color-cursor
123 (skk-cursor-set-color
125 ((not skk-mode) skk-default-cursor-color)
126 (skk-abbrev-mode skk-abbrev-cursor-color)
127 (skk-jisx0208-latin-mode
128 skk-jisx0208-latin-cursor-color)
129 (skk-katakana skk-katakana-cursor-color)
130 (skk-j-mode skk-hiragana-cursor-color)
131 (t skk-latin-cursor-color))))
132 (and skk-use-cursor-change (skk-cursor-change-when-ovwrt))))
135 (defadvice kill-buffer (after skk-cursor-ad activate)
136 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
137 (interactive "bKill buffer: ")
138 (skk-cursor-set-properly))
140 (defadvice other-window (after skk-cursor-ad activate)
141 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
143 (skk-cursor-set-properly))
147 (defadvice select-frame (after skk-cursor-ad activate)
148 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
149 (skk-cursor-set-properly)))
151 (defadvice select-frame (after skk-cursor-ad activate)
152 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
154 (skk-cursor-set-properly))))
156 (defadvice switch-to-buffer (after skk-cursor-ad activate)
157 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
158 (interactive "BSwitch to buffer: ")
159 (skk-cursor-set-properly))
162 ;; cover to original Emacs functions.
166 ;; execute-extended-command
174 ;; cover to SKK functions.
176 skk-gyakubiki-katakana-message
177 skk-gyakubiki-katakana-region
178 skk-gyakubiki-message
180 skk-hurigana-katakana-region
184 skk-jisx0208-latin-region
195 (defadvice (, (intern (symbol-name (car funcs))))
196 (after skk-cursor-ad activate)
197 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
198 ;;
\e$BJL$N%P%C%U%!$XHt$V%3%^%s%I$O
\e(B skk-mode
\e$B$,
\e(B nil
\e$B$G$b%+!<%=%k?'$rD4@0$9$kI,MW$,
\e(B
200 ;; CLASS
\e$B$O
\e(B after.
201 (skk-cursor-set-properly))))
202 (setq funcs (cdr funcs))))
206 (defadvice recenter (after skk-cursor-ad activate)
207 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
208 (and skk-mode (skk-cursor-set-properly))))
210 (defadvice recenter (after skk-cursor-ad activate)
211 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
213 (and skk-mode (skk-cursor-set-properly)))))
222 ;; cover to hilit functions.
226 ;; cover to VIP/Viper functions.
230 vip-intercept-ESC-key
234 viper-hide-replace-overlay
236 viper-intercept-ESC-key
242 (defadvice (, (intern (symbol-name (car funcs))))
243 (after skk-cursor-ad activate)
244 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
245 ;; skk-mode
\e$B$,
\e(B nil
\e$B$+
\e(B non-nil
\e$B$+$NH=DjIU$-!#
\e(B
246 ;; CLASS
\e$B$O
\e(B after.
247 (and skk-mode (skk-cursor-set-properly)))))
248 (setq funcs (cdr funcs))))
250 ;;
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B
251 ;; CLASS
\e$B$O
\e(B before.
252 ;;
\e$B%_%K%P%C%U%!$+$i85$N%+%l%s%H%P%C%U%!$rC5$7=P$7!"%+!<%=%k$r%;%C%H!#
\e(B
253 (let ((funcs '(exit-minibuffer)))
254 (static-if (eq skk-emacs-type 'xemacs)
255 (setq funcs (cons 'minibuffer-keyboard-quit funcs)))
259 (defadvice (, (intern (symbol-name (car funcs))))
260 (before skk-cursor-ad activate)
261 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
262 ;;
\e$B%_%K%P%C%U%!$+$i85$N%+%l%s%H%P%C%U%!$rC5$7=P$7!"%+!<%=%k$r%;%C%H!#
\e(B
263 ;; CLASS
\e$B$O
\e(B before.
264 (with-current-buffer (skk-minibuffer-origin) (skk-cursor-set-properly)))))
265 (setq funcs (cdr funcs))))
267 ;;
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B
268 ;; CLASS
\e$B$O
\e(B around.
269 ;; skk-abbrev-mode
\e$B$N$H$-$@$1%+!<%=%k$r%;%C%H!#
\e(B
271 ;; cover to original Emacs functions.
273 ;; cover to SKK functions.
274 skk-delete-backward-char
281 (defadvice (, (intern (symbol-name (car funcs))))
282 (around skk-cursor-ad activate preactivate)
283 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
284 ;; CLASS
\e$B$O
\e(B around.
285 ;; skk-abbrev-mode
\e$B$N$H$-$@$1%+!<%=%k$r%;%C%H!#
\e(B
287 (progn ad-do-it (skk-cursor-set-properly))
289 (setq funcs (cdr funcs))))
291 (static-when (featurep 'xemacs)
292 (defadvice abort-recursive-edit (before skk-cursor-ad activate preactivate)
293 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
294 (with-current-buffer (skk-minibuffer-origin) (skk-cursor-set-properly))))
296 (defadvice skk-latin-mode (after skk-cursor-ad activate)
297 "
\e$B%+!<%=%k?'$r
\e(B skk-latin-cursor-color
\e$B$KJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
298 (skk-cursor-set-properly skk-latin-cursor-color))
300 (defadvice skk-jisx0208-latin-mode (after skk-cursor-ad activate)
301 "
\e$B%+!<%=%k?'$r
\e(B skk-jisx0208-latin-cursor-color
\e$B$KJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
302 (skk-cursor-set-properly skk-jisx0208-latin-cursor-color))
304 (defadvice skk-abbrev-mode (after skk-cursor-ad activate)
305 "
\e$B1~$8%+!<%=%k?'$r
\e(B skk-abbrev-cursor-color
\e$B$KJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
306 (skk-cursor-set-properly skk-abbrev-cursor-color))
308 (defadvice skk-kakutei (after skk-cursor-ad activate)
309 "
\e$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#
\e(BOvwrt
\e$B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#
\e(B"
310 (if (interactive-p) (skk-cursor-set-properly)))
313 (defadvice skk-mode (after skk-viper-ad activate)
314 (add-hook 'viper-post-command-hooks
315 (function (lambda () (and skk-mode (skk-set-cursor-properly))))
319 (add-hook 'after-make-frame-hook 'skk-cursor-set-properly)
320 (add-hook 'minibuffer-setup-hook 'skk-cursor-set-properly)
321 (add-hook 'minibuffer-exit-hook 'skk-cursor-set-properly 'append)
323 (defalias 'skk-set-cursor-color 'skk-cursor-set-color)
324 (defalias 'skk-change-cursor-when-ovwrt 'skk-cursor-change-when-ovwrt)
325 (defalias 'skk-set-cursor-properly 'skk-cursor-set-properly)
327 ;;
\e$B:G=i$K
\e(B load
\e$B$5$l$?$H$-$O!"
\e(Bskk-cursor adviced function
\e$B$K$J$kA0$N4X?t$K$h$C$F
\e(B
328 ;;
\e$B8F$P$l$F$*$j!"
\e(Badvice
\e$B$,8z$$$F$J$$$N$G!"%H%C%W%l%Y%k$G%+!<%=%k$r9g$o$;$F$*$/!#
\e(B
329 (and (get-buffer-window (current-buffer))
330 ;; only first time when this file loaded.
331 ;;(not skk-mode-invoked)
332 (skk-cursor-set-properly skk-hiragana-cursor-color))
335 (add-hook 'isearch-mode-end-hook 'skk-cursor-set-properly 'append)
337 (provide 'skk-cursor)
340 ;;; skk-cursor.el ends here