int term_init(void)
{
- struct sigaction act;
+ struct sigaction act;
+ int width, height;
last_fg = last_bg = -1;
last_attrs = 0;
if (current_term == NULL)
return FALSE;
+ if (term_get_size(&width, &height)) {
+ current_term->width = width;
+ current_term->height = height;
+ }
+
/* grab CONT signal */
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
void term_deinit(void)
{
if (current_term != NULL) {
+ signal(SIGCONT, SIG_DFL);
g_source_remove(redraw_tag);
term_common_deinit();
vcx += count;
while (vcx >= term_width) {
vcx -= term_width;
- if (vcy < term_height) vcy++;
+ if (vcy < term_height-1) vcy++;
if (vcx > 0) term_lines_empty[vcy] = FALSE;
}
}
if (term_detached) return;
if (vcmove) term_move_real();
- term_printed_text(1);
+
+ /* With UTF-8, move cursor only if this char is either single-byte
+ (8. bit on) or beginning of multibyte (7+8 bits on) */
+ if (term_type != TERM_TYPE_UTF8 ||
+ (chr & 0x80) == 0 || (chr & 0x40) == 0) {
+ term_printed_text(1);
+ }
+
if (vcy != term_height || vcx != 0)
putc(chr, window->term->out);
}
static void term_addch_utf8(TERM_WINDOW *window, unichar chr)
{
- unsigned char buf[10];
+ char buf[10];
int i, len;
len = utf16_char_to_utf8(chr, buf);
if (i >= term_inbuf_pos)
term_inbuf_pos = 0;
- else {
+ else if (i > 0) {
memmove(term_inbuf+i, term_inbuf, term_inbuf_pos-i);
- term_inbuf_pos = i;
+ term_inbuf_pos -= i;
}
}