How to? TCC/LE colour not working with RSpec

I'm trying out TCC under Windows 8.1 as part of my Ruby development environment, but I find that RSpec's --color option doesn't work in TCC/LE -- I see the control codes instead of the colours. I have ANSI colour enabled in TCC. Colour works fine in an Ansicon console (so the problem doesn't seem to be with RSpec), but I see Ansicon is not compatible with TCC.

Is there any way to get RSpec working properly with TCC, or do I have to drop the idea of using TCC?
 
May 20, 2008
3,515
4
Elkridge, MD, USA
Close to 10 years since JP Software implemented its own subset of X3.64, since Microsoft refused to include its own. Enabling "ANSI color" in TCC (both LE and licensed version) sends TCC output through this; it cannot work for other programs ANSICON is another implementation. Did you try to disable TCC's "ANSI color" ?
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
TCC's ANSI support only works for ANSI sequences generated by TCC itself. It doesn't (can't) affect other programs which happen to be running in the same console.

(Adding: ) If the program is not interactive -- if it just runs and sends its output to stdout -- then you can pipe the output through TYPE. That way, TCC can see and expand any ANSI sequences. I know nothing of RSPEC, whether it's interactive or not.
 
Last edited:
@Charles Dye That doesn't make any sense at all. The whole point of the ANSI control sequences is that any console application can send them to the console -- and RSpec is sending the control sequences to the console (I can see them), but the console isn't respecting them. All the Linux shells I know of can (and do) do it, and so does Ansicon.

RSpec is not interactive at all. It's a pure command-line application -- you give it parameters on the command line; it writes its results to STDOUT; TCC fouls up the output that RSpec has written by ignoring the ANSI control sequences.

[edit: piping through TYPE makes no difference whatsoever]
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
@Charles Dye That doesn't make any sense at all. The whole point of the ANSI control sequences is that any console application can send them to the console -- and RSpec is sending the control sequences to the console (I can see them), but the console isn't respecting them. All the Linux shells I know of can (and do) do it, and so does Ansicon.

That's as I would expect. Microsoft's console knows nothing of ANSI sequences. If RSpec sends ANSI sequences to the console, then the console will display gribble. TCC isn't involved, doesn't see RSpec's output and can't interpret it. (Just the same as running RSpec from CMD.EXE.)

[edit: piping through TYPE makes no difference whatsoever]

That is a surprise to me. If RSpec's output goes to stdout, then piping through TYPE ought to find and interpret the ANSI sequences, provided ANSI support is enabled.

If you redirect RSpec's output to a file with >OUTFILE.TXT, does the file contain the expected output, including escape sequences? And does TYPE then display it as expected, including colors?
 
@Charles Dye Sorry, I still don't understand. Where does the Microsoft console come into it? I'm running RSpec from the TCC command line, I don't have a microsoft console running at all. And if I have ANSI colours enabled in TCC, doesn't that make it an ANSI-aware console like KDE Konsole or Ansicon?

No, if I redirect the output to outfile.txt (ok, I'd already done it and called it ansi_test.bin) it strips the control sequences out completely.

Here's what the same command (rspec --color) looks like in ansicon and TCC, together with a hex dump of the redirected file showing that the control characters have been stripped.
 
May 20, 2008
11,414
99
Syracuse, NY, USA
@Charles Dye Sorry, I still don't understand. Where does the Microsoft console come into it? I'm running RSpec from the TCC command line, I don't have a microsoft console running at all.
TCC's console **is** Microsoft's console, the same console that every non-windowed program gets by default. TCC (like CMD, PowerShell, et c.) does not create the window you see. ANSICON is a windowed program. It creates its own window and implements console features in that window.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
@Charles Dye Sorry, I still don't understand. Where does the Microsoft console come into it? I'm running RSpec from the TCC command line, I don't have a microsoft console running at all.

Microsoft's console code is called whenever you run a console program, whether CMD.EXE, RSpec, or TCC. These are all Windows console programs.

And if I have ANSI colours enabled in TCC, doesn't that make it an ANSI-aware console like KDE Konsole or Ansicon?

Nope. Same old Microsoft console, with the same annoying limitations.

No, if I redirect the output to outfile.txt (ok, I'd already done it and called it ansi_test.bin) it strips the control sequences out completely.

Ah, that explains why my TYPE trick fails. Apparently RSpec is smart enough to know when its output is being redirected, and modifies its output accordingly.

The good news is that -- based on about 20 seconds of intensive testing -- ANSICON seems to work okay with TCC/LE. (At least in its default mode of launching a subshell; I didn't test the -P option.) So you can have the best of both worlds.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
ANSICON is a windowed program. It creates its own window and implements console features in that window.

I was completely unaware of ANSICON until Tim brought it to my attention. (Strange; I've used some of Jason Hood's other programs before.) But it looks like ANSICON modifies Microsoft's console support via DLL injection. Pretty cool.
 
May 20, 2008
11,414
99
Syracuse, NY, USA
I have successfully built ANSICON.DLL as a TCC plugin. If I recall correctly, with this plugin and TCC's "ANSI=No" you'd get what you want. I'll look for it, test it a bit, and make it available if you want to try it.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
I have successfully built ANSICON.DLL as a TCC plugin. If I recall correctly, with this plugin and TCC's "ANSI=No" you'd get what you want. I'll look for it, test it a bit, and make it available if you want to try it.

After some cursory testing, ANSICON.EXE -P also seems to work in TCC. Would a plugin offer any advantage over loading it that way?
 
May 20, 2008
11,414
99
Syracuse, NY, USA
I think it just injects the DLL, but you know more about it than I do. (I just read the README.TXT. One of the names in the acknowledgments looks familiar, somehow....)
Well, I tried it with CMD. With "-P" it starts a new CMD and ANSICON.EXE persists. But with "-p" it injects the DLL into the current CMD and does not persist. You're right ... it only needs to inject the DLL, nothing at all more. In fact, if I inject the DLL with my own, gereric, INJECTDLL.EXE, it works just as well.

I had forgotten about my little contribution, which came from a discussion, here, about TCC's ANSI.
 
Similar threads
Thread starter Title Forum Replies Date
Jesse Heines Request for TCC Date Command Custom Format Example TCC/LE Support 4
P TCC LE crashes without any info after recent windows updates TCC/LE Support 3
V TCC LE doesn't expand %~ff correctly TCC/LE Support 5
A vcvarsall.bat command not working on TCC LE command prompt TCC/LE Support 16
M DEBUG dialogs from TCC TCC/LE Support 1
Captain'Flam False condition in IF force loop exit (TCC/LE 14 64bits) TCC/LE Support 3
M How to get the number of chars, which fit in the currently displayed TCC-window? TCC/LE Support 3
M TCC/LE works with Windows Insider Skip Ahead Build 17618 TCC/LE Support 1
D Bug with TCC/LE and volumes mounted under directories TCC/LE Support 5
B Error in TCC/LE when succeed smoothly in native windows cmd.exe TCC/LE Support 6
A TCC/LE x64 no longer works with Windows 10 Insider Preview Build 17063 TCC/LE Support 7
adam_0 TCC/LE string replacement differing from cmd.exe TCC/LE Support 3
D Incorrect icon for TCC/LE prompt here, Windows 10 TCC/LE Support 5
B Run TCC without interactive logon TCC/LE Support 0
T WAD option /u on TCC LE 13.06.77 TCC/LE Support 2
B Copy command to set timestamp not working in TCC/LE TCC/LE Support 5
R WAD TCC/LE does not set %_ffind_files TCC/LE Support 1
P Window width TCC TCC/LE Support 3
A installer for latest tcc/le isn't working TCC/LE Support 0
M Any plans for an updated TCC/LE version TCC/LE Support 16
miXza-81 Fixed There is Batch breaking bug in TCC LE (x64) TCC/LE Support 9
M Getting started with TCC/LE TCC/LE Support 3
John A TCC/LE not finding files in the c:\windows\system32\ directory? TCC/LE Support 4
R converting from NT to TCC/LE TCC/LE Support 3
jbanaszczyk [Q] How to retrieve / set current TCC/LE language TCC/LE Support 1
T C# Process.Start() never ends when starting TCC/LE process? TCC/LE Support 5
R WAD TCC LE pipe fails TCC/LE Support 6
M TCC LE x64 13.0 crash in Win 8 Pro 64-bit TCC/LE Support 0
A ftp on tcc/le TCC/LE Support 2
B What are the TCC settings that will allow maximum cmd.exe compatibility? TCC/LE Support 11
R TCC/LE attrib +/- C? TCC/LE Support 6
S Just wondering what TCC/LE 13.05.68 fixed TCC/LE Support 1
R TCC/LE steals the .btm association? TCC/LE Support 1
S Fixed TCC-LE 13.05.65 x64 "option" command tabs broken TCC/LE Support 4
rconn News TCC/LE 13.05 Released TCC/LE Support 0
F WAD Different value for %~dpfsI in TCC/LE TCC/LE Support 2
Charles Dye ? command, TCC/LE vs. supported TCC/LE Support 3
B TCC/LE prompt here TCC/LE Support 1
G Pin TCC/LE to task bar and start menu TCC/LE Support 6
jason404 A particular program that I like to use no longer works in TCC/LE TCC/LE Support 25
rconn News TCC/LE 13.04.56 Released TCC/LE Support 0
rconn News TCC/LE 13.04.55 Released TCC/LE Support 0
F Problem with TCC window colors TCC/LE Support 3
rconn News TCC/LE Version 13.03.45 Released TCC/LE Support 0
mfarah Things from the full TCC that I'd like to see in TCC/LE. TCC/LE Support 7
N how to terminate tcc/le using /h TCC/LE Support 15
rconn News TCC/LE Version 13.03.40 Released TCC/LE Support 0
rconn News TCC/LE 13.03.39 Released TCC/LE Support 0
R How to? Add TCC Open command box here to context menu TCC/LE Support 2
rconn News TCC/LE 13.03.38 Released TCC/LE Support 0

Similar threads