[uim-commit] r1373 - in branches/r5rs: . fep po qt scm uim xim

tkng at freedesktop.org tkng at freedesktop.org
Wed Aug 31 17:40:00 PDT 2005


Author: tkng
Date: 2005-08-31 17:39:58 -0700 (Wed, 31 Aug 2005)
New Revision: 1373

Added:
   branches/r5rs/fep/helper.c
   branches/r5rs/fep/helper.h
Modified:
   branches/r5rs/
   branches/r5rs/COPYING
   branches/r5rs/configure.ac
   branches/r5rs/fep/Makefile.am
   branches/r5rs/fep/README.ja
   branches/r5rs/fep/callbacks.c
   branches/r5rs/fep/callbacks.h
   branches/r5rs/fep/draw.c
   branches/r5rs/fep/draw.h
   branches/r5rs/fep/escseq.c
   branches/r5rs/fep/udsock.c
   branches/r5rs/fep/uim-fep-tick.c
   branches/r5rs/fep/uim-fep.c
   branches/r5rs/fep/uim-fep.h
   branches/r5rs/po/POTFILES.in
   branches/r5rs/qt/Makefile.am
   branches/r5rs/scm/canna.scm
   branches/r5rs/scm/prime.scm
   branches/r5rs/uim/context.h
   branches/r5rs/uim/iso-639-1.def
   branches/r5rs/uim/m17nlib.c
   branches/r5rs/uim/uim-util.c
   branches/r5rs/uim/uim-util.h
   branches/r5rs/uim/uim.c
   branches/r5rs/xim/connection.cpp
   branches/r5rs/xim/main.cpp
   branches/r5rs/xim/xim.h
   branches/r5rs/xim/ximic.cpp
   branches/r5rs/xim/ximserver.cpp
   branches/r5rs/xim/ximserver.h
   branches/r5rs/xim/ximtrans.cpp
Log:
 r2937 at t42 (orig r1286):  ekato | 2005-08-23 12:02:44 +0900
 * xim/connection.cpp (XConnection::writeProc) : Ignore SIGUSR1
   while XFlush().
 * xim/xim.h : Remove unused force_event().
 * xim/ximtrans.cpp : Ditto.
 * xim/main.cpp (reload_uim) : Revive focusIn() deleted in r1252,
   which is actually needed to set appropriate locale for the
   focused context.
 * xim/ximserver.cpp (XimServer::changeContext) : Update comment.
 
 r2938 at t42 (orig r1287):  ekato | 2005-08-23 12:07:01 +0900
 * scm/skk.scm (skk-flush) : Cosmetic change.
 
 r2941 at t42 (orig r1290):  ekato | 2005-08-23 19:24:17 +0900
 * scm/skk.scm : Fix wrong use of '=' for comparing symbol.
 (skk-get-string) : Use string-length instead of length.
 (skk-proc-state-direct) : Fix return value.
 
 r2942 at t42 (orig r1291):  ekato | 2005-08-23 19:51:56 +0900
 * scm/skk.scm : Add missing style element.
 
 r2943 at t42 (orig r1292):  ekato | 2005-08-23 22:43:31 +0900
 * scm/skk-custom.scm : Fix wrong use of '=' for comparing symbols.
 
 r2948 at t42 (orig r1297):  ekato | 2005-08-24 19:26:08 +0900
 * uim/skk.c (nth_candidate) : Remove unnecessary comments.
 (expand_str) : New.
 (get_purged_words) : Check closing double quotation appropriately
   and remove SIOD dependency.
 (purge_candidate) : Add comment.
 (eval_candidate_with_concat) : New.  Separated from
   skk_eval_candidate() and remove SIOD dependency.
 (skk_eval_candidate) : Simplify.
 
 r2955 at t42 (orig r1304):  yamamoto | 2005-08-24 23:33:00 +0900
 * scm/canna.scm (canna-reset-handler)
 * scm/anthy.scm (anthy-reset-handler)
 * scm/skk.scm (skk-reset-handler)
  Revert the change of r1280 according to [Anthy-dev 2283].
 
 
 r2956 at t42 (orig r1305):  tkng | 2005-08-25 04:51:40 +0900
 * uim/uim-util.c, uim/uim-util.h:
  -(uim_get_language_code_from_language_name): New function.
 
 r2957 at t42 (orig r1306):  tkng | 2005-08-25 05:16:42 +0900
 * uim/iso-639-1.def:
  - Added new entry for Bengali and Byelorussian.
  - Fixed a typo. Divehi -> Dhivehi.
 
 r2958 at t42 (orig r1307):  tkng | 2005-08-25 05:19:02 +0900
 * uim/m17nlib.c:
  -(remap_lang_name): This function is removed because it's no longer used.
  -(pushback_input_method): Call uim_get_language_code_from_language_name instead of
    remap_lang_name.
 
 r2959 at t42 (orig r1308):  tkng | 2005-08-25 05:32:59 +0900
 * uim/iso-639-1.def: Added a entry for Myanmar.
 
 r2961 at t42 (orig r1310):  tkng | 2005-08-25 10:35:53 +0900
 * scm/prime.scm:
  -(action_prime_mode_latin,'action_prime_mode_hiragana,
   action_prime_mode_wide_latin): Shorten short-description.
 
 r2965 at t42 (orig r1314):  ekato | 2005-08-26 03:30:27 +0900
 * scm/anthy.scm (anthy-proc-input-state-no-preedit) : Fix
   parenthesis.
 (anthy-input-state-preedit) : Use string-length instead of length
   on (rk-pending rkc).
 
 r2967 at t42 (orig r1316):  tkng | 2005-08-26 04:58:15 +0900
 * po/POTFILES.in:
  - scm/PY.scm is removed.
  - scm/py.scm is added.
 
 
 r2968 at t42 (orig r1317):  tkng | 2005-08-26 05:16:10 +0900
 * configure.ac: Version updated to 0.5.0.
 
 
 r2969 at t42 (orig r1318):  tkng | 2005-08-26 05:20:06 +0900
 * COPYING
  - Added a description about scm/py.scm.
 
 r2970 at t42 (orig r1319):  tkng | 2005-08-26 06:59:48 +0900
 * configure.ac: Added a check for pthread.
 
 r2971 at t42 (orig r1320):  tkng | 2005-08-26 07:42:11 +0900
 * uim/context.h: Added new macros for pthread mutex.
  -(UIM_NEW_MUTEX, UIM_NEW_MUTEX_STATIC, UIM_LOCK_MUTEX,
    UIM_UNLOCK_MUTEX): New macros.
 
 r2972 at t42 (orig r1321):  tkng | 2005-08-26 07:47:18 +0900
 * uim/uim.c:
  -(initing_or_quiting): New mutex to lock uim_init and uim_quit.
  -(uim_init, uim_quit): Locks added to be thread safe function.
 
 r2974 at t42 (orig r1323):  ekato | 2005-08-26 13:42:44 +0900
 * scm/anthy.scm (anthy-has-preedit?) : Use string-length instead of
   length.
 
 r2991 at t42 (orig r1340):  yamamoto | 2005-08-28 15:14:32 +0900
 * fep/draw.c (draw_statusline) : Draw mode str if mode str is changed.
 * fep/callbacks.c (get_mode_str) : Return empty string if
   uim_get_mode_name returns NULL.
 
 r2992 at t42 (orig r1341):  yamamoto | 2005-08-28 15:36:37 +0900
 * fep/uim-fep.c
   (init_uim) : Renamed from init_agent.
   (main) :
     unlink(s_path_setmode) before mkfifo(s_path_setmode).
     Add -f option.
   (main_loop) : s_setmode_fd is valid even if s_setmode_fd == 0.
   (usage) : Add -f option.
 
 r2993 at t42 (orig r1342):  yamamoto | 2005-08-28 16:23:23 +0900
 * fep/uim-fep.c
   (g_context) : New global variable renamed from
     s_context.
   (main_loop) :
     Don't call draw() if the return value of press_key
       indicates there is no need to draw.
     Call focus_in when any key is pressed.
     Add helper handling code.
   (main) : Call init_helper().
   (done) : Call quit_helper().
 
 * fep/callbacks.c
   (init_callbacks) : Remove 1st parameter.
   (press_key) : Change return type to int *.
   (START_CALLBACKS) : New macro.
   (end_callbacks) : Change return type to int.
   (activate_cb, select_cb, shift_page_cb, deactivate_cb, commit_cb,
     clear_cb, pushback_cb, mode_update_cb) : Call START_CALLBACKS first.
 
 * helper.c : New file.
 
 * helper.h : New file.
 
 * Makefile.am : Add helper.c and helper.h to uim_fep_SOURCES.
 
 
 
 r2994 at t42 (orig r1343):  yamamoto | 2005-08-28 17:27:33 +0900
 * fep/uim-fep.c (main_loop) : Fix the bug. I forgot to call end_callbacks.
 
 r2997 at t42 (orig r1346):  yamamoto | 2005-08-29 01:10:22 +0900
 * fep/escseq.c (get_cursor_position) : bug fix. Second escape
   charactor is not treated.
 
 r3009 at t42 (orig r1358):  yamamoto | 2005-08-30 00:20:01 +0900
 * fep/uim-fep.c (main_loop) :
   Revert the part of the changes of r1342 and r1343.
   Call update_backtick() every time user press keys.
 
 * fep/callbacks.c
   (press_key) : Revert to r1341.
   (START_CALLBACKS) : Merge to start_callbacks.
   (activate_cb, select_cb, shift_page_cb, deactivate_cb, commit_cb,
     clear_cb, pushback_cb, mode_update_cb) : Replace START_CALLBACKS
       with start_callbacks
 
 * fep/draw.c (draw, draw_statusline_*) : Call end_callbacks().
 
 * fep/udsock.c (init_recvsocket) : chmod socket.
 
 r3010 at t42 (orig r1359):  yamamoto | 2005-08-30 02:33:58 +0900
 * scm/canna.scm
   (canna-begin-conv, canna-release-handler) : Add validation of
     canna-context-cc-id.
   (canna-proc-input-state-with-preedit) : Remove unnecessary reset.
 
 r3011 at t42 (orig r1360):  tkng | 2005-08-31 18:10:35 +0900
 * uim/uim.c
  -(context_array_mtx): New mutex.
  -(get_context_id, put_context_id, uim_find_context): Added a lock by context_array_mtx.
 
 r3014 at t42 (orig r1363):  tkng | 2005-08-31 21:07:14 +0900
 * configure.ac: Added checks for moc-qt3 and uic-qt3.
 
 r3015 at t42 (orig r1364):  tkng | 2005-08-31 21:11:37 +0900
 * qt/Makefile.am: Use moc and uic in Qt3 explicitly, because Qt4 also has a moc/uic.
  - All MOC was replaced with MOC_QT3
  - All UIC was replaced with UIC_QT3
 
 r3016 at t42 (orig r1365):  tkng | 2005-08-31 21:23:57 +0900
 * configure.ac: Fixed a typo. (MOC -> MOC_QT3).
 
 r3017 at t42 (orig r1366):  ekato | 2005-09-01 01:38:28 +0900
 * xim/ximserver.cpp (InputContext::~InputContext) : Cosmetic
   change.
 (InputContext::focusOut) : Improve behavior of
   a caret-state-indicator.
 (InputContext::clear_pe_stat) : New.  Renamed from
   clear_preedit() to avoid confusion.
 (InputContext::clear_preedit) : Really clear preedit.
 (InputContext::~InputContext) : Follow the rename of
   clear_preedit().
 (InputContext::clear_cb) : Ditto.
 (InputContext::clear) : Ditto.
 * xim/ximic.cpp (XimIC::unsetFocus) : Update comment following the
   changes in InputContext::focusOut().
 * xim/ximserver.h (class InputContext) : Add clear_pe_stat().
   Change protected to private since this class doesn't have any
   derived class.
 



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

