Revision: 6466
Author: ek.kato
Date: Sun Jun 20 21:12:12 2010
Log: * scm/im-scm (get-candidate) : Fix to use IM encoding to retrieve
  annotation text.
* scm/annotation.scm
  - (annotation-get-text) : Use encoding argument.
  - (annotation-agent-reset) : Ditto.
* uim/eb.c
  - (c_uim_eb_search_text) : Use encoding argument.
  - (uim_plugin_instance_init) : Follow the change.
* uim/uim-eb.c
  - (go_text_eb) : Use encoding.
  - (uim_eb_search_text) : Ditto.
* uim/uim-eb.h : Update declaration of uim_eb_search_text.
* scm/look.scm (look-format-eb) : Follow the change in
  eb-search-text.
* scm/annotation-eb.scm (eb-get-text) : Ditto.

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

Modified:
 /trunk/scm/annotation-eb.scm
 /trunk/scm/annotation.scm
 /trunk/scm/im.scm
 /trunk/scm/look.scm
 /trunk/uim/eb.c
 /trunk/uim/uim-eb.c
 /trunk/uim/uim-eb.h

=======================================
--- /trunk/scm/annotation-eb.scm        Thu May  6 22:55:35 2010
+++ /trunk/scm/annotation-eb.scm        Sun Jun 20 21:12:12 2010
@@ -43,10 +43,10 @@
       (set! eb-ctx (eb-new eb-dic-path)))))

 (define eb-get-text
-  (lambda (text)
+  (lambda (text enc)
     (or (and eb-ctx
           eb-enable-for-annotation?
-          (eb-search-text eb-ctx text))
+          (eb-search-text eb-ctx text enc))
       "")))

 (define eb-release
=======================================
--- /trunk/scm/annotation.scm   Tue Apr 27 18:51:37 2010
+++ /trunk/scm/annotation.scm   Sun Jun 20 21:12:12 2010
@@ -41,7 +41,7 @@

 ;; Returns an annotation string from the given candidate.
 (define annotation-get-text
-  (lambda (text)
+  (lambda (text encoding)
     ""))

 ;; Releases the annotation agent.
@@ -79,5 +79,5 @@
 (define annotation-agent-reset
   (lambda ()
     (set! annotation-init (lambda () #f))
-    (set! annotation-get-text (lambda (text) ""))
+    (set! annotation-get-text (lambda (text encoding) ""))
     (set! annotation-release (lambda () #f))))
=======================================
--- /trunk/scm/im.scm   Tue Apr 27 18:51:37 2010
+++ /trunk/scm/im.scm   Sun Jun 20 21:12:12 2010
@@ -520,7 +520,7 @@
                (not (string=? (last c) "")))
           (set-cdr! (cdr c) (list ""))
           (and (string=? (last c) "")
-               (set-cdr! (cdr c) (list (annotation-get-text (car c))))))
+ (set-cdr! (cdr c) (list (annotation-get-text (car c) (uim-context-encoding uc))))))
       c)))

 (define set-candidate-index
=======================================
--- /trunk/scm/look.scm Fri May  7 02:02:40 2010
+++ /trunk/scm/look.scm Sun Jun 20 21:12:12 2010
@@ -451,7 +451,8 @@
         (eb-format-entry (eb-search-text (look-context-eb-ctx lc)
                                          (string-append
                                           (look-context-left lc)
- (nth (look-context-nth lc) candidates))) + (nth (look-context-nth lc) candidates))
+                                         "UTF-8")
                          look-eb-show-lines))))


=======================================
--- /trunk/uim/eb.c     Sun Jun 20 19:50:59 2010
+++ /trunk/uim/eb.c     Sun Jun 20 21:12:12 2010
@@ -55,11 +55,14 @@
 }

 static uim_lisp
