comparison lisp/international/kkc.el @ 88155:d7ddb3e565de

sync with trunk
author Henrik Enberg <henrik.enberg@telia.com>
date Mon, 16 Jan 2006 00:03:54 +0000
parents 0d8b17d428b5
children
comparison
equal deleted inserted replaced
88154:8ce476d3ba36 88155:d7ddb3e565de
1 ;;; kkc.el --- Kana Kanji converter -*- coding: iso-2022-7bit; -*- 1 ;;; kkc.el --- Kana Kanji converter -*- coding: iso-2022-7bit; -*-
2 2
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 3 ;; Copyright (C) 1997, 1998 Free Software Foundation, Inc.
4 ;; Licensed to the Free Software Foundation. 4 ;; Copyright (C) 1995, 1997, 1998, 2000, 2001, 2003
5 ;; National Institute of Advanced Industrial Science and Technology (AIST)
6 ;; Registration Number H14PRO021
5 7
6 ;; Keywords: mule, multilingual, Japanese 8 ;; Keywords: mule, multilingual, Japanese
7 9
8 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
9 11
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details. 20 ;; GNU General Public License for more details.
19 21
20 ;; You should have received a copy of the GNU General Public License 22 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02111-1307, USA. 25 ;; Boston, MA 02110-1301, USA.
24 26
25 ;;; Commentary: 27 ;;; Commentary:
26 28
27 ;; These routines provide a simple and easy-to-use converter from 29 ;; These routines provide a simple and easy-to-use converter from
28 ;; Kana-string to Kana-Kanji-mixed-string. This converter (here after 30 ;; Kana-string to Kana-Kanji-mixed-string. This converter (here after
547 (setq this-idx 1 msg nil) 549 (setq this-idx 1 msg nil)
548 (if (>= current-idx next-idx) 550 (if (>= current-idx next-idx)
549 ;; The currently selected conversion is after the list shown 551 ;; The currently selected conversion is after the list shown
550 ;; previously. We start calculation of message width from 552 ;; previously. We start calculation of message width from
551 ;; the conversion next of TO. 553 ;; the conversion next of TO.
552 (setq this-idx next-idx msg nil) 554 (setq this-idx next-idx msg nil)))
553 ;; The current conversion is in MSG. Just clear brackets
554 ;; around index number.
555 (if (string-match "<.>" msg)
556 (progn
557 (aset msg (match-beginning 0) ?\ )
558 (aset msg (1- (match-end 0)) ?\ )))))
559 (if (not msg) 555 (if (not msg)
560 (let ((len (length kkc-current-conversions)) 556 (let ((len (length kkc-current-conversions))
561 (max-width (window-width (minibuffer-window))) 557 (max-width (window-width (minibuffer-window)))
562 (width-table kkc-current-conversions-width) 558 (width-table kkc-current-conversions-width)
563 (width 0) 559 (width 0)
585 l (cdr l))) 581 l (cdr l)))
586 (aset first-slot 1 (setq next-idx idx)) 582 (aset first-slot 1 (setq next-idx idx))
587 (setq l (nthcdr this-idx kkc-current-conversions)) 583 (setq l (nthcdr this-idx kkc-current-conversions))
588 (setq msg (format " %c %s" 584 (setq msg (format " %c %s"
589 (aref kkc-show-conversion-list-index-chars 0) 585 (aref kkc-show-conversion-list-index-chars 0)
590 (car l)) 586 (propertize (car l)
587 'kkc-conversion-index this-idx))
591 idx (1+ this-idx) 588 idx (1+ this-idx)
592 l (cdr l)) 589 l (cdr l))
593 (while (< idx next-idx) 590 (while (< idx next-idx)
594 (setq msg (format "%s %c %s" 591 (setq msg (format "%s %c %s"
595 msg 592 msg
596 (aref kkc-show-conversion-list-index-chars 593 (aref kkc-show-conversion-list-index-chars
597 (- idx this-idx)) 594 (- idx this-idx))
598 (car l))) 595 (propertize (car l)
599 (setq idx (1+ idx) 596 'kkc-conversion-index idx))
597 idx (1+ idx)
600 l (cdr l))) 598 l (cdr l)))
601 (aset first-slot 2 msg))) 599 (aset first-slot 2 msg)))
600
601 ;; Highlight the current conversion.
602 (if (> current-idx 0) 602 (if (> current-idx 0)
603 (progn 603 (let ((pos 3)
604 ;; Highlight the current conversion by brackets. 604 (limit (length msg)))
605 (string-match (format " \\(%c\\) " 605 (remove-text-properties 0 (length msg) '(face nil) msg)
606 (aref kkc-show-conversion-list-index-chars 606 (while (not (eq (get-text-property pos 'kkc-conversion-index msg)
607 (- current-idx this-idx))) 607 current-idx))
608 msg) 608 (setq pos (next-single-property-change pos 'kkc-conversion-index
609 (aset msg (match-beginning 0) ?<) 609 msg limit)))
610 (aset msg (1- (match-end 0)) ?>))) 610 (put-text-property pos (next-single-property-change
611 (message "%s" msg))) 611 pos 'kkc-conversion-index msg limit)
612 'face 'highlight msg)))
613 (let ((message-log-max nil))
614 (message "%s" msg))))
612 615
613 ;; Update the conversion area with the latest conversion selected. 616 ;; Update the conversion area with the latest conversion selected.
614 ;; ALL if non nil means to update the whole area, else update only 617 ;; ALL if non nil means to update the whole area, else update only
615 ;; inside quail-overlay-head. 618 ;; inside quail-overlay-head.
616 619
653 (goto-char (overlay-end kkc-overlay-tail)))) 656 (goto-char (overlay-end kkc-overlay-tail))))
654 657
655 ;; 658 ;;
656 (provide 'kkc) 659 (provide 'kkc)
657 660
661 ;;; arch-tag: 3cbfd56e-74e6-4f60-bb46-ba7c2d366fbf
658 ;;; kkc.el ends here 662 ;;; kkc.el ends here