Modified: branches/r5rs/COPYING
===================================================================
--- branches/r5rs/COPYING	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/COPYING	2005-09-01 00:39:58 UTC (rev 1373)
@@ -1,7 +1,6 @@
-You can use, modify, distribute and sell this package
- under the terms of BSD license.
+You can use, modify, distribute and sell this package under the terms of BSD license.
 
-  Copyright (c) 2003,2004 uim Project http://uim.freedesktop.org/
+  Copyright (c) 2003-2005 uim Project http://uim.freedesktop.org/
 
   All rights reserved.
 
@@ -30,15 +29,18 @@
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   SUCH DAMAGE.
 
-But there are two exception. 
+But there are three exceptions.
 
-scm/PY.scm is come from emacs, so you can use, modify, distribute and sell this
- package under the terms of GPL *only*.
-helper/eggtrayicon.[ch] is come from libegg, so you can use, modify, distribute 
- and sell this package under the terms of LGPL *only*.
+   * scm/PY-old.scm is come from emacs, so you can use, modify, distribute and sell this
+   package under the terms of GPL *only*.
 
+  * scm/py.scm is come from m17n-lib,you can use, modify, distribute and sell this
+   package under the terms of LGPL *only*.
 
+  * helper/eggtrayicon.[ch] is come from libegg, so you can use, modify, distribute 
+   and sell this package under the terms of LGPL *only*.
 
+
 This Package uses a scheme system SIOD, and the license follows.
 /* Scheme In One Defun, but in C this time.
 

Modified: branches/r5rs/configure.ac
===================================================================
--- branches/r5rs/configure.ac	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/configure.ac	2005-09-01 00:39:58 UTC (rev 1373)
@@ -1,6 +1,6 @@
 AC_PREREQ(2.57)
 
-AC_INIT([uim], 0.4.8, [tkng at xem.jp])
+AC_INIT([uim], 0.5.0, [tkng at xem.jp])
 AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
 
 AC_CONFIG_SRCDIR([COPYING])
@@ -174,6 +174,7 @@
 AC_CHECK_HEADERS([pty.h utmp.h util.h libutil.h])
 AC_CHECK_HEADERS([curses.h stropts.h])
 AC_CHECK_HEADERS([sys/param.h strings.h])
+AC_CHECK_HEADERS([pthread.h], have_pthread=yes, have_pthread=no)
 
 # Check for type
 AC_CHECK_TYPES(sig_t, , ,
@@ -515,6 +516,7 @@
      LDFLAGS=$saved_LDFLAGS
 fi
 
+
 AM_CONDITIONAL(M17NLIB, test x$use_m17nlib = xyes)
 AM_CONDITIONAL(SCIM, test x$use_scim = xyes)
 AM_CONDITIONAL(ANTHY, test x$use_anthy = xyes)
@@ -537,8 +539,8 @@
 AM_CONDITIONAL(COMPAT_TABLE, test x$enable_compat_table = xyes)
 AM_CONDITIONAL(NEED_SETENV_C, test $ac_cv_func_setenv = no -o $ac_cv_func_unsetenv = no)
 AM_CONDITIONAL(NEED_STRSEP_C, test $ac_cv_func_strsep = no)
+AM_CONDITIONAL(HAVE_PTHREAD, test "x$have_pthread" = "xyes")
 
-
 if test "x$use_applet" = "xyes"; then
   AC_PROG_INTLTOOL
 fi
@@ -619,6 +621,17 @@
     fi
     MOC=$HOST_MOC
 
+    # Check For moc-qt3
+    if test -x "$QTDIR/bin/moc-qt3"; then
+      HOST_MOC="$QTDIR/bin/moc-qt3"
+    else
+      AC_CHECK_PROGS(HOST_MOC_QT3, moc-qt3, "")
+    fi
+    if test -z "$HOST_MOC_QT3"; then
+      AC_MSG_ERROR([No acceptable moc (meta object compiler) found])
+    fi
+    MOC_QT3=$HOST_MOC_QT3
+
     # Check For UIC
     if test -x "$QTDIR/bin/uic"; then
       HOST_UIC="$QTDIR/bin/uic"
@@ -630,6 +643,17 @@
     fi
     UIC=$HOST_UIC
 
+    # Check for uic-qt3
+    if test -x "$QTDIR/bin/uic-qt3"; then
+      HOST_UIC_QT3="$QTDIR/bin/uic-qt3"
+    else
+      AC_CHECK_PROGS(HOST_UIC_QT3, uic-qt3, "")
+    fi
+    if test -z "$HOST_UIC_QT3"; then
+      AC_MSG_ERROR([No acceptable uic-qt3 (user interface compiler) found])
+    fi
+    UIC_QT3=$HOST_UIC_QT3
+
     # GUESS plugins dir for immodule installation
     AC_MSG_CHECKING(for qt-immodule plugins dir)
     if test ! -d "$QTDIR/plugins"; then
@@ -640,7 +664,6 @@
       AC_SUBST(QT_PLUGINSDIR)
     fi
 
-
     # Process for compiler & linker flags
     QT_CXXFLAGS="-I${QTINCDIR} -DQT_GENUINE_STR -DQT_NO_STL"
     if test -z "$enable_debug"; then
@@ -690,7 +713,9 @@
     UIM_QT_CXXFLAGS=$QT_CXXFLAGS
 
     AC_SUBST(MOC)
+    AC_SUBST(MOC_QT3)
     AC_SUBST(UIC)
+    AC_SUBST(UIC_QT3)
     AC_SUBST(UIM_QT_CXXFLAGS)
     AC_SUBST(UIM_QT_LDFLAGS)
 fi
@@ -798,6 +823,7 @@
    DICT            : ${use_dict}
    EB              : ${use_eb}
    libedit         : ${use_libedit}
+   pthread         : ${have_pthread}
    Default toolkit : ${default_toolkit}
 ])
 

Modified: branches/r5rs/fep/Makefile.am
===================================================================
--- branches/r5rs/fep/Makefile.am	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/Makefile.am	2005-09-01 00:39:58 UTC (rev 1373)
@@ -5,7 +5,7 @@
 
 bin_PROGRAMS = uim-fep uim-fep-tick
 
-uim_fep_SOURCES = uim-fep.c uim-fep.h udsock.c udsock.h str.c str.h callbacks.c callbacks.h draw.c draw.h escseq.c escseq.h key.c key.h read.c read.h
+uim_fep_SOURCES = uim-fep.c uim-fep.h udsock.c udsock.h str.c str.h callbacks.c callbacks.h draw.c draw.h escseq.c escseq.h key.c key.h read.c read.h helper.c helper.h
 uim_fep_CPPFLAGS = -I$(top_srcdir)
 uim_fep_CFLAGS =
 uim_fep_LDADD = $(top_builddir)/uim/libuim.la @FEP_LIBADD@

Modified: branches/r5rs/fep/README.ja
===================================================================
--- branches/r5rs/fep/README.ja	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/README.ja	2005-09-01 00:39:58 UTC (rev 1373)
@@ -175,6 +175,13 @@
     ¤Ë¤Ê¤ê¤Þ¤¹¡£
     ($TMP¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï/tmp¤¬»È¤ï¤ì¤ë)
 
+  o -f str
+    $UIM_FEP_SETMODE¤È$UIM_FEP_GETMODE¤Î¥Õ¥¡¥¤¥ë̾¤ò
+    uim-fep-setmode-{str}
+    uim-fep-setmode-{str}
+    ¤Ë¤·¤Þ¤¹¡£{str}¤Ï-f¥ª¥×¥·¥ç¥ó¤Î°ú¿ô¤Ç¤¹¡£
+    UIM_FEP_SETMODE¤ÈUIM_FEP_GETMODE¤¬ÃÖ¤«¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤Ï$TMP¤«
+    TMP¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð/tmp¤Ç¤¹¡£
 
   o -d
     ¸õÊä°ìÍ÷¤Îɽ¼¨¥¹¥¿¥¤¥ë¤òddskk¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£

Modified: branches/r5rs/fep/callbacks.c
===================================================================
--- branches/r5rs/fep/callbacks.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/callbacks.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -49,12 +49,10 @@
 #ifdef HAVE_ASSERT_H
 #include <assert.h>
 #endif
-#include <uim/uim-util.h>
 #include "uim-fep.h"
 #include "str.h"
 #include "callbacks.h"
 
-static uim_context s_context;
 /* ¥¹¥Æ¡¼¥¿¥¹¥é¥¤¥ó¤ÎºÇÂçÉý */
 static int s_max_width;
 static char *s_commit_str;
@@ -65,9 +63,8 @@
 static struct preedit_tag *s_preedit;
 static int s_mode;
 static char *s_nokori_str;
+static int s_start_callbacks = FALSE;
 
-static void start_callbacks(void);
-static void end_callbacks(void);
 static void activate_cb(void *ptr, int nr, int display_limit);
 static void select_cb(void *ptr, int index);
 static void shift_page_cb(void *ptr, int direction);
@@ -119,9 +116,8 @@
 /*
  * ½é´ü²½
  */
