delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/05/02/18:13:23

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

Westley Weimer wrote in
<Pine DOT SOL DOT 4 DOT 44 DOT 0205021423370 DOT 23008-100000 AT argus DOT EECS DOT Berkeley DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019