[uim-commit] r1102 - in branches/r5rs: . helper po scm uim xim

tkng at freedesktop.org tkng at freedesktop.org
Wed Aug 3 00:24:38 EST 2005


Author: tkng
Date: 2005-08-02 07:24:36 -0700 (Tue, 02 Aug 2005)
New Revision: 1102

Removed:
   branches/r5rs/po/stamp-po
Modified:
   branches/r5rs/
   branches/r5rs/configure.ac
   branches/r5rs/helper/GNOME_UimApplet.server.in.in
   branches/r5rs/helper/Makefile.am
   branches/r5rs/scm/m17nlib.scm
   branches/r5rs/uim/scim.cpp
   branches/r5rs/uim/uim-scm.c
   branches/r5rs/uim/uim-scm.h
   branches/r5rs/xim/convdisp.cpp
   branches/r5rs/xim/convdisp.h
Log:
 r2730 at t42 (orig r1079):  tkng | 2005-07-31 14:12:55 +0900
 * scm/m17nlib.scm:
  -(m17nlib-push-key): Call m17nlib-translate-ukey-to-mkey
   also when key is not a symbol.
  -(m17nlib-key-translation-alist): Data to translate symbol
    key to m17n-lib key.
  -(m17nlib-construct-modifier): New function.
  -(m17nlib-translate-ukey-to-mkey): Corresponded when key isn't
   a symbol key.
 
 r2732 at t42 (orig r1081):  tkng | 2005-07-31 15:06:00 +0900
 * scm/m17nlib.scm:
  -(m17nlib-push-key): Condition checking m17nlib-off-key? should
    be called after m17nlib-lib-push-symbol-key.
  -(m17nlib-press-key-handler): If key is off-key, then off-key 
    itself should not be committed.
 
 r2733 at t42 (orig r1082):  tkng | 2005-07-31 15:11:18 +0900
 * scm/m17nlib.scm: Refactoring. Behavior should not be changed.
  -(m17nlib-push-key): Removed off-key check from this procedure.
  -(m17nlib-press-key-handler): off-key check would be processed
    in this procedure.
 
 r2734 at t42 (orig r1083):  tkng | 2005-07-31 16:15:19 +0900
 * configure.ac: Added AC_SUBST(uim_pixmapsdir) to export 
   uim_pixmapsdir.
 
 r2735 at t42 (orig r1084):  tkng | 2005-07-31 16:17:49 +0900
 * helper/GNOME_UimApplet.server.in.in: Changed the icon.
 
 r2736 at t42 (orig r1085):  ekato | 2005-07-31 22:34:32 +0900
 * xim/convdisp.cpp : Draw cursor even with over-the-spot and
   root-window style.
 (class PeWin) : Remove mGlyphWidth and add mCharPos member.
 (class PeLineWin) : Move draw_segment() from public to private.
   Add draw_cursor() and get_char_width().
 (class PeOvWin) : Add draw_cursor() member.
 (PeWin::PeWin) : Add sanity check for gXftFont.
 (PeWin::set_xftfont) : Ditto.
 (PeLineWin::draw_cursor) : New.
 (PeLineWin::get_char_width) : New.
 (PeLinwWin::draw_segment) : Draw cursor.
 (PeLineWin::calc_segment_extent) : New.
 (PeLineWin::calc_extent) : Properly calculate a needed length of
   the window.
 (PeOvWin::draw_a_ce) : Draw cursor.
 (PeOvWin::draw_cursor) : New.
 (Convdisp::get_caret_pos) : New.
 * xim/convdisp.h (class Convdisp) : Add get_caret_pos() member.
 
 r2737 at t42 (orig r1086):  ekato | 2005-07-31 23:54:56 +0900
 * xim/convdisp.cpp (class ConvdispOv) : Remove unused
   calc_ce_width().
 (ConvdispOv::calc_ce_width) : Removed.
 
 r2740 at t42 (orig r1089):  ekato | 2005-08-01 03:08:07 +0900
 * xim/convdisp.cpp (class PeWin) : Move mCharPos into class
   PeLineWin.
 (class PeLineWin) : Add mCharPos and mCursorX.
 (PeLineWin::draw_pe) : Show a cursor after drawing all segments.
 (PeLineWin::draw_cursor) : Move position handling code into
   draw_segment().
 (PeLineWin::draw_segment) : Just set cursor position and don't
   draw cursor here.
 (PeOvWin::draw_ce) : Show a cursor after drawing all char_entries.
 (PeOvWin::draw_a_ce) : Add space for cursor.  Don't draw cursor
   here.
 (PeOvWin::draw_cursor) : Adjust cursor position.
 
 r2741 at t42 (orig r1090):  tkng | 2005-08-01 11:00:59 +0900
 * helper/Makefile.am:
  -(server_in_files): Replace LIBEXECDIR properly.
 
 r2742 at t42 (orig r1091):  tkng | 2005-08-01 14:03:47 +0900
 * scm/m17nlib.scm:
  -(m17nlib-press-key-handler): Improved key event handling.
  Now special key event such as Ctrl-a, Shift-space when
  preedit exist should be handled properly.
 
 r2745 at t42 (orig r1094):  tkng | 2005-08-02 05:17:14 +0900
 * uim/scim.cpp: Main purpose of this commit is translation
   of modifiers correctly.
  -(init_scim): Fixed a typo.
  -(ukey_mod_to_skey_mod): New convert function from modifier of
   uim to modifier of scim.
  -(push_key): Call ukey_mod_to_skey_mod.
  -(push_symbol_key): Simplified a bit.
 
 
 r2746 at t42 (orig r1095):  tkng | 2005-08-02 05:49:21 +0900
 * uim/scim.cpp:
  -(init_scim): create_config require 1 char * argument
   for 1.2 series API.
 
 
 r2747 at t42 (orig r1096):  tkng | 2005-08-02 12:18:33 +0900
 * uim/slib.c:
  -(init_subr, init_subr_0,init_subr_1, init_subr_2, init_subr_2n,
    init_subr_3, init_subr_4, init_subr_5, init_lsubr, init_fsubr,
    init_msubr): Added const.
 
 * uim/uim-scm.c, uim/uim-sch.h:
  -(uim_scm_init_subr_0, uim_scm_init_subr_1, uim_scm_init_subr_2,
    uim_scm_init_subr_3, uim_scm_init_subr_4, uim_scm_init_subr_5):
    Added const.
 
 
 r2748 at t42 (orig r1097):  tkng | 2005-08-02 12:21:35 +0900
 * uim/scim.cpp:
  -(uim_plugin_instance_init): Remove needless casts.
 
 r2749 at t42 (orig r1098):  tkng | 2005-08-02 22:20:29 +0900
 * po/stamp-po: Removed because it's an automatically
   generated file.
 
 r2750 at t42 (orig r1099):  tkng | 2005-08-02 22:45:40 +0900
 * uim/scim.cpp:
  -(push_symbol_key): Call ukey_mod_to_skey_mod to set modifier.
 
 r2752 at t42 (orig r1101):  tkng | 2005-08-02 23:19:33 +0900
 configure.ac: SCIM support should be disabled by default.
 



