version 1.89, 2010/08/11 07:34:43 |
version 1.90, 2010/09/11 16:19:22 |
|
|
void tty_read_callback(struct bufferevent *, void *); |
void tty_read_callback(struct bufferevent *, void *); |
void tty_error_callback(struct bufferevent *, short, void *); |
void tty_error_callback(struct bufferevent *, short, void *); |
|
|
void tty_fill_acs(struct tty *); |
|
|
|
int tty_try_256(struct tty *, u_char, const char *); |
int tty_try_256(struct tty *, u_char, const char *); |
int tty_try_88(struct tty *, u_char, const char *); |
int tty_try_88(struct tty *, u_char, const char *); |
|
|
|
|
void tty_cell(struct tty *, |
void tty_cell(struct tty *, |
const struct grid_cell *, const struct grid_utf8 *); |
const struct grid_cell *, const struct grid_utf8 *); |
|
|
|
#define tty_use_acs(tty) \ |
|
(tty_term_has(tty, TTYC_ACSC) && !((tty)->flags & TTY_UTF8)) |
|
|
void |
void |
tty_init(struct tty *tty, int fd, char *term) |
tty_init(struct tty *tty, int fd, char *term) |
{ |
{ |
|
|
|
|
tty_keys_init(tty); |
tty_keys_init(tty); |
|
|
tty_fill_acs(tty); |
|
|
|
return (0); |
return (0); |
} |
} |
|
|
|
|
memcpy(&tty->cell, &grid_default_cell, sizeof tty->cell); |
memcpy(&tty->cell, &grid_default_cell, sizeof tty->cell); |
|
|
tty_putcode(tty, TTYC_RMKX); |
tty_putcode(tty, TTYC_RMKX); |
tty_putcode(tty, TTYC_ENACS); |
if (tty_use_acs(tty)) |
|
tty_putcode(tty, TTYC_ENACS); |
tty_putcode(tty, TTYC_CLEAR); |
tty_putcode(tty, TTYC_CLEAR); |
|
|
tty_putcode(tty, TTYC_CNORM); |
tty_putcode(tty, TTYC_CNORM); |
|
|
return; |
return; |
|
|
tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1)); |
tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS)); |
if (tty_use_acs(tty)) |
|
tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_RMKX)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_RMKX)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR)); |
|
|
} |
} |
|
|
void |
void |
tty_fill_acs(struct tty *tty) |
|
{ |
|
const char *ptr; |
|
|
|
memset(tty->acs, 0, sizeof tty->acs); |
|
if (!tty_term_has(tty->term, TTYC_ACSC)) |
|
return; |
|
|
|
ptr = tty_term_string(tty->term, TTYC_ACSC); |
|
if (strlen(ptr) % 2 != 0) |
|
return; |
|
for (; *ptr != '\0'; ptr += 2) |
|
tty->acs[(u_char) ptr[0]] = ptr[1]; |
|
} |
|
|
|
u_char |
|
tty_get_acs(struct tty *tty, u_char ch) |
|
{ |
|
if (tty->acs[ch] != '\0') |
|
return (tty->acs[ch]); |
|
return (ch); |
|
} |
|
|
|
void |
|
tty_close(struct tty *tty) |
tty_close(struct tty *tty) |
{ |
{ |
if (tty->log_fd != -1) { |
if (tty->log_fd != -1) { |
|
|
void |
void |
tty_putc(struct tty *tty, u_char ch) |
tty_putc(struct tty *tty, u_char ch) |
{ |
{ |
u_int sx; |
const char *acs; |
|
u_int sx; |
|
|
if (tty->cell.attr & GRID_ATTR_CHARSET) |
if (tty->cell.attr & GRID_ATTR_CHARSET) { |
ch = tty_get_acs(tty, ch); |
acs = tty_acs_get(tty, ch); |
bufferevent_write(tty->event, &ch, 1); |
if (acs != NULL) |
|
bufferevent_write(tty->event, acs, strlen(acs)); |
|
else |
|
bufferevent_write(tty->event, &ch, 1); |
|
} else |
|
bufferevent_write(tty->event, &ch, 1); |
|
|
if (ch >= 0x20 && ch != 0x7f) { |
if (ch >= 0x20 && ch != 0x7f) { |
sx = tty->sx; |
sx = tty->sx; |
|
|
if (memcmp(gc, &grid_default_cell, sizeof *gc) == 0) |
if (memcmp(gc, &grid_default_cell, sizeof *gc) == 0) |
return; |
return; |
|
|
if (tty_term_has(tty->term, TTYC_RMACS) && gc->attr & GRID_ATTR_CHARSET) |
if ((gc->attr & GRID_ATTR_CHARSET) && tty_use_acs(tty)) |
tty_putcode(tty, TTYC_RMACS); |
tty_putcode(tty, TTYC_RMACS); |
tty_putcode(tty, TTYC_SGR0); |
tty_putcode(tty, TTYC_SGR0); |
memcpy(gc, &grid_default_cell, sizeof *gc); |
memcpy(gc, &grid_default_cell, sizeof *gc); |
|
|
} |
} |
if (changed & GRID_ATTR_HIDDEN) |
if (changed & GRID_ATTR_HIDDEN) |
tty_putcode(tty, TTYC_INVIS); |
tty_putcode(tty, TTYC_INVIS); |
if (changed & GRID_ATTR_CHARSET) |
if ((changed & GRID_ATTR_CHARSET) && tty_use_acs(tty)) |
tty_putcode(tty, TTYC_SMACS); |
tty_putcode(tty, TTYC_SMACS); |
} |
} |
|
|