summaryrefslogtreecommitdiff
path: root/src/fe-text
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-11-08 14:28:18 -0300
committerdequis <dx@dxzone.com.ar>2015-11-08 14:28:18 -0300
commit8c98e07eab423ad7926d8e4fa742b60117652eb1 (patch)
tree32df88a246cc323fa0e2cef97df182cdd4a784f2 /src/fe-text
parent7866d2bcd6797b8279238ffb2f710bd9ea599cc8 (diff)
parent50775e92e64561837e6c805fc8fef19aedaafeb4 (diff)
downloadirssi-8c98e07eab423ad7926d8e4fa742b60117652eb1.zip
Merge remote-tracking branch 'origin/master' into bracketed-paste
Diffstat (limited to 'src/fe-text')
-rw-r--r--src/fe-text/gui-entry.c6
-rw-r--r--src/fe-text/gui-printtext.c7
-rw-r--r--src/fe-text/gui-readline.c2
-rw-r--r--src/fe-text/term-terminfo.c29
-rw-r--r--src/fe-text/term.h2
5 files changed, 34 insertions, 12 deletions
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c
index 17a7c507..c7d06404 100644
--- a/src/fe-text/gui-entry.c
+++ b/src/fe-text/gui-entry.c
@@ -35,21 +35,21 @@ static unichar i_toupper(unichar c)
{
if (term_type == TERM_TYPE_UTF8)
return g_unichar_toupper(c);
- return (c >= 0 && c <= 255) ? toupper(c) : c;
+ return c <= 255 ? toupper(c) : c;
}
static unichar i_tolower(unichar c)
{
if (term_type == TERM_TYPE_UTF8)
return g_unichar_tolower(c);
- return (c >= 0 && c <= 255) ? tolower(c) : c;
+ return c <= 255 ? tolower(c) : c;
}
static int i_isalnum(unichar c)
{
if (term_type == TERM_TYPE_UTF8)
return (g_unichar_isalnum(c) || mk_wcwidth(c) == 0);
- return (c >= 0 && c <= 255) ? isalnum(c) : 0;
+ return c <= 255 ? isalnum(c) : 0;
}
GUI_ENTRY_REC *active_entry;
diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c
index 547d39c9..d8272df5 100644
--- a/src/fe-text/gui-printtext.c
+++ b/src/fe-text/gui-printtext.c
@@ -220,16 +220,15 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
get_colors(flags, &fg, &bg, &attr);
if (window == NULL) {
- g_return_if_fail(next_xpos != -1);
+ g_return_if_fail(next_xpos != -1);
term_set_color2(root_window, attr, fg, bg);
term_move(root_window, next_xpos, next_ypos);
if (flags & GUI_PRINT_FLAG_CLRTOEOL)
term_clrtoeol(root_window);
- term_addstr(root_window, str);
- next_xpos += strlen(str); /* FIXME utf8 or big5 */
- return;
+ next_xpos += term_addstr(root_window, str);
+ return;
}
lineinfo.level = dest == NULL ? 0 : dest->level;
diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c
index 6e169b93..96b8b386 100644
--- a/src/fe-text/gui-readline.c
+++ b/src/fe-text/gui-readline.c
@@ -1126,6 +1126,8 @@ void gui_readline_init(void)
key_bind("key", NULL, "meta2-5F", "cend", (SIGNAL_FUNC) key_combo);
key_bind("key", NULL, "meta2-1;5F", "cend", (SIGNAL_FUNC) key_combo);
+ key_bind("key", NULL, "meta-O-M", "return", (SIGNAL_FUNC) key_combo);
+
key_bind("paste_start", "Bracketed paste start", "meta2-200~", "paste_start", (SIGNAL_FUNC) key_paste_start);
/* cursor movement */
diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c
index 9376bda8..3582b9e4 100644
--- a/src/fe-text/term-terminfo.c
+++ b/src/fe-text/term-terminfo.c
@@ -522,15 +522,36 @@ void term_add_unichar(TERM_WINDOW *window, unichar chr)
}
}
-void term_addstr(TERM_WINDOW *window, const char *str)
+int term_addstr(TERM_WINDOW *window, const char *str)
{
- int len;
+ int len, raw_len;
+ unichar tmp;
+ const char *ptr;
if (vcmove) term_move_real();
- len = strlen(str); /* FIXME utf8 or big5 */
+
+ len = 0;
+ raw_len = strlen(str);
+
+ /* The string length depends on the terminal encoding */
+
+ ptr = str;
+
+ if (term_type == TERM_TYPE_UTF8) {
+ while (*ptr != '\0') {
+ tmp = g_utf8_get_char(ptr);
+ len += unichar_isprint(tmp) ? mk_wcwidth(tmp) : 1;
+ ptr = g_utf8_next_char(ptr);
+ }
+ } else
+ len = raw_len;
+
term_printed_text(len);
- fwrite(str, 1, len, window->term->out);
+ /* Use strlen() here since we need the number of raw bytes */
+ fwrite(str, 1, raw_len, window->term->out);
+
+ return len;
}
void term_clrtoeol(TERM_WINDOW *window)
diff --git a/src/fe-text/term.h b/src/fe-text/term.h
index 692ce9c5..5f0a799e 100644
--- a/src/fe-text/term.h
+++ b/src/fe-text/term.h
@@ -83,7 +83,7 @@ void term_set_color(TERM_WINDOW *window, int col);
void term_move(TERM_WINDOW *window, int x, int y);
void term_addch(TERM_WINDOW *window, char chr);
void term_add_unichar(TERM_WINDOW *window, unichar chr);
-void term_addstr(TERM_WINDOW *window, const char *str);
+int term_addstr(TERM_WINDOW *window, const char *str);
void term_clrtoeol(TERM_WINDOW *window);
void term_move_cursor(int x, int y);