What's TCMD's problem with ^e[0m?

May 20, 2008
11,285
95
Syracuse, NY, USA
The ANSI escape sequence ^e[0m is pretty deeply ingrained in Ubuntu. And TCMD can't handle it. It makes TCMD's text black on black (while the underlying console is OK). What exactly is the problem and can it be fixed? I can't run bash or tcsh in a tab unless I re-write all the color related code in many start-up files.
 

rconn

Administrator
Staff member
May 14, 2008
12,315
148
The problem is not TCMD, it's a bug in the Windows 10 ANSI. It's setting the console attributes to a 0 fg and a 0 bg.

I *could* do what the console is doing and automatically convert a 0/0 to a 7/0, but that doesn't seem like a particularly desirable solution.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
The problem is not TCMD, it's a bug in the Windows 10 ANSI. It's setting the console attributes to a 0 fg and a 0 bg.

I *could* do what the console is doing and automatically convert a 0/0 to a 7/0, but that doesn't seem like a particularly desirable solution.
As mentioned before, the attributes are OK in the console screen buffer. I don't understand how the visible console and its underlying buffer can be OK while TCMD gets it wrong. But apparently that's my failure to comprehend how TCMD actually reads console output. Could you get the defaults at startup and use them instead of a hard-coded 7/0? The alternative is to change every reference to ^e[0m which would be quite hard in Linux and which would break if the defaults were changed. I think colored prompts and ls listings are the default in bash and tcsh and those shells work pretty badly in TCMD.
 

rconn

Administrator
Staff member
May 14, 2008
12,315
148
As mentioned before, the attributes are OK in the console screen buffer.

No, they really aren't. The difference is when those 0/0 attributes are written to a visible console window, they get converted to a 7/0. This is a recent break in the Win 10 ANSI support.

TCMD does not convert the console attributes; it displays what is actually there. TCMD gets it right, and the visible console gets it wrong.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Are we talking about the same thing? Here's an image of a TCMD tab not showing the output of "dir /k /m *.txt" and VIEW showing the line "2019-01-13 13:30 15 greenfoo.txt" with (apparently) the correct attributes (7/0). The plugin CONIMAGE uses ReadConsoleOutput() to get the character and attributes and writes the data in raw format to a file. If I use that file and the plugin CONRESTORE (WriteConsoleOutput()) the restored text is visible in TCMD. Where are the 0/0 attributes used by TCMD coming from?

1548464427964.png
 
May 20, 2008
11,285
95
Syracuse, NY, USA
TCMD does not use ReadConsoleOutput, it uses ReadConsoleOutputCharacter and ReadConsoleOutputAttribute. And the latter does *not* autotranslate the 0/0 to a 7/0.
Somewhat amazing ... the two approaches give different results when reading the same console screen buffer! Could it be the other way around? ... 7/0 is really in the console screen buffer and ReadConsoleOutputAttribute is (incorrectly) changing that to 0/0?

I ought to be able to see that for myself ... right?
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Wow! That was pretty easy to see. After I print a bright green on black "Hello ", followed by a "normal" (?) white on black "world!", like this ...
Code:
wprintf(L"\033[32;1mHello \033[0mworld!\n");
... when I read the attributes with ReadConsoleOutputAttribute() I get
Code:
10 10 10 10 10 10 0 0 0 0 0 0
When I read them with ReadConsoleOutput() I get
Code:
10 10 10 10 10 10 7 7 7 7 7 7
Does this bug exist in the release version of Windows 10?
 

rconn

Administrator
Staff member
May 14, 2008
12,315
148
Somewhat amazing ... the two approaches give different results when reading the same console screen buffer! Could it be the other way around? ... 7/0 is really in the console screen buffer and ReadConsoleOutputAttribute is (incorrectly) changing that to 0/0?

Seems pretty unlikely that ReadConsoleOutputAttribute would only be doing that after the ^e[0m escape sequence.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Seems pretty unlikely that ReadConsoleOutputAttribute would only be doing that after the ^e[0m escape sequence.
I agree. But on the other hand, I figure what's in the console screen buffer reflects what you see and that would make 7 (the default) correct.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
But you don't *know* what's in the screen buffer. Different APIs return different things.
I'll go with "what you see is what's really there". Anything I manually put in the console screen buffer with attribute 0 is invisible. I haven't got a clue why I can see it while ReadConsoleOutputAttribute says it has attribute 0. Sadly, I suspect we'll never know what's going on.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Do you give MS any feedback? I reported the issue and sent them this little test app and pic (both attached).
 

Attachments

  • attributes.png
    attributes.png
    14.2 KB · Views: 104
  • Hello.cpp
    919 bytes · Views: 106
Similar threads
Thread starter Title Forum Replies Date
Alpengreis [TCMD v25.00.24] Small space problem with the DE translation in Prefs-GUI Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6
Alpengreis TCMD.INI: The "super hidden" problem ... Support 6
gentzel Fixed TCMD 20 beta @REGEXSUB problem Support 6
Alpengreis Fixed TCMD FileExplorer Start-Directory problem Support 4
jbanaszczyk LUA, tcmd.chm, TCC/LE problem Support 0
C TCMD: Problem attaching console Support 4
rps How to? Portable TCMD display problem Support 2
fromano Problem Installing TCMD 15.01.44 Support 2
D unzip problem in tcmd 12 b 36 Support 3
S "List" decoding problem And TCMD crash. Support 0
S "List" decoding problem And TCMD crash. Support 6
Jay Sage Problem Launching Google Earth from TCMD Support 17
E Single instance/TCMD Here problem Support 7
B Wierd install problem for TCMD 10 Support 4
vefatica Tray min'd TCMD and ACTIVATE Support 6
C How to? starting TCC/TCMD v25 Support 2
CWBillow TCC and TCMD in Powershell Support 6
kb6ojs How to? "Specified Account Already Exists" error installing TCMD v27 Support 12
CWBillow TCMD Colors Support 8
Jay Sage Issues With TCMD File Explorer Support 0
C Last TCMD that supports win 7? Support 5
gentzel TCMD background color confusion Support 6
R Upgrade TCMD 19 to TCC 26 Support 1
Alpengreis Remaining TCMD background process (v26) ... Support 19
S Windows Server version not being detected correctly in TCMD 26RC2 Support 9
G TCMD crash when copy Support 3
Joe Caverly DrawVLine results different in TCMD tab and detached TCC Support 11
Jay Sage TCMD Crashes with "tctoolbar /c /r file" Support 5
nikbackm TCMD 25 - Unregister older TCMD version Support 2
G Documentation on TCMD.INI Support 9
R New Clear Buffer in TCMD Home Menu Support 2
CWBillow Back up TCMD tabs Support 2
CWBillow Upgrade Windows 10's effect on TCMD and TCC Support 3
DrusTheAxe TCMD 24.02.49 x64 crashed due to DivideByZero :-( Support 4
A After update to 24.02.49, helpfile tcmd.chm hangs when opened Support 0
David McClelland TCMD 24 & Perl - perl thinks it's own executable is ...\TCMD24\TCC.EXE??? Support 3
dcantor How to? Can 32-bit TCC be run on a system with 64-bit TCMD and TCC installed? Support 6
W pdir returns diff results between tcc and tcmd - one is an error msg Support 5
CWBillow TCMD PowerShell Tab elevated Support 6
A How to? Copy+Paste in TCMD tabs with Ctrl-Shift-Ins? Support 5
vefatica TCMD output invisible on Win10 Support 22
J Moving from TCC v22 to TCMD v24 issues Support 3
RChrismon How to? Copy TCMD.INI to New Version Support 7
rps TCMD OPTIONS dialog Support 2
rps TCMD Tabs priority option setting Support 0
D Can we fix the scaling for TCmd? Support 14
CWBillow TCMD Tab Defs Support 4
A How to? TCMD Configuration Dialog: 'Smooth Scrolling' Option missing? Support 1
A Fixed [23.0.22]: TCMD crashes shortly after start, TCC keeps running in background Support 6

Similar threads