Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim.exe to 256 colors, too #2821

Closed
wants to merge 6 commits into from
Closed

vim.exe to 256 colors, too #2821

wants to merge 6 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 19, 2018

Hello,

To switch to 256 colors, enter ":set t_Co=256" without the termguicolors.
To return to 16 colors, enter ":set t_Co=16".
It exists with vtp (vcon).
FEAT_TERMGUICOLORS is required.

After I wrote a 24-bit patch, I realized that I can not use the 256 color scheme https://github.com/KKPMW/moonshine-vim so I can use it.

enjoying.

@codecov-io
Copy link

codecov-io commented Apr 19, 2018

Codecov Report

Merging #2821 into master will decrease coverage by <.01%.
The diff coverage is 81.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2821      +/-   ##
==========================================
- Coverage    75.4%   75.39%   -0.01%     
==========================================
  Files          92       92              
  Lines      134598   134739     +141     
==========================================
+ Hits       101490   101593     +103     
- Misses      33108    33146      +38
Impacted Files Coverage Δ
src/misc1.c 84.37% <100%> (+0.03%) ⬆️
src/terminal.c 70.67% <100%> (+0.04%) ⬆️
src/term.c 60.36% <100%> (-0.21%) ⬇️
src/option.c 84.94% <62.5%> (+0.01%) ⬆️
src/os_unix.c 54.48% <0%> (-0.66%) ⬇️
src/buffer.c 77.8% <0%> (-0.37%) ⬇️
src/message.c 74.59% <0%> (-0.25%) ⬇️
src/ex_cmds2.c 78.62% <0%> (-0.08%) ⬇️
src/ex_docmd.c 75.8% <0%> (-0.06%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 285e335...9c78c4d. Read the comment docs.

@brammool
Copy link
Contributor

brammool commented Apr 19, 2018 via email

src/globals.h Outdated
#endif
;

extern int grey_ramp[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be EXTERN instead of extern?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh...

@ghost
Copy link
Author

ghost commented Apr 20, 2018

Only I did the test.
Others have not tested.
I will ask many different people.

@ghost
Copy link
Author

ghost commented Apr 21, 2018

I do not have any friends in the test...

@janlazo
Copy link

janlazo commented Apr 25, 2018

Is tgc still no-op on Windows without +vcon? I was using set tgc with set term=xterm t_Co=256 on ConEmu to get true colors but I'm back to 256 colors after patch 8.0.1531.

@ghost
Copy link
Author

ghost commented Apr 25, 2018

I just got to know ConEmu. I will look at ConEmu from now.
I have not tested in an environment that is not :set term=win32.

@ghost
Copy link
Author

ghost commented Apr 25, 2018

I have seen ConEmu now.
I feel that it is not straightforward. Please wait for a couple of days as I will test again.

@janlazo
Copy link

janlazo commented Apr 25, 2018

I check value of $ConEmuANSI and check if using GVim or terminal. winpty doesn't unset ConEmu environment variables so I unset $ConEmuANSI in GUIs so that I can use terminal Vim in GVim's :terminal.
https://github.com/janlazo/dotvim8/blob/master/shared.vim#L385-L397

For tgc, I check Vim 8 patches for truecolor support and +vcon. I added additional checks because I had screen issues on tmux or when &t_Co <= 16.
https://github.com/janlazo/dotvim8/blob/master/shared.vim#L424-L445

@ghost
Copy link
Author

ghost commented Apr 25, 2018

Thank you for the example.
I returned the patch to 8.0.1530 and confirmed the behavior.
I think I got it fixed.

@janlazo
Copy link

janlazo commented Apr 25, 2018

Is TERM=cygwin supported so the user can run terminal Vim on msys2 sh/bash? I use ConEmu for sh/bash as well instead of mintty.

@ghost
Copy link
Author

ghost commented Apr 26, 2018

With the above fix, TERM=cygwin should also work as expected.
If it is not as expected, please contact here again.

@janlazo
Copy link

janlazo commented Apr 26, 2018

I had issues using 256 colors (with or without tgc) for Vim within :terminal so I updated my vimrc to use 256 colors for Vim outside of :terminal. This happens in the default Vim distributed with msys2/mingw. Not sure if it's Vim or ConEmu bug but feel free to optimize or simplify the code if it helps.

@k-takata
Copy link
Member

k-takata commented Apr 27, 2018

256 colors cannot be used within :terminal (in Win32 version of Vim) because of limitation of Win32 API.
:terminal uses winpty to capture the output of the executed command, and winpty uses Win32 API to capture that. However, Win32 API doesn't provide a way to capture 256 colors (or more).
(This doesn't apply to Cygwin/MSYS2 versions of Vim.)

@ghost
Copy link
Author

ghost commented Apr 27, 2018

This PR is to use 256 colors with "Vim.Win32" with cmd.exe.
However, :terminal in "Vim.Win32" can use 16 index colors with winpty and Win32 API restrictions.
This should have been announced.

With vcon patch (8.0.1531), there was a possibility that I broke the operation before that. It rewrote with the previous commit.
I modified only term=win32. Other term= is no touch

I would like to make it simple, too. It will be discussed again on another occasion.

@brammool
Copy link
Contributor

brammool commented May 1, 2018

Note that, although I included the code change, it would still be nice to have an explanation in the help about how this all works.

@janlazo
Copy link

janlazo commented May 5, 2018

@ntak I cannot set tgc. I get error message E954: 24-bit colors are not supported on this environment: tgc. I'm still stuck with 256 colors. Can you remove this error message and just let the user set it?

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May  4 2018 22:03:03)
MS-Windows 64-bit console version
Included patches: 1-1790
Compiled by appveyor@APPVYR-WIN
Huge version without GUI.  Features included (+) or not (-):
+acl                +eval               -mouseshape         -tag_any_white
+arabic             +ex_extra           +multi_byte_ime/dyn +tcl/dyn
+autocmd            +extra_search       +multi_lang         +termguicolors
+autoservername     +farsi              +mzscheme/dyn       +terminal
-balloon_eval       +file_in_path       -netbeans_intg      -tgetent
+balloon_eval_term  +find_in_path       +num64              -termresponse
-browse             +float              +packages           +textobjects
++builtin_terms     +folding            +path_extra         +timers
+byte_offset        -footer             +perl/dyn           +title
+channel            +gettext/dyn        +persistent_undo    -toolbar
+cindent            -hangul_input       -postscript         +user_commands
+clientserver       +iconv/dyn          +printer            +vertsplit
+clipboard          +insert_expand      +profile            +virtualedit
+cmdline_compl      +job                +python/dyn         +visual
+cmdline_hist       +jumplist           +python3/dyn        +visualextra
+cmdline_info       +keymap             +quickfix           +viminfo
+comments           +lambda             +reltime            +vreplace
+conceal            +langmap            +rightleft          +vtp
+cryptv             +libcall            +ruby/dyn           +wildignore
+cscope             +linebreak          +scrollbind         +wildmenu
+cursorbind         +lispindent         +signs              +windows
+cursorshape        +listcmds           +smartindent        +writebackup
+dialog_con         +localmap           +startuptime        -xfontset
+diff               +lua/dyn            +statusline         -xim
+digraphs           +menu               -sun_workshop       -xpm_w32
-dnd                +mksession          +syntax             -xterm_save
-ebcdic             +modify_fname       +tag_binary         
+emacs_tags         +mouse              +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 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL  -DFEAT_JOB_CHANNEL      -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_MBYTE -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl86t.dll\" -DDYNAMIC_TCL_VER=\"8.6\" -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua53.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python36.dll\" -DFEAT_MZSCHEME -I "C:\Program Files\Racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_a36fs8.dll\" -DDYNAMIC_MZGC_DLL=\"libracket3m_a36fs8.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl524.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\"x64-msvcrt-ruby240.dll\" -DFEAT_HUGE /Fd.\ObjCULYHTRZAMD64/ /Zi
Linking: link  /nologo /subsystem:console,5.02 /opt:ref /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:AMD64   libcmt.lib  user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python36.lib   "C:\Tcl\lib\tclstub86.lib" WSock32.lib /PDB:vim.pdb -debug

@janlazo
Copy link

janlazo commented May 7, 2018

@k-takata Does tgc on cygwin/msys2 releases of Vim depend on mintty terminal and TERM=xterm? I'd like to use ConEmu for those releases as well, similar to native Windows release prior to patch-8.0.1531

@ghost
Copy link
Author

ghost commented May 8, 2018

The current tgc can only be used in Windows 10.
I will send PR to use in xterm.
It is my skill that I cannot solve it once. I am sorry.

@ghost
Copy link
Author

ghost commented May 8, 2018

PR: #2883

adizero pushed a commit to adizero/vim that referenced this pull request May 19, 2018
Problem:    Cannot use 256 colors in a MS-Windows console.
Solution:   Add 256 color support. (Nobuhiro Takasaki, closes vim#2821)
@ghost ghost deleted the vtp2 branch September 28, 2018 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants