diff options
author | nicm <nicm> | 2020-05-16 16:26:34 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-05-16 16:26:34 +0000 |
commit | e2a26740b9880d0066c8a04ca2d7202e7f99bd07 (patch) | |
tree | 25ac0b2a7174e24b1e9df539b58aa21d98f3d65d /tty.c | |
parent | ecbdcc256fd2c69c60c9d900a28922914d6b9896 (diff) | |
download | rtmux-e2a26740b9880d0066c8a04ca2d7202e7f99bd07.tar.gz rtmux-e2a26740b9880d0066c8a04ca2d7202e7f99bd07.tar.bz2 rtmux-e2a26740b9880d0066c8a04ca2d7202e7f99bd07.zip |
Add an option to set the pane border lines style from a choice of single
lines (ACS or UTF-8), double or heavy (UTF-8), simple (plain ASCII) or
number (the pane numbers). Lines that won't work on a non-UTF-8 terminal
are translated back into ACS when they are output.
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 34 |
1 files changed, 20 insertions, 14 deletions
@@ -65,8 +65,6 @@ static void tty_emulate_repeat(struct tty *, enum tty_code_code, enum tty_code_code, u_int); static void tty_repeat_space(struct tty *, u_int); static void tty_draw_pane(struct tty *, const struct tty_ctx *, u_int); -static void tty_cell(struct tty *, const struct grid_cell *, - const struct grid_cell *, int *); static void tty_default_attributes(struct tty *, const struct grid_cell *, int *, u_int); @@ -1243,7 +1241,7 @@ static const struct grid_cell * tty_check_codeset(struct tty *tty, const struct grid_cell *gc) { static struct grid_cell new; - u_int n; + int c; /* Characters less than 0x7f are always fine, no matter what. */ if (gc->data.size == 1 && *gc->data.data < 0x7f) @@ -1252,14 +1250,21 @@ tty_check_codeset(struct tty *tty, const struct grid_cell *gc) /* UTF-8 terminal and a UTF-8 character - fine. */ if (tty->client->flags & CLIENT_UTF8) return (gc); + memcpy(&new, gc, sizeof new); + + /* See if this can be mapped to an ACS character. */ + c = tty_acs_reverse_get(tty, gc->data.data, gc->data.size); + if (c != -1) { + utf8_set(&new.data, c); + new.attr |= GRID_ATTR_CHARSET; + return (&new); + } /* Replace by the right number of underscores. */ - n = gc->data.width; - if (n > UTF8_SIZE) - n = UTF8_SIZE; - memcpy(&new, gc, sizeof new); - new.data.size = n; - memset(new.data.data, '_', n); + new.data.size = gc->data.width; + if (new.data.size > UTF8_SIZE) + new.data.size = UTF8_SIZE; + memset(new.data.data, '_', new.data.size); return (&new); } @@ -1924,7 +1929,7 @@ tty_cmd_syncstart(struct tty *tty, __unused const struct tty_ctx *ctx) tty_sync_start(tty); } -static void +void tty_cell(struct tty *tty, const struct grid_cell *gc, const struct grid_cell *defaults, int *palette) { @@ -1940,12 +1945,13 @@ tty_cell(struct tty *tty, const struct grid_cell *gc, if (gc->flags & GRID_FLAG_PADDING) return; - /* Set the attributes. */ - tty_attributes(tty, gc, defaults, palette); - - /* Get the cell and if ASCII write with putc to do ACS translation. */ + /* Check the output codeset and apply attributes. */ gcp = tty_check_codeset(tty, gc); + tty_attributes(tty, gcp, defaults, palette); + + /* If it is a single character, write with putc to handle ACS. */ if (gcp->data.size == 1) { + tty_attributes(tty, gcp, defaults, palette); if (*gcp->data.data < 0x20 || *gcp->data.data == 0x7f) return; tty_putc(tty, *gcp->data.data); |