Index: third_party/colorama/README.txt |
diff --git a/third_party/colorama/README.txt b/third_party/colorama/README.txt |
index 33467f76e933ca31a0a903b5bc3e361f0f0cb3e9..8910ba5bb529f17414de6455eb1cb1ba722cafa5 100644 |
--- a/third_party/colorama/README.txt |
+++ b/third_party/colorama/README.txt |
@@ -2,17 +2,24 @@ Download and docs: |
http://pypi.python.org/pypi/colorama |
Development: |
http://code.google.com/p/colorama |
+Discussion group: |
+ https://groups.google.com/forum/#!forum/python-colorama |
Description |
=========== |
-Makes ANSI escape character sequences, for producing colored terminal text and |
-cursor positioning, work under MS Windows. |
+Makes ANSI escape character sequences for producing colored terminal text and |
+cursor positioning work under MS Windows. |
ANSI escape character sequences have long been used to produce colored terminal |
text and cursor positioning on Unix and Macs. Colorama makes this work on |
-Windows, too. It also provides some shortcuts to help generate ANSI sequences, |
-and works fine in conjunction with any other ANSI sequence generation library, |
+Windows, too, by wrapping stdout, stripping ANSI sequences it finds (which |
+otherwise show up as gobbledygook in your output), and converting them into the |
+appropriate win32 calls to modify the state of the terminal. On other platforms, |
+Colorama does nothing. |
+ |
+Colorama also provides some shortcuts to help generate ANSI sequences |
+but works fine in conjunction with any other ANSI sequence generation library, |
such as Termcolor (http://pypi.python.org/pypi/termcolor.) |
This has the upshot of providing a simple cross-platform API for printing |
@@ -21,6 +28,11 @@ applications or libraries which use ANSI sequences to produce colored output on |
Linux or Macs can now also work on Windows, simply by calling |
``colorama.init()``. |
+An alternative approach is to install 'ansi.sys' on Windows machines, which |
+provides the same behaviour for all applications running in terminals. Colorama |
+is intended for situations where that isn't easy (e.g. maybe your app doesn't |
+have an installer.) |
+ |
Demo scripts in the source code repository prints some colored text using |
ANSI sequences. Compare their output under Gnome-terminal's built in ANSI |
handling, versus on Windows Command-Prompt using Colorama: |
@@ -39,12 +51,17 @@ These screengrabs show that Colorama on Windows does not support ANSI 'dim |
text': it looks the same as 'normal text'. |
+License |
+======= |
+ |
+Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. |
+ |
+ |
Dependencies |
============ |
None, other than Python. Tested on Python 2.5.5, 2.6.5, 2.7, 3.1.2, and 3.2 |
- |
Usage |
===== |
@@ -79,16 +96,16 @@ Cross-platform printing of colored text can then be done using Colorama's |
constant shorthand for ANSI escape sequences:: |
from colorama import Fore, Back, Style |
- print Fore.RED + 'some red text' |
- print Back.GREEN + and with a green background' |
- print Style.DIM + 'and in dim text' |
- print + Fore.RESET + Back.RESET + Style.RESET_ALL |
- print 'back to normal now' |
+ print(Fore.RED + 'some red text') |
+ print(Back.GREEN + 'and with a green background') |
+ print(Style.DIM + 'and in dim text') |
+ print(Fore.RESET + Back.RESET + Style.RESET_ALL) |
+ print('back to normal now') |
or simply by manually printing ANSI sequences from your own code:: |
- print '/033[31m' + 'some red text' |
- print '/033[30m' # and reset to default color |
+ print('/033[31m' + 'some red text') |
+ print('/033[30m' # and reset to default color) |
or Colorama can be used happily in conjunction with existing ANSI libraries |
such as Termcolor:: |
@@ -100,7 +117,7 @@ such as Termcolor:: |
init() |
# then use Termcolor for all colored text output |
- print colored('Hello, World!', 'green', 'on_red') |
+ print(colored('Hello, World!', 'green', 'on_red')) |
Available formatting constants are:: |
@@ -131,8 +148,8 @@ init(autoreset=False): |
from colorama import init |
init(autoreset=True) |
- print Fore.RED + 'some red text' |
- print 'automatically back to default color again' |
+ print(Fore.RED + 'some red text') |
+ print('automatically back to default color again') |
init(strip=None): |
Pass ``True`` or ``False`` to override whether ansi codes should be |
@@ -154,24 +171,34 @@ init(wrap=True): |
continue to work as normal. To do cross-platform colored output, you can |
use Colorama's ``AnsiToWin32`` proxy directly:: |
+ import sys |
from colorama import init, AnsiToWin32 |
init(wrap=False) |
stream = AnsiToWin32(sys.stderr).stream |
- print >>stream, Fore.BLUE + 'blue text on stderr' |
+ |
+ # Python 2 |
+ print >>stream, Fore.BLUE + 'blue text on stderr' |
+ |
+ # Python 3 |
+ print(Fore.BLUE + 'blue text on stderr', file=stream) |
Status & Known Problems |
======================= |
-I've personally only tested it on WinXP (CMD, Console2) and Ubuntu |
-(gnome-terminal, xterm), although it sounds like others are using it on other |
-platforms too. |
+I've personally only tested it on WinXP (CMD, Console2), Ubuntu |
+(gnome-terminal, xterm), and OSX. |
+ |
+Some presumably valid ANSI sequences aren't recognised (see details below) |
+but to my knowledge nobody has yet complained about this. Puzzling. |
See outstanding issues and wishlist at: |
http://code.google.com/p/colorama/issues/list |
If anything doesn't work for you, or doesn't do what you expected or hoped for, |
-I'd *love* to hear about it on that issues list. |
+I'd love to hear about it on that issues list, would be delighted by patches, |
+and would be happy to grant commit access to anyone who submits a working patch |
+or two. |
Recognised ANSI Sequences |
@@ -181,7 +208,7 @@ ANSI sequences generally take the form: |
ESC [ <param> ; <param> ... <command> |
-Where <param> is an integer, and <command> is a single letter. Zero or more |
+Where <param> is an integer, and <command> is a single letter. Zero or more |
params are passed to a <command>. If no params are passed, it is generally |
synonymous with passing a single zero. No spaces exist in the sequence, they |
have just been inserted here to make it easy to read. |
@@ -216,7 +243,7 @@ The only ANSI sequences that colorama converts into win32 calls are:: |
ESC [ 49 m # reset |
# cursor positioning |
- ESC [ x;y H # position cursor at x,y |
+ ESC [ y;x H # position cursor at x across, y down |
# clear the screen |
ESC [ mode J # clear the screen. Only mode 2 (clear entire screen) |
@@ -240,6 +267,8 @@ google code. |
Development |
=========== |
+Help and fixes welcome! Ask Jonathan for commit rights, you'll get them. |
+ |
Running tests requires: |
- Michael Foord's 'mock' module to be installed. |
@@ -255,10 +284,21 @@ The -s is required because 'nosetests' otherwise applies a proxy of its own to |
stdout, which confuses the unit tests. |
+Contact |
+======= |
+ |
+Created by Jonathan Hartley, tartley@tartley.com |
+ |
+ |
Thanks |
====== |
-Daniel Griffith for multiple fabulous patches. |
-Oscar Lesta for valuable fix to stop ANSI chars being sent to non-tty output. |
-Roger Binns, for many suggestions, valuable feedback, & bug reports. |
-Tim Golden for thought and much appreciated feedback on the initial idea. |
+| Ben Hoyt, for a magnificent fix under 64-bit Windows. |
+| Jesse@EmptySquare for submitting a fix for examples in the README. |
+| User 'jamessp', an observant documentation fix for cursor positioning. |
+| User 'vaal1239', Dave Mckee & Lackner Kristof for a tiny but much-needed Win7 fix. |
+| Julien Stuyck, for wisely suggesting Python3 compatible updates to README. |
+| Daniel Griffith for multiple fabulous patches. |
+| Oscar Lesta for valuable fix to stop ANSI chars being sent to non-tty output. |
+| Roger Binns, for many suggestions, valuable feedback, & bug reports. |
+| Tim Golden for thought and much appreciated feedback on the initial idea. |