Skip to content

Commit cf4b00c

Browse files
committed
patch 8.0.1038: strike-through text not supported
Problem: Strike-through text not supported. Solution: Add support for the "strikethrough" attribute. (Christian Brabandt, Ken Takata)
1 parent da22b8c commit cf4b00c

18 files changed

Lines changed: 107 additions & 20 deletions

runtime/doc/eval.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7723,6 +7723,7 @@ synIDattr({synID}, {what} [, {mode}]) *synIDattr()*
77237723
"standout" "1" if standout
77247724
"underline" "1" if underlined
77257725
"undercurl" "1" if undercurled
7726+
"strike" "1" if strikethrough
77267727

77277728
Example (echoes the color of the syntax item under the
77287729
cursor): >

runtime/doc/options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,6 +4105,7 @@ A jump table for the options with a short description can be found at |Q_op|.
41054105
s standout (termcap entry "so" and "se")
41064106
u underline (termcap entry "us" and "ue")
41074107
c undercurl (termcap entry "Cs" and "Ce")
4108+
t strikethrough (termcap entry "Ts" and "Te")
41084109
n no highlighting
41094110
- no highlighting
41104111
: use a highlight group

runtime/doc/syntax.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4699,13 +4699,14 @@ the same syntax file on all terminals, and use the optimal highlighting.
46994699

47004700
*bold* *underline* *undercurl*
47014701
*inverse* *italic* *standout*
4702-
*nocombine*
4702+
*nocombine* *strikethrough*
47034703
term={attr-list} *attr-list* *highlight-term* *E418*
47044704
attr-list is a comma separated list (without spaces) of the
47054705
following items (in any order):
47064706
bold
47074707
underline
47084708
undercurl not always available
4709+
strikethrough not always available
47094710
reverse
47104711
inverse same as reverse
47114712
italic
@@ -4716,8 +4717,8 @@ term={attr-list} *attr-list* *highlight-term* *E418*
47164717
Note that "bold" can be used here and by using a bold font. They
47174718
have the same effect.
47184719
"undercurl" is a curly underline. When "undercurl" is not possible
4719-
then "underline" is used. In general "undercurl" is only available in
4720-
the GUI. The color is set with |highlight-guisp|.
4720+
then "underline" is used. In general "undercurl" and "strikethrough"
4721+
is only available in the GUI. The color is set with |highlight-guisp|.
47214722

47224723
start={term-list} *highlight-start* *E422*
47234724
stop={term-list} *term-list* *highlight-stop*
@@ -4882,7 +4883,8 @@ guifg={color-name} *highlight-guifg*
48824883
guibg={color-name} *highlight-guibg*
48834884
guisp={color-name} *highlight-guisp*
48844885
These give the foreground (guifg), background (guibg) and special
4885-
(guisp) color to use in the GUI. "guisp" is used for undercurl.
4886+
(guisp) color to use in the GUI. "guisp" is used for undercurl and
4887+
strikethrough.
48864888
There are a few special names:
48874889
NONE no color (transparent)
48884890
bg use normal background color

src/evalfunc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11843,6 +11843,10 @@ f_synIDattr(typval_T *argvars UNUSED, typval_T *rettv)
1184311843
case 's':
1184411844
if (TOLOWER_ASC(what[1]) == 'p') /* sp[#] */
1184511845
p = highlight_color(id, what, modec);
11846+
/* strikeout */
11847+
else if (TOLOWER_ASC(what[1]) == 't' &&
11848+
TOLOWER_ASC(what[2]) == 'r')
11849+
p = highlight_has_attr(id, HL_STRIKETHROUGH, modec);
1184611850
else /* standout */
1184711851
p = highlight_has_attr(id, HL_STANDOUT, modec);
1184811852
break;

