Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Expanded ANSI for Subscript and Superscript Not Working

Jun
1,092
48
  • Build: 36.50.68
  • TCMD: yes
  • Standalone TCC: yes
  • Italic (3): works
  • Double underline (21): works
  • Overline (53): works
  • Superscript (73): ignored
  • Subscript (74): ignored
  • Parser verified by ESC[73;31m and ESC[73;3m, which correctly apply the other attributes.
 
Windows ConPTY bug.

ConPTY isn't a passthrough—conhost interprets the VT stream, maintains its own screen buffer with character attributes, and regenerates a VT stream for the terminal (TCMD or WT). Since conhost's TextAttribute model only supports a limited set of SGR codes (bold, faint, italic, underline, blink, reverse, invisible, strikethrough, double-underline, overline, and colors), SGR 73 and 74 aren't recognized. When the VT parser encounters unrecognized SGR parameters, it simply ignores them and never re-emits them downstream.
 
More information after I went back over my notes for v36:

There is a flag the CreatePseudoConsole (PSEUDOCONSOLE_PASSTHROUGH_MODE) that is supposed to pass VT sequences that Conhost doesn't recognize on to the terminal. However, even with that flag set Conhost still strips some of the "unknown" sequences, including 73/74.

So the only workaround is either to badger Microsoft to allow those sequences, or get the openconsole source and fix it yourself.
 
When version 36 first came out, I reported this problem, and you responded that it was a Windows bug. When you announced the latest version, you included among the improvements, "Expanded ANSI / VT Support: Bold, double underline, overline, subscript, and superscript text," so I thought you had found a workaround or that Microsoft had fixed the problem.
 
TCMD does support superscript and subscript -- if the console host would actually pass the sequence instead of meddling with it.

At some point the WT developers will decide they want to add superscripts & subscripts; until then I don't expect conhost to be fixed. But openhost is still a possibility.
 
I didn't have any use for those sequences, but I often test the new features you announce. It sounds as though some day, after a Windows update, those codes might suddenly start working. You've done your part.

By the way, something strange has been happening with the forum. I have gotten email messages about posts that I do not see here. One is a response from you in this thread that includes the following:

There is no officially defined ANSI sequence for supersript and subscript (and it is not supported in most terminals).​
The format TCMD uses is ESC[73 / ESC[74 / ESC[75. I have never seen the trailing ";31m" / ";3m" syntax - where did you get that and what is it supposed to do?​

I was "discussing" this issue with ChatGPT, and it suggested testing the combined sequences with ";31" and ";3" to debug what was happening with the "73" and "74" codes. Since the additional attribute changes were processed, it confirmed that the sequence was getting through and that Windows was ignoring the 74/75 codes and that it was not a parsing problem.

A post from Vince that I got by email is also not here.
 
Oh, good to know. Maybe Rex did also. With so many messages vanishing, I thought that something might have gone wrong with the forum or my settings.
 
Here's how I do the superscript and subscript in TCC under Windows Terminal;

The code;
Code:
@SETLOCAL
@ECHO OFF
set _UpOneLine=`^e[A`
set _DownOneLine=`^e[B`
set _SaveCursor=`^e[s`
set _RestoreCursor=`^e[u`
set _UnderLine=`^e[4m`
set _Inverse=`^e[7m`
set _Italic=`^e[3m`
set _Bold=`^e[1m`
set _Reset=`^e[0m`
set _SuperScript=`@char[0x00B2]`
echo %_Underline``This is underlined.``%_Reset
color bright green on black
echo.
echo %_Inverse``This is inverse.``%_Reset
color bright green on black
echo.
rem Italic does not work in stand-alone tcc.exe
rem Italic does work in Windows Terminal
echo %_Italic``This is italic.``%_Reset
color bright green on black
echo _conpty: %_conpty
echo Windows Terminal
echo _ver   : %_4ver
echo X%@char[0x00B2] + H%@char[0x2082]O
ENDLOCAL

The output;
1782949294258.webp


Learning more every day.

Joe
 
I wasn't raising the issue because I wanted to do it or couldn't figure out another way to do it; I was pointing out that a feature that was listed as being implemented in the new version of TCC was not working. What you described is a standard way to make superscripted or subscripted characters. The ANSI sequences that Rex has tried to implement in TCC are new ANSI-sequence extensions that Windows apparently is not allowing to be used.
 
Back
Top