summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-03-22 07:16:55 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-03-22 07:16:55 +0000
commit720b7d7bdbfe9d28e5a2b766d23676f83391b04a (patch)
treed5c2982064b305f711b3dbe1107db3263eea6c33
parentfe4898bcf3d15f904e784a47249de050c0167965 (diff)
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--usr.bin/tmux/attributes.c13
-rw-r--r--usr.bin/tmux/grid.c7
-rw-r--r--usr.bin/tmux/input.c8
-rw-r--r--usr.bin/tmux/style.c6
-rw-r--r--usr.bin/tmux/tmux.17
-rw-r--r--usr.bin/tmux/tmux.h10
-rw-r--r--usr.bin/tmux/tty-term.c3
-rw-r--r--usr.bin/tmux/tty.c6
8 files changed, 38 insertions, 22 deletions
diff --git a/usr.bin/tmux/attributes.c b/usr.bin/tmux/attributes.c
index 50580f00177..b51858b165a 100644
--- a/usr.bin/tmux/attributes.c
+++ b/usr.bin/tmux/attributes.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: attributes.c,v 1.6 2017/02/16 10:53:25 nicm Exp $ */
+/* $OpenBSD: attributes.c,v 1.7 2017/03/22 07:16:54 nicm Exp $ */
/*
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
@@ -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);
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c
index fa5cf2529d6..ba0a4eb2fd7 100644
--- a/usr.bin/tmux/grid.c
+++ b/usr.bin/tmux/grid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid.c,v 1.67 2017/03/07 13:47:56 nicm Exp $ */
+/* $OpenBSD: grid.c,v 1.68 2017/03/22 07:16:54 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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;
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index 6d5b40fbeb4..6b2706b4c81 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.117 2017/02/19 07:55:11 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.118 2017/03/22 07:16:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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:
diff --git a/usr.bin/tmux/style.c b/usr.bin/tmux/style.c
index 9f6d457f0d7..57828691ac8 100644
--- a/usr.bin/tmux/style.c
+++ b/usr.bin/tmux/style.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: style.c,v 1.13 2017/01/15 20:48:41 nicm Exp $ */
+/* $OpenBSD: style.c,v 1.14 2017/03/22 07:16:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 79bb02a2810..b070730f84d 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.538 2017/02/15 08:47:55 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.539 2017/03/22 07:16:54 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: February 15 2017 $
+.Dd $Mdocdate: March 22 2017 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -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.
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 713634d778d..f871e09caa4 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.732 2017/03/09 17:06:35 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.733 2017/03/22 07:16:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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 */
diff --git a/usr.bin/tmux/tty-term.c b/usr.bin/tmux/tty-term.c
index ccc07f85c8c..da7d589ac10 100644
--- a/usr.bin/tmux/tty-term.c
+++ b/usr.bin/tmux/tty-term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-term.c,v 1.52 2017/02/21 14:18:12 nicm Exp $ */
+/* $OpenBSD: tty-term.c,v 1.53 2017/03/22 07:16:54 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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" },
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index eea73ba36c3..e692c18c7b2 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.254 2017/03/15 15:22:14 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.255 2017/03/22 07:16:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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);
}