Property changes on: branches/r5rs
___________________________________________________________________
Name: svk:merge
   - fb73e508-85ea-0310-95c3-a85c473e0941:/trunk:1077
   + fb73e508-85ea-0310-95c3-a85c473e0941:/trunk:1101

Modified: branches/r5rs/configure.ac
===================================================================
--- branches/r5rs/configure.ac	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/configure.ac	2005-08-02 14:24:36 UTC (rev 1102)
@@ -66,7 +66,7 @@
       ;;
     esac
   ],
-  [ PKG_CHECK_MODULES(SCIM, scim >= 1.2.0, use_scim="yes",use_scim="no") ])
+  [use_scim="no"] )
 
 # ***********************
 # *** Tests for Anthy ***
@@ -250,6 +250,8 @@
 AC_DEFINE_UNQUOTED(XLIB_DIR, "$x_libraries", [X11 Library Directory])
 
 AC_DEFINE_UNQUOTED(UIM_PIXMAPSDIR, "${DATADIR}/${PACKAGE}/pixmaps", [pixmaps directory])
+uim_pixmapsdir="${DATADIR}/${PACKAGE}/pixmaps"
+AC_SUBST(uim_pixmapsdir)
 
 dnl *****************************
 dnl *** Check for Gtk Library ***

Modified: branches/r5rs/helper/GNOME_UimApplet.server.in.in
===================================================================
--- branches/r5rs/helper/GNOME_UimApplet.server.in.in	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/helper/GNOME_UimApplet.server.in.in	2005-08-02 14:24:36 UTC (rev 1102)
@@ -23,6 +23,6 @@
         <oaf_attribute name="name" type="string" _value="uim Applet"/>
         <oaf_attribute name="description" type="string" _value="uim applet for the GNOME2 panel"/>
         <oaf_attribute name="panel:category" type="string" _value="Utility"/>
-        <oaf_attribute name="panel:icon" type="string" value="gnome-applets.png"/>
+        <oaf_attribute name="panel:icon" type="string" value="@UIM_PIXMAPSDIR@/uim-icon.png"/>
 </oaf_server>
 </oaf_info>

Modified: branches/r5rs/helper/Makefile.am
===================================================================
--- branches/r5rs/helper/Makefile.am	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/helper/Makefile.am	2005-08-02 14:24:36 UTC (rev 1102)
@@ -25,9 +25,10 @@
 	  $(LN_S) uim-toolbar-applet uim-helper-applet
 
 $(server_in_files): $(server_in_in_files) Makefile
-	sed s, at LIBEXECDIR@,$(libexecdir),g <$< >$@
+	sed s, at LIBEXECDIR@,$(libexecdir),g <$< >$<.tmp
+	sed s, at UIM_PIXMAPSDIR@,$(uim_pixmapsdir),g <$<.tmp >$@
 
