Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 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: References: In-Reply-To: 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 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/