A multilingual input method framework
Revision | 78a7b56a5a544bfdf4cd07aa82770fcc8b9c51f2 (tree) |
---|---|
Time | 2012-12-22 11:21:13 |
Author | KIHARA Hideto <deton@m1.i...> |
Commiter | KIHARA Hideto |
Add function to shrink katakana string just after postfix katakana conversion.
* scm/tutcode.scm
@@ -3997,6 +3997,27 @@ | ||
3997 | 3997 | (not (tutcode-context-katakana-mode? pc)))) |
3998 | 3998 | (tutcode-context-set-state! pc 'tutcode-state-postfix-katakana)))))) |
3999 | 3999 | |
4000 | +;;; 直前の後置型カタカナ変換を縮める | |
4001 | +;;; @param count 縮める文字数 | |
4002 | +(define (tutcode-postfix-katakana-shrink pc count) | |
4003 | + (let ((undo (tutcode-context-undo pc))) | |
4004 | + (if (and (pair? undo) | |
4005 | + (eq? (list-ref undo 0) 'tutcode-state-off)) ; 後置型変換 | |
4006 | + (let* ((commit-len (list-ref undo 1)) | |
4007 | + (yomi (list-ref undo 2)) | |
4008 | + (yomi-len (length yomi))) | |
4009 | + (tutcode-postfix-delete-text pc commit-len) | |
4010 | + (receive (kata hira) | |
4011 | + (if (< count yomi-len) | |
4012 | + (split-at yomi (- yomi-len count)) | |
4013 | + (values () yomi)) | |
4014 | + (let ((str (string-list-concat | |
4015 | + (append (tutcode-katakana-convert kata #t) hira)))) | |
4016 | + (tutcode-commit pc str) | |
4017 | + ;; shrinkを繰り返した際にcount文字ずつカタカナを縮められるように | |
4018 | + (tutcode-undo-prepare pc 'tutcode-state-off | |
4019 | + (string-list-concat kata) kata))))))) | |
4020 | + | |
4000 | 4021 | ;;; 後置型カタカナ変換の対象文字列を取得する |
4001 | 4022 | ;;; @param yomi-len 指定された文字数。指定されてない場合は#f。 |
4002 | 4023 | ;;; @return 取得した文字列(文字列の逆順リスト) |