-DISTCLEANFILES = GNOME_UimApplet.server.in GNOME_UimApplet.server
+DISTCLEANFILES = GNOME_UimApplet.server.in GNOME_UimApplet.server GNOME_UimApplet.server.in.in.tmp
 
 else
 install-exec-hook-applet:
@@ -78,7 +79,7 @@
 uim_pref_gtk_SOURCES  = pref-gtk.c pref-gtk-custom-widgets.c pref-gtk-custom-widgets.h
 uim_pref_gtk_LDADD    = @GTK2_LIBS@ $(top_builddir)/uim/libuim-custom.la \
 			$(top_builddir)/uim/libuim.la
-uim_pref_gtk_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)
+uim_pref_gtk_CPPFLAGS = $(helper_defs) -I$(top_srcdir) -I$(top_builddir)
 uim_pref_gtk_CFLAGS   = @GTK2_CFLAGS@ -Wall
 endif
 

Deleted: branches/r5rs/po/stamp-po
===================================================================
--- branches/r5rs/po/stamp-po	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/po/stamp-po	2005-08-02 14:24:36 UTC (rev 1102)
@@ -1 +0,0 @@
-timestamp

Modified: branches/r5rs/scm/m17nlib.scm
===================================================================
--- branches/r5rs/scm/m17nlib.scm	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/scm/m17nlib.scm	2005-08-02 14:24:36 UTC (rev 1102)
@@ -174,17 +174,18 @@
 	  (im-select-candidate mc (m17nlib-lib-get-candidate-index mid))))))
 
 
-(define m17nlib-append-modifiers
-  (lambda (key key-state key-str)
-    (if (shift-key-mask key-state)
-	(set! key-str (string-append "S-" key-str)))
-    (if (control-key-mask key-state)
-	(set! key-str (string-append "C-" key-str)))
-    (if (alt-key-mask key-state)
-	(set! key-str (string-append "A-" key-str)))
-    (if (meta-key-mask key-state)
-	(set! key-str (string-append "M-" key-str)))
-    key-str))
+(define m17nlib-construct-modifier
+  (lambda (key-state)
+    (let ((key-str ""))
+      (if (shift-key-mask key-state)
+	  (set! key-str (string-append "S-" key-str)))
+      (if (control-key-mask key-state)
+	  (set! key-str (string-append "C-" key-str)))
+      (if (alt-key-mask key-state)
+	  (set! key-str (string-append "A-" key-str)))
+      (if (meta-key-mask key-state)
+	  (set! key-str (string-append "M-" key-str)))
+      key-str)))
 
 (define m17nlib-proc-direct-state
   (lambda (mc key key-state)
@@ -196,52 +197,55 @@
   (lambda (mc)
     (im-commit-raw mc)))
 
-
+(define m17nlib-key-translation-alist
+  '((backspace       . "BackSpace")
+    (delete          . "Delete")
+    (escape          . "Escape")
+    (return          . "Return")
+    (tab             . "Tab")
+    (left            . "Left")
+    (up              . "Up")
+    (right           . "Right")
+    (down            . "Down")
+    (prior           . "Page_Down")
+    (next            . "Page_Up")
+    (home            . "Home")
+    (end             . "End")
+    (zenkaku-hankaku . "")
+    (Multi_key       . "")
+    (Mode_switch     . "")
+    (Henkan_Mode     . "")
+    (Muhenkan        . "")
+    (F1              . "F1")
+    (F2              . "F2")
+    (F3              . "F3")
+    (F4              . "F4")
+    (F5              . "F5")
+    (F6              . "F6")
+    (F7              . "F7")
+    (F8              . "F8")
+    (F9              . "F9")
+    (F10             . "F10")
+    (F11             . "F11")
+    (F12             . "F12")
+    (F13             . "F13")
+    (F14             . "F14")
+    (F15             . "F15")
+    (F16             . "F16")
+    (F17             . "F17")
+    (F18             . "F18")
+    (F19             . "F19")
+    (F20             . "F20")))
+  
 ; Unfortunatelly, we don't have simple way to translate...
 (define m17nlib-translate-ukey-to-mkey
   (lambda (key key-state)
-    (m17nlib-append-modifiers
-     key key-state
-     (cdr (assq key
-		'((backspace       . "BackSpace")
-		  (delete          . "Delete")
-		  (escape          . "Escape")
-		  (return          . "Return")
-		  (tab             . "Tab")
-		  (left            . "Left")
-		  (up              . "Up")
-		  (right           . "Right")
-		  (down            . "Down")
-		  (prior           . "Page_Down")
-		  (next            . "Page_Up")
-		  (home            . "Home")
-		  (end             . "End")
-		  (zenkaku-hankaku . "")
-		  (Multi_key       . "")
-		  (Mode_switch     . "")
-		  (Henkan_Mode     . "")
-		  (Muhenkan        . "")
-		  (F1              . "F1")
-		  (F2              . "F2")
-		  (F3              . "F3")
-		  (F4              . "F4")
-		  (F5              . "F5")
-		  (F6              . "F6")
-		  (F7              . "F7")
-		  (F8              . "F8")
-		  (F9              . "F9")
-		  (F10             . "F10")
-		  (F11             . "F11")
-		  (F12             . "F12")
-		  (F13             . "F13")
-		  (F14             . "F14")
-		  (F15             . "F15")
-		  (F16             . "F16")
-		  (F17             . "F17")
-		  (F18             . "F18")
-		  (F19             . "F19")
-		  (F20             . "F20")))))))
-  
+    (string-append 
+     (m17nlib-construct-modifier key-state)
+     (if (symbol? key)
+	 (cdr (assq key m17nlib-key-translation-alist))
+	 (charcode->string key)))))
+
 (define m17nlib-init-handler
   (lambda (id im arg)
     (m17nlib-context-new id im arg)))
