Permalink
Browse files

add missing ansi terminal module

  • Loading branch information...
1 parent 525bd1c commit 36d4bcec4016387db3c4a7e4eaed357c3b560b23 @darius committed May 20, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 deck-player/ansi.py
View
24 deck-player/ansi.py
@@ -0,0 +1,24 @@
+"""
+ANSI terminal control
+"""
+
+prefix = '\x1b['
+
+home = prefix + 'H'
+clear_to_bottom = prefix + 'J'
+clear_screen = prefix + '2J' + home
+clear_to_eol = prefix + 'K'
+
+def goto(x, y):
+ return prefix + ('%d;%dH' % (r, c))
+
+black, red, green, yellow, blue, magenta, cyan, white = range(8)
+
+def bright(color):
+ return 60 + color
+
+def set_foreground(color):
+ return (prefix + '%dm') % (30 + color)
+
+def set_background(color):
+ return (prefix + '%dm') % (40 + color)

0 comments on commit 36d4bce

Please sign in to comment.