Skip to content
Permalink
Browse files

patch 8.0.1531: cannot use 24 bit colors in MS-Windows console

Problem:    Cannot use 24 bit colors in MS-Windows console.
Solution:   Add support for vcon. (Nobuhiro Takasaki, Ken Takasaki,
            fixes #1270, fixes #2060)
  • Loading branch information...
brammool committed Feb 22, 2018
1 parent 19eb665 commit cafafb381a04e33f3ce9cd15dd9f94b73226831f
Showing with 701 additions and 114 deletions.
  1. +21 −11 runtime/doc/options.txt
  2. +4 −4 src/evalfunc.c
  3. +7 −0 src/feature.h
  4. +15 −0 src/misc1.c
  5. +15 −0 src/option.c
  6. +453 −76 src/os_win32.c
  7. +4 −1 src/proto/os_win32.pro
  8. +1 −0 src/proto/term.pro
  9. +19 −0 src/screen.c
  10. +21 −0 src/syntax.c
  11. +131 −22 src/term.c
  12. +1 −0 src/testdir/gen_opt_test.vim
  13. +9 −0 src/version.c
@@ -1,4 +1,4 @@
*options.txt* For Vim version 8.0. Last change: 2018 Feb 03
*options.txt* For Vim version 8.0. Last change: 2018 Feb 22


VIM REFERENCE MANUAL by Bram Moolenaar
@@ -5203,8 +5203,11 @@ A jump table for the options with a short description can be found at |Q_op|.
{not in Vi}
Maximum amount of memory (in Kbyte) to use for one buffer. When this
limit is reached allocating extra memory for a buffer will cause
other memory to be freed. The maximum usable value is about 2000000.
Use this to work without a limit. Also see 'maxmemtot'.
other memory to be freed.
The maximum usable value is about 2000000. Use this to work without a
limit.
The value is ignored when 'swapfile' is off.
Also see 'maxmemtot'.

*'maxmempattern'* *'mmp'*
'maxmempattern' 'mmp' number (default 1000)
@@ -5233,6 +5236,8 @@ A jump table for the options with a short description can be found at |Q_op|.
need more than 2 Gbyte for text editing? Keep in mind that text is
stored in the swap file, one can edit files > 2 Gbyte anyway. We do
need the memory to store undo info.
Buffers with 'swapfile' off still count to the total amount of memory
used.
Also see 'maxmem'.

*'menuitems'* *'mis'*
@@ -5956,14 +5961,13 @@ A jump table for the options with a short description can be found at |Q_op|.
|ins-completion-menu|.

*'pumwidth'* *'pw'*
'pumwidth' 'pw' number (default 0)
'pumwidth' 'pw' number (default 15)
global
{not available when compiled without the
|+insert_expand| feature}
{not in Vi}
Determines the minium width to use for the popup menu for Insert mode
completion. When zero the default of 15 screen cells is used.
|ins-completion-menu|.
completion. |ins-completion-menu|.

*'pythondll'*
'pythondll' string (default depends on the build)
@@ -7903,17 +7907,23 @@ A jump table for the options with a short description can be found at |Q_op|.
:set encoding=utf-8
< You need to do this when your system has no locale support for UTF-8.

*'termguicolors'* *'tgc'*
*'termguicolors'* *'tgc'* *E954*
'termguicolors' 'tgc' boolean (default off)
global
{not in Vi}
{not available when compiled without the
|+termguicolors| feature}
When on, uses |highlight-guifg| and |highlight-guibg| attributes in
the terminal (thus using 24-bit color). Requires a ISO-8613-3
compatible terminal.
If setting this option does not work (produces a colorless UI)
reading |xterm-true-color| might help.
the terminal (thus using 24-bit color).

Requires a ISO-8613-3 compatible terminal. If setting this option
does not work (produces a colorless UI) reading |xterm-true-color|
might help.

For Win32 console, Windows 10 version 1703 (Creators Update) or later
is required. Use this check to find out: >
if has('vcon')
<
Note that the "cterm" attributes are still used, not the "gui" ones.
NOTE: This option is reset when 'compatible' is set.

@@ -851,7 +851,7 @@ static struct fst
#ifdef FEAT_TERMINAL
{"term_dumpdiff", 2, 3, f_term_dumpdiff},
{"term_dumpload", 1, 2, f_term_dumpload},
{"term_dumpwrite", 2, 4, f_term_dumpwrite},
{"term_dumpwrite", 2, 3, f_term_dumpwrite},
{"term_getaltscreen", 1, 1, f_term_getaltscreen},
{"term_getattr", 2, 2, f_term_getattr},
{"term_getcursor", 1, 1, f_term_getcursor},
@@ -6323,9 +6323,9 @@ f_has(typval_T *argvars, typval_T *rettv)
else if (STRICMP(name, "syntax_items") == 0)
n = syntax_present(curwin);
#endif
#if defined(WIN3264)
else if (STRICMP(name, "win95") == 0)
n = FALSE; /* Win9x is no more supported. */
#ifdef FEAT_VTP
else if (STRICMP(name, "vcon") == 0)
n = has_vtp_working();
#endif
#ifdef FEAT_NETBEANS_INTG
else if (STRICMP(name, "netbeans_enabled") == 0)
@@ -1394,3 +1394,10 @@
|| (defined(WIN3264) && defined(FEAT_GUI_W32))
# define FEAT_FILTERPIPE
#endif

/*
* +vtp: Win32 virtual console.
*/
#if !defined(FEAT_GUI) && defined(WIN3264)
# define FEAT_VTP
#endif
@@ -3714,7 +3714,22 @@ vim_beep(
&& !(gui.in_use && gui.starting)
#endif
)
{
out_str_cf(T_VB);
#ifdef FEAT_VTP
/* No restore color information, refresh the screen. */
if (has_vtp_working() != 0
# ifdef FEAT_TERMGUICOLORS
&& p_tgc
# endif
)
{
redraw_later(CLEAR);
update_screen(0);
redrawcmd();
}
#endif
}
else
out_char(BELL);
#ifdef ELAPSED_FUNC
@@ -8690,10 +8690,25 @@ set_bool_option(
/* 'termguicolors' */
else if ((int *)varp == &p_tgc)
{
# ifdef FEAT_VTP
/* Do not turn on 'tgc' when 24-bit colors are not supported. */
if (!has_vtp_working())
{
p_tgc = 0;
return (char_u*)N_("E954: 24-bit colors are not supported on this environment");
}
swap_tcap();
# endif
# ifdef FEAT_GUI
if (!gui.in_use && !gui.starting)
# endif
highlight_gui_started();
# ifdef FEAT_VTP
control_console_color_rgb();
/* reset t_Co */
if (STRCMP(T_NAME, "win32") == 0)
set_termname(T_NAME);
# endif
}
#endif

1 comment on commit cafafb3

@ianchanning

This comment has been minimized.

Copy link

commented on cafafb3 Oct 7, 2018

Can I just say how fantastic it is to have 24-bit colours in the Windows console finally! I've been trying for years to get nice colours in the Windows console. Thank you to all involved. Some screenshots here: https://vi.stackexchange.com/a/17588/11986

Please sign in to comment.
You can’t perform that action at this time.