-void init_callbacks(uim_context context)
+void init_callbacks(void)
 {
-  s_context = context;
   s_max_width = g_win->ws_col;
   if (g_opt.statusline_width != UNDEFINED && g_opt.statusline_width <= s_max_width) {
     s_max_width = g_opt.statusline_width;
@@ -131,12 +127,12 @@
   s_statusline_str = strdup("");
   s_candidate_col = UNDEFINED;
   s_index_str = strdup("");
-  s_mode = uim_get_current_mode(s_context);
+  s_mode = uim_get_current_mode(g_context);
   s_preedit = create_preedit();
-  uim_set_preedit_cb(s_context, clear_cb, pushback_cb, update_cb);
-  uim_set_mode_cb(s_context, mode_update_cb);
+  uim_set_preedit_cb(g_context, clear_cb, pushback_cb, update_cb);
+  uim_set_mode_cb(g_context, mode_update_cb);
   if (g_opt.status_type != NONE) {
-    uim_set_candidate_selector_cb(s_context, activate_cb, select_cb, shift_page_cb, deactivate_cb);
+    uim_set_candidate_selector_cb(g_context, activate_cb, select_cb, shift_page_cb, deactivate_cb);
   }
 
   if (g_opt.ddskk) {
@@ -168,15 +164,19 @@
     debug2(("press key = %d key_state = %d\n", key, key_state));
   }
 #endif
-  start_callbacks();
-  raw = uim_press_key(s_context, key, key_state);
-  uim_release_key(s_context, key, key_state);
-  end_callbacks();
+  raw = uim_press_key(g_context, key, key_state);
+  uim_release_key(g_context, key, key_state);
   return raw;
 }
 
-static void start_callbacks(void)
+
+void start_callbacks(void)
 {
+  if (s_start_callbacks) {
+    return;
+  }
+  s_start_callbacks = TRUE;
+
   debug2(("\n\nstart_callbacks()\n"));
   if (s_commit_str != NULL) {
     free(s_commit_str);
@@ -195,12 +195,21 @@
     s_statusline_str = NULL;
   }
   s_candidate_col = UNDEFINED;
-  s_mode = uim_get_current_mode(s_context);
+  s_mode = uim_get_current_mode(g_context);
 }
 
-static void end_callbacks(void)
+/*
+ * ¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤¬¸Æ¤Ð¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢FALSE¤òÊÖ¤¹
+ */
+int end_callbacks(void)
 {
   debug2(("end_callbacks()\n\n"));
+  if (!s_start_callbacks) {
+    return FALSE;
+  }
+
+  s_start_callbacks = FALSE;
+
   /* cursor¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¤È¤­¤Ï¥×¥ê¥¨¥Ç¥£¥Ã¥È¤ÎËöÈø¤Ë¤¹¤ë */
   if (s_preedit->cursor == UNDEFINED) {
     s_preedit->cursor = s_preedit->width;
@@ -220,6 +229,8 @@
     s_candidate_col = UNDEFINED;
     s_index_str = strdup("");
   }
+
+  return TRUE;
 }
 
 /*
@@ -296,9 +307,14 @@
   return s_mode;
 }
 
+/*
+ * ¸½ºß¤Î¥â¡¼¥Éʸ»úÎó¤òÊÖ¤¹
+ * ÊÖ¤êÃͤÏNULL¤Ë¤Ê¤ë¤³¤È¤Ï¤Ê¤¯¡¢free¤¹¤ëɬÍפ¬¤¢¤ë
+ */
 char *get_mode_str(void)
 {
-  char *mode_str = strdup(uim_get_mode_name(s_context, s_mode));
+  char *mode_str = (char *)uim_get_mode_name(g_context, s_mode);
+  mode_str = strdup(mode_str != NULL ? mode_str : "");
   strhead(mode_str, s_max_width);
   return mode_str;
 }
@@ -313,6 +329,7 @@
 static void activate_cb(void *ptr, int nr, int display_limit)
 {
   debug2(("activate_cb(nr = %d display_limit = %d)\n", nr, display_limit));
+  start_callbacks();
   reset_candidate();
   s_candidate.nr = nr;
   s_candidate.limit = display_limit;
@@ -330,6 +347,7 @@
   debug2(("select_cb(index = %d)\n", index));
   return_if_fail(s_candidate.nr != UNDEFINED);
   return_if_fail(0 <= index && index < s_candidate.nr);
+  start_callbacks();
   s_candidate.index = index;
   s_candidate.page = index2page(index);
 }
@@ -345,6 +363,7 @@
   int index;
   debug2(("shift_page_cb(direction = %d)\n", direction));
   return_if_fail(s_candidate.nr != UNDEFINED);
+  start_callbacks();
   if (direction == 0) {
     direction = -1;
   }
@@ -353,7 +372,7 @@
   return_if_fail(0 <= index && index < s_candidate.nr);
   s_candidate.page = page;
   s_candidate.index = index;
-  uim_set_candidate_index(s_context, s_candidate.index);
+  uim_set_candidate_index(g_context, s_candidate.index);
 }
 
 /*
@@ -363,6 +382,7 @@
 static void deactivate_cb(void *ptr)
 {
   debug2(("deactivate_cb()\n"));
+  start_callbacks();
   reset_candidate();
 }
 
@@ -371,12 +391,14 @@
 {
   debug2(("commit_cb(commit_str = \"%s\")\n", commit_str));
   return_if_fail(commit_str != NULL);
+  start_callbacks();
   s_commit_str = realloc(s_commit_str, strlen(s_commit_str) + strlen(commit_str) + 1);
   strcat(s_commit_str, commit_str);
 }
 
 static void clear_cb(void *ptr)
 {
+  start_callbacks();
   if (s_preedit != NULL) {
     free_preedit(s_preedit);
   }
@@ -395,6 +417,7 @@
   static int cursor = FALSE;
   debug2(("pushback_cb(attr = %d str = \"%s\")\n", attr, str));
   return_if_fail(str && s_preedit != NULL);
+  start_callbacks();
   width = strwidth(str);
   /* UPreeditAttr_Cursor¤Î¤È¤­¤Ë¶õʸ»úÎó¤È¤Ï¸Â¤é¤Ê¤¤ */
   if (attr & UPreeditAttr_Cursor) {
@@ -453,6 +476,7 @@
 static void mode_update_cb(void *ptr, int mode)
 {
   debug2(("mode_update_cb(mode = %d)\n", mode));
+  start_callbacks();
   s_mode = mode;
 }
 
@@ -534,7 +558,7 @@
     int next = FALSE;
     /* "[10/20]" ¤ÎÉý */
     int index_width;
-    uim_candidate cand = uim_get_candidate(s_context, index, index_in_page);
+    uim_candidate cand = uim_get_candidate(g_context, index, index_in_page);
     const char *cand_str_label = uim_candidate_get_heading_label(cand);
     char *cand_str_cand = tab2space(uim_candidate_get_cand_str(cand));
     int cand_label_width = strwidth(cand_str_label);
@@ -758,7 +782,7 @@
     s_candidate_str = strdup("");
     return;
   }
-  cand = uim_get_candidate(s_context, s_candidate.index, 0);
+  cand = uim_get_candidate(g_context, s_candidate.index, 0);
   if (uim_candidate_get_cand_str(cand) == NULL) {
     s_candidate_str = strdup("");
     s_candidate_col = UNDEFINED;

Modified: branches/r5rs/fep/callbacks.h
===================================================================
--- branches/r5rs/fep/callbacks.h	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/callbacks.h	2005-09-01 00:39:58 UTC (rev 1373)
@@ -50,8 +50,10 @@
   } *pseg;
 };
 
-void init_callbacks(uim_context context);
+void init_callbacks(void);
 int press_key(int key, int key_state);
+void start_callbacks(void);
+int end_callbacks(void);
 char *get_commit_str(void);
 char *get_statusline_str(void);
 char *get_candidate_str(void);

Modified: branches/r5rs/fep/draw.c
===================================================================
--- branches/r5rs/fep/draw.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/draw.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -95,7 +95,6 @@
 static int s_winch = FALSE;
 
 static void init_backtick(void);
-static void update_backtick(void);
 static void start_preedit(void);
 static void end_preedit(void);
 static void draw_statusline(int force, int restore, int visible, int draw_background);
@@ -137,7 +136,7 @@
   }
 }
 
