[vim/vim] Explicitly turn off VTP by variable (#5344)

99 views
Skip to first unread message

Nobuhiro Takasaki

unread,
Dec 10, 2019, 10:31:33 AM12/10/19
to vim/vim, Subscribed

Some older compatible terminal apps will complete the procedure for turning on VTP, even if it is not supported.
set vtp=0 turns off VTP. To turn it on again, set vtp=1.
(From vim_use discussion)


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/5344

Commit Summary

  • Support &vtp

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Bram Moolenaar

unread,
Dec 11, 2019, 3:24:17 PM12/11/19
to vim/vim, Subscribed

> Some older compatible terminal apps will complete the procedure for turning on VTP, even if it is not supported.
> ```set vtp=0``` turns off VTP. To turn it on again, ```set vtp=1```.
> (From vim_use discussion)

For a user who doesn't know what 'vtp' means the name is obscure.
Is there a longer name we can use?

The documentation needs a few improvements. E.g., mention that the
option is only available with the +vtp option.

--
hundred-and-one symptoms of being an internet addict:
252. You vote for foreign officials.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Nobuhiro Takasaki

unread,
Dec 11, 2019, 6:08:47 PM12/11/19
to vim/vim, Push

@ntak pushed 1 commit.

  • d75a0c2 Renames to &forcevtp, matched behavior to name


You are receiving this because you are subscribed to this thread.

View it on GitHub or unsubscribe.

Codecov

unread,
Dec 11, 2019, 6:36:51 PM12/11/19
to vim/vim, Subscribed

Codecov Report

Merging #5344 into master will increase coverage by 0.01%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@

##           master    #5344      +/-   ##

==========================================

+ Coverage   82.23%   82.25%   +0.01%     

==========================================

  Files         134      134              

  Lines      147579   147603      +24     

==========================================

+ Hits       121364   121412      +48     

+ Misses      26215    26191      -24
Impacted Files Coverage Δ
src/term.c 81.12% <ø> (ø) ⬆️
src/option.c 87.01% <33.33%> (-0.06%) ⬇️
src/terminal.c 81.74% <0%> (-0.04%) ⬇️
src/window.c 88.3% <0%> (-0.04%) ⬇️
src/ex_docmd.c 83.76% <0%> (-0.01%) ⬇️
src/gui.c 63.73% <0%> (ø) ⬆️
src/version.c 92.1% <0%> (ø) ⬆️
src/popupwin.c 94.51% <0%> (+0.01%) ⬆️
src/eval.c 88.71% <0%> (+0.03%) ⬆️
... and 7 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 e2a3f36...d75a0c2. Read the comment docs.

K.Takata

unread,
Dec 11, 2019, 7:08:59 PM12/11/19
to vim/vim, Subscribed

If the value of this option is only 0 or 1, how about use boolean style like forcevtp and noforcevtp?

Or how about disablevtp/nodisablevtp?
I don't think this option should reflect the current status whether VTP is used or not, because we can use has('vcon').
I suggest the following specification:

						*'disablevtp'*
'disablevtp'		boolean (default off)
			global
			{not available when compiled without the |+vtp|
			feature}
	When off, VTP (Virtual Terminal Processing) is automatically used when
	Vim detects that it is available. (It is available on win32 console on
	Windows 10 version 1703 or later.)
	When on, stop using VTP even Vim detects that it is available.  If
	you are using a 3rd party terminal application which doesn't support
	VTP, turn this option on.

(I don't remember well whether VTP is always used on Win10 1703 (or later) or used only when 'tgc' is set or t_Co=256 is set. If later, the above help needs to be updated.)

Nobuhiro Takasaki

unread,
Dec 12, 2019, 3:30:26 PM12/12/19
to vim/vim, Subscribed

Yes, don't have multiple statuses.
That way, I will use it almost the same.

I am always grateful for your help.
I can prepare from now.

Nobuhiro Takasaki

unread,
Dec 12, 2019, 6:12:31 PM12/12/19
to vim/vim, Push

@ntak pushed 2 commits.

  • 9cda706 Merge remote-tracking branch 'upstream/master' into setvtp
  • c7c1c52 Rename to 'disablevtp'


You are receiving this because you are subscribed to this thread.

Nobuhiro Takasaki

unread,
Dec 12, 2019, 7:03:48 PM12/12/19
to vim/vim, Push

@ntak pushed 1 commit.


You are receiving this because you are subscribed to this thread.

Nobuhiro Takasaki

unread,
Dec 12, 2019, 7:09:50 PM12/12/19
to vim/vim, Subscribed

VTP is turned on in all cases except '16 palette color'. If there is no VTP, only '16 palette color' can be used.

Nobuhiro Takasaki

unread,
Dec 12, 2019, 7:28:08 PM12/12/19
to vim/vim, Push

@ntak pushed 1 commit.


You are receiving this because you are subscribed to this thread.

Nobuhiro Takasaki

unread,
Dec 12, 2019, 8:19:53 PM12/12/19
to vim/vim, Push

@ntak pushed 1 commit.


You are receiving this because you are subscribed to this thread.

h_east

unread,
Dec 12, 2019, 9:24:55 PM12/12/19
to vim_dev
Hi,

`no-disable` is a denial of denial, it looks a bit confusing.
How about 'effortusevtp' and 'noeffortusevtp' ?

*'effortusevtp'*
'effortusevtp' boolean (default on)
global
{not available when compiled without the |+vtp|
feature}
When on, VTP (Virtual Terminal Processing) is automatically used when
Vim detects that it is available. (It is available on win32 console on
Windows 10 version 1703 or later.)
When off, stop using VTP even Vim detects that it is available.  If
you are using a 3rd party terminal application which doesn't support
VTP, turn this option off.

Nick Jensen

unread,
Dec 12, 2019, 9:29:05 PM12/12/19
to vim...@googlegroups.com
The 2019-12-12 18:24, h_east wrote:
>`no-disable` is a denial of denial, it looks a bit confusing.
>How about 'effortusevtp' and 'noeffortusevtp' ?

"effort" also looks strange - it is not a verb. Do you perhaps mean
"attempt"?

Nick

K.Takata

unread,
Dec 12, 2019, 10:50:00 PM12/12/19
to vim/vim, Subscribed

Nobuhiro Takasaki

unread,
Dec 13, 2019, 1:29:47 AM12/13/19
to vim/vim, Subscribed

I thought it was a debate from the beginning, so I chose '&vtp'.
Well, double denial is not cool.

Can I use 'virtualterminal' / 'novirtualterminal' ?
Because 'windowsterminal' is also waiting. At this time, automatic detection is not possible.

Bram Moolenaar

unread,
Dec 13, 2019, 3:23:42 PM12/13/19
to vim/vim, Subscribed

Searching on the internet I find lots of results for VTP, but none related to our use: Virtual Terminal Processing. Isn't this mostly called "Windows Terminal"? Or is that something else?

The option could be something like "trywinterm" for "try using windows terminal". When on you still only get windows terminal support of it was detected (otherwise it can't work, right?).
And "notrywinterm" if you don't want to try using windows terminal, even when it's detected.

Is that less confusing?

Nobuhiro Takasaki

unread,
Dec 14, 2019, 12:27:39 AM12/14/19
to vim/vim, Subscribed

The word 'VTP' was first written that way during the pre-release stage.
The official document at a later date became 'Virtual Terminal Sequences'. 'VTS' ?
This is the sequence supported by ConPTY running on Windows10 'conhostV2'.

There is a Windows Terminal that is supporting the same VTS.
https://github.com/microsoft/terminal/releases
This and ConPTY have the same API, but have a different bug.
The interface and device attribute query (DA) are completely the same as ConPTY, but the behavior is completely different, so the user has to make their own selection.

I brought an implementation of 'trywinterm'. Is this what you mean?

Nobuhiro Takasaki

unread,
Dec 14, 2019, 12:27:54 AM12/14/19
to vim/vim, Push

@ntak pushed 1 commit.


You are receiving this because you are subscribed to this thread.

Nobuhiro Takasaki

unread,
Dec 14, 2019, 12:34:17 AM12/14/19
to vim/vim, Push

@ntak pushed 1 commit.


You are receiving this because you are subscribed to this thread.

Bram Moolenaar

unread,
Dec 14, 2019, 7:36:33 AM12/14/19
to vim/vim, Subscribed

I'm still not clear on terminology. If I understand it correctly, we have three terminal-like environments:

  • The good old Windows console, only supporting 16 colors
  • The new Windows Terminal, still under development, supporting many colors
  • The ConPTY implementation, which is what we use for the terminal window.
    Is that correct?

Nobuhiro Takasaki

unread,
Dec 14, 2019, 1:23:21 PM12/14/19
to vim/vim, Subscribed

https://github.com/microsoft/terminal/labels?page=2&sort=name-asc
Look at the label Product series. This is the classification method used by Microsoft.

The current situation should be:
Product-Cmd.exe (16 good old colors)
Product-Conhost (Windows 10 cmd.exe that I usually use)
Product-Conpty ('*PseudoConsole' API terminal)
Product-Terminal (Windows Store application)
That's four. There is no common term between them.

Supplement:
The winpty terminal is built into Vim, so it needs support, but I think it is complete.
Product-Powershell looks like Product-Conhost with a different shell. I used to have problems with coloring, but I think it was solved.
Product-WSL behaves like ConPTY. The inside seems to work with ConPTY.

The above is except 3rd-party Terminal.

Nobuhiro Takasaki

unread,
Mar 10, 2020, 2:27:59 AM3/10/20
to vim/vim, Subscribed

Can I set a new environment variable VIMVTP?
In order for the command to specify VTP behavior, .vimrc must be able to detect the terminal type.
Also, detecting the type of terminal is not realistic.
The environment on the user's side, probably the environment variable set also changes for each terminal, I want to rely on it.

set "VIMVTP=vtp:enable"
and
set "VIMVTP=vtp:disable,scrollpatch=disable"
I want to write like.

Bram Moolenaar

unread,
Mar 10, 2020, 1:01:18 PM3/10/20
to vim/vim, Subscribed

> Can I set a new environment variable VIMVTP?
> In order for the command to specify VTP behavior, .vimrc must be able to detect the terminal type.
> Also, detecting the type of terminal is not realistic.
> The environment on the user's side, probably the environment variable set also changes for each terminal, I want to rely on it.
>
> set "VIMVTP=vtp:enable"
> and
> set "VIMVTP=vtp:disable,scrollpatch=disable"
> I want to write like.

We generally avoid environment variables, except for some standard ones,
because they can easily be set and forgot.

Why can't we detect the type of terminal? Isn't there an API for that?

If Vim can't detect the terminal, then how would you set that
environment variable to the right value in the right place?

--
Don't be humble ... you're not that great.
-- Golda Meir


/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Nobuhiro Takasaki

unread,
Mar 10, 2020, 3:43:58 PM3/10/20
to vim/vim, Subscribed

There are many terminals, new terminals are increasing, and the combinations are endless.

There is no common API.
Some terminals do not have individual APIs.
Microsoft does not recognize cmd.exe compatible terminals.
Setting the VTP flag will result in an error on older Windows, nothing will happen on compatible terminals (ie the flag will be set).
The meaning was defined for an undefined flag that should have no meaning.

With the advent of WindowsTerminal, "CSI DA (^[[0c)" is destroyed (returns the equivalent of ConPTY) and cannot be relied on.

Currently, cmd.exe compatible terminal is not detected at all.
The appropriate values ​​assume cmd.exe.
Earlier I used a lot of stamina to support an English-only terminal called "Take Command". I can't do that anymore. I think the origin of this PR was its terminal.

So far, I remember that changing environment variables requires special techniques. After all it seems to implement the command.

Forget VIMVTP.

Dustin L. Howett (MSFT)

unread,
Mar 24, 2020, 2:57:32 PM3/24/20
to vim/vim, Subscribed

Microsoft does not recognize cmd.exe compatible terminals.

The windows console host hosts all commandline applications on windows. cmd, wsl, vim, powershell, they all use the same VT code.

Vim should be using ENABLE_VIRTUAL_TERMINAL_PROCESSING on all versions of windows after 10240.

Nobuhiro Takasaki

unread,
Mar 24, 2020, 4:03:12 PM3/24/20
to vim/vim, Subscribed

Relying on the newly added flag breaks operation on all compatible terminals.
Reports of destruction are all downvote to me.
Hea!

Dustin L. Howett (MSFT)

unread,
Mar 24, 2020, 4:04:43 PM3/24/20
to vim/vim, Subscribed

Relying on the newly added flag breaks operation on all compatible terminals.

When an application cannot use ENABLE_VIRTUAL_TERMINAL_PROCESSING, it can implement its own Compatibility mode. This is what Vim does already! 😄

Nobuhiro Takasaki

unread,
Mar 24, 2020, 4:40:30 PM3/24/20
to vim/vim, Subscribed

Compatible terminals simply ignore the added flag.
Therefore, the application needs to provide a new means for manually selecting the sequence to be transmitted. And this issue exists.
The difference between the position of saying "follow me" to all compatible terminals and the position of not being able to say it.

Dustin L. Howett (MSFT)

unread,
Mar 24, 2020, 4:43:16 PM3/24/20
to vim/vim, Subscribed

This does not need to be an option.

What we have today

  1. On linux, macos, unix, bsd, Vim uses VT sequences
  2. On Windows, Vim uses "internal" VT and translates to Win32 API

Proposal

Can we do this?

  1. On linux, macos, unix, bsd, Vim uses VT sequences
  2. On Windows, Vim tries ENABLE_VIRTUAL_TERMINAL_PROCESSING
    1. If it returns TRUE, Vim uses VT sequences
    2. If it returns false, Vim uses "internal" VT and translates to Win32 API

This would make Vim work very well on all versions of Windows 10 and in new terminals that support VT (like ConEmu)

Nobuhiro Takasaki

unread,
Mar 24, 2020, 4:59:40 PM3/24/20
to vim/vim, Subscribed

The problem is how to listen to Vim's petition from a VT unsupported terminal (paid product!) That returns "TRUE" even after trying the flag. Again, I have no authority.
In other words, I have no right to answer. Just follow.

Bram Moolenaar

unread,
Mar 24, 2020, 5:11:11 PM3/24/20
to vim/vim, Subscribed


Dustin L. Howett wrote:

> This does not need to be an option.
>
> ## What we have today
>
> 1. On linux, macos, unix, bsd, Vim uses VT sequences
> 2. On Windows, Vim uses "internal" VT and translates to Win32 API
>
> ## Proposal
>
> Can we do this?
>
> 1. On linux, macos, unix, bsd, Vim uses VT sequences
> 2. On Windows, Vim tries `ENABLE_VIRTUAL_TERMINAL_PROCESSING`
> 1. _If it returns TRUE_, Vim uses VT sequences
> 2. If it returns false, Vim uses "internal" VT and translates to Win32 API
>
> This would make Vim work very well on all versions of Windows 10 _and_

> in new terminals that support VT (like ConEmu)

It generally sounds like a good idea to avoid the Escape-sequence to
Win32 API translation. This then depends on how well the Escape
sequences are implemented. What terminal and version exactly is being
emulated? I assume it won't be covering 100%, is there a specification
of which ones are 100% right? Vim can easily work around missing
entries, but entries that don't work exactly as expected will cause
problems.

This matters especially for color support, mouse dragging and similar
things that are not part of the basic terminals.

--
A mathematician is a device for turning coffee into theorems.
Paul Erdos
A computer programmer is a device for turning coffee into bugs.
Bram Moolenaar


/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bram Moolenaar

unread,
May 31, 2020, 3:13:28 PM5/31/20
to vim/vim, Subscribed

Now looking at this patch again, I see that it makes a difference whether the option is never set, set to true or set to false. Problem is that it's then not possible to go back to the initial situation. It would be better to have an option with three values: Detect the terminal, force-disable vtp, force-enable vtp.

Then we can call the option 'winterm' with the values empty (default), "off" and "on".

Unfortunately I don't feel confortable making these changes without a setup to try it out. And Nobuhiro appears to be inactive. Anybody else wants to take this over?

Nobuhiro Takasaki

unread,
Oct 2, 2020, 9:44:03 PM10/2/20
to vim/vim, Subscribed

Closed #5344.

Reply all
Reply to author
Forward
0 new messages