[uim-commit] r1122 - trunk/fep
yamamoto at freedesktop.org
yamamoto at freedesktop.org
Fri Aug 5 19:57:52 EST 2005
Author: yamamoto
Date: 2005-08-05 02:57:49 -0700 (Fri, 05 Aug 2005)
New Revision: 1122
Modified:
trunk/fep/README.ja
trunk/fep/README.key
trunk/fep/callbacks.c
trunk/fep/key.c
trunk/fep/key.h
trunk/fep/uim-fep.c
Log:
* fep/callbacks.c (init_callbacks) : use uim_iconv instead of iconv
* key.c (escape_sequence2key) :
add length parameter, because input string may contains NUL character
Modified: trunk/fep/README.ja
===================================================================
--- trunk/fep/README.ja 2005-08-05 09:40:14 UTC (rev 1121)
+++ trunk/fep/README.ja 2005-08-05 09:57:49 UTC (rev 1122)
@@ -30,16 +30,23 @@
¤Î¤è¤¦¤Ë½ñ¤¤Þ¤¹¡£
Ãí°Õ
- ¥Ç¥Õ¥©¥ë¥È¤Î¥¡¼¥Ð¥¤¥ó¥É¤Ç¤Ï¡¢uim-fep¤Çanthy¤Î¥«¥¿¥«¥Ê¥â¡¼¥É¤Ê¤É¤Ø¤Î
- ¥â¡¼¥ÉÊѹ¹¤¬¤Ç¤¤Þ¤»¤ó¡£prime¤Ç¤ÏÁ´³Ñ±Ñ¿ô¥â¡¼¥É¤Ø¤Î¥â¡¼¥ÉÊѹ¹¤¬¤Ç¤
- ¤Þ¤»¤ó¡£¤³¤ì¤é¤Î¥â¡¼¥ÉÊѹ¹¤ò¹Ô¤¦¤¿¤á¤Ë¤Ï¼¡¤Î¤è¤¦¤Ë
- ~/.uim¤Ë½ñ¤¤Þ¤¹¡£
+ ¥Ç¥Õ¥©¥ë¥È¤Î¥¡¼¥Ð¥¤¥ó¥É¤Ç¤Ï¡¢uim-fep¤Ç¤Ï°Ê²¼¤ÎÁàºî¤¬¹Ô¤¨¤Þ¤»¤ó¡£
+ anthy
+ ʸÀá¤ò½Ì¤á¤ë
+ prime
+ Á´³Ñ±Ñ¿ô¥â¡¼¥É¤Ë¥â¡¼¥ÉÊѹ¹
+ canna
+ ʸÀá¤ò½Ì¤á¤ë
+ ¤³¤ì¤é¤ÎÁàºî¤ò¹Ô¤¦¤¿¤á¤Ë¤Ïuim-pref¤Ç¥¡¼¥Ð¥¤¥ó¥É¤òÀßÄꤹ¤ë¤«~/.uim¤Ë¼¡¤Î¤è¤¦¤Ë½ñ¤¤Þ¤¹¡£
+
Îã
- (define-key anthy-wide-latin-key? "L")
- (define-key anthy-hankaku-kana-key? "<Control>q")
- (define-key anthy-kana-toggle-key? "q")
+ (require-module "anthy")
+ (define-key anthy-shrink-segment-key? '("tab" "<IgnoreCase><Control>i" "<Shift>left"))
+ (require-module "prime")
(define-key prime-wide-latin-key? '("<Control><Alt>l" "<Control>L"))
+ (require-module "canna")
+ (define-key canna-shrink-segment-key? '("tab" "<IgnoreCase><Control>i" "<Shift>left"))
* ´Ä¶ÊÑ¿ô
Modified: trunk/fep/README.key
===================================================================
--- trunk/fep/README.key 2005-08-05 09:40:14 UTC (rev 1121)
+++ trunk/fep/README.key 2005-08-05 09:57:49 UTC (rev 1122)
@@ -8,7 +8,7 @@
Ctrl + e "<Control>e"
Ctrl + f "<Control>f"
Ctrl + g "<Control>g"
-Ctrl + h "backspace"
+Ctrl + h "<Control>h" or "backspace"
Ctrl + i "tab"
Ctrl + j "<Control>j"
Ctrl + k "<Control>k"
@@ -172,7 +172,7 @@
Esc + Ctrl + e "<Alt><Control>e"
Esc + Ctrl + f "<Alt><Control>f"
Esc + Ctrl + g "<Alt><Control>g"
-Esc + Ctrl + h "<Alt>backspace"
+Esc + Ctrl + h "<Alt><Control>h" or "<Alt>backspace"
Esc + Ctrl + i "<Alt>tab"
Esc + Ctrl + j "<Alt><Control>j"
Esc + Ctrl + k "<Alt><Control>k"
@@ -338,7 +338,7 @@
133 0x85 "<Meta><Control>e"
134 0x86 "<Meta><Control>f"
135 0x87 "<Meta><Control>g"
-136 0x88 "<Meta>backspace"
+136 0x88 "<Meta><Control>h"
137 0x89 "<Meta>tab"
138 0x8a "<Meta><Control>j"
139 0x8b "<Meta><Control>k"
@@ -473,7 +473,7 @@
Esc + 133 0x85 "<Alt><Meta><Control>e"
Esc + 134 0x86 "<Alt><Meta><Control>f"
Esc + 135 0x87 "<Alt><Meta><Control>g"
-Esc + 136 0x88 "<Alt><Meta>backspace"
+Esc + 136 0x88 "<Alt><Meta><Control>h"
Esc + 137 0x89 "<Alt><Meta>tab"
Esc + 138 0x8a "<Alt><Meta><Control>j"
Esc + 139 0x8b "<Alt><Meta><Control>k"
Modified: trunk/fep/callbacks.c
===================================================================
--- trunk/fep/callbacks.c 2005-08-05 09:40:14 UTC (rev 1121)
+++ trunk/fep/callbacks.c 2005-08-05 09:57:49 UTC (rev 1122)
@@ -49,7 +49,6 @@
#ifdef HAVE_ASSERT_H
#include <assert.h>
#endif
-#include <iconv.h>
#include <uim/uim-util.h>
#include "uim-fep.h"
#include "str.h"
@@ -141,29 +140,20 @@
}
if (g_opt.ddskk) {
- iconv_t cd;
- char *nokori_str = "»Ä¤ê";
- size_t inbytesleft = strlen("»Ä¤ê");
- size_t outbytesleft = 6;
+ void *cd;
+ const char *nokori_str = "»Ä¤ê";
const char *enc;
- s_nokori_str = malloc(outbytesleft + 1);
- strcpy(s_nokori_str, "»Ä¤ê");
- if (strcmp(enc = get_enc(), "EUC-JP") != 0) {
- cd = (iconv_t)uim_iconv_open(enc, "EUC-JP");
- if (cd == (iconv_t)-1) {
- perror("error in iconv_open");
- puts("-d option is not available");
- done(EXIT_FAILURE);
+ if (uim_iconv->is_convertible(enc = get_enc(), "EUC-JP")) {
+ cd = uim_iconv->create(enc, "EUC-JP");
+ s_nokori_str = uim_iconv->convert(cd, nokori_str);
+ if (cd) {
+ uim_iconv->release(cd);
}
- if (iconv(cd, (ICONV_CONST char**)&nokori_str, &inbytesleft, &s_nokori_str, &outbytesleft) == (size_t)-1) {
- perror("error in iconv");
- puts("-d option is not available");
- done(EXIT_FAILURE);
- }
- s_nokori_str[0] = '\0';
- s_nokori_str -= (6 - outbytesleft);
- iconv_close(cd);
+ } else {
+ perror("error in iconv_open");
+ puts("-d option is not available");
+ done(EXIT_FAILURE);
}
}
}
Modified: trunk/fep/key.c
===================================================================
--- trunk/fep/key.c 2005-08-05 09:40:14 UTC (rev 1121)
+++ trunk/fep/key.c 2005-08-05 09:57:49 UTC (rev 1122)
@@ -65,7 +65,7 @@
#define _KEY_RIGHT "\033[C"
#define _KEY_LEFT "\033[D"
-static int strcmp_prefix(const char *str, const char *prefix);
+static int strcmp_prefix(const char *str, int str_len, const char *prefix);
int tty2key(char key)
{
@@ -74,8 +74,6 @@
/* c-space */
case 0:
return ' ';
- case '\b':
- return UKey_Backspace;
case '\t':
return UKey_Tab;
case '\r':
@@ -102,8 +100,7 @@
{
int key_state = (key & 0x80) ? UMod_Meta : 0;
key &= 0x7f;
- if (key == '\b' ||
- key == '\t' ||
+ if (key == '\t' ||
key == '\r' ||
key == ESCAPE_CODE ||
key == 0x7f) {
@@ -123,40 +120,40 @@
* ¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¤éUKey_Escape¤È¡¢ÅÓÃæ¤Þ¤Ç°ìÃפ·¤Æ¤¤¤ë¥¨¥¹¥±¡¼¥×¥·¡¼
* ¥±¥ó¥¹¤¬¤¢¤ë¾ì¹ç¤ÏTRUE¤Ê¤¤¾ì¹ç¤ÏFALSE¤òÊÖ¤¹
*/
-int *escape_sequence2key(const char *str)
+int *escape_sequence2key(const char *str, int str_len)
{
static int rval[2];
int len;
int not_enough = 0;
- if ( (not_enough += len = strcmp_prefix(str, _KEY_UP )), len > 0) { rval[0] = UKey_Up;
- } else if ( (not_enough += len = strcmp_prefix(str, _KEY_DOWN )), len > 0) { rval[0] = UKey_Down;
- } else if ( (not_enough += len = strcmp_prefix(str, _KEY_RIGHT )), len > 0) { rval[0] = UKey_Right;
- } else if ( (not_enough += len = strcmp_prefix(str, _KEY_LEFT )), len > 0) { rval[0] = UKey_Left;
- } else if (key_backspace != NULL && (not_enough += len = strcmp_prefix(str, key_backspace)), len > 0) { rval[0] = UKey_Backspace;
- } else if (key_dc != NULL && (not_enough += len = strcmp_prefix(str, key_dc )), len > 0) { rval[0] = UKey_Delete;
- } else if (key_left != NULL && (not_enough += len = strcmp_prefix(str, key_left )), len > 0) { rval[0] = UKey_Left;
- } else if (key_up != NULL && (not_enough += len = strcmp_prefix(str, key_up )), len > 0) { rval[0] = UKey_Up;
- } else if (key_right != NULL && (not_enough += len = strcmp_prefix(str, key_right )), len > 0) { rval[0] = UKey_Right;
- } else if (key_down != NULL && (not_enough += len = strcmp_prefix(str, key_down )), len > 0) { rval[0] = UKey_Down;
- } else if (key_ppage != NULL && (not_enough += len = strcmp_prefix(str, key_ppage )), len > 0) { rval[0] = UKey_Prior;
- } else if (key_npage != NULL && (not_enough += len = strcmp_prefix(str, key_npage )), len > 0) { rval[0] = UKey_Next;
- } else if (key_home != NULL && (not_enough += len = strcmp_prefix(str, key_home )), len > 0) { rval[0] = UKey_Home;
- } else if (key_end != NULL && (not_enough += len = strcmp_prefix(str, key_end )), len > 0) { rval[0] = UKey_End;
- } else if (key_ic != NULL && (not_enough += len = strcmp_prefix(str, key_ic )), len > 0) { rval[0] = UKey_Insert;
- } else if (key_f1 != NULL && (not_enough += len = strcmp_prefix(str, key_f1 )), len > 0) { rval[0] = UKey_F1;
- } else if (key_f2 != NULL && (not_enough += len = strcmp_prefix(str, key_f2 )), len > 0) { rval[0] = UKey_F2;
- } else if (key_f3 != NULL && (not_enough += len = strcmp_prefix(str, key_f3 )), len > 0) { rval[0] = UKey_F3;
- } else if (key_f4 != NULL && (not_enough += len = strcmp_prefix(str, key_f4 )), len > 0) { rval[0] = UKey_F4;
- } else if (key_f5 != NULL && (not_enough += len = strcmp_prefix(str, key_f5 )), len > 0) { rval[0] = UKey_F5;
- } else if (key_f6 != NULL && (not_enough += len = strcmp_prefix(str, key_f6 )), len > 0) { rval[0] = UKey_F6;
- } else if (key_f7 != NULL && (not_enough += len = strcmp_prefix(str, key_f7 )), len > 0) { rval[0] = UKey_F7;
- } else if (key_f8 != NULL && (not_enough += len = strcmp_prefix(str, key_f8 )), len > 0) { rval[0] = UKey_F8;
- } else if (key_f9 != NULL && (not_enough += len = strcmp_prefix(str, key_f9 )), len > 0) { rval[0] = UKey_F9;
- } else if (key_f10 != NULL && (not_enough += len = strcmp_prefix(str, key_f10 )), len > 0) { rval[0] = UKey_F10;
- } else if (key_f11 != NULL && (not_enough += len = strcmp_prefix(str, key_f11 )), len > 0) { rval[0] = UKey_F11;
- } else if (key_f12 != NULL && (not_enough += len = strcmp_prefix(str, key_f12 )), len > 0) { rval[0] = UKey_F12;
+ if ( (not_enough += len = strcmp_prefix(str, str_len, _KEY_UP )), len > 0) { rval[0] = UKey_Up;
+ } else if ( (not_enough += len = strcmp_prefix(str, str_len, _KEY_DOWN )), len > 0) { rval[0] = UKey_Down;
+ } else if ( (not_enough += len = strcmp_prefix(str, str_len, _KEY_RIGHT )), len > 0) { rval[0] = UKey_Right;
+ } else if ( (not_enough += len = strcmp_prefix(str, str_len, _KEY_LEFT )), len > 0) { rval[0] = UKey_Left;
+ } else if (key_backspace != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_backspace)), len > 0) { rval[0] = UKey_Backspace;
+ } else if (key_dc != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_dc )), len > 0) { rval[0] = UKey_Delete;
+ } else if (key_left != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_left )), len > 0) { rval[0] = UKey_Left;
+ } else if (key_up != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_up )), len > 0) { rval[0] = UKey_Up;
+ } else if (key_right != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_right )), len > 0) { rval[0] = UKey_Right;
+ } else if (key_down != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_down )), len > 0) { rval[0] = UKey_Down;
+ } else if (key_ppage != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_ppage )), len > 0) { rval[0] = UKey_Prior;
+ } else if (key_npage != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_npage )), len > 0) { rval[0] = UKey_Next;
+ } else if (key_home != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_home )), len > 0) { rval[0] = UKey_Home;
+ } else if (key_end != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_end )), len > 0) { rval[0] = UKey_End;
+ } else if (key_ic != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_ic )), len > 0) { rval[0] = UKey_Insert;
+ } else if (key_f1 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f1 )), len > 0) { rval[0] = UKey_F1;
+ } else if (key_f2 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f2 )), len > 0) { rval[0] = UKey_F2;
+ } else if (key_f3 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f3 )), len > 0) { rval[0] = UKey_F3;
+ } else if (key_f4 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f4 )), len > 0) { rval[0] = UKey_F4;
+ } else if (key_f5 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f5 )), len > 0) { rval[0] = UKey_F5;
+ } else if (key_f6 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f6 )), len > 0) { rval[0] = UKey_F6;
+ } else if (key_f7 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f7 )), len > 0) { rval[0] = UKey_F7;
+ } else if (key_f8 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f8 )), len > 0) { rval[0] = UKey_F8;
+ } else if (key_f9 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f9 )), len > 0) { rval[0] = UKey_F9;
+ } else if (key_f10 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f10 )), len > 0) { rval[0] = UKey_F10;
+ } else if (key_f11 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f11 )), len > 0) { rval[0] = UKey_F11;
+ } else if (key_f12 != NULL && (not_enough += len = strcmp_prefix(str, str_len, key_f12 )), len > 0) { rval[0] = UKey_F12;
} else {
- rval[0] = UKey_Escape;
+ rval[0] = UKey_Other;
len = not_enough < 0 ? TRUE : FALSE;
}
rval[1] = len;
@@ -168,11 +165,11 @@
* str¤¬prefix¤Î¸ìƬ¤Î¤È¤-strlen(str)¤òÊÖ¤¹
* ¤½¤ì°Ê³°¤Ï0¤òÊÖ¤¹
*/
-static int strcmp_prefix(const char *str, const char *prefix)
+static int strcmp_prefix(const char *str, int str_len, const char *prefix)
{
int i;
assert(str != NULL && prefix != NULL);
- for (i = 0; str[i] != '\0' && prefix[i] != '\0'; i++) {
+ for (i = 0; i < str_len && prefix[i] != '\0'; i++) {
if (str[i] != prefix[i]) {
break;
}
@@ -180,7 +177,7 @@
if (prefix[i] == '\0') {
return i;
}
- if (str[i] == '\0') {
+ if (i == str_len) {
return -i;
}
return 0;
Modified: trunk/fep/key.h
===================================================================
--- trunk/fep/key.h 2005-08-05 09:40:14 UTC (rev 1121)
+++ trunk/fep/key.h 2005-08-05 09:57:49 UTC (rev 1122)
@@ -35,7 +35,7 @@
#define KEY_H
int tty2key(char key);
int tty2key_state(char key);
-int *escape_sequence2key(const char *str);
+int *escape_sequence2key(const char *str, int str_len);
void print_key(int key, int key_state);
#endif
Modified: trunk/fep/uim-fep.c
===================================================================
--- trunk/fep/uim-fep.c 2005-08-05 09:40:14 UTC (rev 1121)
+++ trunk/fep/uim-fep.c 2005-08-05 09:57:49 UTC (rev 1122)
@@ -721,10 +721,7 @@
/* ¥¡¼¥Ü¡¼¥É(stdin)¤«¤é¤ÎÆþÎÏ */
if (FD_ISSET(g_win_in, &fds)) {
- int i;
- int key;
int key_state = 0;
- int key_len;
if ((len = read_stdin(buf, sizeof(buf) - 1)) <= 0) {
/* ¤³¤³¤Ë¤Ï¤³¤Ê¤¤¤È»×¤¦ */
@@ -740,41 +737,50 @@
}
} else {
+ int i;
for (i = 0; i < len; i++) {
- key = tty2key(buf[i]);
- key_state |= tty2key_state(buf[i]);
- if (key == UKey_Escape && (key_state & UMod_Meta) == 0) {
+ int key_len;
+ int *key_and_key_len = escape_sequence2key(buf + i, len - i);
+ int key = key_and_key_len[0];
- int *key_and_key_len = escape_sequence2key(buf + i);
- key = key_and_key_len[0];
+ if (key == UKey_Other) {
- if (key == UKey_Escape) {
- int not_enough = key_and_key_len[1];
- if (not_enough && g_opt.timeout > 0) {
- struct timeval t;
- FD_ZERO(&fds);
- FD_SET(g_win_in, &fds);
- t.tv_sec = 0;
- t.tv_usec = g_opt.timeout;
- if (my_select(nfd, &fds, &t) > 0) {
- len += read_stdin(buf + len, sizeof(buf) - len - 1);
- buf[len] = '\0';
- debug(("read_again \"%s\"\n", buf));
- i--;
- continue;
- }
- }
- if (i + 1 < len && key_state != UMod_Alt) {
- key_state = UMod_Alt;
+ int not_enough;
+ key = tty2key(buf[i]);
+ key_state |= tty2key_state(buf[i]);
+ not_enough = key_and_key_len[1];
+
+ if (buf[i] == ESCAPE_CODE && i == len - 1) {
+ not_enough = TRUE;
+ }
+
+ if (not_enough && g_opt.timeout > 0) {
+ /* ÆþÎϤ¬Â¤é¤Ê¤¤¤Î¤ÇºÆ¤ÓÆɤ߽Ф¹ */
+ struct timeval t;
+ fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(g_win_in, &fds);
+ t.tv_sec = 0;
+ t.tv_usec = g_opt.timeout;
+ if (my_select(g_win_in + 1, &fds, &t) > 0) {
+ len += read_stdin(buf + len, sizeof(buf) - len - 1);
+ buf[len] = '\0';
+ debug(("read_again \"%s\"\n", buf));
+ i--;
continue;
}
- key_len = 1;
- } else {
- key_len = key_and_key_len[1];
}
- } else {
+
+ if (buf[i] == ESCAPE_CODE && i < len - 1) {
+ key_state = UMod_Alt;
+ continue;
+ }
key_len = 1;
+
+ } else { /* key != UKey_Other */
+ key_len = key_and_key_len[1];
}
+
if (g_opt.print_key) {
print_key(key, key_state);
} else {
@@ -788,6 +794,7 @@
}
}
}
+
key_state = 0;
i += (key_len - 1);
}
More information about the uim-commit
mailing list