diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common.h | 2 | ||||
-rw-r--r-- | src/fe-text/gui-entry.c | 20 | ||||
-rw-r--r-- | src/fe-text/gui-entry.h | 1 | ||||
-rw-r--r-- | src/fe-text/gui-readline.c | 6 |
4 files changed, 24 insertions, 5 deletions
diff --git a/src/common.h b/src/common.h index 100d00cb..159f7124 100644 --- a/src/common.h +++ b/src/common.h @@ -6,7 +6,7 @@ #define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */ #define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */ -#define IRSSI_ABI_VERSION 10 +#define IRSSI_ABI_VERSION 11 #define DEFAULT_SERVER_ADD_PORT 6667 #define DEFAULT_SERVER_ADD_TLS_PORT 6697 diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index f05decd2..e91fcfb3 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -936,6 +936,26 @@ void gui_entry_set_pos(GUI_ENTRY_REC *entry, int pos) gui_entry_draw(entry); } +void gui_entry_set_text_and_pos_bytes(GUI_ENTRY_REC *entry, const char *str, int pos_bytes) +{ + int pos; + const char *ptr; + + g_return_if_fail(entry != NULL); + + gui_entry_set_text(entry, str); + + if (entry->utf8) { + g_utf8_validate(str, pos_bytes, &ptr); + pos = g_utf8_pointer_to_offset(str, ptr); + } else if (term_type == TERM_TYPE_BIG5) + pos = strlen_big5((const unsigned char *)str) - strlen_big5((const unsigned char *)(str + pos_bytes)); + else + pos = pos_bytes; + + gui_entry_set_pos(entry, pos); +} + void gui_entry_move_pos(GUI_ENTRY_REC *entry, int pos) { g_return_if_fail(entry != NULL); diff --git a/src/fe-text/gui-entry.h b/src/fe-text/gui-entry.h index 8777f083..000c5f03 100644 --- a/src/fe-text/gui-entry.h +++ b/src/fe-text/gui-entry.h @@ -50,6 +50,7 @@ void gui_entry_set_utf8(GUI_ENTRY_REC *entry, int utf8); void gui_entry_set_text(GUI_ENTRY_REC *entry, const char *str); char *gui_entry_get_text(GUI_ENTRY_REC *entry); char *gui_entry_get_text_and_pos(GUI_ENTRY_REC *entry, int *pos); +void gui_entry_set_text_and_pos_bytes(GUI_ENTRY_REC *entry, const char *str, int pos_bytes); void gui_entry_insert_text(GUI_ENTRY_REC *entry, const char *str); void gui_entry_insert_char(GUI_ENTRY_REC *entry, unichar chr); diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 2c2eac21..3688f15e 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -878,8 +878,7 @@ static void key_completion(int erase, int backward) g_free(text); if (line != NULL) { - gui_entry_set_text(active_entry, line); - gui_entry_set_pos(active_entry, pos); + gui_entry_set_text_and_pos_bytes(active_entry, line, pos); g_free(line); } } @@ -909,8 +908,7 @@ static void key_check_replaces(void) g_free(text); if (line != NULL) { - gui_entry_set_text(active_entry, line); - gui_entry_set_pos(active_entry, pos); + gui_entry_set_text_and_pos_bytes(active_entry, line, pos); g_free(line); } } |