TYPE resets console tab settings

May 20, 2008
9,274
62
Syracuse, NY, USA
Windows 10's enhanced console allows setting the tab stops. I've suggested that TCC v25 give us some interface to this mechanism and I've been experimenting with it myself. I find that many things will cause the console's tabs to revert to the default every 8 spaces ... running any console EXE in the same console ... even running notepad (by name only, but not with START). The most surprising one (because it's internal) is TYPE. See below how the tabs are set to 4 spaces and how they're reset to 8 spaces when I type the file. The file contains "a<tab>b<tab>c ...".
2294

Rex, can you shed some light on why the tab settings change in this and other circumstances. FWIW, I'm setting the tabs using a handle obtained with CreateFile(L"CONOUT$"). I'm using WriteConsole() with ANSI escape sequences to do it and subsequently closing the handle.
 
Last edited:
May 20, 2008
9,274
62
Syracuse, NY, USA
If you have ANSI enabled, TYPE will be calling SetConsoleMode.
Does it change any settings? Is it expected to clobber tabs set with ANSI? What about notepad? Does issuing "notepad" at the prompt trigger a call to SetConsoleMode ... and (again) is that expected to clobber the tab settings?
 

rconn

Administrator
Staff member
May 14, 2008
10,974
97
Does it change any settings? Is it expected to clobber tabs set with ANSI? What about notepad? Does issuing "notepad" at the prompt trigger a call to SetConsoleMode ... and (again) is that expected to clobber the tab settings?
TYPE does a GetConsoleMode to save the original settings, then calls SetConsoleMode to restore them after it's done. There is no flag for ANSI tabs.

Executing Notepad will not trigger a call to SetConsoleMode.

As to all the rest of your questions -- I have no idea. Talk to Microsoft; it's their undocumented feature.
 
May 20, 2008
9,274
62
Syracuse, NY, USA
The escape sequences are documented in Console Virtual Terminal Sequences - Windows Console

That document also has sketchy info on enabling/disabling VT processing with SetConsoleMode().

When, from the plugin function that set the tabs, I use CreateProcess() to run notepad, the tabs settings are not clobbered.

As far as I can tell, SetConsoleMode is called on every keystroke and with every issuance of the prompt. Issuing the command "notepad" causes a few additional calls to SetConsoleMode (with a different value (0x3 vs. 0xe7) for mode). Disabling/re-enabling VT processing may well clobber the tab settings.
 
May 20, 2008
9,274
62
Syracuse, NY, USA
Well, issuing "notepad" clobbers the tab settings. I don't know enough about it to say more now. After 30 years with tabs every 8 characters, I'm eager to see what's possible. Maybe TCC will wind up helping.