Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorC. Scott Ananian <cscott@laptop.org>2007-12-11 19:35:21 (GMT)
committer C. Scott Ananian <cscott@laptop.org>2007-12-11 19:35:21 (GMT)
commit9c3472a73727c28f3920ea950690f6275549eef6 (patch)
tree7f5bbf8c38166c263cdf53f9f55b5c9e4c35aecb /library
parent3b301f699767e42d8c926dc83eff16396f06075f (diff)
Add text-color functions to console library; use them in 'jump' example.
Diffstat (limited to 'library')
-rw-r--r--library/pippy/console.py50
1 files changed, 49 insertions, 1 deletions
diff --git a/library/pippy/console.py b/library/pippy/console.py
index cdbb023..1a00c89 100644
--- a/library/pippy/console.py
+++ b/library/pippy/console.py
@@ -1,5 +1,53 @@
"""Console helpers for pippy."""
+import sys
def clear():
"""Clear screen on console."""
# magic escape sequence
- print '\x1B[H\x1B[J' # clear screen
+ sys.stdout.write('\x1B[H\x1B[J')
+
+def red():
+ """Change text color to red."""
+ # magic escape sequence.
+ sys.stdout.write('\x1B[0;31m')
+
+def green():
+ """Change text color to green."""
+ # magic escape sequence.
+ sys.stdout.write('\x1B[0;32m')
+
+def orange():
+ """Change text color to orange."""
+ # magic escape sequence.
+ sys.stdout.write('\x1B[0;33m')
+
+def blue():
+ """Change text color to blue."""
+ # magic escape sequence.
+ sys.stdout.write('\x1B[0;34m')
+
+def purple():
+ """Change text color to purple."""
+ # magic escape sequence.
+ sys.stdout.write('\x1B[0;35m')
+
+def cyan():
+ """Change text color to cyan."""
+ # magic escape sequence.
+ sys.stdout.write('\x1B[0;36m')
+
+def grey():
+ """Change text color to grey."""
+ # magic escape sequence.
+ sys.stdout.write('\x1B[0;37m')
+gray=grey
+
+def black():
+ """Change text color to blue."""
+ # magic escape sequence.
+ # ;38m seems to be identical to this one.
+ sys.stdout.write('\x1B[0;39m')
+
+def reset():
+ """Clear screen and reset text color to black."""
+ clear()
+ black()