@@ -252,34 +256,31 @@
 
 (define m17nlib-push-key
   (lambda (mc key key-state)
-    (let* ((mid (m17nlib-context-mc-id mc)))
-      (cond
-       ((m17nlib-off-key? key key-state)
-	(m17nlib-context-set-on! mc #f)
-	#t) ;; #t means key event was consumed.
-       (else
-	(if (symbol? key)
-	    (let ((mkey (m17nlib-translate-ukey-to-mkey key key-state)))
-	      (m17nlib-lib-push-symbol-key mid mkey))
-	    (let ((mkey (m17nlib-append-modifiers key key-state (charcode->string key))))
-	      (m17nlib-lib-push-symbol-key mid mkey))))))))
+    (let* ((mid (m17nlib-context-mc-id mc))
+	   (mkey (m17nlib-translate-ukey-to-mkey key key-state)))
+      (m17nlib-lib-push-symbol-key mid mkey))))
 
 (define m17nlib-press-key-handler
   (lambda (mc key key-state)
     (let* ((mid (m17nlib-context-mc-id mc)))
       (if (m17nlib-context-on mc)
 	  (if (m17nlib-push-key mc key key-state)
-	      #f ;; Discard key event
+	      #f  ; Key event is consumed in m17n-push-key
 	      (let* ((result (m17nlib-lib-get-result mid))
 		     (consumed? (car result))
 		     (commit-str (cdr result)))
-		(if (string=? commit-str "")
-		    (im-commit-raw mc)
+		(if (m17nlib-off-key? key key-state)
 		    (begin
-		      (im-commit mc commit-str)
-		      (m17nlib-lib-commit mid)
-		      (if (not consumed?)
-			  (im-commit-raw mc))))))
+		      (m17nlib-context-set-on! mc #f)
+		      (if (not (string=? commit-str ""))
+			  (im-commit mc commit-str)))
+		    (if (string=? commit-str "")
+			(im-commit-raw mc)
+			(begin
+			  (im-commit mc commit-str)
+			  (m17nlib-lib-commit mid)
+			  (if (not consumed?)
+			      (im-commit-raw mc)))))))
 	  (m17nlib-proc-direct-state mc key key-state))
       (m17nlib-update-preedit mc)
       (m17nlib-update-candidate mc))))

