aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaskaran Singh <jaskaransingh7654321@gmail.com>2019-09-14 03:16:19 +0530
committerJustin M. Keyes <justinkz@gmail.com>2019-09-13 14:46:19 -0700
commit3afb397407af3c94fc82d694186e8d451e625237 (patch)
tree6178036f4d81fd706eff8926f96876eb195faeb4 /src
parent35341b34b835eeb184ac9f0e2078ce31f6612fd7 (diff)
downloadrneovim-3afb397407af3c94fc82d694186e8d451e625237.tar.gz
rneovim-3afb397407af3c94fc82d694186e8d451e625237.tar.bz2
rneovim-3afb397407af3c94fc82d694186e8d451e625237.zip
syntax, TUI: support "strikethrough"
fix #3436 Includes: vim-patch:8.0.1038: strike-through text not supported
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c3
-rw-r--r--src/nvim/highlight.c4
-rw-r--r--src/nvim/highlight_defs.h13
-rw-r--r--src/nvim/syntax.c8
-rw-r--r--src/nvim/terminal.c3
-rw-r--r--src/nvim/tui/tui.c16
6 files changed, 34 insertions, 13 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index f9d346ea68..fbfc5a5f76 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -17584,6 +17584,9 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
case 's': {
if (TOLOWER_ASC(what[1]) == 'p') { // sp[#]
p = highlight_color(id, what, modec);
+ } else if (TOLOWER_ASC(what[1]) == 't'
+ && TOLOWER_ASC(what[2]) == 'r') { // strikethrough
+ p = highlight_has_attr(id, HL_STRIKETHROUGH, modec);
} else { // standout
p = highlight_has_attr(id, HL_STANDOUT, modec);
}
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index f44cd5cdab..093cc4923b 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -598,6 +598,10 @@ Dictionary hlattrs2dict(HlAttrs ae, bool use_rgb)
PUT(hl, "reverse", BOOLEAN_OBJ(true));
}
+ if (mask & HL_STRIKETHROUGH) {
+ PUT(hl, "strikethrough", BOOLEAN_OBJ(true));
+ }
+
if (use_rgb) {
if (ae.rgb_fg_color != -1) {
PUT(hl, "foreground", INTEGER_OBJ(ae.rgb_fg_color));
diff --git a/src/nvim/highlight_defs.h b/src/nvim/highlight_defs.h
index 512d87fa34..f9c2c03fc6 100644
--- a/src/nvim/highlight_defs.h
+++ b/src/nvim/highlight_defs.h
@@ -11,12 +11,13 @@ typedef int32_t RgbValue;
///
/// sign bit should not be used here, as it identifies invalid highlight
typedef enum {
- HL_INVERSE = 0x01,
- HL_BOLD = 0x02,
- HL_ITALIC = 0x04,
- HL_UNDERLINE = 0x08,
- HL_UNDERCURL = 0x10,
- HL_STANDOUT = 0x20,
+ HL_INVERSE = 0x01,
+ HL_BOLD = 0x02,
+ HL_ITALIC = 0x04,
+ HL_UNDERLINE = 0x08,
+ HL_UNDERCURL = 0x10,
+ HL_STANDOUT = 0x20,
+ HL_STRIKETHROUGH = 0x40,
} HlAttrFlags;
/// Stores a complete highlighting entry, including colors and attributes
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 613c9e6d63..c811fae916 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -115,11 +115,11 @@ static int include_link = 0; /* when 2 include "nvim/link" and "clear" */
/// The "term", "cterm" and "gui" arguments can be any combination of the
/// following names, separated by commas (but no spaces!).
static char *(hl_name_table[]) =
-{"bold", "standout", "underline", "undercurl",
- "italic", "reverse", "inverse", "NONE"};
+{ "bold", "standout", "underline", "undercurl",
+ "italic", "reverse", "inverse", "strikethrough", "NONE" };
static int hl_attr_table[] =
-{HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE,
- HL_INVERSE, 0};
+{ HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE,
+ HL_INVERSE, HL_STRIKETHROUGH, 0 };
// The patterns that are being searched for are stored in a syn_pattern.
// A match item consists of one pattern.
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index dfee11c468..b1ce0e6592 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -605,7 +605,8 @@ void terminal_get_line_attributes(Terminal *term, win_T *wp, int linenr,
int hl_attrs = (cell.attrs.bold ? HL_BOLD : 0)
| (cell.attrs.italic ? HL_ITALIC : 0)
| (cell.attrs.reverse ? HL_INVERSE : 0)
- | (cell.attrs.underline ? HL_UNDERLINE : 0);
+ | (cell.attrs.underline ? HL_UNDERLINE : 0)
+ | (cell.attrs.strike ? HL_STRIKETHROUGH: 0);
int attr_id = 0;
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 6e1b7ef2db..791756e5c5 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -115,6 +115,7 @@ typedef struct {
int enable_mouse, disable_mouse;
int enable_bracketed_paste, disable_bracketed_paste;
int enable_lr_margin, disable_lr_margin;
+ int enter_strikethrough_mode;
int set_rgb_foreground, set_rgb_background;
int set_cursor_color;
int reset_cursor_color;
@@ -208,6 +209,7 @@ static void terminfo_start(UI *ui)
data->unibi_ext.reset_cursor_color = -1;
data->unibi_ext.enable_bracketed_paste = -1;
data->unibi_ext.disable_bracketed_paste = -1;
+ data->unibi_ext.enter_strikethrough_mode = -1;
data->unibi_ext.enable_lr_margin = -1;
data->unibi_ext.disable_lr_margin = -1;
data->unibi_ext.enable_focus_reporting = -1;
@@ -529,6 +531,7 @@ static void update_attrs(UI *ui, int attr_id)
bool italic = attr & HL_ITALIC;
bool reverse = attr & HL_INVERSE;
bool standout = attr & HL_STANDOUT;
+ bool strikethrough = attr & HL_STRIKETHROUGH;
bool underline;
bool undercurl;
@@ -575,6 +578,9 @@ static void update_attrs(UI *ui, int attr_id)
if (italic) {
unibi_out(ui, unibi_enter_italics_mode);
}
+ if (strikethrough && data->unibi_ext.enter_strikethrough_mode != -1) {
+ unibi_out_ext(ui, data->unibi_ext.enter_strikethrough_mode);
+ }
if (undercurl && data->unibi_ext.set_underline_style != -1) {
UNIBI_SET_NUM_VAR(data->params[0], 3);
unibi_out_ext(ui, data->unibi_ext.set_underline_style);
@@ -615,13 +621,14 @@ static void update_attrs(UI *ui, int attr_id)
}
data->default_attr = fg == -1 && bg == -1
- && !bold && !italic && !underline && !undercurl && !reverse && !standout;
+ && !bold && !italic && !underline && !undercurl && !reverse && !standout
+ && !strikethrough;
// Non-BCE terminals can't clear with non-default background color. Some BCE
// terminals don't support attributes either, so don't rely on it. But assume
// italic and bold has no effect if there is no text.
data->can_clear_attr = !reverse && !standout && !underline && !undercurl
- && (data->bce || bg == -1);
+ && !strikethrough && (data->bce || bg == -1);
}
static void final_column_wrap(UI *ui)
@@ -1826,6 +1833,11 @@ static void augment_terminfo(TUIData *data, const char *term,
"\x1b[r");
}
+ // terminfo describes strikethrough modes as rmxx/smxx with respect
+ // to the ECMA-48 strikeout/crossed-out attributes.
+ data->unibi_ext.enter_strikethrough_mode = (int)unibi_find_ext_str(
+ ut, "smxx");
+
// Dickey ncurses terminfo does not include the setrgbf and setrgbb
// capabilities, proposed by RĂ¼diger Sonderfeld on 2013-10-15. Adding
// them here when terminfo lacks them is an augmentation, not a fixup.