-static void update_backtick(void)
+void update_backtick(void)
 {
   char sendbuf[CANDSIZE];
   if (s_candbuf[0] == '\0') {
@@ -161,6 +160,10 @@
 
   int i;
 
+  if (!end_callbacks()) {
+    return;
+  }
+
   /* üËö¥µ¥¤¥º¤¬Êѹ¹¤µ¤ì¤¿¤È¤­¤Ïs_head¤òÊѹ¹¤¹¤ë */
   if (s_winch && g_start_preedit) {
     if (g_opt.no_report_cursor) {
@@ -328,7 +331,7 @@
   static int statusline_str_width = 0;
   static char *candidate_str = NULL;
   static int candidate_col = UNDEFINED;
-  static int mode = UNDEFINED;
+  static char *mode_str = NULL;
   static char *index_str = NULL;
   static int index_col = UNDEFINED;
 
@@ -336,7 +339,7 @@
   int prev_statusline_str_width;
   char *prev_candidate_str;
   int prev_candidate_col;
-  int prev_mode;
+  char *prev_mode_str;
   char *prev_index_str;
   int prev_index_col;
 
@@ -350,19 +353,22 @@
   if (index_str == NULL) {
     index_str = strdup("");
   }
+  if (mode_str == NULL) {
+    mode_str = strdup("");
+  }
 
   prev_statusline_str = statusline_str;
   prev_statusline_str_width = statusline_str_width;
   prev_candidate_str = candidate_str;
   prev_candidate_col = candidate_col;
-  prev_mode = mode;
+  prev_mode_str = mode_str;
   prev_index_str = index_str;
   prev_index_col = index_col;
 
   statusline_str = get_statusline_str();
   candidate_str = get_candidate_str();
   candidate_col = get_candidate_col();
-  mode = get_mode();
+  mode_str = get_mode_str();
   index_str = get_index_str();
   index_col = get_index_col();
 
@@ -370,8 +376,8 @@
   debug2(("statusline_str = \"%s\"\n", statusline_str));
   debug2(("candidate_str = \"%s\"\n", candidate_str));
   debug2(("candidate_col = %d\n", candidate_col));
-  debug2(("prev_mode = %d\n", prev_mode));
-  debug2(("mode = %d\n", mode));
+  debug2(("prev_mode_str = %s\n", prev_mode_str));
+  debug2(("mode_str = %s\n", mode_str));
   debug2(("index_str = \"%s\"\n", index_str));
   debug2(("index_col = %d\n", index_col));
 
@@ -490,20 +496,19 @@
   }
 end_candidate:
 
-  if (force || mode != prev_mode) {
+  if (force || strcmp(mode_str, prev_mode_str) != 0) {
 
     /* ¸½ºß¤Î¥â¡¼¥É¤òUIM_FEP_GETMODE¤Ë½ñ¤­¹þ¤à */
     if (s_path_getmode[0] != '\0') {
       FILE *fp = fopen(s_path_getmode, "wt");
       if (fp) {
+        int mode = get_mode();
         fprintf(fp, "%d\n", mode);
         fclose(fp);
       }
     }
 
     if (g_opt.status_type != NONE && statusline_str[0] == '\0') {
-      char *mode_str = get_mode_str();
-      return_if_fail(mode_str != NULL);
       if (g_opt.status_type == LASTLINE) {
         if (restore) {
           put_save_cursor();
@@ -520,12 +525,12 @@
       } else if (g_opt.status_type == BACKTICK) {
         strncpy(s_modebuf, mode_str, MODESIZE - 1);
       }
-      free(mode_str);
     }
   }
   free(prev_candidate_str);
   free(prev_statusline_str);
   free(prev_index_str);
+  free(prev_mode_str);
   if (restore) {
     put_restore_cursor();
   }
@@ -544,6 +549,12 @@
  */
 void draw_statusline_restore(void)
 {
+  if (!end_callbacks()) {
+    if (g_opt.status_type == BACKTICK) {
+      update_backtick();
+    }
+    return;
+  }
   draw_statusline(FALSE, TRUE, TRUE, FALSE);
 }
 
@@ -553,6 +564,7 @@
  */
 void draw_statusline_force_no_restore(void)
 {
+  end_callbacks();
   draw_statusline(TRUE, FALSE, FALSE, TRUE);
 }
 
@@ -562,6 +574,7 @@
  */
 void draw_statusline_force_restore(void)
 {
+  end_callbacks();
   draw_statusline(TRUE, TRUE, TRUE, TRUE);
 }
 

Modified: branches/r5rs/fep/draw.h
===================================================================
--- branches/r5rs/fep/draw.h	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/draw.h	2005-09-01 00:39:58 UTC (rev 1373)
@@ -45,6 +45,7 @@
 extern int g_commit;
 
 void init_draw(int master, const char *path_getmode);
+void update_backtick(void);
 void draw(void);
 void draw_statusline_restore(void);
 void draw_statusline_force_no_restore(void);

Modified: branches/r5rs/fep/escseq.c
===================================================================
--- branches/r5rs/fep/escseq.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/escseq.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -504,10 +504,11 @@
   }
 }
 
-#define range_check(i) do { \
-  if ((i) > escseq_len - 1) { \
-    goto retry; \
-  } \
+#define range_check(i)                   \
+do {                                     \
+  if ((i) > escseq_len - 1) {            \
+    goto retry;                          \
+  }                                      \
 } while(FALSE)
 
 /*
@@ -571,7 +572,7 @@
       if (escseq[i] != '[') {
         unget_buf[unget_count++] = escseq[i++];
         if (escseq[i] != '[') {
-          break; /* goto retry */
+          continue;
         }
       }
       
@@ -600,11 +601,11 @@
       }
 
       if (row == UNDEFINED) {
-        break; /* goto retry */
+        continue;
       }
 
       if (escseq[i] != ';') {
-        break; /* goto retry */
+        continue;
       }
 
       range_check(i + 1);
@@ -633,11 +634,11 @@
       }
 
       if (col == UNDEFINED) {
-        break; /* goto retry */
+        continue;
       }
 
       if (escseq[i] != 'R') {
-        break; /* goto retry */
+        continue;
       }
 
       /* ¥¨¥¹¥±¡¼¥×¥·¡¼¥±¥ó¥¹¤ÎÁ°¤Ëʸ»úÎ󤬤¢¤ë¤« */

Added: branches/r5rs/fep/helper.c
===================================================================
--- branches/r5rs/fep/helper.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/helper.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -0,0 +1,256 @@
+/*
+
+  Copyright (c) 2003-2005 uim Project http://uim.freedesktop.org/
+
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+  3. Neither the name of authors nor the names of its contributors
+     may be used to endorse or promote products derived from this software
+     without specific prior written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
+  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  SUCH DAMAGE.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifndef DEBUG
+#define NDEBUG
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include "uim-fep.h"
+#include "callbacks.h"
+#include "helper.h"
+#include "str.h"
+#include <uim/uim-helper.h>
+#include <uim/uim-util.h>
+#include <uim/uim-im-switcher.h>
+
+int g_focus_in = FALSE;
+int g_helper_fd = -1;
+
+static void helper_disconnected_cb(void);
+static void helper_handler_change_im(const char *str);
+static void send_im_list(void);
+static void prop_list_update_cb(void *ptr, const char *str);
+static void prop_label_update_cb(void *ptr, const char *str);
+
+void init_helper(void)
+{
+  g_helper_fd = uim_helper_init_client_fd(helper_disconnected_cb);
+  uim_set_prop_list_update_cb(g_context, prop_list_update_cb);
+  uim_set_prop_label_update_cb(g_context, prop_label_update_cb);
+}
+
+void quit_helper(void)
+{
+  if (g_helper_fd >= 0) {
+    uim_helper_close_client_fd(g_helper_fd);
+  }
+}
+
+static void helper_disconnected_cb(void)
+{
+  debug(("helper_disconnected_cb()\n"));
+  g_helper_fd = -1;
+}
+
+#define str_has_prefix(str, prefix) (strncmp((str), (prefix), strlen((prefix))) == 0)
+void helper_handler(void)
+{
+  char *message;
+  uim_helper_read_proc(g_helper_fd);
+
+  while ((message = uim_helper_get_message()) != NULL) {
+
+    if (str_has_prefix(message, "im_change")) {
+      debug(("im_change\n"));
+      helper_handler_change_im(message);
+
+    } else if (str_has_prefix(message, "prop_update_custom")) {
+      char *eol;
+      debug(("prop_update_custom\n"));
+      if ((eol = strchr(message, '\n')) != NULL) {
+        char *sym = eol + 1;
+        if ((eol = strchr(sym, '\n')) != NULL) {
+          char *value = eol + 1;
+          *eol = '\0';
+          if ((eol = strchr(value, '\n')) != NULL) {
+            *eol = '\0';
+            uim_prop_update_custom(g_context, sym, value);
+          }
+        }
+      }
+
+    } else if (str_has_prefix(message, "custom_reload_notify")) {
+      debug(("custom_reload_notify\n"));
+      uim_prop_reload_configs();
+
+    } else if (g_focus_in) {
+      if (str_has_prefix(message, "prop_list_get")) {
+        debug(("prop_list_get\n"));
+        uim_prop_list_update(g_context);
+
+      } else if (str_has_prefix(message, "prop_label_get")) {
+        debug(("prop_label_get\n"));
+        uim_prop_label_update(g_context);
+
+      } else if (str_has_prefix(message, "prop_activate")) {
+        char *eol;
+        debug(("prop_activate\n"));
+        if ((eol = strchr(message, '\n')) != NULL) {
+          char *menucommand_name = eol + 1;
+          if ((eol = strchr(menucommand_name, '\n')) != NULL) {
+            *eol = '\0';
+            uim_prop_activate(g_context, menucommand_name);
+          }
+        }
+
+      } else if (str_has_prefix(message, "im_list_get")) {
+        debug(("im_list_get\n"));
+        send_im_list();
+
+      } else if (str_has_prefix(message, "commit_string")) {
+        char *eol;
+        debug(("commit_string\n"));
+        if ((eol = strchr(message, '\n')) != NULL) {
+          char *commit_string = eol + 1;
+          if ((eol = strchr(commit_string, '\n')) != NULL) {
+            *eol = '\0';
+            commit_cb(NULL, commit_string);
+          }
+        }
+
+      } else if (str_has_prefix(message, "focus_in")) {
+        debug(("focus_in\n"));
+        g_focus_in = FALSE;
+        /* printf("focus_out\r\n"); */
+      }
+    }
+
+    free(message);
+  }
+}
+
+static void helper_handler_change_im(const char *str)
+{
+  if (str_has_prefix(str, "im_change_whole_desktop") ||
+      (g_focus_in && (
+        str_has_prefix(str, "im_change_this_text_area_only") ||
+        str_has_prefix(str, "im_change_this_application_only")))) {
+    char *eol;
+    if ((eol = strchr(str, '\n')) != NULL) {
+      char *imname = eol + 1;
+      if ((eol = strchr(imname, '\n')) != NULL) {
+        *eol = '\0';
+        uim_switch_im(g_context, imname);
+      }
+    }
+  }
+}
+
+static void send_im_list(void)
+{
+  int i;
+  int nr_im = uim_get_nr_im(g_context);
+  const char *current_im_name = uim_get_current_im_name(g_context);
+  const char *enc = get_enc();
+  char *message = malloc(strlen("im_list\ncharset=") + strlen(enc) + strlen("\n") + 1);
+  sprintf(message, "im_list\ncharset=%s\n", enc);
+
+  for (i = 0; i < nr_im; i++) {
+    const char *name = uim_get_im_name(g_context, i);
+    const char *langcode = uim_get_im_language(g_context, i);
+    const char *lang = uim_get_language_name_from_locale(langcode);
+    const char *short_desc = uim_get_im_short_desc(g_context, i);
+
+    char *im_str = malloc(strlen(name) + strlen("\t") +
+        (lang != NULL ? strlen(lang) : 0) + strlen("\t") +
+        (short_desc != NULL ? strlen(short_desc) : 0) + strlen("\t") +
+        (strcmp(name, current_im_name) == 0 ? strlen("selected") : 0) +
+        strlen("\n") + 1);
+
+    sprintf(im_str, "%s\t%s\t%s\t%s\n", name,
+        (lang != NULL ? lang : ""),
+        (short_desc != NULL ? short_desc : ""),
+        (strcmp(name, current_im_name) == 0 ? "selected" : ""));
+
+    message = realloc(message, strlen(message) + strlen(im_str) + 1);
+    strcat(message, im_str);
+  }
+  uim_helper_send_message(g_helper_fd, message);
+  free(message);
+}
+
+static void prop_list_update_cb(void *ptr, const char *str)
+{
+  const char *enc;
+  char *message_buf;
+
+  debug(("prop_list_update_cb\n"));
+  debug2(("str = %s", str));
+
+  if (!g_focus_in) {
+    return;
+  }
+
+  enc = get_enc();
+  message_buf = malloc(strlen("prop_list_update\ncharset=") + strlen(enc) + strlen("\n") + strlen(str) + 1);
+  sprintf(message_buf, "prop_list_update\ncharset=%s\n%s", enc, str);
+  uim_helper_send_message(g_helper_fd, message_buf);
+  free(message_buf);
+  debug(("prop_list_update_cb send message\n"));
+}
+
+static void prop_label_update_cb(void *ptr, const char *str)
+{
+  const char *enc;
+  char *message_buf;
+
+  debug(("prop_label_update_cb\n"));
+  debug2(("str = %s", str));
+
+  if (!g_focus_in) {
+    return;
+  }
+
+  enc = get_enc();
+  message_buf = malloc(strlen("prop_label_update\ncharset=") + strlen(enc) + strlen("\n") + strlen(str) + 1);
+  sprintf(message_buf, "prop_label_update\ncharset=%s\n%s", enc, str);
+  uim_helper_send_message(g_helper_fd, message_buf);
+  free(message_buf);
+  debug(("prop_label_update_cb send message\n"));
+}
+
+void focus_in(void)
+{
+  g_focus_in = TRUE;
+  uim_helper_client_focus_in(g_context);
+  uim_prop_list_update(g_context);
+  uim_prop_label_update(g_context);
+}

