[nem-en] colors
Alexey Borzenkov
snaury at gmail.com
Sat Jun 30 12:17:40 CEST 2007
On 6/30/07, Kamil Skalski <kamil.skalski at gmail.com> wrote:
> I think it depends on terminal (or maybe also on its settings). I use
> rxvt + cygwin and it works ok. On the contrary, the .NET 2.0
> Console.Color does not work in my setting.
Ah, now I see it (for some reason I thought that code was for linux
with mone, didn't think of rxvt). Well, rxvt is not a real Windows
console, it closes the original one and creates its own window that it
uses for emulation by redirecting standard input/output. Any console
application that uses winapi then fails (or, actually, it's not
failing, it just works on a console that is not there anymore). The
good example is running rxvt from withing Far manager, rxvt doesn't
close the original console then (or maybe it just can't) and it stays
in the background, if you then lauch another instance of Far manager
from within rxvt it shows its preudo-graphics gui in original console,
while standard output goes to rxvt window. Another example, a simple C
program, compiled with mingw:
#include <io.h>
#include <stdio.h>
int main()
{
printf("%s\n", isatty(fileno(stdout)) ? "console" : "redirected");
}
Shows "console" when I run it from normal console and "redirected"
when I run it from rxvt, because rxvt is redirecting and emulating it.
So the problem is different actually. How to determine if
System.Console.Out is tty or not? Because if System.Console.Out/Error
is tty, you can safely use Console.Color (even on linux under mono, I
believe). However when it's not tty you can't use Console.Color, and
you either use ansi color codes or no colors at all.
Best regards,
Alexey.
More information about the devel-en
mailing list