-c_uim_eb_search_text(uim_lisp ueb_, uim_lisp text_)
+c_uim_eb_search_text(uim_lisp ueb_, uim_lisp text_, uim_lisp encoding_)
 {
   char *str;
-
-  if ((str = uim_eb_search_text(C_PTR(ueb_), REFER_C_STR(text_))) == NULL)
+  const char *enc;
+
+  enc = NULLP(encoding_) ? "UTF-8" : REFER_C_STR(encoding_);
+
+ if ((str = uim_eb_search_text(C_PTR(ueb_), REFER_C_STR(text_), enc)) == NULL)
     return MAKE_STR("");
   return MAKE_STR_DIRECTLY(str);
 }
@@ -77,7 +80,7 @@
   uim_eb_open();

   uim_scm_init_proc1("eb-new", c_uim_eb_new);
-  uim_scm_init_proc2("eb-search-text", c_uim_eb_search_text);
+  uim_scm_init_proc3("eb-search-text", c_uim_eb_search_text);
   uim_scm_init_proc1("eb-destroy", c_uim_eb_destroy);
 }

=======================================
--- /trunk/uim/uim-eb.c Sun Jun 20 19:59:30 2010
+++ /trunk/uim/uim-eb.c Sun Jun 20 21:12:12 2010
@@ -67,7 +67,8 @@

 static void go_text_eb (uim_eb *ueb,
                        EB_Position position,
-                       char **str);
+                       char **str,
+                       const char *enc);

 static int
 uim_eb_strappend(char **dest, const char *append, size_t append_len)
@@ -145,7 +146,7 @@


 char *
-uim_eb_search_text (uim_eb *ueb, const char *text_utf8)
+uim_eb_search_text (uim_eb *ueb, const char *key, const char *enc)
 {
   char *text;
   int i;
@@ -153,8 +154,9 @@
   iconv_t cd;

   /* FIXME! check return value */
-  cd = (iconv_t)uim_iconv->create("EUC-JP", "UTF-8");
-  text = uim_iconv->convert(cd, text_utf8);
+
+  cd = (iconv_t)uim_iconv->create("EUC-JP", enc);
+  text = uim_iconv->convert(cd, key);
   uim_iconv->release(cd);

   if (!text)
@@ -176,7 +178,7 @@
       /*EB_Position headp = hits[j].heading;*/
       EB_Position textp = hits[j].text;

-      go_text_eb(ueb, textp, &str);
+      go_text_eb(ueb, textp, &str, enc);
       uim_eb_strappend(&str, "\n", sizeof("\n"));
     }
   }
@@ -188,7 +190,7 @@


 static void
-go_text_eb (uim_eb *ueb, EB_Position position, char **str)
+go_text_eb (uim_eb *ueb, EB_Position position, char **str, const char *enc)
 {
   EB_Hookset hookset;
   char text[MAX_TEXT + 1];
@@ -203,7 +205,7 @@

   eb_initialize_hookset(&hookset);
   for (i = 0; i < 1; i++) {
-    char *text_utf8;
+    char *local;
     iconv_t cd;

     if (eb_read_text(&ueb->book, NULL, &hookset,
@@ -218,13 +220,13 @@
       break;

     /* FIXME! check return value */
-    cd = (iconv_t)uim_iconv->create("UTF-8", "EUC-JP");
-    text_utf8 = uim_iconv->convert(cd, text);
+    cd = (iconv_t)uim_iconv->create(enc, "EUC-JP");
+    local = uim_iconv->convert(cd, text);
     uim_iconv->release(cd);

-    uim_eb_strappend(str, text_utf8, strlen(text_utf8));
-
-    free(text_utf8);
+    uim_eb_strappend(str, local, strlen(local));
+
+    free(local);
   }
   eb_finalize_hookset(&hookset);
 }
=======================================
--- /trunk/uim/uim-eb.h Sun Jun 20 19:50:59 2010
+++ /trunk/uim/uim-eb.h Sun Jun 20 21:12:12 2010
@@ -43,7 +43,8 @@
 void   uim_eb_close        (void);
 uim_eb *uim_eb_new         (const char *bookpath);
 char   *uim_eb_search_text (uim_eb *ueb,
-                           const char *text);
+                           const char *text,
+                           const char *encoding);
 void    uim_eb_destroy     (uim_eb *ueb);

 #endif /* UIM_GTK_UIM_EB_H */

Reply via email to