Added: branches/r5rs/fep/helper.h
===================================================================
--- branches/r5rs/fep/helper.h	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/helper.h	2005-09-01 00:39:58 UTC (rev 1373)
@@ -0,0 +1,46 @@
+/*
+
+  Copyright (c) 2003-2005 uim Project http://uim.freedesktop.org/
+
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+  3. Neither the name of authors nor the names of its contributors
+     may be used to endorse or promote products derived from this software
+     without specific prior written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
+  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  SUCH DAMAGE.
+
+*/
+
+#ifndef HELPER_H
+#define HELPER_H
+
+extern int g_focus_in;
+extern int g_helper_fd;
+
+void init_helper(void);
+void quit_helper(void);
+void helper_handler(void);
+void focus_in(void);
+
+#endif
+

Modified: branches/r5rs/fep/udsock.c
===================================================================
--- branches/r5rs/fep/udsock.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/udsock.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -56,6 +56,9 @@
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
 
 #include "udsock.h"
 
@@ -117,6 +120,7 @@
     perror(sock_path);
     exit(1);
   }
+  chmod(sock_path, S_IRUSR|S_IWUSR);
 }
 
 void close_socket(void)

Modified: branches/r5rs/fep/uim-fep-tick.c
===================================================================
--- branches/r5rs/fep/uim-fep-tick.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/uim-fep-tick.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -45,7 +45,8 @@
 #include <unistd.h>
 #endif
 #include "udsock.h"
-#include "uim-fep.h"
+#define FALSE 0
+#define TRUE 1
 #define EOT 4
 #define BUFSIZE 600
 

Modified: branches/r5rs/fep/uim-fep.c
===================================================================
--- branches/r5rs/fep/uim-fep.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/uim-fep.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -53,7 +53,6 @@
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
-#include <uim/uim.h>
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
@@ -117,6 +116,7 @@
 #include "escseq.h"
 #include "key.h"
 #include "read.h"
+#include "helper.h"
 
 #define DEFAULT_STATUS LASTLINE
 
@@ -135,8 +135,8 @@
 int g_win_in = STDIN_FILENO;
 int g_win_out = STDOUT_FILENO;
 struct winsize *g_win;
+uim_context g_context;
 
-static uim_context s_context;
 /* µ¿»÷üËö¤Îmaster¤Î¥Õ¥¡¥¤¥ëµ­½Ò»Ò */
 static int s_master;
 /* µ¯Æ°»þ¤ÎüËö¾õÂÖ */
@@ -148,7 +148,7 @@
 static char s_path_getmode[MAXPATHLEN];
 static int s_setmode_fd = -1;
 
-static void init_agent(const char *engine);
+static void init_uim(const char *engine);
 static const char *get_default_im_name(void);
 static int make_color_escseq(const char *instr, struct attribute_tag *attr);
 static int colorname2n(const char *name);
@@ -171,7 +171,7 @@
  * uim¤ò½é´ü²½¤¹¤ë
  * engine ÊÑ´¹¥¨¥ó¥¸¥ó¤Î̾Á°
  */
-static void init_agent(const char *engine)
+static void init_uim(const char *engine)
 {
   int nr;
   int i;
@@ -179,10 +179,10 @@
     printf("uim_init error\n");
     exit(EXIT_FAILURE);
   }
-  s_context = uim_create_context(NULL, get_enc(), NULL, engine, uim_iconv, commit_cb);
-  nr = uim_get_nr_im(s_context);
+  g_context = uim_create_context(NULL, get_enc(), NULL, engine, uim_iconv, commit_cb);
+  nr = uim_get_nr_im(g_context);
   for (i = 0; i < nr; i++) {
-    if (strcmp(engine, uim_get_im_name(s_context, i)) == 0) {
+    if (strcmp(engine, uim_get_im_name(g_context, i)) == 0) {
       break;
     }
   }
@@ -224,6 +224,7 @@
     UNDEFINED  /* background */
   };
   FILE *fp;
+  const char *suffix = NULL;
   const char *tmp_dir;
   const char *sty_str;
   const char *win_str;
@@ -231,11 +232,6 @@
 
   int op;
 
-  if (getenv("UIM_FEP_PID")) {
-    puts("uim-fep is already running");
-    return EXIT_FAILURE;
-  }
-
   if ((command[0] = getenv("SHELL")) == NULL || *command[0] == '\0') {
     struct passwd *pw;
     if ((pw = getpwuid(getuid())) == NULL || *(command[0] = pw->pw_shell) == '\0') {
@@ -247,7 +243,7 @@
   init_str();
   engine = get_default_im_name();
 
-  while ((op = getopt(argc, argv, "e:s:u:b:w:t:C:SciodKvh")) != -1) {
+  while ((op = getopt(argc, argv, "e:s:u:b:w:t:C:f:SciodKvh")) != -1) {
     int i;
     switch (op) {
       case 'e':
@@ -311,6 +307,10 @@
         sock_path = optarg;
         break;
 
+      case 'f':
+        suffix = optarg;
+        break;
+
       case 'w':
         g_opt.statusline_width = atoi(optarg);
         if (g_opt.statusline_width <= 0) {
@@ -354,6 +354,26 @@
     return EXIT_FAILURE;
   }
 
+  if (gnu_screen) {
+    g_opt.status_type = BACKTICK;
+    s_master = PROC_FILENO;
+    g_win_in = WIN_IN_FILENO;
+    g_win_out = WIN_OUT_FILENO;
+  }
+
+  if (g_opt.status_type == BACKTICK) {
+    init_sendsocket(sock_path);
+  }
+
+  if (getenv("UIM_FEP_PID")) {
+    if (gnu_screen) {
+      sendline("uim-fep is already running");
+    } else {
+      puts("uim-fep is already running");
+    }
+    return EXIT_FAILURE;
+  }
+
   if (attr_uim.foreground == UNDEFINED) {
     attr_uim.foreground = FALSE;
   }
@@ -361,13 +381,6 @@
     attr_uim.background = FALSE;
   }
 
-  if (gnu_screen) {
-    g_opt.status_type = BACKTICK;
-    s_master = PROC_FILENO;
-    g_win_in = WIN_IN_FILENO;
-    g_win_out = WIN_OUT_FILENO;
-  }
-
   if (!isatty(g_win_in)) {
     g_win_in = open("/dev/tty", O_RDONLY);
   }
@@ -390,13 +403,17 @@
     snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s-%s", tmp_dir, sty_str, win_str);
     if (stat(s_path_getmode, &stat_buf) == 0 || stat(s_path_setmode, &stat_buf) == 0) {
       char msg[100];
-      init_sendsocket(sock_path);
       snprintf(msg, 100, "uim-fep is already running on window %s", win_str);
       sendline(msg);
       return EXIT_FAILURE;
     }
-    snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s-%s-screen", tmp_dir, sty_str, win_str);
-    snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s-%s-screen", tmp_dir, sty_str, win_str);
+    if (suffix != NULL) {
+      snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s", tmp_dir, suffix);
+      snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s", tmp_dir, suffix);
+    } else {
+      snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s-%s-screen", tmp_dir, sty_str, win_str);
+      snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s-%s-screen", tmp_dir, sty_str, win_str);
+    }
   } else {
     if (sty_str != NULL && win_str != NULL) {
       snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s-%s-screen", tmp_dir, sty_str, win_str);
@@ -405,17 +422,28 @@
         printf("uim-fep is already running on window %s as filter\n", win_str);
         return EXIT_FAILURE;
       }
-      snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s-%s", tmp_dir, sty_str, win_str);
-      snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s-%s", tmp_dir, sty_str, win_str);
+      if (suffix != NULL) {
+        snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s", tmp_dir, suffix);
+        snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s", tmp_dir, suffix);
+      } else {
+        snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s-%s", tmp_dir, sty_str, win_str);
+        snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s-%s", tmp_dir, sty_str, win_str);
+      }
     } else {
-      int file_suffix = 1;
+      if (suffix != NULL) {
+        snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s", tmp_dir, suffix);
+        snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s", tmp_dir, suffix);
+      } else {
+        int file_suffix = 1;
+        int pid = getpid();
 
-      snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%d", tmp_dir, getpid());
-      snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%d", tmp_dir, getpid());
-      while (stat(s_path_getmode, &stat_buf) == 0 || stat(s_path_setmode, &stat_buf) == 0) {
-        snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%d-%d", tmp_dir, getpid(), file_suffix);
-        snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%d-%d", tmp_dir, getpid(), file_suffix);
-        file_suffix++;
+        snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%d", tmp_dir, pid);
+        snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%d", tmp_dir, pid);
+        while (stat(s_path_getmode, &stat_buf) == 0 || stat(s_path_setmode, &stat_buf) == 0) {
+          snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%d-%d", tmp_dir, pid, file_suffix);
+          snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%d-%d", tmp_dir, pid, file_suffix);
+          file_suffix++;
+        }
       }
     }
   }
@@ -434,6 +462,7 @@
     s_path_getmode[0] = '\0';
   }
 
+  unlink(s_path_setmode);
   if (mkfifo(s_path_setmode, 0600) != -1) {
     unlink(s_path_setmode);
     env_buf = malloc(strlen("UIM_FEP_SETMODE=") + strlen(s_path_setmode) + 1);
@@ -469,14 +498,12 @@
     g_opt.statusline_width = CANDSIZE / 2;
   }
 
-  if (g_opt.status_type == BACKTICK) {
-    init_sendsocket(sock_path);
-  }
-  init_agent(engine);
+  init_uim(engine);
   if (gnu_screen) {
-    uim_set_mode(s_context, 1);
+    uim_set_mode(g_context, 1);
   }
-  init_callbacks(s_context);
+  init_helper();
+  init_callbacks();
   init_draw(s_master, s_path_getmode);
   init_escseq(&attr_uim);
   set_signal_handler();
@@ -695,6 +722,9 @@
       nfd = s_setmode_fd;
     }
   }
