[uim-commit] r2314 - in trunk: doc xim

ekato at freedesktop.org ekato at freedesktop.org
Thu Dec 1 21:58:13 PST 2005


Author: ekato
Date: 2005-12-01 21:58:09 -0800 (Thu, 01 Dec 2005)
New Revision: 2314

Modified:
   trunk/doc/HELPER-PROTOCOL
   trunk/xim/compose.cpp
   trunk/xim/helper.cpp
   trunk/xim/ximserver.h
Log:
* doc/HELPER-ROTOCOL : Add charset_specifier to "commit_string".

* xim/compose.cpp : Move declaration of mb_string_to_utf8 to
  ximserver.h.
(mb_string_to_utf8) : Remove static qualifier.
* xim/ximserver.h : Move mb_string_to_utf8 declaration from
  compose.cpp.
* xim/helper.cpp : Handle charset.


Modified: trunk/doc/HELPER-PROTOCOL
===================================================================
--- trunk/doc/HELPER-PROTOCOL	2005-12-01 20:23:47 UTC (rev 2313)
+++ trunk/doc/HELPER-PROTOCOL	2005-12-02 05:58:09 UTC (rev 2314)
@@ -342,7 +342,7 @@
     This message commits a string to currently focused context. See also
     focus_in.
     
-    commit_string = "commit_string\n" str_to_commit "\n"
+    commit_string = "commit_string\n" charset_specifier str_to_commit "\n"
     str_to_commit = /^[^\n]+$/
 
 

Modified: trunk/xim/compose.cpp
===================================================================
--- trunk/xim/compose.cpp	2005-12-01 20:23:47 UTC (rev 2313)
+++ trunk/xim/compose.cpp	2005-12-02 05:58:09 UTC (rev 2314)
@@ -58,7 +58,6 @@
 
 static int parse_line(char *line, char **argv, int argsize);
 static unsigned int KeySymToUcs4(KeySym keysym);
-static int mb_string_to_utf8(char *utf8, const char *str, int to_len, const char *enc);
 
 Compose::Compose(DefTree *top, XimIC *xic)
 {
@@ -1142,7 +1141,7 @@
 	return 0;
 }
 
-static int
+int
 mb_string_to_utf8(char *utf8, const char *str, int len, const char *enc) {
     size_t outbufsize = len + 1;
     const char *inbuf;

Modified: trunk/xim/helper.cpp
===================================================================
--- trunk/xim/helper.cpp	2005-12-01 20:23:47 UTC (rev 2313)
+++ trunk/xim/helper.cpp	2005-12-02 05:58:09 UTC (rev 2314)
@@ -186,7 +186,27 @@
 		*eol = '\0';
 	    else
 		return;
-	    focusedContext->extra_input(line);
+	    if (!strncmp(line, "charset=", 8)) {
+		const char *charset = line + 8;
+		line = eol + 1;
+		eol = strchr(line, '\n');
+		if (eol != NULL)
+		    *eol = '\0';
+		else
+		    return;
+		if (!strcmp(charset, "UTF-8"))
+		    focusedContext->extra_input(line);
+		else {
+		    int len = strlen(line);
+		    char *utf8_str = (char *)malloc(len * 6 + 1);
+		    if (!utf8_str)
+			return;
+		    mb_string_to_utf8(utf8_str, line, len * 6, charset);
+		    focusedContext->extra_input(utf8_str);
+		    free(utf8_str);
+		}
+	    } else
+		focusedContext->extra_input(line);
 	    return;
 	}
     }

Modified: trunk/xim/ximserver.h
===================================================================
--- trunk/xim/ximserver.h	2005-12-01 20:23:47 UTC (rev 2313)
+++ trunk/xim/ximserver.h	2005-12-02 05:58:09 UTC (rev 2314)
@@ -235,6 +235,7 @@
 const char *find_localename_from_encoding(const char *encoding);
 int utf8_mbtowc(uchar *wc, const unsigned char *src, int src_len);
 int utf8_wctomb(unsigned char *dest, uchar wc); // dest must have size 6
+int mb_string_to_utf8(char *utf8, const char *str, int to_len, const char *enc);
 
 class XimServer {
 public:



More information about the uim-commit mailing list