Commit 30af996e authored by Yuanle Song's avatar Yuanle Song
Browse files

v2.0.6 support space in full-width mode

parent 5bee1948
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -85,12 +85,20 @@ cd ~/lisp/elisp/zero/
** 2019-11-10 关于屏幕闪烁,我临时解决方案是中文输入时,当光标到达半屏的时候,自动跳到首行,这样也方便一些,不过还是期待后续版本能解决这个问题
* current                                                             :entry:
** 
** 2019-11-10 space doesn't work in full-width mode.
** 2019-11-03 add completion support for zero-input-set-im
complete registered im symbols.
** 2019-10-23 checkdoc and package-lint can't ignore some non-issues.
I can't run them in git pre-commit hook.
* done                                                                :entry:
** 2019-11-10 space doesn't work in full-width mode.
全角和半角 - 维基百科,自由的百科全书
https://zh.wikipedia.org/wiki/%E5%85%A8%E5%BD%A2%E5%92%8C%E5%8D%8A%E5%BD%A2

ascii   full-width unicode codepoint.
0x20 	" " 	U+3000

- add a failing unit test.

** 2019-11-07 full width mode no longer works. why?
C-c , . enabled full-width mode.
but modeline is not changed.
+2 −1
Original line number Diff line number Diff line
@@ -29,7 +29,8 @@
  (should (eq (zero-input-cycle-list '(a b c) 'd) nil)))

(ert-deftest zero-input-convert-ch-to-full-width ()
  (should (= (zero-input-convert-ch-to-full-width ?\!) ?\!)))
  (should (= (zero-input-convert-ch-to-full-width ?\!) ?\!))
  (should (= (zero-input-convert-ch-to-full-width ?\s) ?\u3000)))

(ert-deftest zero-input-convert-str-to-full-width ()
  (should (string-equal "!" (zero-input-convert-str-to-full-width "!")))
+11 −7
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ If item is not in lst, return nil."

;; zero-input-el version
(defvar zero-input-version nil "Zero package version.")
(setq zero-input-version "2.0.5")
(setq zero-input-version "2.0.6")

;; FSM state
(defconst zero-input--state-im-off 'IM-OFF)
@@ -352,13 +352,17 @@ COMPLETE-FUNC the function to call when build candidates completes."
    ;; update cache to make SPC and digit key selection possible.
    (funcall complete-func candidates)))

(defvar zero-input-full-width-char-map
  ;; ascii 33 to 126 map to
  ;; unicode FF01 to FF5E
(defvar zero-input-full-width-char-map nil
  "An alist that map half-width char to full-width char.")
(setq zero-input-full-width-char-map
      (cons
       ;; ascii 32 -> unicode 3000
       (cons ?\s ?\u3000)
       ;; ascii [33, 126] -> unicode [FF01, FF5E]
       (cl-loop
	for i from 33 to 126
   collect (cons (make-char 'ascii i) (make-char 'unicode 0 255 (- i 32))))
  "An alist that map half-width char to full-width char.")
	collect (cons (make-char 'ascii i)
		      (make-char 'unicode 0 255 (- i 32))))))

(defun zero-input-convert-ch-to-full-width (ch)
  "Convert half-width char CH to full-width.
+12 −8
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
;; See the License for the specific language governing permissions and
;; limitations under the License.

;; Version: 2.0.5
;; Version: 2.0.6
;; URL: https://gitlab.emacsos.com/sylecn/zero-el
;; Package-Requires: ((emacs "24.3") (s "1.2.0"))

@@ -243,7 +243,7 @@ If item is not in lst, return nil."

;; zero-input-el version
(defvar zero-input-version nil "Zero package version.")
(setq zero-input-version "2.0.5")
(setq zero-input-version "2.0.6")

;; FSM state
(defconst zero-input--state-im-off 'IM-OFF)
@@ -463,13 +463,17 @@ COMPLETE-FUNC the function to call when build candidates completes."
    ;; update cache to make SPC and digit key selection possible.
    (funcall complete-func candidates)))

(defvar zero-input-full-width-char-map
  ;; ascii 33 to 126 map to
  ;; unicode FF01 to FF5E
(defvar zero-input-full-width-char-map nil
  "An alist that map half-width char to full-width char.")
(setq zero-input-full-width-char-map
      (cons
       ;; ascii 32 -> unicode 3000
       (cons ?\s ?\u3000)
       ;; ascii [33, 126] -> unicode [FF01, FF5E]
       (cl-loop
	for i from 33 to 126
   collect (cons (make-char 'ascii i) (make-char 'unicode 0 255 (- i 32))))
  "An alist that map half-width char to full-width char.")
	collect (cons (make-char 'ascii i)
		      (make-char 'unicode 0 255 (- i 32))))))

(defun zero-input-convert-ch-to-full-width (ch)
  "Convert half-width char CH to full-width.