Revision: 6117
Author: iratqq
Date: Tue Dec  8 01:51:31 2009
Log: * scm/look.scm (look-format-eb):
  - Trim newline and append lines.
* scm/look-custom.scm (look-eb-show-lines):
  - New variable.

http://code.google.com/p/uim/source/detail?r=6117

Modified:
 /trunk/scm/look-custom.scm
 /trunk/scm/look.scm

=======================================
--- /trunk/scm/look-custom.scm  Mon Dec  7 22:29:08 2009
+++ /trunk/scm/look-custom.scm  Tue Dec  8 01:51:31 2009
@@ -71,6 +71,17 @@
                  (lambda ()
                    look-use-eb?))

+(define-custom 'look-eb-show-lines 2
+  '(look)
+  '(integer 1 65535)
+  (N_ "[Look] Show annotation of lines")
+  (N_ "long description will be here."))
+
+(custom-add-hook 'look-eb-show-lines
+                 'custom-activity-hooks
+                 (lambda ()
+                   look-use-eb?))
+
 (define-custom 'look-beginning-character-length 1
   '(look)
   '(integer 1 65535)
=======================================
--- /trunk/scm/look.scm Mon Dec  7 22:29:08 2009
+++ /trunk/scm/look.scm Tue Dec  8 01:51:31 2009
@@ -436,15 +436,26 @@
                        "]"))))

 (define (look-format-eb lc)
+  (define (eb-format-entry str lines)
+    (let loop ((l (string->list str))
+             (lines lines)
+             (rest '()))
+      (cond ((or (null? l)
+                 (= 0 lines))
+             (list->string (reverse rest)))
+            ((eq? #\newline (car l))
+           (loop (cdr l) (- lines 1) (cons #\space rest)))
+            (else
+             (loop (cdr l) lines (cons (car l) rest))))))
   (let ((candidates (look-context-candidates lc)))
     (if (or (= 0 (string-length (look-context-left lc)))
             (<= (length candidates) (look-context-nth lc)))
         ""
-        (string-append "\n"
-                       (eb-search-text (look-context-eb-ctx lc)
-                                       (string-append
-                                        (look-context-left lc)
- (nth (look-context-nth lc) candidates)))))))
+        (eb-format-entry (eb-search-text (look-context-eb-ctx lc)
+                                         (string-append
+                                          (look-context-left lc)
+ (nth (look-context-nth lc) candidates)))
+                         look-eb-show-lines))))


 (define (look-update-preedit lc)

Reply via email to