summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-09-02 18:33:56 +0200
committerBram Moolenaar <Bram@vim.org>2017-09-02 18:33:56 +0200
commitcf4b00c856ef714482d8d060332ac9a4d74e6b88 (patch)
treea17efb73ba6cffbdc8c17adbec2152ac41c35803 /src
parentda22b8cc8b1b96fabd5a4c35c57b04a351340fb1 (diff)
patch 8.0.1038: strike-through text not supportedv8.0.1038
Problem: Strike-through text not supported. Solution: Add support for the "strikethrough" attribute. (Christian Brabandt, Ken Takata)
Diffstat (limited to 'src')
-rw-r--r--src/evalfunc.c4
-rw-r--r--src/gui.c5
-rw-r--r--src/gui.h1
-rw-r--r--src/gui_gtk_x11.c39
-rw-r--r--src/gui_mac.c5
-rw-r--r--src/gui_w32.c12
-rw-r--r--src/gui_x11.c10
-rw-r--r--src/option.c2
-rw-r--r--src/screen.c11
-rw-r--r--src/syntax.c6
-rw-r--r--src/term.c7
-rw-r--r--src/term.h4
-rw-r--r--src/terminal.c4
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h3
15 files changed, 99 insertions, 16 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index d11d96db94..1cdb6b682a 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -11843,6 +11843,10 @@ f_synIDattr(typval_T *argvars UNUSED, typval_T *rettv)
case 's':
if (TOLOWER_ASC(what[1]) == 'p') /* sp[#] */
p = highlight_color(id, what, modec);
+ /* strikeout */
+ else if (TOLOWER_ASC(what[1]) == 't' &&
+ TOLOWER_ASC(what[2]) == 'r')
+ p = highlight_has_attr(id, HL_STRIKETHROUGH, modec);
else /* standout */
p = highlight_has_attr(id, HL_STANDOUT, modec);
break;
diff --git a/src/gui.c b/src/gui.c
index f774750f2b..97fac50432 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -2396,6 +2396,7 @@ gui_outstr_nowrap(
/* Do we underline the text? */
if (hl_mask_todo & HL_UNDERLINE)
draw_flags |= DRAW_UNDERL;
+
#else
/* Do we underline the text? */
if ((hl_mask_todo & HL_UNDERLINE) || (hl_mask_todo & HL_ITALIC))
@@ -2405,6 +2406,10 @@ gui_outstr_nowrap(
if (hl_mask_todo & HL_UNDERCURL)
draw_flags |= DRAW_UNDERC;
+ /* Do we strikethrough the text? */
+ if (hl_mask_todo & HL_STRIKETHROUGH)
+ draw_flags |= DRAW_STRIKE;
+
/* Do we draw transparently? */
if (flags & GUI_MON_TRS_CURSOR)
draw_flags |= DRAW_TRANSP;
diff --git a/src/gui.h b/src/gui.h
index 476971624c..37cc239926 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -142,6 +142,7 @@
# define DRAW_ITALIC 0x10 /* draw italic text */
#endif
#define DRAW_CURSOR 0x20 /* drawing block cursor (win32) */
+#define DRAW_STRIKE 0x40 /* strikethrough */
/* For our own tearoff menu item */
#define TEAR_STRING "-->Detach"
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 3d4ac93ae4..361f16c659 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -5908,6 +5908,27 @@ draw_under(int flags, int row, int col, int cells)
#endif
}
+ /* Draw a strikethrough line */
+ if (flags & DRAW_STRIKE)
+ {
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_set_line_width(cr, 1.0);
+ cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
+ cairo_set_source_rgba(cr,
+ gui.spcolor->red, gui.spcolor->green, gui.spcolor->blue,
+ gui.spcolor->alpha);
+ cairo_move_to(cr, FILL_X(col), y + 1 - gui.char_height/2 + 0.5);
+ cairo_line_to(cr, FILL_X(col + cells), y + 1 - gui.char_height/2 + 0.5);
+ cairo_stroke(cr);
+#else
+ gdk_gc_set_foreground(gui.text_gc, gui.spcolor);
+ gdk_draw_line(gui.drawarea->window, gui.text_gc,
+ FILL_X(col), y + 1 - gui.char_height/2,
+ FILL_X(col + cells), y + 1 - gui.char_height/2);
+ gdk_gc_set_foreground(gui.text_gc, gui.fgcolor);
+#endif
+ }
+
/* Underline: draw a line at the bottom of the character cell. */
if (flags & DRAW_UNDERL)
{
@@ -5916,16 +5937,14 @@ draw_under(int flags, int row, int col, int cells)
if (p_linespace > 1)
y -= p_linespace - 1;
#if GTK_CHECK_VERSION(3,0,0)
- {
- cairo_set_line_width(cr, 1.0);
- cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
- cairo_set_source_rgba(cr,
- gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue,
- gui.fgcolor->alpha);
- cairo_move_to(cr, FILL_X(col), y + 0.5);
- cairo_line_to(cr, FILL_X(col + cells), y + 0.5);
- cairo_stroke(cr);
- }
+ cairo_set_line_width(cr, 1.0);
+ cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
+ cairo_set_source_rgba(cr,
+ gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue,
+ gui.fgcolor->alpha);
+ cairo_move_to(cr, FILL_X(col), y + 0.5);
+ cairo_line_to(cr, FILL_X(col + cells), y + 0.5);
+ cairo_stroke(cr);
#else
gdk_draw_line(gui.drawarea->window, gui.text_gc,
FILL_X(col), y,
diff --git a/src/gui_mac.c b/src/gui_mac.c
index dea648ac88..8803487dea 100644
--- a/src/gui_mac.c
+++ b/src/gui_mac.c
@@ -3899,6 +3899,11 @@ draw_string_QD(int row, int col, char_u *s, int len, int flags)
MoveTo(FILL_X(col), FILL_Y(row + 1) - 1);
LineTo(FILL_X(col + len) - 1, FILL_Y(row + 1) - 1);
}
+ if (flags & DRAW_STRIKE)
+ {
+ MoveTo(FILL_X(col), FILL_Y(row + 1) - gui.char_height/2);
+ LineTo(FILL_X(col + len) - 1, FILL_Y(row + 1) - gui.char_height/2);
+ }
}
if (flags & DRAW_UNDERC)
diff --git a/src/gui_w32.c b/src/gui_w32.c
index e94379ba7c..c4a57e675a 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -6427,6 +6427,18 @@ gui_mch_draw_string(
DeleteObject(SelectObject(s_hdc, old_pen));
}
+ /* Strikethrough */
+ if (flags & DRAW_STRIKE)
+ {
+ hpen = CreatePen(PS_SOLID, 1, gui.currSpColor);
+ old_pen = SelectObject(s_hdc, hpen);
+ y = FILL_Y(row + 1) - gui.char_height/2;
+ MoveToEx(s_hdc, FILL_X(col), y, NULL);
+ /* Note: LineTo() excludes the last pixel in the line. */
+ LineTo(s_hdc, FILL_X(col + len), y);
+ DeleteObject(SelectObject(s_hdc, old_pen));
+ }
+
/* Undercurl */
if (flags & DRAW_UNDERC)
{
diff --git a/src/gui_x11.c b/src/gui_x11.c
index a638222251..1e790a81c4 100644
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -2542,6 +2542,16 @@ gui_mch_draw_string(
y, FILL_X(col + cells) - 1, y);
}
+ if (flags & DRAW_STRIKE)
+ {
+ int y = FILL_Y(row + 1) - gui.char_height/2;
+
+ XSetForeground(gui.dpy, gui.text_gc, prev_sp_color);
+ XDrawLine(gui.dpy, gui.wid, gui.text_gc, FILL_X(col),
+ y, FILL_X(col + cells) - 1, y);
+ XSetForeground(gui.dpy, gui.text_gc, prev_fg_color);
+ }
+
#ifdef FEAT_XFONTSET
if (current_fontset != NULL)
XSetClipMask(gui.dpy, gui.text_gc, None);
diff --git a/src/option.c b/src/option.c
index 5f8489fdd4..a1304c9447 100644
--- a/src/option.c
+++ b/src/option.c
@@ -3216,8 +3216,10 @@ static struct vimoption options[] =
p_term("t_so", T_SO)
p_term("t_SR", T_CSR)
p_term("t_sr", T_SR)
+ p_term("t_Te", T_STE)
p_term("t_te", T_TE)
p_term("t_ti", T_TI)
+ p_term("t_Ts", T_STS)
p_term("t_ts", T_TS)
p_term("t_u7", T_U7)
p_term("t_ue", T_UE)
diff --git a/src/screen.c b/src/screen.c
index c3bcd3b446..ca7b658360 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -235,7 +235,7 @@ redraw_later_clear(void)
else
#endif
/* Use attributes that is very unlikely to appear in text. */
- screen_attr = HL_BOLD | HL_UNDERLINE | HL_INVERSE;
+ screen_attr = HL_BOLD | HL_UNDERLINE | HL_INVERSE | HL_STRIKETHROUGH;
}
/*
@@ -8086,6 +8086,8 @@ screen_start_highlight(int attr)
out_str(T_CZH);
if ((attr & HL_INVERSE) && T_MR != NULL) /* inverse (reverse) */
out_str(T_MR);
+ if ((attr & HL_STRIKETHROUGH) && T_STS != NULL) /* strike */
+ out_str(T_STS);
/*
* Output the color or start string after bold etc., in case the
@@ -8210,6 +8212,13 @@ screen_stop_highlight(void)
else
out_str(T_CZR);
}
+ if (screen_attr & HL_STRIKETHROUGH)
+ {
+ if (STRCMP(T_STE, T_ME) == 0)
+ do_ME = TRUE;
+ else
+ out_str(T_STE);
+ }
if (do_ME || (screen_attr & (HL_BOLD | HL_INVERSE)))
out_str(T_ME);
diff --git a/src/syntax.c b/src/syntax.c
index 7303575202..00e292932d 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -86,9 +86,9 @@ static int include_link = 0; /* when 2 include "link" and "clear" */
*/
static char *(hl_name_table[]) =
{"bold", "standout", "underline", "undercurl",
- "italic", "reverse", "inverse", "nocombine", "NONE"};
+ "italic", "reverse", "inverse", "nocombine", "strikethrough", "NONE"};
static int hl_attr_table[] =
- {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_NOCOMBINE, 0};
+ {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_NOCOMBINE, HL_STRIKETHROUGH, 0};
#define ATTR_COMBINE(attr_a, attr_b) ((((attr_b) & HL_NOCOMBINE) ? attr_b : (attr_a)) | (attr_b))
static int get_attr_entry(garray_T *table, attrentry_T *aep);
@@ -9951,6 +9951,8 @@ highlight_changed(void)
break;
case 'c': attr |= HL_UNDERCURL;
break;
+ case 't': attr |= HL_STRIKETHROUGH;
+ break;
case ':': ++p; /* highlight group name */
if (attr || *p == NUL) /* no combinations */
return FAIL;
diff --git a/src/term.c b/src/term.c
index 7460be9772..413d4bb88d 100644
--- a/src/term.c
+++ b/src/term.c
@@ -217,6 +217,8 @@ static struct builtin_term builtin_termcaps[] =
{(int)KS_US, IF_EB("\033|8h", ESC_STR "|8h")}, /* HL_UNDERLINE */
{(int)KS_UCE, IF_EB("\033|8C", ESC_STR "|8C")}, /* HL_UNDERCURL */
{(int)KS_UCS, IF_EB("\033|8c", ESC_STR "|8c")}, /* HL_UNDERCURL */
+ {(int)KS_STE, IF_EB("\033|4C", ESC_STR "|4C")}, /* HL_STRIKETHROUGH */
+ {(int)KS_STS, IF_EB("\033|4c", ESC_STR "|4c")}, /* HL_STRIKETHROUGH */
{(int)KS_CZR, IF_EB("\033|4H", ESC_STR "|4H")}, /* HL_ITALIC */
{(int)KS_CZH, IF_EB("\033|4h", ESC_STR "|4h")}, /* HL_ITALIC */
{(int)KS_VB, IF_EB("\033|f", ESC_STR "|f")},
@@ -831,6 +833,8 @@ static struct builtin_term builtin_termcaps[] =
{(int)KS_MD, IF_EB("\033[1m", ESC_STR "[1m")},
{(int)KS_UE, IF_EB("\033[m", ESC_STR "[m")},
{(int)KS_US, IF_EB("\033[4m", ESC_STR "[4m")},
+ {(int)KS_STE, IF_EB("\033[29m", ESC_STR "[29m")},
+ {(int)KS_STS, IF_EB("\033[9m", ESC_STR "[9m")},
{(int)KS_MS, "y"},
{(int)KS_UT, "y"},
{(int)KS_LE, "\b"},
@@ -1151,6 +1155,8 @@ static struct builtin_term builtin_termcaps[] =
{(int)KS_US, "[US]"},
{(int)KS_UCE, "[UCE]"},
{(int)KS_UCS, "[UCS]"},
+ {(int)KS_STE, "[STE]"},
+ {(int)KS_STS, "[STS]"},
{(int)KS_MS, "[MS]"},
{(int)KS_UT, "[UT]"},
{(int)KS_XN, "[XN]"},
@@ -1595,6 +1601,7 @@ set_termname(char_u *term)
{KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"},
{KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"},
{KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"},
+ {KS_STE,"Te"}, {KS_STS,"Ts"},
{KS_CM, "cm"}, {KS_SR, "sr"},
{KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"},
{KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"},
diff --git a/src/term.h b/src/term.h
index 0fedfeaa85..b95b4f6de8 100644
--- a/src/term.h
+++ b/src/term.h
@@ -55,6 +55,8 @@ enum SpecialKey
KS_US, /* underscore (underline) mode */
KS_UCE, /* exit undercurl mode */
KS_UCS, /* undercurl mode */
+ KS_STE, /* exit strikethrough mode */
+ KS_STS, /* strikethrough mode */
KS_MS, /* save to move cur in reverse mode */
KS_CM, /* cursor motion */
KS_SR, /* scroll reverse (backward) */
@@ -149,6 +151,8 @@ extern char_u *(term_strings[]); /* current terminal strings */
#define T_US (TERM_STR(KS_US)) /* underscore (underline) mode */
#define T_UCE (TERM_STR(KS_UCE)) /* exit undercurl mode */
#define T_UCS (TERM_STR(KS_UCS)) /* undercurl mode */
+#define T_STE (TERM_STR(KS_STE)) /* exit strikethrough mode */
+#define T_STS (TERM_STR(KS_STS)) /* strikethrough mode */
#define T_MS (TERM_STR(KS_MS)) /* save to move cur in reverse mode */
#define T_CM (TERM_STR(KS_CM)) /* cursor motion */
#define T_SR (TERM_STR(KS_SR)) /* scroll reverse (backward) */
diff --git a/src/terminal.c b/src/terminal.c
index faa74f7f47..05c0fd9169 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1735,7 +1735,7 @@ cell2attr(VTermScreenCellAttrs cellattrs, VTermColor cellfg, VTermColor cellbg)
if (cellattrs.italic)
attr |= HL_ITALIC;
if (cellattrs.strike)
- attr |= HL_STANDOUT;
+ attr |= HL_STRIKETHROUGH;
if (cellattrs.reverse)
attr |= HL_INVERSE;
@@ -2451,7 +2451,7 @@ f_term_getattr(typval_T *argvars, typval_T *rettv)
{"bold", HL_BOLD},
{"italic", HL_ITALIC},
{"underline", HL_UNDERLINE},
- {"strike", HL_STANDOUT},
+ {"strike", HL_STRIKETHROUGH},
{"reverse", HL_INVERSE},
};
diff --git a/src/version.c b/src/version.c
index 8af46882e4..e8e508f8a6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1038,
+/**/
1037,
/**/
1036,
diff --git a/src/vim.h b/src/vim.h
index 7fea70b90e..77081e202a 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -681,7 +681,8 @@ extern int (*dyn_libintl_putenv)(const char *envstring);
#define HL_UNDERCURL 0x10
#define HL_STANDOUT 0x20
#define HL_NOCOMBINE 0x40
-#define HL_ALL 0x7f
+#define HL_STRIKETHROUGH 0x80
+#define HL_ALL 0xff
/* special attribute addition: Put message in history */
#define MSG_HIST 0x1000