branch: externals/pyim commit a52c11ada2381a162b1fd75d98282320601a1a1e Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
Add pyim-process-ui-* functions. * pyim-process.el (pyim-process-ui-init) (pyim-process-ui-refresh, pyim-process-ui-hide): New functions. (pyim-process-run-1, pyim-process-run-async) (pyim-process-terminate): Use New functions. * pyim-page.el (pyim-page-next-page, pyim-page-next-word): Use New functions. --- pyim-page.el | 4 ++-- pyim-process.el | 17 ++++++++++++++--- pyim.el | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/pyim-page.el b/pyim-page.el index db239d4c6c..923dfd2d6b 100644 --- a/pyim-page.el +++ b/pyim-page.el @@ -250,7 +250,7 @@ page 的概念,比如,上面的 “nihao” 的 *待选词列表* 就可以 (if (> new 0) (if (> new maxpos) 1 new) maxpos))) - (run-hooks 'pyim-process-ui-refresh-hook)))) + (pyim-process-ui-refresh)))) (defun pyim-page-previous-page (arg) (interactive "p") @@ -268,7 +268,7 @@ page 的概念,比如,上面的 “nihao” 的 *待选词列表* 就可以 (if (>= len new) (if (> new 0) new len) 1)) - (run-hook-with-args 'pyim-process-ui-refresh-hook 'hightlight-current)))) + (pyim-process-ui-refresh 'hightlight-current)))) (defun pyim-page-previous-word (arg) (interactive "p") diff --git a/pyim-process.el b/pyim-process.el index 045808bf4a..ebd9b73f9e 100644 --- a/pyim-process.el +++ b/pyim-process.el @@ -138,6 +138,10 @@ entered (nihaom) 的第一个候选词。 '(pyim-process-input-ascii pyim-process-translating)) +(defun pyim-process-ui-init () + "初始化 pyim 相关 UI." + (run-hooks 'pyim-process-ui-init-hook)) + (defun pyim-process-init-dcaches (&optional force) "PYIM 流程,词库相关的初始化工作。" (pyim-recreate-local-variables) @@ -336,7 +340,11 @@ entered (nihaom) 的第一个候选词。 (pyim-entered-get 'point-after)) (pyim-process-terminate)) (t (setq pyim-candidate-position 1) - (run-hooks 'pyim-process-ui-refresh-hook)))))) + (pyim-process-ui-refresh)))))) + +(defun pyim-process-ui-refresh (&optional hightlight-current) + "刷新 pyim 相关 UI." + (run-hook-with-args 'pyim-process-ui-refresh-hook hightlight-current)) (defun pyim-process-self-insert-command-p (cmd) "测试 CMD 是否是一个 pyim self insert command." @@ -348,7 +356,7 @@ entered (nihaom) 的第一个候选词。 (words (delete-dups (pyim-candidates-create pyim-imobjs scheme-name t)))) (when words (setq pyim-candidates words) - (run-hooks 'pyim-process-ui-refresh-hook)))) + (pyim-process-ui-refresh)))) (defun pyim-process-run-async-timer-reset () "Reset `pyim-process-run-async-timer'." @@ -652,14 +660,17 @@ BUG:拼音无法有效地处理多音字。" (setq pyim-process-force-input-chinese nil) (setq pyim-candidates nil) (setq pyim-candidates-last nil) - (run-hooks 'pyim-process-ui-hide-hook) (setq pyim-cstring-to-code-criteria nil) (pyim-process-run-async-timer-reset) + (pyim-process-ui-hide) (let* ((class (pyim-scheme-get-option (pyim-scheme-name) :class)) (func (intern (format "pyim-process-terminate:%S" class)))) (when (and class (functionp func)) (funcall func)))) +(defun pyim-process-ui-hide () + "隐藏 pyim 相关 UI." + (run-hooks 'pyim-process-ui-hide-hook)) ;; * Footer (provide 'pyim-process) diff --git a/pyim.el b/pyim.el index 8924a95a3b..98bdeb9476 100644 --- a/pyim.el +++ b/pyim.el @@ -144,7 +144,7 @@ Tip: 用户也可以利用 `pyim-outcome-trigger-function-default' 函数 overriding-local-map) (list key) ;; (message "call with key: %S" key-or-string) - (run-hooks 'pyim-process-ui-init-hook) + (pyim-process-ui-init) (with-silent-modifications (unwind-protect (let ((input-string (pyim-input-method-1 key)))