[uim-commit] r2489 - trunk/emacs

ekato at freedesktop.org ekato at freedesktop.org
Fri Dec 9 05:19:16 PST 2005


Author: ekato
Date: 2005-12-09 05:19:11 -0800 (Fri, 09 Dec 2005)
New Revision: 2489

Modified:
   trunk/emacs/uim-candidate.el
Log:
2005-12-09 Konosuke Watanabe
* emacs/uim-candidate.el
  - Improve candidate displaying of Emacs-20.x and XEmacs which
    don't enlarge echo region automatically.


Modified: trunk/emacs/uim-candidate.el
===================================================================
--- trunk/emacs/uim-candidate.el	2005-12-09 13:17:43 UTC (rev 2488)
+++ trunk/emacs/uim-candidate.el	2005-12-09 13:19:11 UTC (rev 2489)
@@ -316,31 +316,88 @@
 	  (message cands)
 	  )
       ;; Emacs-20 or XEmacs
-      (let* ((page-width (+ (string-width uim-candidate-page-label) 2))
+;;       (let* ((page-width (+ (string-width uim-candidate-page-label) 2))
+;; 	     (cands-width (string-width cands))
+;; 	     (echoreg-width (- (- (window-width) 1) page-width)))
+;; 	(if (>= echoreg-width cands-width)
+;; 	    (setq cands
+;; 		  (concat cands
+;; 			  (make-string (- echoreg-width cands-width) 32)
+;; 			  "(" uim-candidate-page-label ")"))
+;; 	  (if (> (string-width (substring cands 0 selend))
+;; 		 (+ (- cands-width echoreg-width) 3))
+;; 	      (setq cands
+;; 		    (concat "..."
+;; 			    (truncate-string-to-width cands
+;; 						      cands-width 
+;; 						      (+ (- cands-width echoreg-width) 3))
+;; 			    "(" uim-candidate-page-label ")"))
+;; 	    (setq cands 
+;; 		  (concat "..."
+;; 			  (truncate-string-to-width (substring cands (- selend 1))
+;; 						    (if (> echoreg-width 6)
+;; 							(- echoreg-width 6)
+;; 						      0))
+;; 			  "..."
+;; 			  "(" uim-candidate-page-label ")")))))
+
+      (let* ((page-space (- (string-width page-total) 
+			    (string-width page-current)))
+	     (page-label (concat (if (> page-space 0) 
+				     (make-string page-space 32))
+				  page-current  "/" page-total " "))
+	     (page-width (string-width page-label))
 	     (cands-width (string-width cands))
 	     (echoreg-width (- (- (window-width) 1) page-width)))
-	(if (>= echoreg-width cands-width)
-	    (setq cands
-		  (concat cands
-			  (make-string (- echoreg-width cands-width) 32)
-			  "(" uim-candidate-page-label ")"))
-	  (if (> (string-width (substring cands 0 selend))
-		 (+ (- cands-width echoreg-width) 3))
-	      (setq cands
-		    (concat "..."
-			    (truncate-string-to-width cands
-						      cands-width 
-						      (+ (- cands-width echoreg-width) 3))
-			    "(" uim-candidate-page-label ")"))
-	    (setq cands 
-		  (concat "..."
-			  (truncate-string-to-width (substring cands (- selend 1))
-						    (if (> echoreg-width 6)
-							(- echoreg-width 6)
-						      0))
-			  "..."
-			  "(" uim-candidate-page-label ")")))))
-      
+
+	(cond ((>= echoreg-width cands-width)
+	       (setq cands
+		     (concat page-label cands)))
+
+	      ((= selstart 0)
+	       ;; | 10/134 [1.xxxxx] 2.yyyyy 3.zzzzz ...|
+	       (setq cands 
+		     (truncate-string-to-width cands
+					       (if (> echoreg-width 3)
+						   (- echoreg-width 3)
+						 0)))
+	       (setq cands
+		     (concat page-label
+			     cands
+			     (make-string (- echoreg-width
+					     (string-width cands))
+					  ?.)))
+
+	       )
+	      ((> (string-width (substring cands 0 selstart))
+		  (+ (- cands-width echoreg-width) 3))
+	       ;; | 10/134 ...yyy [3.zzzzz] 
+	       (setq cands
+		     (truncate-string-to-width cands
+					       cands-width 
+					       (+ (- cands-width echoreg-width) 3)))
+	       (setq cands
+		     (concat page-label
+			     (make-string (- echoreg-width 
+					     (string-width cands))
+					  ?.)
+			     cands)))
+	      (t
+	       ;; | 10/134 ...[3.zzzzz] ---- ...|
+	       (setq cands 
+		     (concat "..."
+			     (truncate-string-to-width (substring cands selstart)
+						       (if (> echoreg-width 6)
+							   (- echoreg-width 6)
+							 0))
+			     ))
+	       (setq cands
+		     (concat page-label
+			     cands
+			     (make-string (- echoreg-width 
+					     (string-width cands))
+					  ?.))))))
+
       (let (message-log-max)
 	(message cands))
       )



More information about the uim-commit mailing list