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

Updates to ms-terminal terminal type in terminfo to 1.4 from 0.2 #8303

Open
jdebp opened this issue Nov 17, 2020 · 6 comments
Open

Updates to ms-terminal terminal type in terminfo to 1.4 from 0.2 #8303

jdebp opened this issue Nov 17, 2020 · 6 comments
Labels
Area-VT Virtual Terminal sequence support Issue-Task It's a feature request, but it doesn't really need a major design. Product-Meta The product is the management of the products. Product-Terminal The new Windows Terminal.
Milestone

Comments

@jdebp
Copy link

jdebp commented Nov 17, 2020

In #8291 it was noted that the ms-terminal record in the terminfo database dates from version 0.2 of Windows Terminal. We are now on version 1.4. So let's construct a list of concrete and specific amendments to the 0.2 ms-terminal record that match the current behaviour of Windows Terminal.

Here's what I can see so far:

  • Se=\E[2 q and Ss=\E[%p1%d q — Windows Terminal supports DECSCUSR (dynamic cursorShape for shell vi mode #4734)
  • xterm+256setaf — Windows Terminal supports indexed colour. Perhaps instead xterm+indirect which also contains the RGB capability, because Windows Terminal supports direct colour too, although that does change the semantics of colours 8 to 255.

Furthermore:

Note that this is not #2958 . This is not about Microsoft creating its own terminfo record, but is rather about what can be passed along to Thomas Dickey for updating the Dickey terminfo database from Windows Terminal 0.2 to 1.4.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Nov 17, 2020
@DHowett DHowett added Area-VT Virtual Terminal sequence support Issue-Task It's a feature request, but it doesn't really need a major design. Product-Meta The product is the management of the products. Product-Terminal The new Windows Terminal. labels Nov 17, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Nov 17, 2020
@DHowett
Copy link
Member

DHowett commented Nov 17, 2020

This will also help with the representation of the Windows Console in terminfo. Since conhost (here, OpenConsole) is our front line for VT support[1], everything supported by Terminal is in the fullness of time supported by conhost.

There'll be some interesting fallout from this: conhost is versioned with Windows, and each version supports a different and ever-growing set of control sequences. Terminal is versioned outside of Windows, and is always going to be "the latest conhost plus some", but in either case TERM does not afford for versioning.

[1] because of ConPTY

@DHowett
Copy link
Member

DHowett commented Nov 17, 2020

A parallel effort is required to update the "Console Virtual Terminal Sequences" document with robust version documentation. I feel like these efforts should go hand-in-hand and, perhaps, one could be programmatically derived from the other. 🤔

@DHowett DHowett removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Nov 17, 2020
@DHowett DHowett added this to the Console Backlog milestone Nov 17, 2020
@12Me21
Copy link

12Me21 commented Jan 29, 2021

The way xterm-direct works is that it redefines setaf and setab like this:

  • if the input parameter is 0-255 (this range is defined by the RGB capability), it is treated as an indexed color (and so, it's backwards compatible with xterm-256color)
  • otherwise, it's treated as a 24 bit rgb color. (as in, 0xRRGGBB)

The flaw here is that these ranges overlap, and this prevents the use of the first 256 rgb colors (anything with red=0 and green=0)

In addition, xterm-direct256 does not allow redefining colors (the initc capability) like xterm-256color.

Emacs (and possibly other programs) will use the nonstandard capabilities setf24 and setb24 if they are available, which only accept rgb colors (so you use setaf/b for indexed color and setf/b24 for direct color)
so I would recommend defining these instead of (or in addition to) the xterm-direct256-style setaf/b

Another note
the xterm-direct256 entry is defined incorrectly, as use=xterm,use=xterm+direct256, when it should be use=xterm+direct256,use=xterm, since earlier definitions take priority over later ones.

@12Me21
Copy link

12Me21 commented Feb 1, 2021

My best guess for a proper terminfo entry at the moment would be something like this:

ms-terminal|Windows 10 terminal,
# no italics (tested)
	sitm@, ritm@,
# no margins
	mgc@, smglr@,
# apparently insert mode doesn't work yet
	smir@, rmir@,
# emacs direct color capabilities (tested)
# note that windows terminal uses semicolons (this is incorrect, but very common) instead of colons
	setf24=\E[38;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%dm,
	setb24=\E[48;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%dm,
# cursor style (tested)
	Se=\E[2 q, Ss=\E[%p1%d q,
# allow setting window title (tested)
	use=xterm+sl,
# base xterm
	use=xterm-256color,

Keep in mind that terminfo does not represent the full capabilities of a terminal, so being compatible with xterm-256color (which is pretty reasonable, and you're already very close, I think) is not the same as being compatible with all of the features xterm supports.

There are likely a few control sequences that are currently broken (and I think it's better to fix these, rather than altering the terminfo entry to work around them), but I can't test properly right now because my WSL installation was broken by a windows update a while ago.

After thinking about it more, I don't think the xterm-direct capabilities are worth adding. I don't know of any program that uses them (except emacs, but it doesn't properly account for the overlap between rgb and indexed colors, so it's better to use setf24/setb24 for that)

@zadjii-msft
Copy link
Member

There are likely a few control sequences that are currently broken (and I think it's better to fix these, rather than altering the terminfo entry to work around them),

That's been my point of view since always ☺️ I'd rather close the gap on our side, than have more fracturing.

@felker
Copy link

felker commented Feb 7, 2022

FYI @12Me21 the xterm-direct256 use-order was fixed in October in Ncurses 6.3
https://invisible-island.net/ncurses/announce.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-VT Virtual Terminal sequence support Issue-Task It's a feature request, but it doesn't really need a major design. Product-Meta The product is the management of the products. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

5 participants