src/gui.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,6 +2396,7 @@ gui_outstr_nowrap(
23962396
/* Do we underline the text? */
23972397
if (hl_mask_todo & HL_UNDERLINE)
23982398
draw_flags |= DRAW_UNDERL;
2399+
23992400
#else
24002401
/* Do we underline the text? */
24012402
if ((hl_mask_todo & HL_UNDERLINE) || (hl_mask_todo & HL_ITALIC))
@@ -2405,6 +2406,10 @@ gui_outstr_nowrap(
24052406
if (hl_mask_todo & HL_UNDERCURL)
24062407
draw_flags |= DRAW_UNDERC;
24072408

2409+
/* Do we strikethrough the text? */
2410+
if (hl_mask_todo & HL_STRIKETHROUGH)
2411+
draw_flags |= DRAW_STRIKE;
2412+
24082413
/* Do we draw transparently? */
24092414
if (flags & GUI_MON_TRS_CURSOR)
24102415
draw_flags |= DRAW_TRANSP;

src/gui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
# define DRAW_ITALIC 0x10 /* draw italic text */
143143
#endif
144144
#define DRAW_CURSOR 0x20 /* drawing block cursor (win32) */
145+
#define DRAW_STRIKE 0x40 /* strikethrough */
145146

146147
/* For our own tearoff menu item */
147148
#define TEAR_STRING "-->Detach"

src/gui_gtk_x11.c

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5908,6 +5908,27 @@ draw_under(int flags, int row, int col, int cells)
59085908
#endif
59095909
}
59105910

5911+
/* Draw a strikethrough line */
5912+
if (flags & DRAW_STRIKE)
5913+
{
5914+
#if GTK_CHECK_VERSION(3,0,0)
5915+
cairo_set_line_width(cr, 1.0);
5916+
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
5917+
cairo_set_source_rgba(cr,
5918+
gui.spcolor->red, gui.spcolor->green, gui.spcolor->blue,
5919+
gui.spcolor->alpha);
5920+
cairo_move_to(cr, FILL_X(col), y + 1 - gui.char_height/2 + 0.5);
5921+
cairo_line_to(cr, FILL_X(col + cells), y + 1 - gui.char_height/2 + 0.5);
5922+
cairo_stroke(cr);
5923+
#else
5924+
gdk_gc_set_foreground(gui.text_gc, gui.spcolor);
5925+
gdk_draw_line(gui.drawarea->window, gui.text_gc,
5926+
FILL_X(col), y + 1 - gui.char_height/2,
5927+
FILL_X(col + cells), y + 1 - gui.char_height/2);
5928+
gdk_gc_set_foreground(gui.text_gc, gui.fgcolor);
5929+
#endif
5930+
}
5931+
59115932
/* Underline: draw a line at the bottom of the character cell. */
59125933
if (flags & DRAW_UNDERL)
59135934
{
@@ -5916,16 +5937,14 @@ draw_under(int flags, int row, int col, int cells)
59165937
if (p_linespace > 1)
59175938
y -= p_linespace - 1;
59185939
#if GTK_CHECK_VERSION(3,0,0)
5919-
{
5920-
cairo_set_line_width(cr, 1.0);
5921-
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
5922-
cairo_set_source_rgba(cr,
5923-
gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue,
5924-
gui.fgcolor->alpha);
5925-
cairo_move_to(cr, FILL_X(col), y + 0.5);
5926-
cairo_line_to(cr, FILL_X(col + cells), y + 0.5);
5927-
cairo_stroke(cr);
5928-
}
5940+
cairo_set_line_width(cr, 1.0);
5941+
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
5942+
cairo_set_source_rgba(cr,
5943+
gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue,
5944+
gui.fgcolor->alpha);
5945+
cairo_move_to(cr, FILL_X(col), y + 0.5);
5946+
cairo_line_to(cr, FILL_X(col + cells), y + 0.5);
5947+
cairo_stroke(cr);
59295948
#else
59305949
gdk_draw_line(gui.drawarea->window, gui.text_gc,
59315950
FILL_X(col), y,

src/gui_mac.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3899,6 +3899,11 @@ draw_string_QD(int row, int col, char_u *s, int len, int flags)
38993899
MoveTo(FILL_X(col), FILL_Y(row + 1) - 1);
39003900
LineTo(FILL_X(col + len) - 1, FILL_Y(row + 1) - 1);
39013901
}
3902+
if (flags & DRAW_STRIKE)
3903+
{
3904+
MoveTo(FILL_X(col), FILL_Y(row + 1) - gui.char_height/2);
3905+
LineTo(FILL_X(col + len) - 1, FILL_Y(row + 1) - gui.char_height/2);
3906+
}
39023907
}
39033908

39043909
if (flags & DRAW_UNDERC)

src/gui_w32.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6427,6 +6427,18 @@ gui_mch_draw_string(
64276427
DeleteObject(SelectObject(s_hdc, old_pen));
64286428
}
64296429

6430+
/* Strikethrough */
6431+
if (flags & DRAW_STRIKE)
6432+
{
6433+
hpen = CreatePen(PS_SOLID, 1, gui.currSpColor);
6434+
old_pen = SelectObject(s_hdc, hpen);
6435+
y = FILL_Y(row + 1) - gui.char_height/2;
6436+
MoveToEx(s_hdc, FILL_X(col), y, NULL);
6437+
/* Note: LineTo() excludes the last pixel in the line. */
6438+
LineTo(s_hdc, FILL_X(col + len), y);
6439+
DeleteObject(SelectObject(s_hdc, old_pen));
6440+
}
6441+
64306442
/* Undercurl */
64316443
if (flags & DRAW_UNDERC)
64326444
{

src/gui_x11.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,6 +2542,16 @@ gui_mch_draw_string(
25422542
y, FILL_X(col + cells) - 1, y);
25432543
}
25442544

2545+
if (flags & DRAW_STRIKE)
2546+
{
2547+
int y = FILL_Y(row + 1) - gui.char_height/2;
2548+
2549+
XSetForeground(gui.dpy, gui.text_gc, prev_sp_color);
2550+
XDrawLine(gui.dpy, gui.wid, gui.text_gc, FILL_X(col),
2551+
y, FILL_X(col + cells) - 1, y);
2552+
XSetForeground(gui.dpy, gui.text_gc, prev_fg_color);
2553+
}
2554+
25452555
#ifdef FEAT_XFONTSET
25462556
if (current_fontset != NULL)
25472557
XSetClipMask(gui.dpy, gui.text_gc, None);

0 commit comments

Comments
 (0)