diff options
author | nicm <nicm> | 2017-03-22 07:16:54 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-03-22 07:16:54 +0000 |
commit | df3ab87964fc52c6f44b2bbe014c8bec202d0528 (patch) | |
tree | 18acb5eb18fa51e177d47eb5e0e828e0322a69ee | |
parent | 04e17a7e110bb0c70bc917b340aedd94fa60891f (diff) | |
download | rtmux-df3ab87964fc52c6f44b2bbe014c8bec202d0528.tar.gz rtmux-df3ab87964fc52c6f44b2bbe014c8bec202d0528.tar.bz2 rtmux-df3ab87964fc52c6f44b2bbe014c8bec202d0528.zip |
Add support for the strikethrough attribute (SGR 9), using the new smxx
terminfo capability. This means there are now nine attribute bits, so
anything above 0xff uses an extended cell.
-rw-r--r-- | attributes.c | 11 | ||||
-rw-r--r-- | grid.c | 5 | ||||
-rw-r--r-- | input.c | 6 | ||||
-rw-r--r-- | style.c | 4 | ||||
-rw-r--r-- | tmux.1 | 3 | ||||
-rw-r--r-- | tmux.h | 8 | ||||
-rw-r--r-- | tty-term.c | 1 | ||||
-rw-r--r-- | tty.c | 4 |
8 files changed, 29 insertions, 13 deletions
diff --git a/attributes.c b/attributes.c index 046cdcc5..1e45e584 100644 --- a/attributes.c +++ b/attributes.c @@ -23,7 +23,7 @@ #include "tmux.h" const char * -attributes_tostring(u_char attr) +attributes_tostring(int attr) { static char buf[128]; size_t len; @@ -31,14 +31,15 @@ attributes_tostring(u_char attr) if (attr == 0) return ("none"); - len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s", + len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s%s", (attr & GRID_ATTR_BRIGHT) ? "bright," : "", (attr & GRID_ATTR_DIM) ? "dim," : "", (attr & GRID_ATTR_UNDERSCORE) ? "underscore," : "", (attr & GRID_ATTR_BLINK)? "blink," : "", (attr & GRID_ATTR_REVERSE) ? "reverse," : "", (attr & GRID_ATTR_HIDDEN) ? "hidden," : "", - (attr & GRID_ATTR_ITALICS) ? "italics," : ""); + (attr & GRID_ATTR_ITALICS) ? "italics," : "", + (attr & GRID_ATTR_STRIKETHROUGH) ? "strikethrough," : ""); if (len > 0) buf[len - 1] = '\0'; @@ -49,7 +50,7 @@ int attributes_fromstring(const char *str) { const char delimiters[] = " ,|"; - u_char attr; + int attr; size_t end; if (*str == '\0' || strcspn(str, delimiters) == 0) @@ -78,6 +79,8 @@ attributes_fromstring(const char *str) attr |= GRID_ATTR_HIDDEN; else if (end == 7 && strncasecmp(str, "italics", end) == 0) attr |= GRID_ATTR_ITALICS; + else if (end == 13 && strncasecmp(str, "strikethrough", end) == 0) + attr |= GRID_ATTR_STRIKETHROUGH; else return (-1); str += end + strspn(str + end, delimiters); @@ -85,6 +85,8 @@ grid_need_extended_cell(const struct grid_cell_entry *gce, { if (gce->flags & GRID_FLAG_EXTENDED) return (1); + if (gc->attr > 0xff) + return (1); if (gc->data.size != 1 || gc->data.width != 1) return (1); if ((gc->fg & COLOUR_FLAG_RGB) ||(gc->bg & COLOUR_FLAG_RGB)) @@ -687,7 +689,8 @@ grid_string_cells_code(const struct grid_cell *lastgc, { GRID_ATTR_UNDERSCORE, 4 }, { GRID_ATTR_BLINK, 5 }, { GRID_ATTR_REVERSE, 7 }, - { GRID_ATTR_HIDDEN, 8 } + { GRID_ATTR_HIDDEN, 8 }, + { GRID_ATTR_STRIKETHROUGH, 9 } }; n = 0; @@ -1764,6 +1764,9 @@ input_csi_dispatch_sgr(struct input_ctx *ictx) case 8: gc->attr |= GRID_ATTR_HIDDEN; break; + case 9: + gc->attr |= GRID_ATTR_STRIKETHROUGH; + break; case 22: gc->attr &= ~(GRID_ATTR_BRIGHT|GRID_ATTR_DIM); break; @@ -1782,6 +1785,9 @@ input_csi_dispatch_sgr(struct input_ctx *ictx) case 28: gc->attr &= ~GRID_ATTR_HIDDEN; break; + case 29: + gc->attr &= ~GRID_ATTR_STRIKETHROUGH; + break; case 30: case 31: case 32: @@ -31,10 +31,8 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc, struct grid_cell savedgc; const char delimiters[] = " ,"; char tmp[32]; - int val; + int val, fg, bg, attr, flags; size_t end; - int fg, bg; - u_char attr, flags; if (*in == '\0') return (0); @@ -2664,8 +2664,9 @@ or a comma-delimited list of one or more of: .Ic blink , .Ic reverse , .Ic hidden , -or .Ic italics , +or +.Ic strikethrough to turn an attribute on, or an attribute prefixed with .Ql no to turn one off. @@ -395,6 +395,7 @@ enum tty_code_code { TTYC_SMKX, /* keypad_xmit, ks */ TTYC_SMSO, /* enter_standout_mode, so */ TTYC_SMUL, /* enter_underline_mode, us */ + TTYC_SMXX, TTYC_SS, /* set cursor style, Ss */ TTYC_TC, /* 24-bit "true" colour, Tc */ TTYC_TSL, /* to_status_line, tsl */ @@ -506,7 +507,7 @@ enum utf8_state { #define COLOUR_FLAG_256 0x01000000 #define COLOUR_FLAG_RGB 0x02000000 -/* Grid attributes. */ +/* Grid attributes. Anything above 0xff is stored in an extended cell. */ #define GRID_ATTR_BRIGHT 0x1 #define GRID_ATTR_DIM 0x2 #define GRID_ATTR_UNDERSCORE 0x4 @@ -515,6 +516,7 @@ enum utf8_state { #define GRID_ATTR_HIDDEN 0x20 #define GRID_ATTR_ITALICS 0x40 #define GRID_ATTR_CHARSET 0x80 /* alternative character set */ +#define GRID_ATTR_STRIKETHROUGH 0x100 /* Grid flags. */ #define GRID_FLAG_FG256 0x1 @@ -531,7 +533,7 @@ enum utf8_state { /* Grid cell data. */ struct grid_cell { u_char flags; - u_char attr; + u_short attr; int fg; int bg; struct utf8_data data; @@ -1909,7 +1911,7 @@ int colour_fromstring(const char *s); u_char colour_256to16(u_char); /* attributes.c */ -const char *attributes_tostring(u_char); +const char *attributes_tostring(int); int attributes_fromstring(const char *); /* grid.c */ @@ -249,6 +249,7 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_SMKX] = { TTYCODE_STRING, "smkx" }, [TTYC_SMSO] = { TTYCODE_STRING, "smso" }, [TTYC_SMUL] = { TTYCODE_STRING, "smul" }, + [TTYC_SMXX] = { TTYCODE_STRING, "smxx" }, [TTYC_SS] = { TTYCODE_STRING, "Ss" }, [TTYC_TC] = { TTYCODE_FLAG, "Tc" }, [TTYC_TSL] = { TTYCODE_STRING, "tsl" }, @@ -1557,7 +1557,7 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc, const struct window_pane *wp) { struct grid_cell *tc = &tty->cell, gc2; - u_char changed; + int changed; /* Ignore cell if it is the same as the last one. */ if (wp != NULL && @@ -1627,6 +1627,8 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc, } if (changed & GRID_ATTR_HIDDEN) tty_putcode(tty, TTYC_INVIS); + if (changed & GRID_ATTR_STRIKETHROUGH) + tty_putcode(tty, TTYC_SMXX); if ((changed & GRID_ATTR_CHARSET) && tty_use_acs(tty)) tty_putcode(tty, TTYC_SMACS); } |