diff options
| author | Kenichi Handa | 2003-04-11 03:58:22 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-04-11 03:58:22 +0000 |
| commit | 17388a6277f5e4ed891def2c5fc4a40580cd8032 (patch) | |
| tree | fed4f534b083df19fa00c78038d72e15e63d0cc5 | |
| parent | 389144243f4235ba0cd408992da809a781f8be5f (diff) | |
| download | emacs-17388a6277f5e4ed891def2c5fc4a40580cd8032.tar.gz emacs-17388a6277f5e4ed891def2c5fc4a40580cd8032.zip | |
* international/quail.el (quail-guidance-str)
(quail-guidance-frame): New variables.
(quail-guidance-win): Delete this variable.
(quail-setup-overlays): Make overlay not rear-advancing.
(quail-kill-guidance-buf): Delete this function.
(quail-activate): Add/remove quail-show-guidance to/from
post-command-hook.
(quail-input-method): Don't setup quail-guidance-buf. Initialize
quail-guidance-str to "".
(quail-start-translation): Call quail-show-guidance at first.
(quail-start-conversion): Likewise.
(quail-terminate-translation): Don't erase quail-guidance-buf.
(quail-update-translation): Stretch overlays if their starting and
ending positions are same.
(quail-update-current-translations): Check the width of the
current window, not the width of quail-guidance-win.
(quail-make-guidance-frame): Delete the arg BUF. Fix position
calculation. Don't set the window buffer, just return the new
frame.
(quail-minibuffer-message): New function.
(quail-show-guidance): Renamed from quail-show-guidance-buf. Use
message and quail-minibuffer-message to display the guidance.
(quail-hide-guidance): Renamed from quail-hide-guidance-buf. Only
delete quail-guidance-frame.
(quail-update-guidance): Just update quail-guidance-str, not
display it.
(quail-get-translations): Renamed from quail-show-translations.
Return a string instead of inserting it in quail-guaidance-buf.
| -rw-r--r-- | lisp/ChangeLog | 31 | ||||
| -rw-r--r-- | lisp/international/quail.el | 388 |
2 files changed, 209 insertions, 210 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 74b574ecb3c..e3c0b9d2d14 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,36 @@ | |||
| 1 | 2003-04-11 Kenichi Handa <handa@m17n.org> | 1 | 2003-04-11 Kenichi Handa <handa@m17n.org> |
| 2 | 2 | ||
| 3 | * international/quail.el (quail-guidance-str) | ||
| 4 | (quail-guidance-frame): New variables. | ||
| 5 | (quail-guidance-win): Delete this variable. | ||
| 6 | (quail-setup-overlays): Make overlay not rear-advancing. | ||
| 7 | (quail-kill-guidance-buf): Delete this function. | ||
| 8 | (quail-activate): Add/remove quail-show-guidance to/from | ||
| 9 | post-command-hook. | ||
| 10 | (quail-input-method): Don't setup quail-guidance-buf. Initialize | ||
| 11 | quail-guidance-str to "". | ||
| 12 | (quail-start-translation): Call quail-show-guidance at first. | ||
| 13 | (quail-start-conversion): Likewise. | ||
| 14 | (quail-terminate-translation): Don't erase quail-guidance-buf. | ||
| 15 | (quail-update-translation): Stretch overlays if their starting and | ||
| 16 | ending positions are same. | ||
| 17 | (quail-update-current-translations): Check the width of the | ||
| 18 | current window, not the width of quail-guidance-win. | ||
| 19 | (quail-make-guidance-frame): Delete the arg BUF. Fix position | ||
| 20 | calculation. Don't set the window buffer, just return the new | ||
| 21 | frame. | ||
| 22 | (quail-minibuffer-message): New function. | ||
| 23 | (quail-show-guidance): Renamed from quail-show-guidance-buf. Use | ||
| 24 | message and quail-minibuffer-message to display the guidance. | ||
| 25 | (quail-hide-guidance): Renamed from quail-hide-guidance-buf. Only | ||
| 26 | delete quail-guidance-frame. | ||
| 27 | (quail-update-guidance): Just update quail-guidance-str, not | ||
| 28 | display it. | ||
| 29 | (quail-get-translations): Renamed from quail-show-translations. | ||
| 30 | Return a string instead of inserting it in quail-guaidance-buf. | ||
| 31 | |||
| 32 | 2003-04-11 Kenichi Handa <handa@m17n.org> | ||
| 33 | |||
| 3 | * international/mule-cmds.el (sort-coding-systems): Set lower | 34 | * international/mule-cmds.el (sort-coding-systems): Set lower |
| 4 | priority to a utf-16 base coding system. Set higher priority to a | 35 | priority to a utf-16 base coding system. Set higher priority to a |
| 5 | coding system listed in coding-category-list. | 36 | coding system listed in coding-category-list. |
diff --git a/lisp/international/quail.el b/lisp/international/quail.el index 81a991263fa..187a7532091 100644 --- a/lisp/international/quail.el +++ b/lisp/international/quail.el | |||
| @@ -66,20 +66,19 @@ See the documentation of `quail-package-alist' for the format.") | |||
| 66 | (make-variable-buffer-local 'quail-current-package) | 66 | (make-variable-buffer-local 'quail-current-package) |
| 67 | (put 'quail-current-package 'permanent-local t) | 67 | (put 'quail-current-package 'permanent-local t) |
| 68 | 68 | ||
| 69 | ;; Quail uses the following two buffers to assist users. | 69 | ;; Quail uses the following variables to assist users. |
| 70 | ;; A buffer to show available key sequence or translation list. | 70 | ;; A string containing available key sequences or translation list. |
| 71 | (defvar quail-guidance-buf nil) | 71 | (defvar quail-guidance-str nil) |
| 72 | ;; A buffer to show completion list of the current key sequence. | 72 | ;; A buffer to show completion list of the current key sequence. |
| 73 | (defvar quail-completion-buf nil) | 73 | (defvar quail-completion-buf nil) |
| 74 | ;; We may display the guidance string in a buffer on a one-line frame. | ||
| 75 | (defvar quail-guidance-buf nil) | ||
| 76 | (defvar quail-guidance-frame nil) | ||
| 74 | 77 | ||
| 75 | ;; Each buffer in which Quail is activated should use different | 78 | ;; Each buffer in which Quail is activated should use different |
| 76 | ;; guidance buffers. | 79 | ;; guidance string. |
| 77 | (make-variable-buffer-local 'quail-guidance-buf) | 80 | (make-variable-buffer-local 'quail-guidance-str) |
| 78 | (put 'quail-guidance-buf 'permanent-local t) | 81 | (put 'quail-guidance-str 'permanent-local t) |
| 79 | |||
| 80 | ;; A main window showing Quail guidance buffer. | ||
| 81 | (defvar quail-guidance-win nil) | ||
| 82 | (make-variable-buffer-local 'quail-guidance-win) | ||
| 83 | 82 | ||
| 84 | (defvar quail-overlay nil | 83 | (defvar quail-overlay nil |
| 85 | "Overlay which covers the current translation region of Quail.") | 84 | "Overlay which covers the current translation region of Quail.") |
| @@ -514,7 +513,7 @@ non-Quail commands." | |||
| 514 | (let ((pos (point))) | 513 | (let ((pos (point))) |
| 515 | (if (overlayp quail-overlay) | 514 | (if (overlayp quail-overlay) |
| 516 | (move-overlay quail-overlay pos pos) | 515 | (move-overlay quail-overlay pos pos) |
| 517 | (setq quail-overlay (make-overlay pos pos nil nil t)) | 516 | (setq quail-overlay (make-overlay pos pos)) |
| 518 | (if input-method-highlight-flag | 517 | (if input-method-highlight-flag |
| 519 | (overlay-put quail-overlay 'face 'underline)) | 518 | (overlay-put quail-overlay 'face 'underline)) |
| 520 | (let ((l (quail-overlay-plist))) | 519 | (let ((l (quail-overlay-plist))) |
| @@ -525,7 +524,7 @@ non-Quail commands." | |||
| 525 | (if (overlayp quail-conv-overlay) | 524 | (if (overlayp quail-conv-overlay) |
| 526 | (if (not (overlay-start quail-conv-overlay)) | 525 | (if (not (overlay-start quail-conv-overlay)) |
| 527 | (move-overlay quail-conv-overlay pos pos)) | 526 | (move-overlay quail-conv-overlay pos pos)) |
| 528 | (setq quail-conv-overlay (make-overlay pos pos nil nil t)) | 527 | (setq quail-conv-overlay (make-overlay pos pos)) |
| 529 | (if input-method-highlight-flag | 528 | (if input-method-highlight-flag |
| 530 | (overlay-put quail-conv-overlay 'face 'underline)))))) | 529 | (overlay-put quail-conv-overlay 'face 'underline)))))) |
| 531 | 530 | ||
| @@ -536,11 +535,6 @@ non-Quail commands." | |||
| 536 | (if (and (overlayp quail-conv-overlay) (overlay-start quail-conv-overlay)) | 535 | (if (and (overlayp quail-conv-overlay) (overlay-start quail-conv-overlay)) |
| 537 | (delete-overlay quail-conv-overlay))) | 536 | (delete-overlay quail-conv-overlay))) |
| 538 | 537 | ||
| 539 | ;; Kill Quail guidance buffer. Set in kill-buffer-hook. | ||
| 540 | (defun quail-kill-guidance-buf () | ||
| 541 | (if (buffer-live-p quail-guidance-buf) | ||
| 542 | (kill-buffer quail-guidance-buf))) | ||
| 543 | |||
| 544 | (defun quail-inactivate () | 538 | (defun quail-inactivate () |
| 545 | "Inactivate Quail input method. | 539 | "Inactivate Quail input method. |
| 546 | 540 | ||
| @@ -562,9 +556,10 @@ While this input method is active, the variable | |||
| 562 | ;; Let's inactivate Quail input method. | 556 | ;; Let's inactivate Quail input method. |
| 563 | (unwind-protect | 557 | (unwind-protect |
| 564 | (progn | 558 | (progn |
| 565 | (quail-hide-guidance-buf) | ||
| 566 | (quail-delete-overlays) | 559 | (quail-delete-overlays) |
| 567 | (setq describe-current-input-method-function nil) | 560 | (setq describe-current-input-method-function nil) |
| 561 | (quail-hide-guidance) | ||
| 562 | (remove-hook 'post-command-hook 'quail-show-guidance t) | ||
| 568 | (run-hooks 'quail-inactivate-hook)) | 563 | (run-hooks 'quail-inactivate-hook)) |
| 569 | (kill-local-variable 'input-method-function)) | 564 | (kill-local-variable 'input-method-function)) |
| 570 | ;; Let's activate Quail input method. | 565 | ;; Let's activate Quail input method. |
| @@ -578,12 +573,13 @@ While this input method is active, the variable | |||
| 578 | (setq inactivate-current-input-method-function 'quail-inactivate) | 573 | (setq inactivate-current-input-method-function 'quail-inactivate) |
| 579 | (setq describe-current-input-method-function 'quail-help) | 574 | (setq describe-current-input-method-function 'quail-help) |
| 580 | (quail-delete-overlays) | 575 | (quail-delete-overlays) |
| 581 | (quail-show-guidance-buf) | 576 | (setq quail-guidance-str "") |
| 577 | (quail-show-guidance) | ||
| 582 | ;; If we are in minibuffer, turn off the current input method | 578 | ;; If we are in minibuffer, turn off the current input method |
| 583 | ;; before exiting. | 579 | ;; before exiting. |
| 584 | (if (eq (selected-window) (minibuffer-window)) | 580 | (when (eq (selected-window) (minibuffer-window)) |
| 585 | (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer)) | 581 | (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer) |
| 586 | (add-hook 'kill-buffer-hook 'quail-kill-guidance-buf nil t) | 582 | (add-hook 'post-command-hook 'quail-show-guidance nil t)) |
| 587 | (run-hooks 'quail-activate-hook) | 583 | (run-hooks 'quail-activate-hook) |
| 588 | (make-local-variable 'input-method-function) | 584 | (make-local-variable 'input-method-function) |
| 589 | (setq input-method-function 'quail-input-method))) | 585 | (setq input-method-function 'quail-input-method))) |
| @@ -1313,25 +1309,17 @@ Do so while interleaving with the following special events: | |||
| 1313 | (quail-setup-overlays (quail-conversion-keymap)) | 1309 | (quail-setup-overlays (quail-conversion-keymap)) |
| 1314 | (let ((modified-p (buffer-modified-p)) | 1310 | (let ((modified-p (buffer-modified-p)) |
| 1315 | (buffer-undo-list t)) | 1311 | (buffer-undo-list t)) |
| 1316 | (or (and quail-guidance-win | ||
| 1317 | (window-live-p quail-guidance-win) | ||
| 1318 | (eq (window-buffer quail-guidance-win) quail-guidance-buf) | ||
| 1319 | (not input-method-use-echo-area)) | ||
| 1320 | (quail-show-guidance-buf)) | ||
| 1321 | (unwind-protect | 1312 | (unwind-protect |
| 1322 | (let ((input-string (if (quail-conversion-keymap) | 1313 | (let ((input-string (if (quail-conversion-keymap) |
| 1323 | (quail-start-conversion key) | 1314 | (quail-start-conversion key) |
| 1324 | (quail-start-translation key)))) | 1315 | (quail-start-translation key)))) |
| 1316 | (setq quail-guidance-str "") | ||
| 1325 | (when (and (stringp input-string) | 1317 | (when (and (stringp input-string) |
| 1326 | (> (length input-string) 0)) | 1318 | (> (length input-string) 0)) |
| 1327 | (if input-method-exit-on-first-char | 1319 | (if input-method-exit-on-first-char |
| 1328 | (list (aref input-string 0)) | 1320 | (list (aref input-string 0)) |
| 1329 | (quail-input-string-to-events input-string)))) | 1321 | (quail-input-string-to-events input-string)))) |
| 1330 | (quail-delete-overlays) | 1322 | (quail-delete-overlays) |
| 1331 | (if (buffer-live-p quail-guidance-buf) | ||
| 1332 | (with-current-buffer quail-guidance-buf | ||
| 1333 | (erase-buffer))) | ||
| 1334 | (quail-hide-guidance-buf) | ||
| 1335 | (set-buffer-modified-p modified-p) | 1323 | (set-buffer-modified-p modified-p) |
| 1336 | ;; Run this hook only when the current input method doesn't require | 1324 | ;; Run this hook only when the current input method doesn't require |
| 1337 | ;; conversion. When conversion is required, the conversion function | 1325 | ;; conversion. When conversion is required, the conversion function |
| @@ -1378,6 +1366,7 @@ Return the input string." | |||
| 1378 | (setq unread-command-events (cons key unread-command-events))) | 1366 | (setq unread-command-events (cons key unread-command-events))) |
| 1379 | (while quail-translating | 1367 | (while quail-translating |
| 1380 | (set-buffer-modified-p modified-p) | 1368 | (set-buffer-modified-p modified-p) |
| 1369 | (quail-show-guidance) | ||
| 1381 | (let* ((keyseq (read-key-sequence | 1370 | (let* ((keyseq (read-key-sequence |
| 1382 | (and input-method-use-echo-area | 1371 | (and input-method-use-echo-area |
| 1383 | (concat input-method-previous-message | 1372 | (concat input-method-previous-message |
| @@ -1442,8 +1431,7 @@ Return the input string." | |||
| 1442 | quail-current-str "" | 1431 | quail-current-str "" |
| 1443 | quail-translating t) | 1432 | quail-translating t) |
| 1444 | (quail-setup-overlays nil))) | 1433 | (quail-setup-overlays nil))) |
| 1445 | ;; Hide '... loaded' message. | 1434 | (quail-show-guidance) |
| 1446 | (message nil) | ||
| 1447 | (let* ((keyseq (read-key-sequence | 1435 | (let* ((keyseq (read-key-sequence |
| 1448 | (and input-method-use-echo-area | 1436 | (and input-method-use-echo-area |
| 1449 | (concat input-method-previous-message | 1437 | (concat input-method-previous-message |
| @@ -1492,9 +1480,7 @@ Return the input string." | |||
| 1492 | (defun quail-terminate-translation () | 1480 | (defun quail-terminate-translation () |
| 1493 | "Terminate the translation of the current key." | 1481 | "Terminate the translation of the current key." |
| 1494 | (setq quail-translating nil) | 1482 | (setq quail-translating nil) |
| 1495 | (if (buffer-live-p quail-guidance-buf) | 1483 | (setq quail-guidance-str " ")) |
| 1496 | (with-current-buffer quail-guidance-buf | ||
| 1497 | (erase-buffer)))) | ||
| 1498 | 1484 | ||
| 1499 | (defun quail-select-current () | 1485 | (defun quail-select-current () |
| 1500 | "Accept the currently selected translation." | 1486 | "Accept the currently selected translation." |
| @@ -1535,9 +1521,18 @@ with more keys." | |||
| 1535 | (quail-simple)) | 1521 | (quail-simple)) |
| 1536 | (setq control-flag t))))))) | 1522 | (setq control-flag t))))))) |
| 1537 | (or input-method-use-echo-area | 1523 | (or input-method-use-echo-area |
| 1538 | (progn | 1524 | (let (pos) |
| 1539 | (quail-delete-region) | 1525 | (quail-delete-region) |
| 1540 | (insert quail-current-str))) | 1526 | (setq pos (point)) |
| 1527 | (insert quail-current-str) | ||
| 1528 | (move-overlay quail-overlay pos (point)) | ||
| 1529 | (if (overlayp quail-conv-overlay) | ||
| 1530 | (if (not (overlay-start quail-conv-overlay)) | ||
| 1531 | (move-overlay quail-conv-overlay pos (point)) | ||
| 1532 | (if (< (overlay-end quail-conv-overlay) (point)) | ||
| 1533 | (move-overlay quail-conv-overlay | ||
| 1534 | (overlay-start quail-conv-overlay) | ||
| 1535 | (point))))))) | ||
| 1541 | (let (quail-current-str) | 1536 | (let (quail-current-str) |
| 1542 | (quail-update-guidance)) | 1537 | (quail-update-guidance)) |
| 1543 | (or (stringp quail-current-str) | 1538 | (or (stringp quail-current-str) |
| @@ -1601,7 +1596,7 @@ Make RELATIVE-INDEX the current translation." | |||
| 1601 | (< cur start) ; We moved to the previous block. | 1596 | (< cur start) ; We moved to the previous block. |
| 1602 | (>= cur end)) ; We moved to the next block. | 1597 | (>= cur end)) ; We moved to the next block. |
| 1603 | (let ((len (length (cdr quail-current-translations))) | 1598 | (let ((len (length (cdr quail-current-translations))) |
| 1604 | (maxcol (- (window-width quail-guidance-win) | 1599 | (maxcol (- (window-width) |
| 1605 | quail-guidance-translations-starting-column)) | 1600 | quail-guidance-translations-starting-column)) |
| 1606 | (block (nth 3 indices)) | 1601 | (block (nth 3 indices)) |
| 1607 | col idx width trans num-items blocks) | 1602 | col idx width trans num-items blocks) |
| @@ -1863,8 +1858,8 @@ Remaining args are for FUNC." | |||
| 1863 | 1858 | ||
| 1864 | ;; Guidance, Completion, and Help buffer handlers. | 1859 | ;; Guidance, Completion, and Help buffer handlers. |
| 1865 | 1860 | ||
| 1866 | (defun quail-make-guidance-frame (buf) | 1861 | (defun quail-make-guidance-frame () |
| 1867 | "Make a new one-line frame for Quail guidance buffer." | 1862 | "Make a new one-line frame for Quail guidance." |
| 1868 | (let* ((fparam (frame-parameters)) | 1863 | (let* ((fparam (frame-parameters)) |
| 1869 | (top (cdr (assq 'top fparam))) | 1864 | (top (cdr (assq 'top fparam))) |
| 1870 | (border (cdr (assq 'border-width fparam))) | 1865 | (border (cdr (assq 'border-width fparam))) |
| @@ -1872,14 +1867,11 @@ Remaining args are for FUNC." | |||
| 1872 | (newtop (- top | 1867 | (newtop (- top |
| 1873 | (frame-char-height) (* internal-border 2) (* border 2)))) | 1868 | (frame-char-height) (* internal-border 2) (* border 2)))) |
| 1874 | (if (< newtop 0) | 1869 | (if (< newtop 0) |
| 1875 | (setq newtop (+ top (frame-pixel-height)))) | 1870 | (setq newtop (+ top (frame-pixel-height) internal-border border))) |
| 1876 | (let* ((frame (make-frame (append '((user-position . t) (height . 1) | 1871 | (make-frame (append '((user-position . t) (height . 1) |
| 1877 | (minibuffer) (menu-bar-lines . 0)) | 1872 | (minibuffer) |
| 1878 | (cons (cons 'top newtop) fparam)))) | 1873 | (menu-bar-lines . 0) (tool-bar-lines . 0)) |
| 1879 | (win (frame-first-window frame))) | 1874 | (cons (cons 'top newtop) fparam))))) |
| 1880 | (set-window-buffer win buf) | ||
| 1881 | ;;(set-window-dedicated-p win t) | ||
| 1882 | ))) | ||
| 1883 | 1875 | ||
| 1884 | (defun quail-setup-completion-buf () | 1876 | (defun quail-setup-completion-buf () |
| 1885 | "Setup Quail completion buffer." | 1877 | "Setup Quail completion buffer." |
| @@ -1900,124 +1892,96 @@ Remaining args are for FUNC." | |||
| 1900 | (not (quail-simple)) | 1892 | (not (quail-simple)) |
| 1901 | t)))) | 1893 | t)))) |
| 1902 | 1894 | ||
| 1903 | (defun quail-show-guidance-buf () | 1895 | |
| 1904 | "Display a guidance buffer for Quail input method in some window. | 1896 | ;; Quail specific version of minibuffer-message. It displays STRING |
| 1905 | Create the buffer if it does not exist yet. | 1897 | ;; with timeout 1000000 seconds instead of two seconds. |
| 1906 | The buffer is normally displayed at the echo area, | 1898 | |
| 1907 | but if the current buffer is a minibuffer, it is shown in | 1899 | (defun quail-minibuffer-message (string) |
| 1908 | the bottom-most ordinary window of the same frame, | 1900 | (message nil) |
| 1909 | or in a newly created frame (if the selected frame has no other windows)." | 1901 | (let ((point-max (point-max)) |
| 1910 | (when (quail-require-guidance-buf) | 1902 | (inhibit-quit t)) |
| 1911 | ;; At first, setup a guidance buffer. | 1903 | (save-excursion |
| 1912 | (let ((default-enable-multibyte-characters enable-multibyte-characters)) | 1904 | (goto-char point-max) |
| 1913 | (or (buffer-live-p quail-guidance-buf) | 1905 | (insert string)) |
| 1914 | (setq quail-guidance-buf (generate-new-buffer " *Quail-guidance*")))) | 1906 | (sit-for 1000000) |
| 1915 | (let ((package quail-current-package)) | 1907 | (delete-region point-max (point-max)) |
| 1916 | (with-current-buffer quail-guidance-buf | 1908 | (when quit-flag |
| 1917 | ;; To show the title of Quail package. | 1909 | (setq quit-flag nil |
| 1918 | (setq quail-current-package package | 1910 | unread-command-events '(7))))) |
| 1919 | current-input-method (quail-name) | 1911 | |
| 1920 | current-input-method-title (quail-title)) | 1912 | (defun quail-show-guidance () |
| 1921 | (erase-buffer) | 1913 | "Display a guidance for Quail input method in some window. |
| 1922 | (or (overlayp quail-overlay) | 1914 | The guidance is normally displayed at the echo area, |
| 1923 | (progn | 1915 | or in a newly created frame (if the current buffer is a |
| 1924 | (setq quail-overlay (make-overlay 1 1)) | 1916 | minibuffer and the selected frame has no other windows)." |
| 1925 | (overlay-put quail-overlay 'face 'highlight))) | 1917 | ;; At first, setup a buffer for completion. |
| 1926 | (delete-overlay quail-overlay) | ||
| 1927 | (set-buffer-modified-p nil))) | ||
| 1928 | (bury-buffer quail-guidance-buf) | ||
| 1929 | |||
| 1930 | ;; Assign the buffer " *Minibuf-N*" to all windows which are now | ||
| 1931 | ;; displaying quail-guidance-buf. | ||
| 1932 | (let ((win-list (get-buffer-window-list quail-guidance-buf t t))) | ||
| 1933 | (while win-list | ||
| 1934 | (set-window-buffer (car win-list) | ||
| 1935 | (format " *Minibuf-%d*" (minibuffer-depth))) | ||
| 1936 | (setq win-list (cdr win-list)))) | ||
| 1937 | |||
| 1938 | ;; Then, display it in an appropriate window. | ||
| 1939 | (let ((win (minibuffer-window))) | ||
| 1940 | (if (or (eq (selected-window) win) | ||
| 1941 | input-method-use-echo-area) | ||
| 1942 | ;; Since we are in minibuffer, we can't use it for guidance. | ||
| 1943 | (if (eq win (frame-root-window)) | ||
| 1944 | ;; Create a frame. It is sure that we are using some | ||
| 1945 | ;; window system. | ||
| 1946 | (quail-make-guidance-frame quail-guidance-buf) | ||
| 1947 | ;; Find the bottom window and split it if necessary. | ||
| 1948 | (setq win (window-at | ||
| 1949 | 0 (1- (- (frame-height) (window-height win))))) | ||
| 1950 | (let ((height (window-height win)) | ||
| 1951 | (window-min-height 2)) | ||
| 1952 | ;; If WIN is tall enough, split it vertically and use | ||
| 1953 | ;; the lower one. | ||
| 1954 | (when (>= height 4) | ||
| 1955 | ;; Here, `split-window' returns a lower window | ||
| 1956 | ;; which is what we wanted. | ||
| 1957 | (setq win (split-window win (- height 2)))) | ||
| 1958 | (set-window-buffer win quail-guidance-buf) | ||
| 1959 | (with-current-buffer quail-guidance-buf | ||
| 1960 | (fit-window-to-buffer win nil (window-height win))))) | ||
| 1961 | (set-window-buffer win quail-guidance-buf) | ||
| 1962 | (set-minibuffer-window win)) | ||
| 1963 | (setq quail-guidance-win win))) | ||
| 1964 | |||
| 1965 | ;; And, create a buffer for completion. | ||
| 1966 | (quail-setup-completion-buf) | 1918 | (quail-setup-completion-buf) |
| 1967 | (bury-buffer quail-completion-buf)) | 1919 | (bury-buffer quail-completion-buf) |
| 1968 | 1920 | ||
| 1969 | (defun quail-hide-guidance-buf () | 1921 | ;; Then, show the guidance. |
| 1970 | "Hide the Quail guidance buffer." | 1922 | (when (and (quail-require-guidance-buf) |
| 1971 | (if (buffer-live-p quail-guidance-buf) | 1923 | (null unread-command-events) |
| 1972 | (let ((win-list (get-buffer-window-list quail-guidance-buf t t)) | 1924 | (null unread-post-input-method-events)) |
| 1973 | win) | 1925 | (if (or (eq (selected-window) (minibuffer-window)) |
| 1974 | (while win-list | 1926 | input-method-use-echo-area) |
| 1975 | (setq win (car win-list) win-list (cdr win-list)) | 1927 | (if (eq (minibuffer-window) (frame-root-window)) |
| 1976 | (if (window-minibuffer-p win) | 1928 | ;; Use another frame. It is sure that we are using some |
| 1977 | ;; We are using echo area for the guidance buffer. | 1929 | ;; window system. |
| 1978 | ;; Vacate it to the deepest minibuffer. | 1930 | (let ((guidance quail-guidance-str)) |
| 1979 | (set-window-buffer win | 1931 | (or (frame-live-p quail-guidance-frame) |
| 1980 | (format " *Minibuf-%d*" (minibuffer-depth))) | 1932 | (setq quail-guidance-frame |
| 1981 | (if (eq win (frame-root-window (window-frame win))) | 1933 | (quail-make-guidance-frame))) |
| 1982 | (progn | 1934 | (or (buffer-live-p quail-guidance-buf) |
| 1983 | ;; We are using a separate frame for guidance buffer. | 1935 | (setq quail-guidance-buf |
| 1984 | ;;(set-window-dedicated-p win nil) | 1936 | (get-buffer-create " *Quail-guidance*"))) |
| 1985 | (delete-frame (window-frame win))) | 1937 | (save-excursion |
| 1986 | ;;(set-window-dedicated-p win nil) | 1938 | (set-buffer quail-guidance-buf) |
| 1987 | (delete-window win)))) | 1939 | (erase-buffer) |
| 1988 | (setq quail-guidance-win nil)))) | 1940 | (setq cursor-type nil) |
| 1941 | (insert guidance)) | ||
| 1942 | (set-window-buffer (frame-root-window quail-guidance-frame) | ||
| 1943 | quail-guidance-buf) | ||
| 1944 | (quail-minibuffer-message | ||
| 1945 | (format " [%s]" current-input-method-title))) | ||
| 1946 | ;; Show the guidance in the next line of the currrent | ||
| 1947 | ;; minibuffer. | ||
| 1948 | (quail-minibuffer-message | ||
| 1949 | (format " [%s]\n%s" | ||
| 1950 | current-input-method-title quail-guidance-str))) | ||
| 1951 | ;; Show the guidance in echo area without logging. | ||
| 1952 | (let ((message-log-max nil)) | ||
| 1953 | (message "%s" quail-guidance-str))))) | ||
| 1954 | |||
| 1955 | (defun quail-hide-guidance () | ||
| 1956 | "Hide the Quail guidance." | ||
| 1957 | (when (and (quail-require-guidance-buf) | ||
| 1958 | (or (eq (selected-window) (minibuffer-window)) | ||
| 1959 | input-method-use-echo-area) | ||
| 1960 | (eq (minibuffer-window) (frame-root-window))) | ||
| 1961 | ;; We are using another frame for the guidance. | ||
| 1962 | (if (frame-live-p quail-guidance-frame) | ||
| 1963 | (delete-frame quail-guidance-frame)) | ||
| 1964 | (if (buffer-live-p quail-guidance-buf) | ||
| 1965 | (kill-buffer quail-guidance-buf)))) | ||
| 1989 | 1966 | ||
| 1990 | (defun quail-update-guidance () | 1967 | (defun quail-update-guidance () |
| 1991 | "Update the Quail guidance buffer and completion buffer (if displayed now)." | 1968 | "Update the Quail guidance buffer and completion buffer (if displayed now)." |
| 1992 | ;; Update guidance buffer. | 1969 | ;; Update the guidance string. |
| 1993 | (if (quail-require-guidance-buf) | 1970 | (when (quail-require-guidance-buf) |
| 1994 | (let ((guidance (quail-guidance))) | 1971 | (let ((guidance (quail-guidance))) |
| 1995 | (unless (and (eq (selected-frame) (window-frame (minibuffer-window))) | 1972 | (cond ((or (eq guidance t) |
| 1996 | (eq (selected-frame) (window-frame quail-guidance-win))) | 1973 | (consp guidance)) |
| 1997 | ;; The guidance window is not shown in this frame, show it. | 1974 | ;; Show the current possible translations. |
| 1998 | (quail-show-guidance-buf)) | 1975 | (setq quail-guidance-str |
| 1999 | (cond ((or (eq guidance t) | 1976 | (quail-get-translations))) |
| 2000 | (consp guidance)) | 1977 | ((null guidance) |
| 2001 | ;; Show the current possible translations. | 1978 | ;; Show the current input keys. |
| 2002 | (quail-show-translations)) | 1979 | (let ((key quail-current-key)) |
| 2003 | ((null guidance) | 1980 | (if (quail-kbd-translate) |
| 2004 | ;; Show the current input keys. | 1981 | (setq key (quail-keyseq-translate key))) |
| 2005 | (let ((key quail-current-key)) | 1982 | (setq quail-guidance-str (if (stringp key) key (string key))))) |
| 2006 | (if (quail-kbd-translate) | 1983 | (t |
| 2007 | (setq key (quail-keyseq-translate key))) | 1984 | (setq quail-guidance-str " "))))) |
| 2008 | (with-current-buffer quail-guidance-buf | ||
| 2009 | (erase-buffer) | ||
| 2010 | (insert key))))) | ||
| 2011 | ;; Make sure the height of the guidance window is OK -- | ||
| 2012 | ;; sometimes, if the minibuffer window expands due to user | ||
| 2013 | ;; input (for instance if the newly inserted character is in a | ||
| 2014 | ;; different font), it will cause the guidance window to be | ||
| 2015 | ;; only partially visible. We force a redisplay first because | ||
| 2016 | ;; this automatic expansion doesn't happen until then, and we | ||
| 2017 | ;; want to see the window sizes after the expansion. | ||
| 2018 | (sit-for 0) | ||
| 2019 | (fit-window-to-buffer quail-guidance-win nil | ||
| 2020 | (window-height quail-guidance-win)))) | ||
| 2021 | 1985 | ||
| 2022 | ;; Update completion buffer if displayed now. We highlight the | 1986 | ;; Update completion buffer if displayed now. We highlight the |
| 2023 | ;; selected candidate string in *Completion* buffer if any. | 1987 | ;; selected candidate string in *Completion* buffer if any. |
| @@ -2036,8 +2000,8 @@ or in a newly created frame (if the selected frame has no other windows)." | |||
| 2036 | (delete-overlay quail-overlay) | 2000 | (delete-overlay quail-overlay) |
| 2037 | (setq pos (point)) | 2001 | (setq pos (point)) |
| 2038 | (if (and str (search-forward (concat "." str) nil t)) | 2002 | (if (and str (search-forward (concat "." str) nil t)) |
| 2039 | (move-overlay quail-overlay (1+ (match-beginning 0)) (point)) | 2003 | (move-overlay quail-overlay (1+ (match-beginning 0)) (point)) |
| 2040 | (move-overlay quail-overlay (match-beginning 0) (point))) | 2004 | (move-overlay quail-overlay (match-beginning 0) (point))) |
| 2041 | ;; Now POS points end of KEY and (point) points end of STR. | 2005 | ;; Now POS points end of KEY and (point) points end of STR. |
| 2042 | (if (pos-visible-in-window-p (point) win) | 2006 | (if (pos-visible-in-window-p (point) win) |
| 2043 | ;; STR is already visible. | 2007 | ;; STR is already visible. |
| @@ -2051,63 +2015,67 @@ or in a newly created frame (if the selected frame has no other windows)." | |||
| 2051 | (set-window-start win pos)) | 2015 | (set-window-start win pos)) |
| 2052 | )))))) | 2016 | )))))) |
| 2053 | 2017 | ||
| 2054 | (defun quail-show-translations () | 2018 | (defun quail-get-translations () |
| 2055 | "Show the current possible translations." | 2019 | "Return a string containing the current possible translations." |
| 2056 | (let* ((key quail-current-key) | 2020 | (let ((map (quail-lookup-key quail-current-key)) |
| 2057 | (map (quail-lookup-key quail-current-key)) | 2021 | (str (copy-sequence quail-current-key))) |
| 2058 | (current-translations quail-current-translations)) | ||
| 2059 | (if quail-current-translations | 2022 | (if quail-current-translations |
| 2060 | (quail-update-current-translations)) | 2023 | (quail-update-current-translations)) |
| 2061 | (with-current-buffer quail-guidance-buf | ||
| 2062 | (erase-buffer) | ||
| 2063 | |||
| 2064 | ;; Show the current key. | ||
| 2065 | (let ((guidance (quail-guidance))) | ||
| 2066 | (if (listp guidance) | ||
| 2067 | ;; We must show the specified PROMPTKEY instead of the | ||
| 2068 | ;; actual typed keys. | ||
| 2069 | (let ((i 0) | ||
| 2070 | (len (length key)) | ||
| 2071 | prompt-key) | ||
| 2072 | (while (< i len) | ||
| 2073 | (setq prompt-key (cdr (assoc (aref key i) guidance))) | ||
| 2074 | (insert (or prompt-key (aref key i))) | ||
| 2075 | (setq i (1+ i)))) | ||
| 2076 | (insert key))) | ||
| 2077 | 2024 | ||
| 2078 | ;; Show followable keys. | 2025 | ;; Show the current key. |
| 2079 | (if (and (> (length key) 0) (cdr map)) | 2026 | (let ((guidance (quail-guidance))) |
| 2080 | (let ((keys (mapcar (function (lambda (x) (car x))) | 2027 | (if (listp guidance) |
| 2081 | (cdr map)))) | 2028 | ;; We must replace thetyped key with the specified PROMPTKEY. |
| 2082 | (setq keys (sort keys '<)) | 2029 | (dotimes (i (length str)) |
| 2083 | (insert "[") | 2030 | (let ((prompt-key (cdr (assoc (aref str i) guidance)))) |
| 2084 | (while keys | 2031 | (if prompt-key |
| 2085 | (insert (car keys)) | 2032 | (aset str i (aref prompt-key 0))))))) |
| 2086 | (setq keys (cdr keys))) | ||
| 2087 | (insert "]"))) | ||
| 2088 | 2033 | ||
| 2034 | ;; Show followable keys. | ||
| 2035 | (if (and (> (length quail-current-key) 0) (cdr map)) | ||
| 2036 | (setq str | ||
| 2037 | (format "%s[%s]" | ||
| 2038 | str | ||
| 2039 | (concat (sort (mapcar (function (lambda (x) (car x))) | ||
| 2040 | (cdr map)) | ||
| 2041 | '<))))) | ||
| 2089 | ;; Show list of translations. | 2042 | ;; Show list of translations. |
| 2090 | (if (and current-translations | 2043 | (if (and quail-current-translations |
| 2091 | (not (quail-deterministic))) | 2044 | (not (quail-deterministic))) |
| 2092 | (let* ((indices (car current-translations)) | 2045 | (let* ((indices (car quail-current-translations)) |
| 2093 | (cur (car indices)) | 2046 | (cur (car indices)) |
| 2094 | (start (nth 1 indices)) | 2047 | (start (nth 1 indices)) |
| 2095 | (end (nth 2 indices)) | 2048 | (end (nth 2 indices)) |
| 2096 | (idx start)) | 2049 | (idx start)) |
| 2097 | (indent-to (- quail-guidance-translations-starting-column 7)) | 2050 | (if (< (string-width str) |
| 2098 | (insert (format "(%02d/"(nth 3 indices)) | 2051 | (- quail-guidance-translations-starting-column 7)) |
| 2099 | (if (nth 4 indices) | 2052 | (setq str |
| 2100 | (format "%02d)" (nth 4 indices)) | 2053 | (concat str |
| 2101 | "??)")) | 2054 | (make-string |
| 2055 | (- quail-guidance-translations-starting-column | ||
| 2056 | 7 (string-width str)) | ||
| 2057 | 32)))) | ||
| 2058 | (setq str (format "%s(%02d/%s)" | ||
| 2059 | str (nth 3 indices) | ||
| 2060 | (if (nth 4 indices) | ||
| 2061 | (format "%02d" (nth 4 indices)) | ||
| 2062 | "??"))) | ||
| 2102 | (while (< idx end) | 2063 | (while (< idx end) |
| 2103 | (insert (format " %d." (if (= (- idx start) 9) 0 | 2064 | (let ((len (length str)) |
| 2104 | (1+ (- idx start))))) | 2065 | (trans (aref (cdr quail-current-translations) idx))) |
| 2105 | (let ((pos (point))) | 2066 | (or (stringp trans) |
| 2106 | (insert (aref (cdr current-translations) idx)) | 2067 | (setq trans (string trans))) |
| 2068 | (setq str (format "%s %d.%s" | ||
| 2069 | str | ||
| 2070 | (if (= (- idx start) 9) 0 | ||
| 2071 | (1+ (- idx start))) | ||
| 2072 | trans)) | ||
| 2107 | (if (= idx cur) | 2073 | (if (= idx cur) |
| 2108 | (move-overlay quail-overlay pos (point)))) | 2074 | (put-text-property (+ len 3) (length str) |
| 2109 | (setq idx (1+ idx))))) | 2075 | 'face 'highlight str)) |
| 2110 | ))) | 2076 | (setq idx (1+ idx)))))) |
| 2077 | |||
| 2078 | str)) | ||
| 2111 | 2079 | ||
| 2112 | (defvar quail-completion-max-depth 5 | 2080 | (defvar quail-completion-max-depth 5 |
| 2113 | "The maximum depth of Quail completion list.") | 2081 | "The maximum depth of Quail completion list.") |