Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
From: Sam Edge <sam_edgeZZZ@hotmail.com>
To: cygwin@cygwin.com
Subject: Re: Color Output with Printf
Date: Thu, 02 May 2002 23:12:04 +0100
Organization: .
Reply-To: cygwin@cygwin.com
Message-ID: <m5e3du87cot34rfftk4fpefk0uon21hq1a@4ax.com>
References: <Pine.SOL.4.44.0205021423370.23008-100000@argus.EECS.Berkeley.EDU>
In-Reply-To: <Pine.SOL.4.44.0205021423370.23008-100000@argus.EECS.Berkeley.EDU>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id g42MDM009162

Westley Weimer wrote in
<Pine.SOL.4.44.0205021423370.23008-100000@argus.EECS.Berkeley.EDU>
on Thu, 2 May 2002 14:41:24 -0700 (PDT):

> Clearly it is possible to get red text in a dos prompt window: cygwin does
> it somehow. My personal theory is that the normal cygwin version is doing
> some special setup before main is called that causes stdout to be treated
> differently.

I assume that a Cygwin application running directly in a console
window has its standard I/O passed through a terminal emulator inside
cygwin1.dll, yes. This appears to be using the WriteConsoleOutput
Win32 API call to write both text and attribute information to the
console window.

> I would like to get red text in a dos window without with either
> gcc -mno-cygwin or cl. Does anyone know how to do this? Does anyone know
> why "gcc" and "gcc -mno-cygwin" behave differently in this regard?

As described above, there must be a basic terminal emulator in
cygwin1.dll that provides the cygwin terminal type. If you don't link
with this then your code will end up writing directly to the console
window without setting attributes. (The console itself doesn't
understand ANSI sequences.)

For a non-Cygwin application you need to use the Win32 console output
routines. Take a look at WriteConsoleOutput and
WriteConsoleOutputAttribute in the Win32 API for setting colours.

If you don't have MSDN on CD, you should check out the on-line
version, in this case
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/conchar_9ktw.asp


-- 
Sam Edge

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

