Re: strikethrough text in gvim

524 views
Skip to first unread message

Christian Brabandt

unread,
Jul 30, 2013, 3:56:39 PM7/30/13
to vim...@googlegroups.com, vim-dev Mailingliste
On Mi, 24 Jul 2013, Jeroen Budts wrote:

> I have a feature request for gvim, I'm not sure if I should ask it
> here or on the dev list?
> Would it be possible to add support for strikethrough text in Gvim?
> Since gvim can already display bold, italic, underline and undercurl
> text I guess it can't be too difficult to add this to gvim?
>
> Strikethrough text would be useful in multiple occasions imho. For
> example in Vimwiki you can add ~~some text~~ which will be rendered
> to html as strikethrough, so it would be nice if gvim could actually
> show it as strikethrough (exactly the same as currently for *bold*
> and _italic_ text in vimwiki).
> Or for example to clearly indicate removed text when viewing a diff.
>
> Jeroen

This sounds like an interesting idea and I thought, it would be fun, to
check how easy it would be to implement it.

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.

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.

regards,
Christian
strikethrough.diff

Ken Takata

unread,
Oct 12, 2013, 10:25:06 AM10/12/13
to vim...@googlegroups.com, vim...@googlegroups.com, vim-dev Mailingliste
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
strikethrough.diff

Christian Brabandt

unread,
Oct 19, 2013, 8:46:15 AM10/19/13
to vim...@googlegroups.com, vim...@googlegroups.com, vim-dev Mailingliste
Hi Ken!
Very nice, thanks!

regards,
Christian
--
Wie man sein Kind nicht nennen sollte:
Rod Ation

Ken Takata

unread,
Mar 10, 2016, 10:47:05 AM3/10/16
to vim_dev, vim...@googlegroups.com, vim...@vim.org
Hi,

I found that this patch cannot be used for GTK3, but I don't know how to fix it.
I hope someone can fix this.


Regards,
Ken Takata

Christian Brabandt

unread,
Apr 25, 2016, 12:53:17 PM4/25/16
to vim_dev, vim...@googlegroups.com, vim...@vim.org
Hi Ken!
Seems like you did fix this with the latest version here:
https://bitbucket.org/k_takata/vim-ktakata-mq/src/9e19c0c57c4812557e7750629de02986249a5246/strikethrough.diff?fileviewer=file-view-default

Seems to work fine for me. Bram, I think this might be a nice addition
for vim 8.


Best,
Christian
--
Um sich von einer zu großen Liebe oder Duldsamkeit für etwas zu
heilen, muß man nicht die Feinde davon lesen, sondern die Freunde.
Lavater
-- Jean Paul

Ken Takata

unread,
Apr 25, 2016, 4:47:37 PM4/25/16
to vim_dev, vim...@googlegroups.com, vim...@vim.org
Hi Christian,
I made a fix but I haven't tested it yet.

> Seems to work fine for me. Bram, I think this might be a nice addition
> for vim 8.

Thank you for checking. Does it work both with GTK2 and GTK3?

Regards,
Ken Takata

Christian Brabandt

unread,
Apr 26, 2016, 2:12:51 AM4/26/16
to vim_dev, vim...@googlegroups.com, vim...@vim.org
Hi Ken!
,----
| :syn region htmlStrike start="<del>"ms=s+5 end="</del>"me=e-6
| :hi def htmlStrike gui=strikethrough term=strikethrough
| i<del>foobar</del>
`----

This works in GTK2 and GTK3 gui but I couldn't check the terminal, since
I don't have a terminal that has this capability


Best,
Christian
--
Frauen sind das beste in dieser Art.
-- Curt Goetz

Ken Takata

unread,
Apr 26, 2016, 9:51:07 AM4/26/16
to vim_dev, vim...@googlegroups.com, vim...@vim.org
Hi,
Thank you for checking.
Now I check with Win32 GUI and also with terminal (mintty). Both works fine.
As I wrote before, I have to set the following esc sequences:

let &t_Ts="\e[9m"
let &t_Te="\e[29m"

Hayaki Saito told me that xterm (with patch#305) also supported these sequences.
Is it better to set these sequences as default when $TERM is xterm?


Regards,
Ken Takata

Christian Brabandt

unread,
Apr 26, 2016, 9:57:57 AM4/26/16
to vim...@googlegroups.com, Ken Takata
Am 2016-04-26 15:51, schrieb Ken Takata:
[strikethrough patch]

> Thank you for checking.
> Now I check with Win32 GUI and also with terminal (mintty). Both works
> fine.
> As I wrote before, I have to set the following esc sequences:
>
> let &t_Ts="\e[9m"
> let &t_Te="\e[29m"
>
> Hayaki Saito told me that xterm (with patch#305) also supported these
> sequences.
> Is it better to set these sequences as default when $TERM is xterm?

Yes, I think this would be better.

Best,
Christian

Ken Takata

unread,
Apr 26, 2016, 11:41:07 AM4/26/16
to vim_dev, ktakat...@gmail.com

Ken Takata

unread,
Jul 17, 2016, 10:16:44 PM7/17/16
to vim_dev, ktakat...@gmail.com

Ken Takata

unread,
Aug 23, 2017, 5:40:27 AM8/23/17
to vim_dev, ktakat...@gmail.com
Hi,

I have updated the patch to support the terminal feature.
With this patch, strikethrough lines in a terminal will be shown as expected.
(Without this, they are shown as inverted text.)

E.g.:
:terminal
echo -e "\e[9mhello\e[m"

The string "hello" will be shown with a strike line.


Please check the attached patch.

Regards,
Ken Takata

strikethrough.diff
Reply all
Reply to author
Forward
0 new messages