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

Open
opened 2026-01-31 02:48:07 +00:00 by claunia · 6 comments
Owner

Originally created by @jdebp on GitHub (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 (#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:

  • What, if anything, needs to be fixed to get the problem in #6733 to go away? Windows Terminal has REP now, so ansi+rep should be alright now.
  • Is IRM supported yet? (#1947) Otherwise rmir@ and smir@ are needed.
  • What do we need for XM? (#8291)

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.

Originally created by @jdebp on GitHub (Nov 17, 2020). In #8291 it was noted that the [`ms-terminal`](https://invisible-island.net/ncurses/terminfo.src.html#tic-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 (#4734) * [`xterm+256setaf`](https://invisible-island.net/ncurses/terminfo.src.html#tic-xterm_256setaf) — Windows Terminal supports indexed colour. Perhaps instead [`xterm+indirect`](https://invisible-island.net/ncurses/terminfo.src.html#tic-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: * What, if anything, needs to be fixed to get the problem in #6733 to go away? Windows Terminal has REP now, so [`ansi+rep`](https://invisible-island.net/ncurses/terminfo.src.html#tic-ansi_rep) should be alright now. * Is IRM supported yet? (#1947) Otherwise `rmir@` and `smir@` are needed. * What do we need for `XM`? (#8291) 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.
claunia added the Issue-TaskArea-VTProduct-TerminalProduct-Meta labels 2026-01-31 02:48:08 +00:00
Author
Owner

@DHowett commented on GitHub (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 commented on GitHub (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
Author
Owner

@DHowett commented on GitHub (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 commented on GitHub (Nov 17, 2020): A parallel effort is required to update [the "Console Virtual Terminal Sequences" document](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) with robust version documentation. I feel like these efforts should go hand-in-hand and, perhaps, one could be programmatically derived from the other. 🤔
Author
Owner

@12Me21 commented on GitHub (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 commented on GitHub (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.
Author
Owner

@12Me21 commented on GitHub (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)

@12Me21 commented on GitHub (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)
Author
Owner

@zadjii-msft commented on GitHub (Feb 1, 2021):

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.

@zadjii-msft commented on GitHub (Feb 1, 2021): > 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.
Author
Owner

@felker commented on GitHub (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

@felker commented on GitHub (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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11456