lifepillar / vim-wwdc16-theme

Colorful dark color scheme for Vim inspired by Apple's WWDC16 page
MIT License
102 stars 14 forks source link

italics problem under Windows 10 with CMD vim and #6

Open clach04 opened 11 hours ago

clach04 commented 11 hours ago

Vim version info at end.

I'm seeing comments showing up with a bright yellow background under Windows 10 with CMD. gvim is fine, as is Linux (with an older vim version).

The problem appears to be related to the italic check.

demo screenshot of the problem

Using:

vim -n colors\wwdc16.vim

Comments are in a bright yellow background

image

A hack to fix this is:

"let s:italic = (&t_ZH != '' && &t_ZH != '^[[7m') || has('gui_running') || has('nvim')
let s:italic = has('gui_running') || has('nvim')

image

If I echo the t_ZH I see:

^[|225m

Annoyingly I could not see in Vim that the ^ character was a real escape character.

My initial attempt at a fix:

let s:italic = (&t_ZH != '' && &t_ZH != ''  && &t_ZH != '^|225m') || has('gui_running') || has('nvim')

failed, but using a real escape char did:

let s:italic = (&t_ZH != '' && &t_ZH != ''  && &t_ZH != '|225m') || has('gui_running') || has('nvim')

This monstrosity also works for me :-) and maybe more obvious:

let s:italic = (&t_ZH != '' && &t_ZH != '' && (!has('win32') && !has("gui_running"))) || has('gui_running') || has('nvim')

What's the best way to fix this? The embedded escape is surprising so I'm not sure on best way forward. Happy to post a PR once figured out.

I'm wondering if this also impacts https://github.com/lifepillar/vim-colortemplate ?

Thanks for making this available, very neat! 🙏

vim 9.0 version details

C:\>vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jun 28 2022 13:10:49)
MS-Windows 32-bit console version
Compiled by appveyor@APPVYR-WIN
Huge version without GUI.  Features included (+) or not (-):
+acl                +ex_extra           +multi_lang         -tag_any_white
+arabic             +extra_search       +mzscheme/dyn       -tcl
+autocmd            -farsi              -netbeans_intg      +termguicolors
+autochdir          +file_in_path       +num64              +terminal
+autoservername     +find_in_path       +packages           -termresponse
-balloon_eval       +float              +path_extra         +textobjects
+balloon_eval_term  +folding            +perl/dyn           +textprop
-browse             -footer             +persistent_undo    -tgetent
++builtin_terms     +gettext/dyn        +popupwin           +timers
+byte_offset        -hangul_input       -postscript         +title
+channel            +iconv/dyn          +printer            -toolbar
+cindent            +insert_expand      +profile            +user_commands
+clientserver       +ipv6               +python/dyn         +vartabs
+clipboard          +job                +python3/dyn        +vertsplit
+cmdline_compl      +jumplist           +quickfix           +vim9script
+cmdline_hist       +keymap             +reltime            +viminfo
+cmdline_info       +lambda             +rightleft          +virtualedit
+comments           +langmap            +ruby/dyn           +visual
+conceal            +libcall            +scrollbind         +visualextra
+cryptv             +linebreak          +signs              +vreplace
+cscope             +lispindent         +smartindent        +vtp
+cursorbind         +listcmds           +sodium/dyn         +wildignore
+cursorshape        +localmap           +sound              +wildmenu
+dialog_con         +lua/dyn            +spell              +windows
+diff               +menu               +startuptime        +writebackup
+digraphs           +mksession          +statusline         -xfontset
-dnd                +modify_fname       -sun_workshop       -xim
-ebcdic             +mouse              +syntax             -xpm_w32
+emacs_tags         -mouseshape         +tag_binary         -xterm_save
+eval               +multi_byte_ime/dyn -tag_old_static
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
       defaults file: "$VIMRUNTIME\defaults.vim"
Compilation: cl -c /W3 /GF /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_SOUND  -DFEAT_JOB_CHANNEL -DFEAT_IPV6    -DHAVE_SODIUM -DDYNAMIC_SODIUM -DDYNAMIC_SODIUM_DLL=\"libsodium.dll\" /I "C:\libsodium\include" -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /source-charset:utf-8 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG /arch:IA32 /Zl /MT /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua54.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python310.dll\" -DFEAT_MZSCHEME -I "C:\racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_da32rk.dll\" -DDYNAMIC_MZGC_DLL=\"libracket3m_da32rk.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl532.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby300.dll\" -DRUBY_VERSION=30 -DFEAT_HUGE /Fd.\ObjCULYHRZi386/ /Zi
Linking: link /nologo /opt:ref /LTCG oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib user32.lib  /machine:i386   libcmt.lib   /nodefaultlib:lua54.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python310.lib    winmm.lib WSock32.lib Ws2_32.lib   /PDB:vim.pdb -debug
clach04 commented 11 hours ago

Obviously this DOES impact https://github.com/lifepillar/vim-wwdc17-theme

clach04 commented 11 hours ago

https://github.com/search?q=repo%3Alifepillar%2Fvim-colortemplate%20%20t_ZH&type=code

lifepillar commented 10 hours ago

Thanks for your feedback. The italics check is a hack, in fact, but that's the first report I get of an environment where it doesn't work.

What's the best way to fix this?

I don't think there is a proper “fix”: we may try to mitigate the problem. In this case, I have no preference between your proposed workarounds: if you tell me that they both work and offer an argument to prefer one, I will use that. I wonder if there is a way to enable italics under your environment and if there is a way to reliably detect it (I doubt it).

I'm wondering if this also impacts [Colortemplate]

Yes it does, and it does impact all the color schemes generated by Colortemplate v2 that use italics in some highlight group.

Colortemplate v3 does not implicitly add any check for italics, leaving the responsibility to the template's author, so this issue does not affect Colortemplate v3.

clach04 commented 7 hours ago

Thanks for the quick response @lifepillar!

I propose a change to:

let s:italic = has('gui_running') || has('nvim') || (&t_ZH != '' && &t_ZH != '' && (!has('win32') && !has("gui_running")))

changing the italic-check-hack to switch the order, with more easily understood items at the start and then the less obvious stuff at the end (it was tempting to move the t_ZH check right at the end).

I think a Windows-specific check, with a Windows non-GUI check is the least-worst way to avoid italics accidentally being enabled ;-)

It's in band aid territory. I will try and come up with a smaller test case for vim upstream to get some clarity on expected behavior.

I also think it's worth a comment in the file as an explanation to what is going on (I do not recognize the escape sequences, I don't recognize the Windows one I found 🤣 ).

I'm not at all familiar with the templating framework here, it's on my backlog of cool stuff to check out. I'm assuming the change would be made to https://github.com/lifepillar/vim-wwdc16-theme/blob/master/template/wwdc16.colortemplate#L68 ? I've simply been hacking the color/wwdc16.vim file 😆

clach04 commented 7 hours ago

Quickly opened https://github.com/vim/vim/issues/15723 to see if we can gain any insight on the Windows side of things.