Modified: branches/r5rs/uim/scim.cpp
===================================================================
--- branches/r5rs/uim/scim.cpp	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/uim/scim.cpp	2005-08-02 14:24:36 UTC (rev 1102)
@@ -156,7 +156,7 @@
 static uim_lisp
 init_scim()
 {
-    fprintf( stderr, "init_scm()\n" );
+    fprintf( stderr, "init_scim()\n" );
     if ( !initialized )
     {
         context_list.clear();
@@ -175,7 +175,7 @@
             return uim_scm_f();
         }
 
-        config = config_module->create_config( "scim" );
+        config = config_module->create_config("scim");
         if ( config.null() )
         {
             fprintf(stderr, "create_config failed\n");
@@ -369,19 +369,39 @@
     return NULL;
 }
 
+static int
+ukey_mod_to_skey_mod(int mod)
+{
+  int rv = 0;
+  if (mod & UMod_Shift) {
+    rv |= SCIM_KEY_ShiftMask;
+  }
+  if (mod & UMod_Control) {
+    rv |= SCIM_KEY_ControlMask;
+  }
+  if (mod & UMod_Alt) {
+    rv |= SCIM_KEY_AltMask;
+  }
+  if (mod & UMod_Super) {  /* assuming mod3 */
+    rv |= SCIM_KEY_Mod3Mask;
+  }
+  if (mod & UMod_Hyper) {  /* assuming mod4 */
+    rv |= SCIM_KEY_Mod3Mask;
+  }
+  return rv;
+}
+
 static uim_lisp
 push_key(uim_lisp id_, uim_lisp key_, uim_lisp mod_)
 {
-    fprintf(stderr, "push_key!!!!!\n");
+    fprintf(stderr, "push_key\n");
     int id = uim_scm_c_int( id_ );
     int code = uim_scm_c_int( key_ );
     int mod = uim_scm_c_int( mod_ );
 
-    // FIXME
-    // adhoc
     KeyEvent scim_key;
     scim_key.code = code;
-    scim_key.mask = mod;
+    scim_key.mask = ukey_mod_to_skey_mod(mod);
 
     SCIMContext *ic = get_context_from_id( id );
     if ( ic->instance->process_key_event( scim_key ) )
@@ -395,20 +415,18 @@
 static uim_lisp
 push_symbol_key(uim_lisp id_, uim_lisp key_, uim_lisp mod_)
 {
-    int id = uim_scm_c_int( id_ );
-    char *sym = uim_scm_c_str( key_ );
-
+    int id = uim_scm_c_int(id_);
+    int mod = uim_scm_c_int(mod_);
+    const char *sym = uim_scm_refer_c_str(key_);
     fprintf(stderr, "push_symbol_key = %s\n", sym);
 
     KeyEvent scim_key;
     uim_keysymbol_to_scim_keysymbol(sym, &scim_key);
-    free( sym );
+    scim_key.mask = ukey_mod_to_skey_mod(mod);
 
     SCIMContext *ic = get_context_from_id( id );
-    if ( ic->instance->process_key_event( scim_key ) )
-    {
-
-        return uim_scm_t();
+    if (ic->instance->process_key_event( scim_key )) {
+      return uim_scm_t();
     }
 
     return uim_scm_f();
@@ -599,15 +617,15 @@
 extern "C" void
 uim_plugin_instance_init(void)
 {
-    uim_scm_init_subr_0((char*)"scim-lib-init", init_scim);
-    uim_scm_init_subr_0((char*)"scim-lib-nr-input-methods", get_nr_input_methods);
-    uim_scm_init_subr_1((char*)"scim-lib-nth-input-method-lang", get_input_method_lang);
-    uim_scm_init_subr_1((char*)"scim-lib-nth-input-method-name", get_input_method_name);
-    uim_scm_init_subr_1((char*)"scim-lib-alloc-context", alloc_id);
-    uim_scm_init_subr_1((char*)"scim-lib-free-context", free_id);
-    uim_scm_init_subr_3((char*)"scim-lib-push-key", push_key);
-    uim_scm_init_subr_3((char*)"scim-lib-push-symbol-key", push_symbol_key);
-    uim_scm_init_subr_2((char*)"sicm-lib-nth-candidate", get_nth_candidate);
+    uim_scm_init_subr_0("scim-lib-init", init_scim);
+    uim_scm_init_subr_0("scim-lib-nr-input-methods", get_nr_input_methods);
+    uim_scm_init_subr_1("scim-lib-nth-input-method-lang", get_input_method_lang);
+    uim_scm_init_subr_1("scim-lib-nth-input-method-name", get_input_method_name);
+    uim_scm_init_subr_1("scim-lib-alloc-context", alloc_id);
+    uim_scm_init_subr_1("scim-lib-free-context", free_id);
+    uim_scm_init_subr_3("scim-lib-push-key", push_key);
+    uim_scm_init_subr_3("scim-lib-push-symbol-key", push_symbol_key);
+    uim_scm_init_subr_2("sicm-lib-nth-candidate", get_nth_candidate);
 }
 
 extern "C" void

Modified: branches/r5rs/uim/uim-scm.c
===================================================================
--- branches/r5rs/uim/uim-scm.c	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/uim/uim-scm.c	2005-08-02 14:24:36 UTC (rev 1102)
@@ -43,6 +43,23 @@
 #include "uim-compat-scm.h"
 #include "context.h"
 
+/*
+  To avoid namespace pollution, all siod functions are defined as
+  static and wrapped into uim-scm.c by direct inclusion rather than
+  linked via public symbols. After elaboration of uim-scm API, the
+  Scheme interpreter implementation can be switched to another one
+  such as uim-scm-tinyscheme.c or uim-scm-gauche.c. But *.[hc] under
+  uim/ and *.scm are still depending on siod in several ways. At least
+  full test suite for *.scm files are required to migrate to another
+  Scheme implementation.  -- YamaKen 2004-12-21, 2005-01-10
+*/
+#include "slib.c"
+#ifdef UIM_COMPAT_SCM
+#include "uim-compat-scm.c"
+#endif
+
+static void siod_init_subr(const char *name, long type, SUBR_FUNC fcn);
+
 static uim_lisp true_sym;
 static uim_lisp false_sym;
 static uim_lisp protected_arg0;
@@ -433,7 +450,7 @@
 }
 
 #if 0
-siod_init_subr(char *name, long type, SUBR_FUNC fcn)
+siod_init_subr(const char *name, long type, SUBR_FUNC fcn)
 {
   uim_lisp stack_start;
 
@@ -444,38 +461,38 @@
 #endif
 
 void
-uim_scm_init_subr_0(char *name, uim_lisp (*func)(void))
+uim_scm_init_subr_0(const char *name, uim_lisp (*fcn)(void))
 {
   Scm_InitSubr0(name, func);
 }
 
 void
-uim_scm_init_subr_1(char *name, uim_lisp (*func)(uim_lisp))
+uim_scm_init_subr_1(const char *name, uim_lisp (*fcn)(uim_lisp))
 {
   Scm_InitSubr1(name, func);
 }
 
 void
-uim_scm_init_subr_2(char *name, uim_lisp (*func)(uim_lisp, uim_lisp))
+uim_scm_init_subr_2(const char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp))
 {
   Scm_InitSubr2(name, func);
 }
 
 void
-uim_scm_init_subr_3(char *name, uim_lisp (*func)(uim_lisp, uim_lisp, uim_lisp))
+uim_scm_init_subr_3(const char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp, uim_lisp))
 {
   Scm_InitSubr3(name, func);
 }
 
 void
-uim_scm_init_subr_4(char *name, uim_lisp (*func)(uim_lisp, uim_lisp, uim_lisp,
+uim_scm_init_subr_4(const char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp, uim_lisp,
 						uim_lisp))
 {
   Scm_InitSubr4(name, func);
 }
 
 void
-uim_scm_init_subr_5(char *name, uim_lisp (*func)(uim_lisp, uim_lisp, uim_lisp,
+uim_scm_init_subr_5(const char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp, uim_lisp,
 						uim_lisp, uim_lisp))
 {
   Scm_InitSubr5(name, func);

Modified: branches/r5rs/uim/uim-scm.h
===================================================================
--- branches/r5rs/uim/uim-scm.h	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/uim/uim-scm.h	2005-08-02 14:24:36 UTC (rev 1102)
@@ -162,18 +162,18 @@
 uim_scm_make_func_ptr(uim_func_ptr func_ptr);
 
 void
-uim_scm_init_subr_0(char *name, uim_lisp (*fcn)(void));
+uim_scm_init_subr_0(const char *name, uim_lisp (*fcn)(void));
+void 
+uim_scm_init_subr_1(const char *name, uim_lisp (*fcn)(uim_lisp));
 void
-uim_scm_init_subr_1(char *name, uim_lisp (*fcn)(uim_lisp));
+uim_scm_init_subr_2(const char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp));
 void
-uim_scm_init_subr_2(char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp));
+uim_scm_init_subr_3(const char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp, uim_lisp));
 void
-uim_scm_init_subr_3(char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp, uim_lisp));
-void
-uim_scm_init_subr_4(char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp, uim_lisp,
+uim_scm_init_subr_4(const char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp, uim_lisp,
 		   				 uim_lisp));
 void
-uim_scm_init_subr_5(char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp, uim_lisp,
+uim_scm_init_subr_5(const char *name, uim_lisp (*fcn)(uim_lisp, uim_lisp, uim_lisp,
 						uim_lisp, uim_lisp));
 
 /* constants */

Modified: branches/r5rs/xim/convdisp.cpp
===================================================================
--- branches/r5rs/xim/convdisp.cpp	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/xim/convdisp.cpp	2005-08-02 14:24:36 UTC (rev 1102)
@@ -214,7 +214,6 @@
     XftDraw *mXftDraw;
     XftColor mXftColorFg;
     XftColor mXftColorFgRev;
-    int mGlyphWidth;
 #endif
     XFontSet mFontset;
     const char *mEncoding;
@@ -231,12 +230,16 @@
 
     void draw_pe(pe_stat *p);
 
-    void draw_segment(pe_ustring *s);
-
 private:
     void calc_extent(pe_stat *p);
+    int calc_segment_extent(pe_ustring *s);
+    void draw_segment(pe_ustring *s);
+    void draw_cursor();
+    int get_char_width(uchar ch);
 
     int m_x;
+    int mCharPos;
+    int mCursorX;
 };
 
 // window for over the spot style
@@ -249,6 +252,7 @@
     virtual ~PeOvWin();
 private:
     void draw_a_ce(char_ent *ce);
+    void draw_cursor(char_ent *ce);
     Pixmap m_mask_pix;
     GC m_mask_pix_gc;
 };
