Hi Christian, 2013/07/31 Wed 4:56:39 UTC+9 Christian Brabandt wrote: > Attached is a patch to try out. It seems to work for me with GTK and > Motif Gui. I am a Unix gui and can't say for sure the code for Windows > and Mac is actually correct and works, though.
I checked your patch on Windows. It works fine. I checked it with the following process: > gvim -N foo.html :syn enable :syn region htmlStrike start="<del\>" end="</del>"me=e-6 contains=@htmlTop :hi def htmlStrike term=strikethrough cterm=strikethrough gui=strikethrough i<del>foo</del> > Secondly, I am unsure about the changes to term.c and term.h > I don't know, if these changes are actually needed, so I simply took the > undercurl code as an example and changed it so it would fit for > strikethrough. I think it is better to add term cap entries. Currently, termcap doesn't support strikethrough attributes, so we have to use our own attribute names. (E.g. 't_Ts'/'t_Te' or 't_SS'/'t_SE') I also think that a new flag (e.g. 't' or 'S') should be added in the 'highlight' option. I and Hayaki Saito updated your patch to add them. After applying this patch and setting escape sequences properly, let &t_Ts="\e[9m" let &t_Te="\e[29m" some terminals (*) will show strikethrough lines. (*) RLogin: http://nanno.dip.jp/softlib/man/rlogin/ (Japanese) pangoterm: https://launchpad.net/pangoterm/ Regards, Ken Takata -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -5881,6 +5881,7 @@ "standout" "1" if standout "underline" "1" if underlined "undercurl" "1" if undercurled + "strike" "1" if strikethrough Example (echoes the color of the syntax item under the cursor): > diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3927,6 +3927,7 @@ s standout (termcap entry "so" and "se") u underline (termcap entry "us" and "ue") c undercurl (termcap entry "Cs" and "Ce") + t strikethrough (termcap entry "Ts" and "Te") n no highlighting - no highlighting : use a highlight group diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -4457,12 +4457,14 @@ *bold* *underline* *undercurl* *inverse* *italic* *standout* + *strikethrough* term={attr-list} *attr-list* *highlight-term* *E418* attr-list is a comma separated list (without spaces) of the following items (in any order): bold underline undercurl not always available + strikethrough not always available reverse inverse same as reverse italic @@ -4472,8 +4474,8 @@ Note that "bold" can be used here and by using a bold font. They have the same effect. "undercurl" is a curly underline. When "undercurl" is not possible - then "underline" is used. In general "undercurl" is only available in - the GUI. The color is set with |highlight-guisp|. + then "underline" is used. In general "undercurl" and "strikethrough" + is only available in the GUI. The color is set with |highlight-guisp|. start={term-list} *highlight-start* *E422* stop={term-list} *term-list* *highlight-stop* @@ -4631,7 +4633,8 @@ guibg={color-name} *highlight-guibg* guisp={color-name} *highlight-guisp* These give the foreground (guifg), background (guibg) and special - (guisp) color to use in the GUI. "guisp" is used for undercurl. + (guisp) color to use in the GUI. "guisp" is used for undercurl and + strikethrough. There are a few special names: NONE no color (transparent) bg use normal background color diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -272,8 +272,6 @@ t_ts set window title start (to status line) *t_ts* *'t_ts'* t_ue underline end *t_ue* *'t_ue'* t_us underline mode *t_us* *'t_us'* - t_Ce undercurl end *t_Ce* *'t_Ce'* - t_Cs undercurl mode *t_Cs* *'t_Cs'* t_ut clearing uses the current background color *t_ut* *'t_ut'* t_vb visual bell *t_vb* *'t_vb'* t_ve cursor visible *t_ve* *'t_ve'* @@ -285,6 +283,10 @@ t_ZR italics end *t_ZR* *'t_ZR'* Added by Vim (there are no standard codes for these): + t_Ce undercurl end *t_Ce* *'t_Ce'* + t_Cs undercurl mode *t_Cs* *'t_Cs'* + t_Te strikethrough end *t_Te* *'t_Te'* + t_Ts strikethrough mode *t_Ts* *'t_Ts'* t_IS set icon text start *t_IS* *'t_IS'* t_IE set icon text end *t_IE* *'t_IE'* t_WP set window position (Y, X) in pixels *t_WP* *'t_WP'* diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -18043,6 +18043,10 @@ 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 --- a/src/gui.c +++ b/src/gui.c @@ -2382,6 +2382,7 @@ /* 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) @@ -2395,6 +2396,10 @@ 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 --- 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 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -4883,6 +4883,15 @@ FILL_X(col), y, FILL_X(col + cells) - 1, y); } + + /* Draw a strikethrough line */ + if (flags & DRAW_STRIKE) + { + 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); + } } int diff --git a/src/gui_mac.c b/src/gui_mac.c --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -4043,6 +4043,11 @@ 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 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -2670,6 +2670,18 @@ 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 --- a/src/gui_x11.c +++ b/src/gui_x11.c @@ -2676,6 +2676,16 @@ 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 --- a/src/option.c +++ b/src/option.c @@ -2980,6 +2980,8 @@ p_term("t_se", T_SE) p_term("t_so", T_SO) p_term("t_sr", T_SR) + p_term("t_Te", T_STE) + p_term("t_Ts", T_STS) p_term("t_ts", T_TS) p_term("t_te", T_TE) p_term("t_ti", T_TI) diff --git a/src/screen.c b/src/screen.c --- a/src/screen.c +++ b/src/screen.c @@ -225,7 +225,7 @@ 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; } /* @@ -7557,6 +7557,8 @@ 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 @@ -7660,6 +7662,13 @@ 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 --- a/src/syntax.c +++ b/src/syntax.c @@ -82,10 +82,10 @@ * following names, separated by commas (but no spaces!). */ static char *(hl_name_table[]) = - {"bold", "standout", "underline", "undercurl", + {"bold", "standout", "underline", "undercurl", "strikethrough", "italic", "reverse", "inverse", "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_STRIKETHROUGH, HL_ITALIC, HL_INVERSE, HL_INVERSE, 0}; static int get_attr_entry __ARGS((garray_T *table, attrentry_T *aep)); static void syn_unadd_group __ARGS((void)); @@ -9534,6 +9534,8 @@ 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 --- a/src/term.c +++ b/src/term.c @@ -195,6 +195,8 @@ {(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")}, @@ -1205,6 +1207,8 @@ {(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]"}, # ifdef TERMINFO @@ -1601,6 +1605,7 @@ {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 --- a/src/term.h +++ b/src/term.h @@ -51,6 +51,8 @@ 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) */ @@ -129,6 +131,8 @@ #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/vim.h b/src/vim.h --- a/src/vim.h +++ b/src/vim.h @@ -677,7 +677,8 @@ #define HL_UNDERLINE 0x08 #define HL_UNDERCURL 0x10 #define HL_STANDOUT 0x20 -#define HL_ALL 0x3f +#define HL_STRIKETHROUGH 0x40 +#define HL_ALL 0x7f /* special attribute addition: Put message in history */ #define MSG_HIST 0x1000