+  if (g_helper_fd > nfd) {
+    nfd = g_helper_fd;
+  }
   nfd++;
 
   while (TRUE) {
@@ -704,7 +734,7 @@
       FD_ZERO(&fds);
       FD_SET(g_win_in, &fds);
       FD_SET(s_master, &fds);
-      if (s_setmode_fd > 0) {
+      if (s_setmode_fd >= 0) {
         FD_SET(s_setmode_fd, &fds);
       }
       t.tv_sec = 0;
@@ -719,9 +749,12 @@
     FD_ZERO(&fds);
     FD_SET(g_win_in, &fds);
     FD_SET(s_master, &fds);
-    if (s_setmode_fd > 0) {
+    if (s_setmode_fd >= 0) {
       FD_SET(s_setmode_fd, &fds);
     }
+    if (g_helper_fd >= 0) {
+      FD_SET(g_helper_fd, &fds);
+    }
     if (my_select(nfd, &fds, NULL) <= 0) {
       /* signal¤Ç³ä¤ê¹þ¤Þ¤ì¤¿¤È¤­¤Ë¤¯¤ë¡£select¤ÎÊÖ¤êÃͤÏ-1¤Çerrno==EINTR */
       continue;
@@ -729,7 +762,7 @@
 
 
     /* ¥â¡¼¥É¤òÊѹ¹¤¹¤ë */
-    if (s_setmode_fd > 0 && FD_ISSET(s_setmode_fd, &fds)) {
+    if (s_setmode_fd >= 0 && FD_ISSET(s_setmode_fd, &fds)) {
       int start, end;
 #ifdef __CYGWIN32__
       if ((len = read(s_setmode_fd, buf, sizeof(buf) - 1)) <= 0) {
@@ -747,10 +780,10 @@
         for (start = end; start > 0 && isdigit((unsigned char)buf[start - 1]); --start);
         buf[end + 1] = '\0';
         mode = atoi(&buf[start]);
-        if (mode != uim_get_current_mode(s_context)) {
+        if (mode != uim_get_current_mode(g_context)) {
           debug2(("mode change %d\n", mode));
-          uim_set_mode(s_context, mode);
-          callbacks_set_mode(uim_get_current_mode(s_context));
+          uim_set_mode(g_context, mode);
+          /* callbacks_set_mode(uim_get_current_mode(g_context)); */
           draw_statusline_restore();
         }
       }
@@ -760,6 +793,9 @@
     /* ¥­¡¼¥Ü¡¼¥É(stdin)¤«¤é¤ÎÆþÎÏ */
     if (FD_ISSET(g_win_in, &fds)) {
       int key_state = 0;
+      if (!g_focus_in) {
+        focus_in();
+      }
 
       if ((len = read_stdin(buf, sizeof(buf) - 1)) <= 0) {
         /* ¤³¤³¤Ë¤Ï¤³¤Ê¤¤¤È»×¤¦ */
@@ -824,6 +860,9 @@
           } else {
             int raw = press_key(key, key_state);
             draw();
+            if (g_opt.status_type == BACKTICK) {
+              update_backtick();
+            }
             if (raw && !g_start_preedit) {
               if (key_state & UMod_Alt) {
                 write(s_master, buf + i - 1, key_len + 1);
@@ -869,6 +908,11 @@
         put_pty_str(buf, len);
       }
     }
+
+    if (g_helper_fd >= 0 && FD_ISSET(g_helper_fd, &fds)) {
+      helper_handler();
+      draw();
+    }
   }
 }
 
@@ -1034,11 +1078,12 @@
 {
   uim_quit();
   quit_escseq();
+  quit_helper();
   if (g_opt.status_type == BACKTICK) {
     clear_backtick();
   }
   tcsetattr(g_win_in, TCSAFLUSH, &s_save_tios);
-  if (s_setmode_fd > 0) {
+  if (s_setmode_fd >= 0) {
     close(s_setmode_fd);
   }
   if (s_path_setmode[0] != '\0') {
@@ -1076,14 +1121,19 @@
   uim_init();
   context = uim_create_context(NULL, get_enc(), NULL, NULL, uim_iconv, commit_cb);
 
-  printf("uim-fep %s\n", PACKAGE_VERSION);
-  printf("usage: uim-fep [OPTIONS]\n"
-      "\n"
+  printf("uim-fep version %s\n", PACKAGE_VERSION);
+  printf("Usage: uim-fep [OPTIONS]\n");
+  printf("  or   uim-fep [OPTIONS] -e command arg1 arg2 ...\n");
+  printf("  or   uim-fep [OPTIONS] -S\n");
+  printf("  or   uim-fep [-t <sec>] -K\n");
+  printf("\n");
+  printf("Options\n"
       "-u <input method>                         input method      [default=%s]\n"
       "-s <lastline/backtick/none>               statusline type   [default=%s]\n"
       "-b <file>                                 socket file       [default=%s]\n"
       "-w <width>                                statusline width\n"
       "%s"
+      "%s"
       "-e command arg1 arg2 ...                  executed command  [default=%s]\n"
       "%s",
       get_default_im_name(),
@@ -1095,8 +1145,9 @@
       "-c                                        reverse cursor\n"
       "-i                                        use cursor_invisible(civis)\n"
       "-o                                        on the spot\n"
+      "-d                                        ddskk like candidate style\n",
+      "-f                                        file name suffix of $UIM_FEP_SETMODE and $UIM_FEP_GETMODE\n"
       "-S                                        GNU screen mode\n"
-      "-d                                        ddskk like candidate style\n"
       "-K                                        show key code\n",
       getenv("SHELL") != NULL ? getenv("SHELL") : "/bin/sh",
       "-h                                        display this help\n"
@@ -1149,7 +1200,7 @@
  */
 static void version(void)
 {
-  printf("uim-fep %s\n", PACKAGE_VERSION);
+  printf("uim-fep version %s\n", PACKAGE_VERSION);
 }
 
 #if defined(DEBUG) && DEBUG > 1

Modified: branches/r5rs/fep/uim-fep.h
===================================================================
--- branches/r5rs/fep/uim-fep.h	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/fep/uim-fep.h	2005-09-01 00:39:58 UTC (rev 1373)
@@ -34,12 +34,16 @@
 #ifndef UIM_FEP_H
 #define UIM_FEP_H
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
 #endif
+#include <uim/uim.h>
 
 #define FALSE 0
 #define TRUE 1
@@ -76,6 +80,7 @@
 extern int g_win_in;
 extern int g_win_out;
 extern struct winsize *g_win;
+extern uim_context g_context;
 
 void done(int exit_value);
 

Modified: branches/r5rs/po/POTFILES.in
===================================================================
--- branches/r5rs/po/POTFILES.in	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/po/POTFILES.in	2005-09-01 00:39:58 UTC (rev 1373)
@@ -29,7 +29,7 @@
 qt/toolbar-standalone-qt.cpp
 qt/pref-qt.cpp
 qt/pref-customwidgets.cpp
-scm/PY.scm
+scm/py.scm
 scm/action.scm
 scm/anthy-custom.scm
 scm/anthy-key-custom.scm

Modified: branches/r5rs/qt/Makefile.am
===================================================================
--- branches/r5rs/qt/Makefile.am	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/qt/Makefile.am	2005-09-01 00:39:58 UTC (rev 1373)
@@ -25,7 +25,7 @@
 	chardict-chargridview.h \
 	chardict-kseparator.h \
 	chardict-qt.h
-MOC_FILES = \
+MOC_QT3_FILES = \
 	toolbar-common-quimhelpertoolbar.moc \
 	toolbar-common-uimstateindicator.moc \
 	toolbar-standalone-qt.moc \
@@ -65,7 +65,7 @@
 	immodule-candidatewindow.h immodule-qhelpermanager.h \
 	immodule-quiminputcontext.h immodule-quiminputcontext_with_slave.h \
 	immodule-subwindow.h
-MOC_FILES += \
+MOC_QT3_FILES += \
 	immodule-candidatewindow.moc immodule-qhelpermanager.moc \
 	immodule-quiminputcontext.moc immodule-quiminputcontext_with_slave.moc \
 	immodule-subwindow.moc
@@ -138,18 +138,18 @@
 pref-kseparator.cpp: pref-kseparator.moc
 
 pref-olisteditformbase.cpp: pref-olisteditformbase.h pref-olisteditformbase.moc
-	$(UIC) $(top_srcdir)/qt/pref-olisteditformbase.ui -i pref-olisteditformbase.h > pref-olisteditformbase.cpp.tmp
+	$(UIC_QT3) $(top_srcdir)/qt/pref-olisteditformbase.ui -i pref-olisteditformbase.h > pref-olisteditformbase.cpp.tmp
 	echo '#include "pref-olisteditformbase.moc"' >> pref-olisteditformbase.cpp.tmp
 	mv pref-olisteditformbase.cpp.tmp pref-olisteditformbase.cpp
 pref-olisteditformbase.h:
-	$(UIC) $(top_srcdir)/qt/pref-olisteditformbase.ui -o pref-olisteditformbase.h
+	$(UIC_QT3) $(top_srcdir)/qt/pref-olisteditformbase.ui -o pref-olisteditformbase.h
 
 pref-keyeditformbase.cpp: pref-keyeditformbase.h pref-keyeditformbase.moc
-	$(UIC) $(top_srcdir)/qt/pref-keyeditformbase.ui -i pref-keyeditformbase.h > pref-keyeditformbase.cpp.tmp
+	$(UIC_QT3) $(top_srcdir)/qt/pref-keyeditformbase.ui -i pref-keyeditformbase.h > pref-keyeditformbase.cpp.tmp
 	echo '#include "pref-keyeditformbase.moc"' >> pref-keyeditformbase.cpp.tmp
 	mv pref-keyeditformbase.cpp.tmp pref-keyeditformbase.cpp
 pref-keyeditformbase.h:
-	$(UIC) $(top_srcdir)/qt/pref-keyeditformbase.ui -o pref-keyeditformbase.h
+	$(UIC_QT3) $(top_srcdir)/qt/pref-keyeditformbase.ui -o pref-keyeditformbase.h
 
 uim_chardict_qt_SOURCES = \
 	chardict-qt.cpp chardict-qt.h \
@@ -172,12 +172,12 @@
 helperdata_DATA = bushu.t
 
 CLEANFILES = \
-	$(MOC_FILES) \
+	$(MOC_QT3_FILES) \
 	$(UI_TMP_FILES)
 
 .h.moc: 
-	$(MOC) $< -o $*.moc
+	$(MOC_QT3) $< -o $*.moc
 .ui.h: 
-	$(UIC) $< -o $*.h
+	$(UIC_QT3) $< -o $*.h
 endif
 

Modified: branches/r5rs/scm/canna.scm
===================================================================
--- branches/r5rs/scm/canna.scm	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/scm/canna.scm	2005-09-01 00:39:58 UTC (rev 1373)
@@ -296,7 +296,8 @@
                                                          multi-segment-type-hiragana)
                          (multi-segment-make-right-string (canna-context-right-string cc)
                                                           multi-segment-type-hiragana))))
-      (if (> (string-length preconv-str) 0)
+      (if (and (number? cc-id)
+               (> (string-length preconv-str) 0))
           (begin
             (canna-context-set-index-list!
               cc
@@ -395,7 +396,6 @@
 
 (define (canna-proc-input-state-with-preedit cc key key-state)
   (let ((rkc (canna-context-rkc cc))
-	(cc-id (canna-context-cc-id cc))
 	(kana (canna-context-kana-mode cc))
 	(rule (canna-context-input-rule cc)))
 
@@ -408,13 +408,11 @@
 ;      (canna-begin-conv cc))
      ;; backspace
      ((canna-backspace-key? key key-state)
-      (begin
-	(canna-lib-reset-conversion cc-id)
-	(if (not (rk-backspace rkc))
-	    (if (canna-context-left-string cc)
-		(canna-context-set-left-string!
-		 cc
-		 (cdr (canna-context-left-string cc)))))))
+      (if (not (rk-backspace rkc))
+          (if (canna-context-left-string cc)
+              (canna-context-set-left-string!
+                cc
+                (cdr (canna-context-left-string cc))))))
      ;; delete
      ((canna-delete-key? key key-state)
       (if (not (rk-delete rkc))
@@ -679,7 +677,8 @@
 
 (define (canna-release-handler cc)
   (let ((cc-id (canna-context-cc-id cc)))
-    (canna-lib-release-context cc-id)))
+    (if (number? cc-id)
+        (canna-lib-release-context cc-id))))
 
 (define (canna-move-segment cc dir)
   (let ((pos (+ (canna-context-cur-seg cc) dir))

Modified: branches/r5rs/scm/prime.scm
===================================================================
--- branches/r5rs/scm/prime.scm	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/scm/prime.scm	2005-09-01 00:39:58 UTC (rev 1373)
@@ -56,7 +56,7 @@
 		 (control-key-mask key-state))))))
 
 ;; key
-(define-key prime-language-toggle-key?        "F11")
+(define-key prime-language-toggle-key?  "F11")
 (define-key prime-expand-segment-key? '("<Control>o" "<Shift>right"))
 (define-key prime-shrink-segment-key? '("<Control>i" "<Shift>left"))
 
@@ -430,7 +430,7 @@
 (register-action 'action_prime_mode_latin
 		 (lambda (context)
 		   '(figure_prime_mode_latin
-		     "p[--]"
+		     "--"
 		     "Ä̾ïÆþÎÏ"
 		     "PRIME¤ò¥ª¥Õ"))
 		 (lambda (context)
@@ -442,7 +442,7 @@
 (register-action 'action_prime_mode_hiragana
 		 (lambda (context)
 		   '(figure_prime_mode_hiragana
-		     "P[¤¢]"
+		     "¤¢"
 		     "ÆüËܸì"
 		     "PRIME¤ò¥ª¥ó"))
 		 (lambda (context)
@@ -454,7 +454,7 @@
 (register-action 'action_prime_mode_wide_latin
 		 (lambda (context)
 		   '(figure_prime_mode_wide_latin
-		     "P[£Á]"
+		     "£Á"
 		     "Á´³Ñ±Ñ¿ô"
 		     "Á´³Ñ¤òÆþÎÏ"))
 		 (lambda (context)
@@ -466,7 +466,7 @@
 (register-action 'action_prime_mode_application
 		 (lambda (context)
 		   '(figure_prime_mode_application
-		     "P[¡ª]"
+		     "¡ª"
 		     "Æüì"
 		     "¥¢¥×¥ê¥±¡¼¥·¥ç¥ó°Í¸"))
 		 (lambda (context)

Modified: branches/r5rs/uim/context.h
===================================================================
--- branches/r5rs/uim/context.h	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/uim/context.h	2005-09-01 00:39:58 UTC (rev 1373)
@@ -137,6 +137,19 @@
 #define UIM_EVAL_SEXP_AS_STRING
 #endif
 
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+  #define UIM_NEW_MUTEX(mtx)                pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER
+  #define UIM_NEW_MUTEX_STATIC(mtx)  static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER
+  #define UIM_LOCK_MUTEX(mtx)    pthread_mutex_lock(&mtx)
+  #define UIM_UNLOCK_MUTEX(mtx)  pthread_mutex_unlock(&mtx)
+#else
+  #define UIM_NEW_MUTEX(mtx)
+  #define UIM_NEW_MUTEX_STATIC(mtx)
+  #define UIM_LOCK_MUTEX(mtx)
+  #define UIM_UNLOCK_MUTEX(mtx)
+#endif /* HAVE_PTHREAD_H */
+
 #ifdef ENABLE_NLS
 #define UIM_PREPARE_SAVING_TEXTDOMAIN_CODESET() \
     char *enc, *orig_encoding = NULL; \

Modified: branches/r5rs/uim/iso-639-1.def
===================================================================
--- branches/r5rs/uim/iso-639-1.def	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/uim/iso-639-1.def	2005-09-01 00:39:58 UTC (rev 1373)
@@ -49,6 +49,7 @@
  {"ba",    N_("Bashkir")},
  {"eu",    N_("Basque")},
  {"bn",    N_("Bengali (Bangla)")},
+ {"bn",    N_("Bengali")},
  {"dz",    N_("Bhutani")},
  {"bh",    N_("Bihari")},
  {"bi",    N_("Bislama")}, 
@@ -56,6 +57,7 @@
  {"bg",    N_("Bulgarian")},
  {"my",    N_("Burmese")},
  {"be",    N_("Byelorussian (Belarusian)")},
+ {"be",    N_("Byelorussian")},
  {"km",    N_("Cambodian")},
  {"ca",    N_("Catalan")},
  {"la",    N_("Chewa")},
@@ -67,7 +69,7 @@
  {"hr",    N_("Croatian")},
  {"cs",    N_("Czech")},
  {"da",    N_("Danish")},
- {"dv",    N_("Divehi")},
+ {"dv",    N_("Dhivehi")},
  {"nl",    N_("Dutch")},
  {"en",    N_("English")},
  {"eo",    N_("Esperanto")},
@@ -125,6 +127,7 @@
  {"mr",    N_("Marathi")},
  {"mo",    N_("Moldavian")},
  {"mn",    N_("Mongolian")},
+ {"my",    N_("Myanmar")},
  {"na",    N_("Nauru")},
  {"ne",    N_("Nepali")},
  {"no",    N_("Norwegian")},

Modified: branches/r5rs/uim/m17nlib.c
===================================================================
--- branches/r5rs/uim/m17nlib.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/uim/m17nlib.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -36,6 +36,7 @@
 #include <string.h>
 #include <m17n.h>
 #include "uim-scm.h"
+#include "uim-util.h"
 #include "context.h"
 #include "plugin.h"
 
@@ -78,58 +79,11 @@
   return max_input_contexts - 1;
 }
 
-static char *
-remap_lang_name(char *lang)
-{
-  static struct lang_map_ {
-    char *lib_lang;
-    char *lang;
-  } lang_map[] = {
-    {"Japanese", "ja"},
-    {"Amharic", "am"},
-    {"Assamese", "as"},
-    {"Bengali", "bn"},
-    {"Tibetan", "bo"},
-    {"Greek", "el"},
-    {"Arabic", "ar"},
-    /*    {"Farsi", ""},*/
-    {"Gujarati", "gu"},
-    {"Hebrew", "he"},
-    {"Hindi", "hi"},
-    {"Croatian", "hr"},
-    {"Kazakh", "kk"},
-    /*    {"Caombodia", ""},*/
-    {"Kannada", "kn"},
-    {"Korean", "ko"},
-    {"Laothian", "lo"},
-    {"Malayalam", "ml"},
-    {"Oriya", "or"},
-    {"Punjabi", "pa"},/* Panjabi ? */
-    {"Russian", "ru"},
-    {"Slovak", "sl"},/* Slovenia ? */
-    {"Serbian", "sr"},
-    {"Tamil", "ta"},
-    {"Telugu", "te"},
-    {"Thai", "th"},
-    {"Vietnamese", "vi"},
-    {"Chinese", "zh"},
-    {NULL, NULL}
-  };
-
-  struct lang_map_ *l;
-  for (l = lang_map; l->lib_lang; l++) {
-    if (!strcmp(lang, l->lib_lang)) {
-      return l->lang;
-    }
-  }
-  return NULL;
-}
-
 static void
 pushback_input_method(MInputMethod *im,
 		      char *lib_lang, char *name)
 {
-  char *lang = remap_lang_name(lib_lang);
+  char *lang = uim_get_language_code_from_language_name(lib_lang);
 
   im_array = realloc(im_array, 
 		     sizeof(struct im_) * (nr_input_methods + 1));

Modified: branches/r5rs/uim/uim-util.c
===================================================================
--- branches/r5rs/uim/uim-util.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/uim/uim-util.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -597,6 +597,18 @@
   return get_language_name_from_locale(localename);
 }
 
+const char *
+uim_get_language_code_from_language_name(const char *language_name)
+{
+  unsigned int i;
+  for (i = 0; i < NR_LOCALE_LANGUAGE; i++) {
+    if (strcmp(locale_language_table[i].language, language_name) == 0) {
+      return locale_language_table[i].locale;
+    }
+  }
+  return NULL;
+}
+
 static uim_lisp
 lang_code_to_lang_name_raw(uim_lisp code_)
 {

Modified: branches/r5rs/uim/uim-util.h
===================================================================
--- branches/r5rs/uim/uim-util.h	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/uim/uim-util.h	2005-09-01 00:39:58 UTC (rev 1373)
@@ -52,6 +52,9 @@
 const char *
 uim_get_language_name_from_locale(const char *localename);
 
+const char *
+uim_get_language_code_from_language_name(const char *language_name);
+
 int
 is_setugid(void);
 

Modified: branches/r5rs/uim/uim.c
===================================================================
--- branches/r5rs/uim/uim.c	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/uim/uim.c	2005-09-01 00:39:58 UTC (rev 1373)
@@ -60,6 +60,10 @@
 static int uim_initialized;
 static int uim_quiting;
 
+/* Definition of mutex */
+UIM_NEW_MUTEX_STATIC(initing_or_quiting);
+UIM_NEW_MUTEX_STATIC(context_array_mtx);
+
 void
 uim_set_preedit_cb(uim_context uc,
 		   void (*clear_cb)(void *ptr),
@@ -77,20 +81,25 @@
 get_context_id(uim_context uc)
 {
   int i;
+  UIM_LOCK_MUTEX(context_array_mtx);
   for (i = 0; i < CONTEXT_ARRAY_SIZE; i++) {
     if (!context_array[i]) {
       context_array[i] = uc;
       uc->id = i;
+      UIM_UNLOCK_MUTEX(context_array_mtx);
       return;
     }
   }
   uc->id = -1;
+  UIM_UNLOCK_MUTEX(context_array_mtx);
 }
 
 static void
 put_context_id(uim_context uc)
 {
+  UIM_LOCK_MUTEX(context_array_mtx);
   context_array[uc->id] = NULL;
+  UIM_UNLOCK_MUTEX(context_array_mtx);
 }
 
 uim_context
@@ -280,7 +289,9 @@
 uim_context
 uim_find_context(int id)
 {
+  UIM_LOCK_MUTEX(context_array_mtx);
   return context_array[id];
+  UIM_UNLOCK_MUTEX(context_array_mtx);
 }
 
 int
@@ -618,7 +629,7 @@
 }
 
 static void
-uim_init_scm()
+uim_init_scm(void)
 {
   int i;
   char *scm_files = NULL;
@@ -677,7 +688,10 @@
 int
 uim_init(void)
 {
+  UIM_LOCK_MUTEX(initing_or_quiting);
+
   if (uim_initialized) {
+    UIM_UNLOCK_MUTEX(initing_or_quiting);
     return 0;
   }
   uim_last_client_encoding = NULL;
@@ -685,6 +699,8 @@
   uim_nr_im = 0;
   uim_init_scm();
   uim_initialized = 1;
+
+  UIM_UNLOCK_MUTEX(initing_or_quiting);
   return 0;
 }
 
@@ -693,7 +709,10 @@
 {
   int i;
 
+  UIM_LOCK_MUTEX(initing_or_quiting);
+  
   if (!uim_initialized || uim_quiting) {
+    UIM_UNLOCK_MUTEX(initing_or_quiting);
     return;
   }
   /* Some multithreaded applications calls uim_quit bursty. */
@@ -712,4 +731,5 @@
   uim_last_client_encoding = NULL;
   uim_initialized = 0;
   uim_quiting = 0;
+  UIM_UNLOCK_MUTEX(initing_or_quiting);
 }

Modified: branches/r5rs/xim/connection.cpp
===================================================================
--- branches/r5rs/xim/connection.cpp	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/xim/connection.cpp	2005-09-01 00:39:58 UTC (rev 1373)
@@ -39,6 +39,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <signal.h>
 #include "connection.h"
 #include <list>
 #include <map>
@@ -398,7 +399,11 @@
     writePassivePacket();
     writeNormalPacket();
 
+    // interrupt while _XFlushInt() here will cause lock up of the display.
+    sig_t old_sigusr1 = signal(SIGUSR1, SIG_IGN);
     XFlush(XimServer::gDpy);
+    signal(SIGUSR1, old_sigusr1);
+
     if (mIsCloseWait) {
 	remove_window_watch(mClientWin);
 	mClientWin = None;

Modified: branches/r5rs/xim/main.cpp
===================================================================
--- branches/r5rs/xim/main.cpp	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/xim/main.cpp	2005-09-01 00:39:58 UTC (rev 1373)
@@ -539,6 +539,11 @@
 	}
     }
 
+    // make sure to use appropriate locale for the focused context
+    InputContext *focusedContext = InputContext::focusedContext();
+    if (focusedContext)
+	focusedContext->focusIn();
+
     pretrans_setup();
 }
 

Modified: branches/r5rs/xim/xim.h
===================================================================
--- branches/r5rs/xim/xim.h	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/xim/xim.h	2005-09-01 00:39:58 UTC (rev 1373)
@@ -327,8 +327,6 @@
 };
 
 XimIC *create_ic(Connection *, RxPacket *, int imid, int id, const char *engine);
-void force_event(Window w);
-
 void procXClientMessage(XClientMessageEvent *m);
 
 #endif

Modified: branches/r5rs/xim/ximic.cpp
===================================================================
--- branches/r5rs/xim/ximic.cpp	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/xim/ximic.cpp	2005-09-01 00:39:58 UTC (rev 1373)
@@ -407,6 +407,9 @@
     }
 }
 
+// Note that the sequence of XIM_SET_IC_FOCUS and XIM_UNSET_FOCUS
+// events is not consistent.  Be careful about hiding caret state and
+// candidate window.
 void XimIC::unsetFocus()
 {
     if (!mIsActive)
@@ -415,14 +418,6 @@
     mIsActive = false;
     nrActiveIC--;
     m_kkContext->focusOut();
-    // Since the sequence of XIM_SET_IC_FOCUS and XIM_UNSET_FOCUS
-    // events is not consistent, unsetting focus of candidate window
-    // is now handled in XimIC::setFocus() and focus_in message from
-    // helper application.
-    //
-    // if (mConvdisp && m_kkContext->hasActiveCandwin()) {
-    //     mConvdisp->unset_focus();
-    // }
 }
 
 void XimIC::OnKeyEvent(keyEventX e)

Modified: branches/r5rs/xim/ximserver.cpp
===================================================================
--- branches/r5rs/xim/ximserver.cpp	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/xim/ximserver.cpp	2005-09-01 00:39:58 UTC (rev 1373)
@@ -131,7 +131,7 @@
     for (it = ic_list.begin(); it != ic_list.end(); it++) {
 	(*it)->changeContext(engine);
     }
-    // make sure to update locale of focused context
+    // make sure to use appropriate locale for the focused context
     InputContext *focusedContext = InputContext::focusedContext();
     if (focusedContext)
 	focusedContext->focusIn();
@@ -331,7 +331,7 @@
 	mFocusedContext = NULL;
 
     if (mConvdisp)
-	mConvdisp->set_pe(0);
+	mConvdisp->set_pe(NULL);
 
     delete m_pe;
     uim_release_context(mUc);
@@ -477,6 +477,13 @@
 InputContext::focusOut()
 {
     uim_helper_client_focus_out(mUc);
+    if (mFocusedContext == this) {
+	Canddisp *disp = canddisp_singleton();
+	if (isCaretStateShown())
+	    disp->hide_caret_state();
+	if (hasActiveCandwin())
+	    disp->hide();
+    }
 }
 
 XimServer *
@@ -497,7 +504,7 @@
     InputContext *ic = (InputContext *)ptr;
     XimIC *xic = ic->get_ic();
 
-    clear_cb(ptr);
+    ic->clear_pe_stat();
     ic->update_preedit();
     xic->commit_string(str);
 }
@@ -505,7 +512,7 @@
 void InputContext::clear_cb(void *ptr)
 {
     InputContext *ic = (InputContext *)ptr;
-    ic->clear_preedit();
+    ic->clear_pe_stat();
 }
 
 void InputContext::pushback_cb(void *ptr, int attr, const char *str)
@@ -560,11 +567,18 @@
       ic->update_prop_label(str);
 }
 
-void InputContext::clear_preedit()
+void InputContext::clear_pe_stat()
 {
     m_pe->clear();
 }
 
+void InputContext::clear_preedit()
+{
+    clear_pe_stat();
+    if (mConvdisp)
+	mConvdisp->clear_preedit();
+}
+
 uString InputContext::get_preedit_string()
 {
     uString str;
@@ -640,11 +654,10 @@
     return mCandwinActive;
 }
 
+// reset
 void InputContext::clear()
 {
     clear_preedit();
-    if (mConvdisp)
-	mConvdisp->clear_preedit();
     candidate_deactivate();
     uim_reset_context(mUc);
 }

Modified: branches/r5rs/xim/ximserver.h
===================================================================
--- branches/r5rs/xim/ximserver.h	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/xim/ximserver.h	2005-09-01 00:39:58 UTC (rev 1373)
@@ -194,15 +194,15 @@
     static void update_prop_label_cb(void *ptr, const char *str);
     static InputContext *focusedContext();
     static void deletefocusedContext();
-protected:
+private:
     void commit_string(char *);
+    void clear_pe_stat();
+
     XimIC *mXic;
     XimServer *mServer;
     pe_stat *m_pe;
     Convdisp *mConvdisp;
     uim_context mUc;
-private:
-    static InputContext *mFocusedContext;
     bool mCandwinActive;
     int mDisplayLimit;
     int mNumPage;
@@ -212,6 +212,8 @@
     char *mEngineName;
     char *mLocaleName;
     bool mCaretStateShown;
+private:
+    static InputContext *mFocusedContext;
 };
 
 class Locale {

Modified: branches/r5rs/xim/ximtrans.cpp
===================================================================
--- branches/r5rs/xim/ximtrans.cpp	2005-08-31 23:36:51 UTC (rev 1372)
+++ branches/r5rs/xim/ximtrans.cpp	2005-09-01 00:39:58 UTC (rev 1373)
@@ -189,16 +189,6 @@
     }
 }
 
-void force_event(Window w)
-{
-    Window fw;
-    int rev;
-    XGetInputFocus(XimServer::gDpy, &fw, &rev);
-    XSetInputFocus(XimServer::gDpy, w, rev, CurrentTime);
-    XSetInputFocus(XimServer::gDpy, fw, rev, CurrentTime);
-    XFlush(XimServer::gDpy);
-}
-
 Connection::Connection(XimServer *svr)
 {
     mIsCloseWait = false;



More information about the uim-commit mailing list