Commit f07f8824 authored by Yuanle Song's avatar Yuanle Song
Browse files

v2.0.0 renamed package file to zero-input.el

since this is a backward incompatible change, I set version to v2.0.0.
all symbols and functions is now prefixed with zero-input.

This change is suggested by melpa reviewer.
parent 0944ff0c
VERSION := $(shell grep 'setq zero-version' zero-framework.el | cut -d'"' -f2)
VERSION := $(shell grep 'setq zero-input-version' zero-input-framework.el | cut -d'"' -f2)
default: dist
#===============
# multiple file
#===============
check:
emacs -Q --batch -l zero-reload-all.el -f zero-rebuild -l zero-table.el -l zero-table-test.el -f ert-run-tests-batch
emacs -Q --batch -l zero-input-reload-all.el -f zero-input-rebuild -l zero-input-table.el -l zero-input-table-test.el -f ert-run-tests-batch
zip:
git archive -o zero-el-$(VERSION).zip --prefix=zero/ HEAD
git archive -o zero-input-el-$(VERSION).zip --prefix=zero-input/ HEAD
#==========================
# single file distribution
#==========================
......@@ -16,9 +16,12 @@ build:
if [ ! -x ~/.local/bin/pytest ]; then python3 -m pip install --user pytest; fi
~/.local/bin/pytest build.py
./build.py
sed -i "s/PKG_VERSION/$(VERSION)/g" zero.el
sed -i "s/PKG_VERSION/$(VERSION)/g" zero-input.el
dist-check: build
emacs -Q --batch -l ~/.emacs.d/elpa/s-1.11.0/s.el -l zero.el -l zero-panel-test.el -l zero-pinyin-service-test.el -l zero-framework-test.el -l zero-pinyin-test.el -l zero-table.el -l zero-table-test.el -f ert-run-tests-batch
@echo "testing byte-compile is clean..."
emacs -Q --batch -l ~/.emacs.d/elpa/s-1.11.0/s.el --eval='(byte-compile-file "zero-input.el")'
@echo "running unit tests..."
emacs -Q --batch -l ~/.emacs.d/elpa/s-1.11.0/s.el -l zero-input.el -l zero-input-panel-test.el -l zero-input-pinyin-service-test.el -l zero-input-framework-test.el -l zero-input-pinyin-test.el -l zero-input-table.el -l zero-input-table-test.el -f ert-run-tests-batch
#====================
# other make targets
#====================
......
zero-el
Copyright (C) 2019 Yuanle Song <sylecn@gmail.com>
zero--ibus-compute-pixel-position function in zero.el is copied from ibus.el.
This function is under GPLv3 license. Copyright (C) 2010-2012 S. Irie
zero-input--ibus-compute-pixel-position function in zero-input.el is copied
from ibus.el. This function is under GPLv3 license. Copyright (C) 2010-2012
S. Irie
* COMMENT -*- mode: org -*-
#+Date: 2019-09-01
Time-stamp: <2019-10-16>
Time-stamp: <2019-10-28>
* zero-el
zero-el provides zero-pinyin, an Emacs pinyin input method for Chinese and
zero-framework, which is an emacs Chinese input method framework.
zero-el provides zero-input-pinyin, an Emacs pinyin input method for Chinese
and zero-input-framework, which is an emacs Chinese input method framework.
* File list
- zero.el
- zero-input.el
It's a generated file for one-file package distribution. Not used for
development.
- zero-framework.el
- zero-input-framework.el
zero framework source code. This provides the framework and user interface
for zero-el.
- zero-panel.el
- zero-input-panel.el
dbus client to zero-panel service.
- zero-pinyin-service.el
- zero-input-pinyin-service.el
dbus client to zero-pinyin-service.
- zero-pinyin.el
- zero-input-pinyin.el
Pinyin input method implemented using zero.el
- zero-quickdial.el
- zero-input-quickdial.el
proof of concept of how to create an input method in emacs using minor mode.
- zero-reload-all.el
- zero-input-reload-all.el
zero-el development utility.
- zero-table.el
- zero-input-table.el
serves as an example of how to use zero framework to create new input
methods.
......@@ -49,5 +49,5 @@ https://blog.emacsos.com/zero-el.html
* License
zero-el is under Apache License 2.0
zero--ibus-compute-pixel-position function in zero-framework.el is under
GPLv3. see NOTICE file.
zero-input--ibus-compute-pixel-position function in zero-input-framework.el is
under GPLv3. see NOTICE file.
......@@ -2,7 +2,7 @@
# coding=utf-8
"""
build zero.el from zero.el.in and other el files
build zero-input.el from zero-input.el.in and other el files
"""
import logging
......@@ -18,9 +18,10 @@ def placeholder_for_file(fn):
def test_placeholder_for_file():
assert placeholder_for_file("zero-panel.el") == "INCLUDE_ZERO_PANEL_EL"
assert placeholder_for_file("zero-pinyin-service.el") == (
"INCLUDE_ZERO_PINYIN_SERVICE_EL")
assert placeholder_for_file("zero-input-panel.el") == (
"INCLUDE_ZERO_INPUT_PANEL_EL")
assert placeholder_for_file("zero-input-pinyin-service.el") == (
"INCLUDE_ZERO_INPUT_PINYIN_SERVICE_EL")
def get_el_file_body(fn):
......@@ -57,16 +58,16 @@ def main():
logging.basicConfig(
format='%(asctime)s [%(module)s] %(levelname)-8s %(message)s',
level=logging.INFO)
with open("zero.el.in") as tpl:
with open("zero-input.el.in") as tpl:
content = tpl.read()
expanded_content = expand_placeholder_for_files(content, [
"zero-panel.el",
"zero-framework.el",
"zero-table.el",
"zero-pinyin-service.el",
"zero-pinyin.el",
"zero-input-panel.el",
"zero-input-framework.el",
"zero-input-table.el",
"zero-input-pinyin-service.el",
"zero-input-pinyin.el",
])
with open('zero.el', 'w') as out:
with open('zero-input.el', 'w') as out:
out.write(expanded_content)
......
......@@ -2,5 +2,5 @@
set -e
if git branch |grep '^\* master'; then
make dist-check
git add zero.el
git add zero-input.el
fi
* COMMENT -*- mode: org -*-
#+Date: 2019-10-08
Time-stamp: <2019-10-23>
Time-stamp: <2019-10-28>
#+STARTUP: content
* notes :entry:
** 2019-04-01 zero.el a Chinese IM framework in emacs; FSM :doc:
** 2019-04-01 zero-el a Chinese IM framework in emacs; FSM :doc:
title was: how to write a modern im for emacs.
cd ~/lisp/elisp/zero/
- DONE can I implement it as a minor mode? yes.
......@@ -13,8 +13,8 @@ cd ~/lisp/elisp/zero/
| Imp | state | action | next state | trigger action |
|-----+------------------+-----------------------------------------------------+------------------+---------------------------------------------------------------------------------------------------------|
| Y | IM_OFF | M-x zero-on or zero-toggle | IM_WAITING_INPUT | turn on minor mode |
| Y | IM_WAITING_INPUT | type M-x zero-off or zero-toggle | IM_OFF | turn off minor mode |
| Y | IM_OFF | M-x zero-input-on or zero-input-toggle | IM_WAITING_INPUT | turn on minor mode |
| Y | IM_WAITING_INPUT | type M-x zero-input-off or zero-input-toggle | IM_OFF | turn off minor mode |
| Y | IM_WAITING_INPUT | type character that can start a sequence | IM_PREEDITING | update preedit str, show candidate list |
| Y | IM_WAITING_INPUT | type character that can not start a sequence | IM_WAITING_INPUT | insert character (full-width aware) |
| Y | IM_WAITING_INPUT | type [,.?!\] | IM_WAITING_INPUT | insert Chinese punctuation character (full-width aware) |
......@@ -23,7 +23,7 @@ cd ~/lisp/elisp/zero/
| Y | IM_PREEDITING | type SPC | IM_WAITING_INPUT | commit first candidate or preedit str (full-width aware), reset preedit str |
| Y | IM_PREEDITING | type digit keys | IM_WAITING_INPUT | commit nth candidate if it exists, otherwise, append to preedit str |
| | IM_PREEDITING | type C-g | IM_WAITING_INPUT | reset IM (reset preedit str, hide candidate list) |
| Y | IM_PREEDITING | type M-x zero-off or zero-toggle | IM_OFF | reset IM, turn off minor mode |
| Y | IM_PREEDITING | type M-x zero-input-off or zero-input-toggle | IM_OFF | reset IM, turn off minor mode |
| Y | IM_PREEDITING | type <backspace>, when preedit str is longer than 1 | IM_PREEDITING | update preedit str, update and show candidate list |
| Y | IM_PREEDITING | type <backspace>, when preedit str is length 1 | IM_WAITING_INPUT | reset IM |
| Y | IM_PREEDITING | focus in | IM_PREEDITING | show candidat list |
......@@ -35,10 +35,10 @@ cd ~/lisp/elisp/zero/
in IM_OFF state, zero should not do any preedit try nor do punctuation
translate.
- DONE make zero-quickdial IM work in emacs.
see ~/lisp/elisp/zero/zero-quickdial.el
- DONE make zero-table IM work in emacs. with zero-panel.
see ~/lisp/elisp/zero/zero-table.el
- DONE make zero-input-quickdial IM work in emacs.
see ~/lisp/elisp/zero/zero-input-quickdial.el
- DONE make zero-input-table IM work in emacs. with zero-input-panel.
see ~/lisp/elisp/zero/zero-input-table.el
- during development, press F8 to byte-compile and load the current el file.
this will also look for errors in the file.
......@@ -52,7 +52,7 @@ cd ~/lisp/elisp/zero/
user can click mouse in another emacs window.
whenever focus is moved outside current buffer, I need a hook to run
zero-focus-out.
zero-input-focus-out.
how to reproduce the problem
=============================
......@@ -75,7 +75,7 @@ cd ~/lisp/elisp/zero/
- how to check whether string contains character?
without converting char to string.
(zero-table-can-start-sequence) can use this.
(zero-input-table-can-start-sequence) can use this.
** 2019-10-10 documents
- Using of D-Bus
https://www.gnu.org/software/emacs/manual/html_mono/dbus.html
......@@ -92,8 +92,8 @@ I can't run them in git pre-commit hook.
Need to add headers to make it happy.
Because it doesn't have concept on multi-file package, it insists all
functions in file start with file name prefix. I can't have zero-* utility
function in zero-panel.el
functions in file start with file name prefix. I can't have zero-input-* utility
function in zero-input-panel.el
- M-x package-lint-current-buffer fail on zero.el file
this line:
......@@ -129,7 +129,7 @@ I can't run them in git pre-commit hook.
package-lint doesn't support multiple file pkg yet.
- create a single zero.el file for distribution.
rename current zero.el to zero-framework.el
rename current zero.el to zero-input-framework.el
create zero.el.in
- make build
should generate zero.el and run checks on it.
......@@ -146,7 +146,7 @@ I can't run them in git pre-commit hook.
-
** 2019-10-11 move tests to separated files.
otherwise (require 'zero-pinyin) will fail because (require 'ert) is not in
otherwise (require 'zero-input-pinyin) will fail because (require 'ert) is not in
source code.
** 2019-10-09 release zero-el on melpa
......
;;; zero-framework-test.el --- tests for zero-framework.el -*- lexical-binding: t -*-
;;; zero-input-framework-test.el --- tests for zero-input-framework.el -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
......@@ -14,31 +14,31 @@
;;; Commentary:
;; tests for zero-framework.el
;; tests for zero-input-framework.el
;;; Code:
(require 'zero-framework)
(require 'zero-input-framework)
(require 'ert)
(ert-deftest zero-cycle-list ()
(should (= (zero-cycle-list '(1 2 3) 1) 2))
(should (eq (zero-cycle-list '(a b c) 'a) 'b))
(should (eq (zero-cycle-list '(a b c) 'b) 'c))
(should (eq (zero-cycle-list '(a b c) 'c) 'a))
(should (eq (zero-cycle-list '(a b c) 'd) nil)))
(ert-deftest zero-input-cycle-list ()
(should (= (zero-input-cycle-list '(1 2 3) 1) 2))
(should (eq (zero-input-cycle-list '(a b c) 'a) 'b))
(should (eq (zero-input-cycle-list '(a b c) 'b) 'c))
(should (eq (zero-input-cycle-list '(a b c) 'c) 'a))
(should (eq (zero-input-cycle-list '(a b c) 'd) nil)))
(ert-deftest zero-convert-ch-to-full-width ()
(should (= (zero-convert-ch-to-full-width ?\!) ?\!)))
(ert-deftest zero-input-convert-ch-to-full-width ()
(should (= (zero-input-convert-ch-to-full-width ?\!) ?\!)))
(ert-deftest zero-convert-str-to-full-width ()
(should (string-equal "!" (zero-convert-str-to-full-width "!")))
(should (string-equal "(" (zero-convert-str-to-full-width "(")))
(should (string-equal "(:)" (zero-convert-str-to-full-width "(:)")))
(should (string-equal "ABab" (zero-convert-str-to-full-width "ABab")))
(should (string-equal "hehe" (zero-convert-str-to-full-width "hehe")))
(should (string-equal "(A)" (zero-convert-str-to-full-width "(A)"))))
(ert-deftest zero-input-convert-str-to-full-width ()
(should (string-equal "!" (zero-input-convert-str-to-full-width "!")))
(should (string-equal "(" (zero-input-convert-str-to-full-width "(")))
(should (string-equal "(:)" (zero-input-convert-str-to-full-width "(:)")))
(should (string-equal "ABab" (zero-input-convert-str-to-full-width "ABab")))
(should (string-equal "hehe" (zero-input-convert-str-to-full-width "hehe")))
(should (string-equal "(A)" (zero-input-convert-str-to-full-width "(A)"))))
(provide 'zero-framework-test)
(provide 'zero-input-framework-test)
;;; zero-framework-test.el ends here
;;; zero-input-framework-test.el ends here
;;; zero-panel-test.el --- tests for zero-panel.el -*- lexical-binding: t -*-
;;; zero-input-panel-test.el --- tests for zero-input-panel.el -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
......@@ -19,17 +19,17 @@
;;; Code:
(require 'ert)
(require 'zero-panel)
(require 'zero-input-panel)
(ert-deftest zero-alist-to-asv ()
(should (equal (zero-alist-to-asv nil) '(:array :signature "{sv}")))
(should (equal (zero-alist-to-asv
(ert-deftest zero-input-alist-to-asv ()
(should (equal (zero-input-alist-to-asv nil) '(:array :signature "{sv}")))
(should (equal (zero-input-alist-to-asv
'(("name" "foo")
("timeout" :int32 10)))
'(:array
(:dict-entry "name" (:variant "foo"))
(:dict-entry "timeout" (:variant :int32 10))))))
(provide 'zero-panel-test)
(provide 'zero-input-panel-test)
;;; zero-panel-test.el ends here
;;; zero-input-panel-test.el ends here
;;; zero-panel --- Provide emacs interface for zero-panel dbus service. -*- lexical-binding: t -*-
;;; zero-input-panel --- Provide emacs interface for zero-input-panel dbus service. -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
......@@ -14,7 +14,7 @@
;;; Commentary:
;; use dbus to communicate with zero-panel service.
;; use dbus to communicate with zero-input-panel service.
;;; Code:
......@@ -25,19 +25,19 @@
(require 'dbus)
(require 's)
(defun zero-panel-error-handler (event error)
(defun zero-input-panel-error-handler (event error)
"Handle dbus errors.
EVENT and ERROR are error-handler arguments."
(when (or (string-equal "com.emacsos.zero.Panel"
(dbus-event-interface-name event))
(s-contains-p "com.emacsos.zero.Panel" (cadr error)))
(error "Zero-panel dbus failed: %S" (cadr error))))
(error "Zero-Input-panel dbus failed: %S" (cadr error))))
(add-hook 'dbus-event-error-functions 'zero-panel-error-handler)
(add-hook 'dbus-event-error-functions 'zero-input-panel-error-handler)
(defun zero-panel-async-call (method _handler &rest args)
"Call METHOD on zero-panel service asynchronously.
(defun zero-input-panel-async-call (method _handler &rest args)
"Call METHOD on zero-input-panel service asynchronously.
This is a wrapper around `dbus-call-method-asynchronously'.
ARGS optional extra args to pass to the wrapped function."
......@@ -52,13 +52,13 @@ ARGS optional extra args to pass to the wrapped function."
;; public utility function
;;=========================
(defun zero-alist-to-asv (hints)
(defun zero-input-alist-to-asv (hints)
"Convert Lisp alist to dbus a{sv} data structure.
HINTS should be an alist of form '((k1 [v1type] v1) (k2 [v2type] v2)).
For example,
\(zero-alist-to-asv
\(zero-input-alist-to-asv
'((\"name\" \"foo\")
(\"timeout\" :int32 10)))
=>
......@@ -76,34 +76,34 @@ For example,
;; public API
;;============
(defun zero-panel-move (x y)
(defun zero-input-panel-move (x y)
"Move panel to specific coordinate (X, Y).
Origin (0, 0) is at screen top left corner."
(zero-panel-async-call "Move" nil :int32 x :int32 y))
(zero-input-panel-async-call "Move" nil :int32 x :int32 y))
(defun zero-panel-show-candidates (preedit_str candidate_length candidates &optional hints)
(defun zero-input-panel-show-candidates (preedit_str candidate_length candidates &optional hints)
"Show CANDIDATES.
Argument PREEDIT_STR the preedit string.
Argument CANDIDATE_LENGTH how many candidates are in candidates list."
(zero-panel-async-call "ShowCandidates" nil
(zero-input-panel-async-call "ShowCandidates" nil
:string preedit_str
:uint32 candidate_length
(or candidates '(:array))
(zero-alist-to-asv hints)))
(zero-input-alist-to-asv hints)))
(defun zero-panel-show ()
(defun zero-input-panel-show ()
"Show panel."
(zero-panel-async-call "Show" nil))
(zero-input-panel-async-call "Show" nil))
(defun zero-panel-hide ()
(defun zero-input-panel-hide ()
"Hide panel."
(zero-panel-async-call "Hide" nil))
(zero-input-panel-async-call "Hide" nil))
(defun zero-panel-quit ()
(defun zero-input-panel-quit ()
"Quit panel application."
(interactive)
(zero-panel-async-call "Quit" nil))
(zero-input-panel-async-call "Quit" nil))
(provide 'zero-panel)
(provide 'zero-input-panel)
;;; zero-panel.el ends here
;;; zero-input-panel.el ends here
;;; zero-pinyin-service-test.el --- tests for zero-pinyin-service.el -*- lexical-binding: t -*-
;;; zero-input-pinyin-service-test.el --- tests for zero-input-pinyin-service.el -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
......@@ -18,42 +18,42 @@
;;; Code:
(require 'zero-pinyin-service)
(require 'zero-input-pinyin-service)
(require 'ert)
(eval-when-compile (require 'cl-macs))
(ert-deftest zero-pinyin-candidate-pinyin-indices-to-dbus-format ()
(should (equal (zero-pinyin-candidate-pinyin-indices-to-dbus-format '((22 31)))
(ert-deftest zero-input-pinyin-candidate-pinyin-indices-to-dbus-format ()
(should (equal (zero-input-pinyin-candidate-pinyin-indices-to-dbus-format '((22 31)))
'(:array (:struct :int32 22 :int32 31))))
(should (equal (zero-pinyin-candidate-pinyin-indices-to-dbus-format
(should (equal (zero-input-pinyin-candidate-pinyin-indices-to-dbus-format
'((17 46) (7 55)))
'(:array (:struct :int32 17 :int32 46)
(:struct :int32 7 :int32 55)))))
(ert-deftest zero-pinyin-service-get-candidates ()
(ert-deftest zero-input-pinyin-service-get-candidates ()
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "liyifeng" 1)
(zero-input-pinyin-service-get-candidates "liyifeng" 1)
(should (or (and (equal (car cs) "李易峰")
(= (car ls) 8))
(and (equal (car cs) "利益")
(= (car ls) 4)))))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "wenti" 1)
(zero-input-pinyin-service-get-candidates "wenti" 1)
(should (equal (car cs) "问题"))
(should (= (car ls) 5)))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "meiyou" 1)
(zero-input-pinyin-service-get-candidates "meiyou" 1)
(should (equal (car cs) "没有"))
(should (= (car ls) 6)))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "shi" 1)
(zero-input-pinyin-service-get-candidates "shi" 1)
(should (equal (car cs) "是"))
(should (= (car ls) 3)))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "de" 1)
(zero-input-pinyin-service-get-candidates "de" 1)
(should (equal (car cs) "的"))
(should (= (car ls) 2))))
(provide 'zero-pinyin-service-test)
(provide 'zero-input-pinyin-service-test)
;;; zero-pinyin-service-test.el ends here
;;; zero-input-pinyin-service-test.el ends here
;;; zero-pinyin-service.el --- Provide emacs interface for zero-pinyin-service dbus service. -*- lexical-binding: t -*-
;;; zero-input-pinyin-service.el --- Provide emacs interface for zero-input-pinyin-service dbus service. -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
......@@ -23,67 +23,67 @@
(require 'dbus)
(require 's)
(defvar zero-pinyin-service-service-name
(defvar zero-input-pinyin-service-service-name
"com.emacsos.zero.ZeroPinyinService1")
(defvar zero-pinyin-service-path
(defvar zero-input-pinyin-service-path
"/com/emacsos/zero/ZeroPinyinService1")
(defvar zero-pinyin-service-interface
(defvar zero-input-pinyin-service-interface
"com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface")
(defvar zero-pinyin-fuzzy-flag 0)
(defvar zero-input-pinyin-fuzzy-flag 0)
(defun zero-pinyin-service-error-handler (event error)
(defun zero-input-pinyin-service-error-handler (event error)
"Handle dbus errors.
EVENT, ERROR are arguments passed to the handler."
(when (or (string-equal zero-pinyin-service-service-name
(when (or (string-equal zero-input-pinyin-service-service-name
(dbus-event-interface-name event))
(s-contains-p zero-pinyin-service-service-name (cadr error)))
(error "`zero-pinyin-service' dbus failed: %S" (cadr error))))
(s-contains-p zero-input-pinyin-service-service-name (cadr error)))
(error "`zero-input-pinyin-service' dbus failed: %S" (cadr error))))
(add-hook 'dbus-event-error-functions 'zero-pinyin-service-error-handler)
(add-hook 'dbus-event-error-functions 'zero-input-pinyin-service-error-handler)
(defun zero-pinyin-service-async-call (method handler &rest args)
"Call METHOD on zero-pinin-service asynchronously.
(defun zero-input-pinyin-service-async-call (method handler &rest args)
"Call METHOD on zero-input-pinin-service asynchronously.
This is a wrapper around `dbus-call-method-asynchronously'.
Argument HANDLER the handler function.
Optional argument ARGS extra arguments to pass to the wrapped function."
(apply 'dbus-call-method-asynchronously
:session zero-pinyin-service-service-name
zero-pinyin-service-path
zero-pinyin-service-interface
:session zero-input-pinyin-service-service-name
zero-input-pinyin-service-path
zero-input-pinyin-service-interface
method handler :timeout 1000 args))
(defun zero-pinyin-service-call (method &rest args)
"Call METHOD on zero-pinin-service synchronously.
(defun zero-input-pinyin-service-call (method &rest args)
"Call METHOD on zero-input-pinin-service synchronously.
This is a wrapper around `dbus-call-method'.
Optional argument ARGS extra arguments to pass to the wrapped function."
(apply 'dbus-call-method
:session zero-pinyin-service-service-name
zero-pinyin-service-path
zero-pinyin-service-interface
:session zero-input-pinyin-service-service-name
zero-input-pinyin-service-path
zero-input-pinyin-service-interface
method :timeout 1000 args))
;;============
;; public API
;;============
(defun zero-pinyin-service-get-candidates (preedit-str fetch-size)
(defun zero-input-pinyin-service-get-candidates (preedit-str fetch-size)
"Get candidates for pinyin in PREEDIT-STR synchronously.
preedit-str the preedit-str, should be pure pinyin string
FETCH-SIZE try to fetch this many candidates or more"
(zero-pinyin-service-call "GetCandidatesV2" :string preedit-str :uint32 fetch-size :uint32 zero-pinyin-fuzzy-flag))
(zero-input-pinyin-service-call "GetCandidatesV2" :string preedit-str :uint32 fetch-size :uint32 zero-input-pinyin-fuzzy-flag))
(defun zero-pinyin-service-get-candidates-async (preedit-str fetch-size get-candidates-complete)
(defun zero-input-pinyin-service-get-candidates-async (preedit-str fetch-size get-candidates-complete)
"Get candidates for pinyin in PREEDIT-STR asynchronously.
PREEDIT-STR the preedit string, should be pure pinyin string.
FETCH-SIZE try to fetch this many candidates or more.
GET-CANDIDATES-COMPLETE the async handler function."
(zero-pinyin-service-async-call
"GetCandidatesV2" get-candidates-complete :string preedit-str :uint32 fetch-size :uint32 zero-pinyin-fuzzy-flag))
(zero-input-pinyin-service-async-call
"GetCandidatesV2" get-candidates-complete :string preedit-str :uint32 fetch-size :uint32 zero-input-pinyin-fuzzy-flag))
(defun zero-pinyin-candidate-pinyin-indices-to-dbus-format (candidate_pinyin_indices)
(defun zero-input-pinyin-candidate-pinyin-indices-to-dbus-format (candidate_pinyin_indices)
"Convert CANDIDATE_PINYIN_INDICES to Emacs dbus format."
(let (result)
(push :array result)
......@@ -94,28 +94,28 @@ GET-CANDIDATES-COMPLETE the async handler function."
result))
(reverse result)))
(defun zero-pinyin-service-commit-candidate-async (candidate candidate_pinyin_indices)
(defun zero-input-pinyin-service-commit-candidate-async (candidate candidate_pinyin_indices)
"Commit candidate asynchronously.
CANDIDATE the candidate user selected.
CANDIDATE_PINYIN_INDICES the candidate's pinyin shengmu and yunmu index."
;; don't care about the result, so no callback.
(zero-pinyin-service-async-call
(zero-input-pinyin-service-async-call
"CommitCandidate" nil
:string candidate
(zero-pinyin-candidate-pinyin-indices-to-dbus-format candidate_pinyin_indices)))
(zero-input-pinyin-candidate-pinyin-indices-to-dbus-format candidate_pinyin_indices)))
(defun zero-pinyin-service-delete-candidates-async (candidate delete-candidate-complete)
(defun zero-input-pinyin-service-delete-candidates-async (candidate delete-candidate-complete)
"Delete CANDIDATE asynchronously.
DELETE-CANDIDATE-COMPLETE the async handler function."
(zero-pinyin-service-async-call
(zero-input-pinyin-service-async-call
"DeleteCandidate" delete-candidate-complete :string candidate))
(defun zero-pinyin-service-quit ()
(defun zero-input-pinyin-service-quit ()
"Quit panel application."
(zero-pinyin-service-async-call "Quit" nil))
(zero-input-pinyin-service-async-call "Quit" nil))