[uim-commit] r2494 - branches/1.0/emacs
ekato at freedesktop.org
ekato at freedesktop.org
Fri Dec 9 05:40:44 PST 2005
Author: ekato
Date: 2005-12-09 05:40:39 -0800 (Fri, 09 Dec 2005)
New Revision: 2494
Modified:
branches/1.0/emacs/uim-candidate.el
branches/1.0/emacs/uim-key.el
branches/1.0/emacs/uim-keymap.el
branches/1.0/emacs/uim-preedit.el
branches/1.0/emacs/uim-var.el
branches/1.0/emacs/uim.el
Log:
* emacs/uim-keymap.el
* emacs/uim-var.el
* emacs/uimm-key.el
* emacs/uim-preedit.el
* emacs/uim.el
* emacs/uim-candidate.el
- Port r2488-2492 from trunk.
Modified: branches/1.0/emacs/uim-candidate.el
===================================================================
--- branches/1.0/emacs/uim-candidate.el 2005-12-09 13:39:13 UTC (rev 2493)
+++ branches/1.0/emacs/uim-candidate.el 2005-12-09 13:40:39 UTC (rev 2494)
@@ -64,7 +64,7 @@
;; mark current-point
(setq mark-base (point-marker))
- (uim-debug (format "before: %s" (marker-position mark-base)))
+ ;;(uim-debug (format "before: %s" (marker-position mark-base)))
;; save original string
(setq uim-candidate-original-str
@@ -90,7 +90,7 @@
(setq base-ofs (- (marker-position mark-base) uim-candidate-start))
(setq uim-candidate-start (+ uim-candidate-start base-ofs)))
- (uim-debug (format "after: %s" (marker-position mark-base)))
+ ;;(uim-debug (format "after: %s" (marker-position mark-base)))
(set-marker mark-base nil)
@@ -101,7 +101,7 @@
(setq offset
(uim-string-width (buffer-substring (point) uim-candidate-start))))
- (uim-debug (format "offset: %s" offset))
+ ;;(uim-debug (format "offset: %s" offset))
;; if offset + maxwidth >= window-width then reduce offset
(if (>= (+ offset maxwidth 2) (window-width))
@@ -316,31 +316,88 @@
(message cands)
)
;; Emacs-20 or XEmacs
- (let* ((page-width (+ (string-width uim-candidate-page-label) 2))
+;; (let* ((page-width (+ (string-width uim-candidate-page-label) 2))
+;; (cands-width (string-width cands))
+;; (echoreg-width (- (- (window-width) 1) page-width)))
+;; (if (>= echoreg-width cands-width)
+;; (setq cands
+;; (concat cands
+;; (make-string (- echoreg-width cands-width) 32)
+;; "(" uim-candidate-page-label ")"))
+;; (if (> (string-width (substring cands 0 selend))
+;; (+ (- cands-width echoreg-width) 3))
+;; (setq cands
+;; (concat "..."
+;; (truncate-string-to-width cands
+;; cands-width
+;; (+ (- cands-width echoreg-width) 3))
+;; "(" uim-candidate-page-label ")"))
+;; (setq cands
+;; (concat "..."
+;; (truncate-string-to-width (substring cands (- selend 1))
+;; (if (> echoreg-width 6)
+;; (- echoreg-width 6)
+;; 0))
+;; "..."
+;; "(" uim-candidate-page-label ")")))))
+
+ (let* ((page-space (- (string-width page-total)
+ (string-width page-current)))
+ (page-label (concat (if (> page-space 0)
+ (make-string page-space 32))
+ page-current "/" page-total " "))
+ (page-width (string-width page-label))
(cands-width (string-width cands))
(echoreg-width (- (- (window-width) 1) page-width)))
- (if (>= echoreg-width cands-width)
- (setq cands
- (concat cands
- (make-string (- echoreg-width cands-width) 32)
- "(" uim-candidate-page-label ")"))
- (if (> (string-width (substring cands 0 selend))
- (+ (- cands-width echoreg-width) 3))
- (setq cands
- (concat "..."
- (truncate-string-to-width cands
- cands-width
- (+ (- cands-width echoreg-width) 3))
- "(" uim-candidate-page-label ")"))
- (setq cands
- (concat "..."
- (truncate-string-to-width (substring cands (- selend 1))
- (if (> echoreg-width 6)
- (- echoreg-width 6)
- 0))
- "..."
- "(" uim-candidate-page-label ")")))))
-
+
+ (cond ((>= echoreg-width cands-width)
+ (setq cands
+ (concat page-label cands)))
+
+ ((= selstart 0)
+ ;; | 10/134 [1.xxxxx] 2.yyyyy 3.zzzzz ...|
+ (setq cands
+ (truncate-string-to-width cands
+ (if (> echoreg-width 3)
+ (- echoreg-width 3)
+ 0)))
+ (setq cands
+ (concat page-label
+ cands
+ (make-string (- echoreg-width
+ (string-width cands))
+ ?.)))
+
+ )
+ ((> (string-width (substring cands 0 selstart))
+ (+ (- cands-width echoreg-width) 3))
+ ;; | 10/134 ...yyy [3.zzzzz]
+ (setq cands
+ (truncate-string-to-width cands
+ cands-width
+ (+ (- cands-width echoreg-width) 3)))
+ (setq cands
+ (concat page-label
+ (make-string (- echoreg-width
+ (string-width cands))
+ ?.)
+ cands)))
+ (t
+ ;; | 10/134 ...[3.zzzzz] ---- ...|
+ (setq cands
+ (concat "..."
+ (truncate-string-to-width (substring cands selstart)
+ (if (> echoreg-width 6)
+ (- echoreg-width 6)
+ 0))
+ ))
+ (setq cands
+ (concat page-label
+ cands
+ (make-string (- echoreg-width
+ (string-width cands))
+ ?.))))))
+
(let (message-log-max)
(message cands))
)
@@ -583,11 +640,6 @@
(save-excursion
(goto-char uim-candidate-original-start)
(insert uim-candidate-original-str))
-
- ;; delete overlay
- ;;(mapcar 'delete-overlay uim-candidate-overlays)
- ;;(setq uim-candidate-overlays nil)
-
)
;; clear minibuffer
Modified: branches/1.0/emacs/uim-key.el
===================================================================
--- branches/1.0/emacs/uim-key.el 2005-12-09 13:39:13 UTC (rev 2493)
+++ branches/1.0/emacs/uim-key.el 2005-12-09 13:40:39 UTC (rev 2494)
@@ -219,6 +219,7 @@
(if (eq bind 'self-insert-command)
(progn
(setq this-command bind)
+ (setq last-command-char (aref keyvec 0))
(call-interactively bind)
(uim-concat-undo))
(setq this-command bind)
@@ -279,7 +280,9 @@
(lastkey (nth (- (length keylist) 1) keylist)))
(cond ((setq button
(assoc lastkey
- '((button1 . 1) (button2 . 2) (button3 . 3))))
+ '((button1 . 1) (button2 . 2)
+ (button3 . 3) (button4 . 4)
+ (button5 . 5))))
;; mouse press
(delq lastkey keylist)
(setq event
@@ -288,7 +291,9 @@
)
((setq button
(assoc lastkey
- '((button1up . 1) (button2up . 2) (button3up . 3))))
+ '((button1up . 1) (button2up . 2)
+ (button3up . 3) (button4up . 4)
+ (button5up . 5))))
;; mouse up
(delq lastkey keylist)
(setq event
@@ -543,7 +548,7 @@
;;(uim-debug (format "stacked-key-vector: %s" uim-stacked-key-vector))
- (cond ((and uim-preedit-displayed
+ (cond ((and uim-preedit-keymap-enabled
(uim-is-escape uim-stacked-key-vector)) ;; preedit ESC-ESC
(uim-debug "Escape")
;; stop waiting and return ESC key
@@ -553,10 +558,10 @@
(setq keyvec (vector (uim-xemacs-make-event [escape]))))
(setq uim-stacked-key-vector nil)
)
- ((or (and uim-preedit-displayed ;; with preedit
+ ((or (and uim-preedit-keymap-enabled
(and replace-continue ;; wait ESC- key vector
(uim-is-start-with-escape uim-stacked-key-vector)))
- (and (not uim-preedit-displayed) ;; without preedit
+ (and (not uim-preedit-keymap-enabled)
(or replace-continue ;; wait all
(keymapp (uim-getbind uim-stacked-key-vector)))))
;; wait next
Modified: branches/1.0/emacs/uim-keymap.el
===================================================================
--- branches/1.0/emacs/uim-keymap.el 2005-12-09 13:39:13 UTC (rev 2493)
+++ branches/1.0/emacs/uim-keymap.el 2005-12-09 13:40:39 UTC (rev 2494)
@@ -77,7 +77,7 @@
(defun uim-unbind-mouse-event ()
(let ((mouse-modifiers uim-mouse-modifiers))
(while mouse-modifiers
- (let ((mouse '(mouse-1 mouse-2 mouse-3)))
+ (let ((mouse '(mouse-1 mouse-2 mouse-3 mouse-4 mouse-5)))
(while mouse
(let ((event (vector (append (car mouse-modifiers)
(list (car mouse))))))
@@ -206,44 +206,65 @@
nil))
(defun uim-enable-preedit-keymap ()
- (setcdr (assq 'uim-mode minor-mode-map-alist)
- uim-preedit-map)
+ (when (not uim-preedit-keymap-enabled)
- (when (not uim-minor-mode-map-alist)
- (setq uim-minor-mode-map-alist minor-mode-map-alist)
- (setq minor-mode-map-alist (list (assq 'uim-mode minor-mode-map-alist)))
+ (setq uim-preedit-keymap-enabled t)
+ (uim-debug "enable preedit keymap")
- (when (and uim-emacs (= emacs-major-version 22))
- (setq uim-emulation-mode-map-alists emulation-mode-map-alists)
- (setq emulation-mode-map-alists nil)))
+ (setcdr (assq 'uim-mode minor-mode-map-alist)
+ uim-preedit-map)
- (when uim-xemacs
- (make-variable-buffer-local 'toolbar-map)
- (setq toolbar-map uim-toolbar-map)
- (uim-xemacs-save-menubar)
+ ;; disable other keymaps
+ (when (not uim-minor-mode-map-alist)
+ (setq uim-minor-mode-map-alist minor-mode-map-alist)
+ (setq minor-mode-map-alist (list (assq 'uim-mode minor-mode-map-alist)))
+
+ (when (and uim-emacs (= emacs-major-version 22))
+ (setq uim-emulation-mode-map-alists emulation-mode-map-alists)
+ (setq emulation-mode-map-alists nil)))
+
+ (when uim-xemacs
+ ;; disable toolbar and menubar
+ (make-variable-buffer-local 'toolbar-map)
+ (setq toolbar-map uim-toolbar-map)
+ (uim-xemacs-save-menubar))
)
-
)
(defun uim-disable-preedit-keymap ()
+ (when uim-preedit-keymap-enabled
+ (setq uim-preedit-keymap-enabled nil)
+ (uim-debug "disable preedit keymap")
- (when uim-minor-mode-map-alist
- (setq minor-mode-map-alist uim-minor-mode-map-alist)
- (setq uim-minor-mode-map-alist nil)
+ ;; enable other keymaps
+ (when uim-minor-mode-map-alist
+ (setq minor-mode-map-alist uim-minor-mode-map-alist)
+ (setq uim-minor-mode-map-alist nil)
- (when (and uim-emacs (= emacs-major-version 22))
- (setq emulation-mode-map-alists uim-emulation-mode-map-alists)
- (setq uim-emulation-mode-map-alists nil)))
+ (when (and uim-emacs (= emacs-major-version 22))
+ (setq emulation-mode-map-alists uim-emulation-mode-map-alists)
+ (setq uim-emulation-mode-map-alists nil)))
- (uim-enable-mode-keymap)
+ (uim-enable-mode-keymap)
- (when uim-xemacs
- (kill-local-variable 'toolbar-map)
- (uim-xemacs-restore-menubar)
+ (when uim-xemacs
+ ;;enable toolbar and menubar
+ (kill-local-variable 'toolbar-map)
+ (uim-xemacs-restore-menubar))
+
)
)
+;; (defun uim-mode-keymap-enabled ()
+;; (eq (cdr (assq 'uim-mode minor-mode-map-alist))
+;; uim-mode-map))
+
+;; (defun uim-preedit-keymap-enabled ()
+;; (eq (cdr (assq 'uim-mode minor-mode-map-alist))
+;; uim-preedit-map))
+
+
;;
;; Copy toggle key to uim-mode-map
;;
Modified: branches/1.0/emacs/uim-preedit.el
===================================================================
--- branches/1.0/emacs/uim-preedit.el 2005-12-09 13:39:13 UTC (rev 2493)
+++ branches/1.0/emacs/uim-preedit.el 2005-12-09 13:40:39 UTC (rev 2494)
@@ -57,18 +57,16 @@
(mapcar
'(lambda (x)
- (let (cand-start-cand
- (preedit-flag (format "%s" (car x)))
+ (let ((preedit-flag (format "%s" (car x)))
(preedit-str (car (cdr x))))
;; save point for candidate displaying before insertion
;; i.e. head of the block
(if (string-match "c" preedit-flag)
- (progn
- (if (> (length preedit-str) 0)
- (setq uim-candidate-start (point))
- ;; workaround for uim-prime
- (setq uim-candidate-start block-start-point))))
+ (if (> (length preedit-str) 0)
+ (setq uim-candidate-start (point))
+ ;; workaround for uim-prime
+ (setq uim-candidate-start block-start-point)))
(setq block-start-point (point))
@@ -79,10 +77,10 @@
(let ((face (cond
((string-match "s" preedit-flag)
'uim-separator-face)
- ((string-match "u" preedit-flag)
- 'uim-preedit-underline-face)
((string-match "ru" preedit-flag)
'uim-preedit-highlight-underline-face)
+ ((string-match "u" preedit-flag)
+ 'uim-preedit-underline-face)
((string-match "r" preedit-flag)
'uim-preedit-highlight-face)
(t
Modified: branches/1.0/emacs/uim-var.el
===================================================================
--- branches/1.0/emacs/uim-var.el 2005-12-09 13:39:13 UTC (rev 2493)
+++ branches/1.0/emacs/uim-var.el 2005-12-09 13:40:39 UTC (rev 2494)
@@ -34,7 +34,7 @@
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
-(defconst uim-el-version "0.0.6-beta2")
+(defconst uim-el-version "0.0.6-beta3")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -335,6 +335,7 @@
(uim-deflocalvar uim-undo-stacking nil)
+(uim-deflocalvar uim-preedit-keymap-enabled nil)
;; save font-lock mode
(uim-deflocalvar uim-font-lock-mode nil)
Modified: branches/1.0/emacs/uim.el
===================================================================
--- branches/1.0/emacs/uim.el 2005-12-09 13:39:13 UTC (rev 2493)
+++ branches/1.0/emacs/uim.el 2005-12-09 13:40:39 UTC (rev 2494)
@@ -361,7 +361,7 @@
;; hide candidate/preedit when buffer-save has been called
(add-hook 'local-write-file-hooks
'(lambda ()
- (if uim-preedit-displayed
+ (if (or uim-preedit-displayed uim-candidate-displayed)
(uim-process-agent-output '(("e"))))))
;; change IM engine to uim-default-im-engine
@@ -528,6 +528,7 @@
;;
(defun uim-restore-undo ()
(when uim-buffer-undo-list-saved
+ (uim-debug "restore undo list")
(buffer-enable-undo)
(setq buffer-undo-list uim-buffer-undo-list)
(setq uim-buffer-undo-list-saved nil))
@@ -539,6 +540,7 @@
;;
(defun uim-save-undo ()
(when (not uim-buffer-undo-list-saved)
+ (uim-debug "save undo list")
(setq uim-buffer-undo-list buffer-undo-list)
(buffer-disable-undo)
(setq uim-buffer-undo-list-saved 't))
@@ -909,7 +911,7 @@
(setq sendkey
(uim-convert-keystr-to-uimagent-vector (key-description keyvec)))
- (cond ((string-match "button\\(1\\|2\\|3\\)"
+ (cond ((string-match "button\\(1\\|2\\|3\\|4\\|5\\)"
(key-description keyvec))
;; through mouse event
(setq mouse t)
@@ -920,8 +922,9 @@
(setq bypass t)
(setq count (prefix-numeric-value arg)))
- ((and (not uim-preedit-displayed)
- (uim-buffer-not-editable) )
+ ((and (not (or uim-preedit-displayed
+ uim-candidate-displayed))
+ (uim-buffer-not-editable))
;; through uim-el-agent when buffer is uneditable
(setq bypass t)
))
@@ -943,13 +946,14 @@
(setq count (prefix-numeric-value arg)))
((and (eventp event)
(memq (event-basic-type event)
- '(mouse-1 mouse-2 mouse-3)))
+ '(mouse-1 mouse-2 mouse-3 mouse-4 mouse-5)))
;; detect mouse event
;;(uim-debug "mouse event")
(setq bypass t)
(setq mouse t)
)
- ((and (not uim-preedit-displayed)
+ ((and (not (or uim-preedit-displayed
+ uim-candidate-displayed))
(uim-buffer-not-editable))
(setq bypass t))
(t
@@ -1001,22 +1005,24 @@
;; process return expression from uim-el-agent
(defun uim-process-agent-output (str)
- (let (preedit-exists
- candidate-exists
- key commit (preedit nil) candidate default label imlist)
+ (let (preedit-existed
+ candidate-existed
+ key commit preedit candidate default label imlist)
(let ((modified (buffer-modified-p)))
;; remove candidate anyway
(when uim-candidate-displayed
- (setq candidate-exists t)
+ (setq candidate-existed t)
(uim-remove-candidate)
- (setq uim-candidate-displayed nil))
+ (setq uim-candidate-displayed nil)
+ (goto-char uim-candidate-start))
;; remove preedit anyway
(when uim-preedit-displayed
- (setq preedit-exists t)
+ (setq preedit-existed t)
(uim-remove-preedit)
- (setq uim-preedit-displayed nil))
+ (setq uim-preedit-displayed nil)
+ (goto-char uim-preedit-start))
;; restore modified flag
(set-buffer-modified-p modified))
@@ -1033,7 +1039,7 @@
(if uim-last-key-vector
(progn
(setq key uim-last-key-vector)
- (uim-debug (format "%s" key)))
+ (uim-debug (format "last-key: %s" key)))
(setq key (car rval)))
)
((string= rcode "s") ;; commit string
@@ -1070,77 +1076,97 @@
(when imlist
(uim-update-imlist imlist))
- (if (or commit
- (and preedit-exists (not preedit)))
- (uim-restore-undo))
(if commit
- (mapcar '(lambda (x)
- (insert x) (undo-boundary))
- commit))
+ (let ((buffer-undo-list-saved uim-buffer-undo-list-saved))
+ ;; restore undo history before committing
+ (when buffer-undo-list-saved
+ (uim-debug "call restore undo")
+ (uim-restore-undo))
- (if key
- ;; process raw key
- (progn
- (if preedit-exists
- (uim-disable-preedit-keymap))
- (uim-process-keyvec key))
+ ;; insert committed strings
+ (mapcar
+ '(lambda (x)
+ (insert x)
+ (uim-debug (format "insert %s" x))
+ (undo-boundary))
+ commit)
- ;; process preedit
- (if preedit
- (let ((modified (buffer-modified-p)))
+ ;; save undo hisotry again
+ (when buffer-undo-list-saved
+ (uim-debug "call save undo")
+ (uim-save-undo)))
+ )
- (uim-flush-concat-undo)
- ;; switch keymap to preedit mode
- (if (not preedit-exists)
- (uim-enable-preedit-keymap))
+ (if (or preedit candidate)
+ ;; process preedit/candidate
+ (let ((modified (buffer-modified-p)))
- (uim-save-undo)
+ ;; save undo list if not saved
+ (when (not uim-buffer-undo-list-saved)
+ (uim-flush-concat-undo)
+ (uim-debug "call save undo")
+ (uim-save-undo))
- (setq uim-preedit-displayed t)
+ ;; change keymap and freeze faces at first time
+ (when (not uim-preedit-keymap-enabled)
+ (uim-debug "call enable keymap")
+ (uim-enable-preedit-keymap)
+ (if (= (minibuffer-depth) 0)
+ (uim-freeze-buffer)))
- ;; freeze buffer if the first preedit display
- (if (and (not preedit-exists)
- (= (minibuffer-depth) 0))
- (uim-freeze-buffer))
+ ;; show preedit
+ (if preedit
+ (progn
+ (setq uim-preedit-displayed t)
+ (uim-insert-preedit preedit))
+ (setq uim-candidate-start (point))
+ (setq uim-candidate-vofs 0)
+ (setq uim-preedit-cursor (point)))
- (uim-insert-preedit preedit)
+ ;; show candidate
+ (if candidate
+ (progn
+ (setq uim-candidate-displayed t)
+ (if (uim-check-candidate-space)
+ (uim-show-candidate candidate))))
+
+ (set-buffer-modified-p modified)
- ;; show candidate
- (if candidate
- (progn
- (setq uim-candidate-displayed t)
- (if (uim-check-candidate-space)
- (uim-show-candidate candidate))))
+ )
- (set-buffer-modified-p modified)
- )
+ ;; no preedit/candidate
- (when (and preedit-exists
- uim-buffer-frozen)
- (uim-disable-preedit-keymap)
- (uim-unfreeze-buffer)
+ ;; restore undo-list before raw key processing
+ (when uim-buffer-undo-list-saved
+ (uim-debug "call restore undo")
+ (uim-restore-undo))
- )
- )
+ ;; no raw-key and no preedit/candidate
+ (when uim-preedit-keymap-enabled
+ (uim-debug "call disable preedit keymap")
+ (uim-disable-preedit-keymap)
+ (uim-unfreeze-buffer))
- (when (and candidate-exists
- (not uim-candidate-displayed)
- uim-window-force-scrolled)
- (uim-debug "recenter: window-force-scrolled is true")
- (setq uim-window-force-scrolled nil)
- (recenter)
- )
-
+ (if key
+ ;; process raw key
+ (uim-process-keyvec key))
+ )
- ;; move cursor
+ ;; scroll buffer after candidate removed
+ ;; recenter if buffer is force scrolled at candidate displaying
+ (when (and candidate-existed
+ (not uim-candidate-displayed)
+ uim-window-force-scrolled)
+ (uim-debug "recenter: window-force-scrolled is true")
+ (setq uim-window-force-scrolled nil)
+ (recenter))
- (when uim-preedit-displayed
- (goto-char uim-preedit-cursor))
- )
+ ;; move cursor
+ (when (or uim-preedit-displayed uim-candidate-displayed)
+ (goto-char uim-preedit-cursor))
-
))
More information about the uim-commit
mailing list