|
|
| |
#endif | #endif |
| |
|
static inline void term_send_event(struct terminal *term, struct event *ev) |
|
{ |
|
((struct window *)&term->windows)->next->handler(term->windows.next, ev, 0); |
|
} |
|
|
|
static inline void term_send_ucs(struct terminal *term, struct event *ev, int u) |
|
{ |
|
unsigned char *recoded; |
|
|
|
if (u == 0xA0) u = ' '; |
|
recoded = u2cp(u, term->spec->charset); |
|
if (! recoded) recoded = "*"; |
|
while (*recoded) { |
|
ev->x = *recoded; |
|
term_send_event(term, ev); |
|
recoded ++; |
|
} |
|
} |
|
|
void in_term(struct terminal *term) | void in_term(struct terminal *term) |
{ | { |
struct event *ev; | struct event *ev; |
|
|
goto send_redraw; | goto send_redraw; |
} | } |
else if (ev->ev == EV_KBD && ev->x == KBD_CTRL_C) ((struct window *)&term->windows)->prev->handler(term->windows.prev, ev, 0); | else if (ev->ev == EV_KBD && ev->x == KBD_CTRL_C) ((struct window *)&term->windows)->prev->handler(term->windows.prev, ev, 0); |
else ((struct window *)&term->windows)->next->handler(term->windows.next, ev, 0); |
else if (ev->ev == EV_KBD) { |
|
if (term->utf_8.len) { |
|
if ((ev->x & 0xC0) == 0x80 && term->spec->utf_8_io) { |
|
term->utf_8.ucs <<= 6; |
|
term->utf_8.ucs |= ev->x & 0x3F; |
|
if (! --term->utf_8.len) { |
|
int u = term->utf_8.ucs; |
|
|
|
if (u < term->utf_8.min) u = UCS_NO_CHAR; |
|
term_send_ucs(term, ev, u); |
|
} |
|
goto mm; |
|
} else { |
|
term->utf_8.len = 0; |
|
term_send_ucs(term, ev, UCS_NO_CHAR); |
|
} |
|
} |
|
if (ev->x < 0x80 || ev->x > 0xFF || ! term->spec->utf_8_io) { |
|
term_send_event(term, ev); |
|
goto mm; |
|
} else if ((ev->x & 0xC0) == 0xC0 && (ev->x & 0xFE) != 0xFE) { |
|
int mask, len = 0, cov = 0x80; |
|
|
|
for (mask = 0x80; ev->x & mask; mask >>= 1) { |
|
len++; |
|
term->utf_8.min = cov; |
|
cov = 1 << (1 + 5 * len); |
|
} |
|
term->utf_8.len = len - 1; |
|
term->utf_8.ucs = ev->x & (mask - 1); |
|
goto mm; |
|
} |
|
term_send_ucs(term, ev, UCS_NO_CHAR); |
|
} else term_send_event(term, ev); |
} | } |
if (ev->ev == EV_ABORT) { | if (ev->ev == EV_ABORT) { |
destroy_terminal(term); | destroy_terminal(term); |
|
|
| |
unsigned char frame_dumb[48] = " ||||++||++++++--|-+||++--|-+----++++++++ "; | unsigned char frame_dumb[48] = " ||||++||++++++--|-+||++--|-+----++++++++ "; |
unsigned char frame_vt100[48] = "aaaxuuukkuxkjjjkmvwtqnttmlvwtqnvvwwmmllnnjla "; | unsigned char frame_vt100[48] = "aaaxuuukkuxkjjjkmvwtqnttmlvwtqnvvwwmmllnnjla "; |
|
unsigned char frame_vt100_u[48] = { |
|
177,177,177,179,180,180,180,191, |
|
191,180,179,191,217,217,217,191, |
|
192,193,194,195,196,197,195,195, |
|
192,218,193,194,195,196,197,193, |
|
193,194,194,192,192,218,218,197, |
|
197,217,218,177, 32, 32, 32, 32 |
|
}; |
unsigned char frame_koi[48] = { | unsigned char frame_koi[48] = { |
144,145,146,129,135,178,180,167, | 144,145,146,129,135,178,180,167, |
166,181,161,168,174,173,172,131, | 166,181,161,168,174,173,172,131, |
|
|
unsigned char c = ch & 0xff; \ | unsigned char c = ch & 0xff; \ |
unsigned char A = ch >> 8 & 0x7f; \ | unsigned char A = ch >> 8 & 0x7f; \ |
if (s->mode == TERM_LINUX) { \ | if (s->mode == TERM_LINUX) { \ |
if (s->m11_hack) { \ |
if (s->m11_hack && !s->utf_8_io) { \ |
if ((int)(ch >> 15) != mode) { \ | if ((int)(ch >> 15) != mode) { \ |
if (!(mode = ch >> 15)) add_to_str(&a, &l, "\033[10m"); \ | if (!(mode = ch >> 15)) add_to_str(&a, &l, "\033[10m"); \ |
else add_to_str(&a, &l, "\033[11m"); \ | else add_to_str(&a, &l, "\033[11m"); \ |
|
|
if (s->restrict_852 && (ch >> 15) && c >= 176 && c < 224) { \ | if (s->restrict_852 && (ch >> 15) && c >= 176 && c < 224) { \ |
if (frame_restrict[c - 176]) c = frame_restrict[c - 176]; \ | if (frame_restrict[c - 176]) c = frame_restrict[c - 176]; \ |
} \ | } \ |
} else if (s->mode == TERM_VT100) { \ |
} else if (s->mode == TERM_VT100 && !s->utf_8_io) { \ |
if ((int)(ch >> 15) != mode) { \ | if ((int)(ch >> 15) != mode) { \ |
if (!(mode = ch >> 15)) add_to_str(&a, &l, "\x0f"); \ | if (!(mode = ch >> 15)) add_to_str(&a, &l, "\x0f"); \ |
else add_to_str(&a, &l, "\x0e"); \ | else add_to_str(&a, &l, "\x0e"); \ |
} \ | } \ |
if (mode && c >= 176 && c < 224) c = frame_vt100[c - 176]; \ | if (mode && c >= 176 && c < 224) c = frame_vt100[c - 176]; \ |
|
} else if (s->mode == TERM_VT100 && (ch >> 15) && c >= 176 && c < 224) { \ |
|
c = frame_vt100_u[c - 176]; \ |
} else if (s->mode == TERM_KOI8 && (ch >> 15) && c >= 176 && c < 224) { c = frame_koi[c - 176];\ | } else if (s->mode == TERM_KOI8 && (ch >> 15) && c >= 176 && c < 224) { c = frame_koi[c - 176];\ |
} else if (s->mode == TERM_FREEBSD && (ch >> 15) && c >= 176 && c < 224) { c = frame_freebsd[c - 176];\ | } else if (s->mode == TERM_FREEBSD && (ch >> 15) && c >= 176 && c < 224) { c = frame_freebsd[c - 176];\ |
} else if (s->mode == TERM_DUMB && (ch >> 15) && c >= 176 && c < 224) c = frame_dumb[c - 176];\ | } else if (s->mode == TERM_DUMB && (ch >> 15) && c >= 176 && c < 224) c = frame_dumb[c - 176];\ |
|
|
if (attrib & 0100) add_to_str(&a, &l, ";1"); \ | if (attrib & 0100) add_to_str(&a, &l, ";1"); \ |
add_to_str(&a, &l, "m"); \ | add_to_str(&a, &l, "m"); \ |
} \ | } \ |
if (c >= ' ' && c != 127/* && c != 155*/) add_chr_to_str(&a, &l, c); \ |
if (c >= ' ' && c != 127/* && c != 155*/) { \ |
|
int charset = s->charset; \ |
|
\ |
|
if (ch >> 15) { \ |
|
int frames_charset = (s->mode == TERM_LINUX || s->mode == TERM_VT100) \ |
|
? get_cp_index("cp437") \ |
|
: s->mode == TERM_KOI8 \ |
|
? get_cp_index("koi8-r") \ |
|
: -1; \ |
|
if (frames_charset != -1) charset = frames_charset; \ |
|
} \ |
|
if (s->utf_8_io) add_to_str(&a, &l, cp2utf_8(charset, c)); \ |
|
else add_chr_to_str(&a, &l, c); \ |
|
} \ |
else if (!c || c == 1) add_chr_to_str(&a, &l, ' '); \ | else if (!c || c == 1) add_chr_to_str(&a, &l, ' '); \ |
else add_chr_to_str(&a, &l, '.'); \ | else add_chr_to_str(&a, &l, '.'); \ |
cx++; \ | cx++; \ |