@@ -270,7 +274,6 @@
     void make_ce_array();
     void draw_preedit();
     void do_draw_preedit();
-    int calc_ce_width(int b, int e);
 #ifdef FLASHPLAYER_WORKAROUND
     int get_ce_font_height(char_ent *ce, int len);
     int revised_spot_y;
@@ -370,6 +373,8 @@
     if (mConvdisp->use_xft() == true) {
 #if HAVE_XFT_UTF8_STRING
 	mXftFontSize = DEFAULT_FONT_SIZE;
+	if (!gXftFont)
+	    init_default_xftfont();
 	if (!strcmp(gXftFontLocale, locale)) {
 	    mXftFont = gXftFont;
 	} else {
@@ -461,7 +466,6 @@
 #ifdef HAVE_XFT_UTF8_STRING
 	XGlyphInfo ginfo;
 	XftTextExtentsUtf8(XimServer::gDpy, mXftFont, (unsigned char *)utf8, len, &ginfo);
-	mGlyphWidth = ginfo.xOff;
 	if (stat & PE_REVERSE) {
 	    XftDrawRect(mXftDraw, &mXftColorFg, x, y - (mXftFontSize - 2), ginfo.xOff, mXftFontSize);
 	    XftDrawStringUtf8(mXftDraw, &mXftColorFgRev, mXftFont, x, y, (unsigned char *)utf8, len);
@@ -537,6 +541,9 @@
 {
 	int size = get_fontsize(xfld);
 	const char *locale = mConvdisp->get_locale_name();
+
+	if (!gXftFont)
+	    init_default_xftfont();
 	if (size != -1 && (mXftFontSize != size || strcmp(locale, gXftFontLocale))) {
 	    if (mXftFont != gXftFont)
 		XftFontClose(XimServer::gDpy, mXftFont);
@@ -642,9 +649,14 @@
 //
 // PeLineWin
 //
+#define PE_LINE_WIN_WIDTH	400
+#define PE_LINE_WIN_HEIGHT	28
+#define PE_LINE_WIN_FONT_POS_Y	20
+#define PE_LINE_WIN_MARGIN_X	2
+
 PeLineWin::PeLineWin(Window w, const char *im_lang, const char *encoding, const char *locale, Convdisp *cd) : PeWin(w, im_lang, encoding, locale, cd)
 {
-    set_size(400, 28); // set window height wider than its font height 16
+    set_size(PE_LINE_WIN_WIDTH, PE_LINE_WIN_HEIGHT);
     clear();
 }
 
@@ -656,43 +668,108 @@
 {
     clear();
     calc_extent(p);
-    m_x = 0;
+    m_x = PE_LINE_WIN_MARGIN_X;
+    mCursorX = m_x;
+    mCharPos = 0;
     std::list<pe_ustring>::iterator i;
     for (i = p->ustrings.begin(); i != p->ustrings.end(); i++) {
 	draw_segment(&(*i));
     }
+    draw_cursor();
 }
 
+void PeLineWin::draw_cursor()
+{
+    XDrawLine(XimServer::gDpy, mPixmap, mGC,
+		    mCursorX,
+		    (PE_LINE_WIN_HEIGHT - PE_LINE_WIN_FONT_POS_Y) / 2 + 1,
+		    mCursorX,
+		    PE_LINE_WIN_FONT_POS_Y + 1);
+}
+
+int PeLineWin::get_char_width(uchar ch)
+{
+    int width = 0;
+    char utf8[6];
+
+    int len = utf8_wctomb((unsigned char *)utf8, ch);
+    utf8[len] = '\0';
+
+    if (mConvdisp->use_xft() == true) {
+#ifdef HAVE_XFT_UTF8_STRING
+	XGlyphInfo ginfo;
+	XftTextExtentsUtf8(XimServer::gDpy, mXftFont, (unsigned char *)utf8,
+			len, &ginfo);
+	width = ginfo.xOff;
+#endif
+    } else {
+	XRectangle ink, logical;
+
+	if (!strcmp(mEncoding, "UTF-8")) {
+	    XwcTextExtents(mFontset, &ch, 1, &ink, &logical);
+	} else {
+	    char *native_str;
+	    XimIM *im = get_im_by_id(mConvdisp->get_context()->get_ic()->get_imid());
+
+	    native_str = im->utf8_to_native_str(utf8);
+	    if (!native_str)
+		return 0;
+	    len = strlen(native_str);
+	    XmbTextExtents(mFontset, native_str, len, &ink, &logical);
+	    free(native_str);
+	}
+	width = logical.width;
+    }
+
+    return width;
+}
+
 void PeLineWin::draw_segment(pe_ustring *s)
 {
     uString::iterator i;
+    int caret_pos = mConvdisp->get_caret_pos();
+
     for (i = s->s.begin(); i != s->s.end(); i++) {
 	uchar ch = *i;
-	draw_char(m_x, 20, ch, s->stat);
+	int width = get_char_width(ch);
+	draw_char(m_x, PE_LINE_WIN_FONT_POS_Y, ch, s->stat);
+	mCharPos++;
 
-	int width;
-
-#if HAVE_XFT_UTF8_STRING
-	if (mConvdisp->use_xft() == true)
-	    width = mGlyphWidth;
-	else
-#endif
-	    width = 16;
-
 	if (s->stat & PE_UNDERLINE) {
 	    XDrawLine(XimServer::gDpy, mPixmap, mGC,
-			    m_x, 20 + UNDERLINE_HEIGHT,
-			    m_x + width, 20 + UNDERLINE_HEIGHT);
+			    m_x, PE_LINE_WIN_FONT_POS_Y + UNDERLINE_HEIGHT,
+			    m_x + width, PE_LINE_WIN_FONT_POS_Y + UNDERLINE_HEIGHT);
 	}
 	m_x += width;
+	if (mCharPos == caret_pos)
+	    mCursorX= m_x;
     }
 }
 
+int PeLineWin::calc_segment_extent(pe_ustring *s)
+{
+    int width = 0;
+    uString::iterator i;
+
+    for (i = s->s.begin(); i != s->s.end(); i++) {
+	uchar ch = *i;
+	width += get_char_width(ch);
+    }
+    return width;
+}
+
 void PeLineWin::calc_extent(pe_stat *p)
 {
-    int c;
-    c = p->get_char_count();
-    set_size(400, 28); // XXX need to extent
+    int width = 0;
+    std::list<pe_ustring>::iterator i;
+
+    for (i = p->ustrings.begin(); i != p->ustrings.end(); i++)
+	width += calc_segment_extent(&(*i));	
+
+    if (width < PE_LINE_WIN_WIDTH)
+	set_size(PE_LINE_WIN_WIDTH, PE_LINE_WIN_HEIGHT);
+    else
+	set_size(width + PE_LINE_WIN_MARGIN_X * 2, PE_LINE_WIN_HEIGHT);
 }
 
 
@@ -747,17 +824,20 @@
     for (i = 0; i < len; i++) {
 	draw_a_ce(&ce[i]);
     }
+    draw_cursor(ce);
     XShapeCombineMask(XimServer::gDpy, mWin, ShapeBounding,
 		      0, 0, m_mask_pix, ShapeSet);
     do_map();
 }
 
+#define CURSOR_WIDTH	1
 void PeOvWin::draw_a_ce(char_ent *ce)
 {
     draw_char(ce->x, ce->y, ce->c, ce->stat);
+
     XFillRectangle(XimServer::gDpy, m_mask_pix, m_mask_pix_gc,
 		   ce->x, ce->y - ce->height + 2,
-		   ce->width, ce->height + UNDERLINE_HEIGHT - 1);
+		   ce->width + CURSOR_WIDTH, ce->height + UNDERLINE_HEIGHT - 1);
     if (ce->stat & PE_UNDERLINE) {
 	XDrawLine(XimServer::gDpy, mPixmap, mGC,
 		  ce->x, ce->y + UNDERLINE_HEIGHT,
@@ -765,6 +845,25 @@
     }
 }
 
+void PeOvWin::draw_cursor(char_ent *ce)
+{
+    int x;
+    int caret_pos = mConvdisp->get_caret_pos();
+    char_ent *caret_ce;
+
+    if (caret_pos == 0) {
+	caret_ce = &ce[caret_pos];
+	x = caret_ce->x;
+    } else {
+	caret_ce = &ce[caret_pos - 1];
+	x = caret_ce->x + caret_ce->width;
+    }
+
+    XDrawLine(XimServer::gDpy, mPixmap, mGC,
+		    x, caret_ce->y - caret_ce->height,
+		    x, caret_ce->y);
+}
+
 //
 //
 //
@@ -828,6 +927,13 @@
     return mKkContext;
 }
 
+int Convdisp::get_caret_pos()
+{
+    if (!m_pe)
+	return 0;
+    return m_pe->caret_pos;
+}
+
 // Root window style
 ConvdispRw::ConvdispRw(InputContext *k, icxatr *a) : Convdisp(k, a)
 {
@@ -1061,7 +1167,7 @@
     if (!check_win())
 	return;
 
-    m_ce = (char_ent *)malloc(sizeof(char_ent)*m_ce_len);
+    m_ce = (char_ent *)malloc(sizeof(char_ent) * m_ce_len);
     make_ce_array();
     layoutCharEnt();
     do_draw_preedit();
@@ -1210,7 +1316,7 @@
 	    m_atr->font_set = choose_default_fontset(mIMLang, mLocaleName);
     }
     if (!m_atr->has_atr(ICA_LineSpace)) {
-	m_atr->line_space = 16;
+	m_atr->line_space = DEFAULT_FONT_SIZE;
     }
 
     if (!m_atr->has_atr(ICA_Foreground))
@@ -1316,15 +1422,6 @@
     }
 }
 
