mirror of
https://github.com/irssi/irssi.git
synced 2024-09-08 04:26:01 -04:00
Merge pull request #318 from LemonBoy/fix-utf8-elements
Fix the display of utf8 sequences in the gui
This commit is contained in:
commit
79fa2fcb59
@ -227,8 +227,7 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
|
|||||||
term_move(root_window, next_xpos, next_ypos);
|
term_move(root_window, next_xpos, next_ypos);
|
||||||
if (flags & GUI_PRINT_FLAG_CLRTOEOL)
|
if (flags & GUI_PRINT_FLAG_CLRTOEOL)
|
||||||
term_clrtoeol(root_window);
|
term_clrtoeol(root_window);
|
||||||
term_addstr(root_window, str);
|
next_xpos += term_addstr(root_window, str);
|
||||||
next_xpos += strlen(str); /* FIXME utf8 or big5 */
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
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);
|
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)
|
void term_clrtoeol(TERM_WINDOW *window)
|
||||||
|
@ -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_move(TERM_WINDOW *window, int x, int y);
|
||||||
void term_addch(TERM_WINDOW *window, char chr);
|
void term_addch(TERM_WINDOW *window, char chr);
|
||||||
void term_add_unichar(TERM_WINDOW *window, unichar 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_clrtoeol(TERM_WINDOW *window);
|
||||||
|
|
||||||
void term_move_cursor(int x, int y);
|
void term_move_cursor(int x, int y);
|
||||||
|
Loading…
Reference in New Issue
Block a user