[Pypt-offline-general] SF.net SVN: pypt-offline: [178] trunk/pypt_core.py
Status: Beta
Brought to you by:
riteshsarraf
|
From: <rit...@us...> - 2007-08-09 21:07:56
|
Revision: 178
http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=178&view=rev
Author: riteshsarraf
Date: 2007-08-09 14:07:59 -0700 (Thu, 09 Aug 2007)
Log Message:
-----------
* Added documentation about ANSI Color Codes for ANSI Compliant Terminals
* Now it is just a matter of writing the proper call of colors.
* And here comes another Vim v/s Eclipse Editor Indentation problem.
Modified Paths:
--------------
trunk/pypt_core.py
Modified: trunk/pypt_core.py
===================================================================
--- trunk/pypt_core.py 2007-08-09 18:08:37 UTC (rev 177)
+++ trunk/pypt_core.py 2007-08-09 21:07:59 UTC (rev 178)
@@ -163,6 +163,53 @@
White = 15
Light Red = 12
Light Cyan = 11
+
+ #FIXME: The Windows Command Interpreter does support colors natively. I think that support has been since Win2k.
+
+ That's all for Windows Command Interpreter.
+
+
+ As for ANSI Compliant Terminals (which most Linux/Unix Terminals are.).....
+ I think the ANSI Color Codes would be good enough for my requirements to print colored text on an ANSI compliant terminal.
+
+ The ANSI Terminal Specification gives programs the ability to change the text color or background color.
+ An ansi code begins with the ESC character [^ (ascii 27) followed by a number (or 2 or more separated by a semicolon) and a letter.
+
+ In the case of colour codes, the trailing letter is "m"...
+
+ So as an example, we have ESC[31m ... this will change the foreground colour to red.
+
+ The codes are as follows:
+
+ For Foreground Colors
+ 1m - Hicolour (bold) mode
+ 4m - Underline (doesn't seem to work)
+ 5m - BLINK!!
+ 8m - Hidden (same colour as bg)
+ 30m - Black
+ 31m - Red
+ 32m - Green
+ 33m - Yellow
+ 34m - Blue
+ 35m - Magenta
+ 36m - Cyan
+ 37m - White
+
+ For Background Colors
+
+ 40m - Change Background to Black
+ 41m - Red
+ 42m - Green
+ 43m - Yellow
+ 44m - Blue
+ 45m - Magenta
+ 46m - Cyan
+ 47m - White
+
+ 7m - Change to Black text on a White bg
+ 0m - Turn off all attributes.
+
+ Now for example, say I wanted blinking, yellow text on a magenta background... I'd type ESC[45;33;5m
'''
def __init__(self, verbose, color = None, lock = None):
@@ -206,8 +253,8 @@
sys.stderr.write(msg)
sys.stderr.flush()
- if self.color:
- WConio.textcolor(15) #Once the error is displayed, change back to the normal color
+ if self.color:
+ WConio.textcolor(15) #Once the error is displayed, change back to the normal color
if self.lock:
self.DispLock.release()
@@ -224,8 +271,8 @@
sys.stdout.write(msg)
sys.stdout.flush()
- if self.color:
- WConio.textcolor(15) #Once the error is displayed, change back to the normal color
+ if self.color:
+ WConio.textcolor(15) #Once the error is displayed, change back to the normal color
if self.lock:
self.DispLock.release()
@@ -244,8 +291,8 @@
sys.stdout.write(msg)
sys.stdout.flush()
- if self.color:
- WConio.textcolor(15) #Once the error is displayed, change back to the normal color
+ if self.color:
+ WConio.textcolor(15) #Once the error is displayed, change back to the normal color
if self.lock:
self.DispLock.release()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|