-int ConvdispOv::calc_ce_width(int b, int e)
-{
-    int i, w = 0;
-    for (i = b; i < e; i++) {
-	w += m_ce[i].width;
-    }
-    return w;
-}
-
 #ifdef FLASHPLAYER_WORKAROUND
 int ConvdispOv::get_ce_font_height(char_ent *ce, int len)
 {

Modified: branches/r5rs/xim/convdisp.h
===================================================================
--- branches/r5rs/xim/convdisp.h	2005-08-02 14:19:33 UTC (rev 1101)
+++ branches/r5rs/xim/convdisp.h	2005-08-02 14:24:36 UTC (rev 1102)
@@ -45,16 +45,17 @@
     virtual ~Convdisp();
     void set_pe(pe_stat *);
     uString get_pe();
+    void set_focus();
+    void unset_focus();
+    InputContext *get_context();
+    int get_caret_pos();
     virtual void update_preedit() = 0;
     virtual void clear_preedit() = 0;
     virtual void update_icxatr() = 0;
-    virtual void set_focus();
-    virtual void unset_focus();
     virtual void move_candwin() = 0;
     virtual void set_im_lang(const char *im_lang);
     virtual void set_locale_name(const char *locale);
     virtual const char *get_locale_name();
-    virtual InputContext *get_context();
     virtual bool use_xft() = 0;
 
 protected:



More information about the uim-commit mailing list