diff options
author | Chris Ball <cjb@pullcord.laptop.org> | 2007-12-13 18:16:54 (GMT) |
---|---|---|
committer | Chris Ball <cjb@pullcord.laptop.org> | 2007-12-13 18:21:53 (GMT) |
commit | 0a0d707f09c83df113c81e78d93fecaad4ffd64a (patch) | |
tree | 26860d5142b5722f60250fa8961923c0299bddf2 | |
parent | 756748678eee93c7bc0c27cb9def26e59a1db1f0 (diff) |
Add pippy.console.size() to get rows/cols, make "thanks" use it.
-rw-r--r-- | data/string/thanks | 10 | ||||
-rw-r--r-- | library/pippy/console.py | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/data/string/thanks b/data/string/thanks index c771192..406f1d5 100644 --- a/data/string/thanks +++ b/data/string/thanks @@ -22,12 +22,18 @@ import random, time from pippy.console import * from textwrap import fill +# Determine the number of columns in our window in +# order to wrap text to that width -- this changes +# when we run as a standalone activity instead of +# inside the output pane. +lines, cols = size().split(" ") + while True: reset() - print fill("OLPC would like to take this opportunity to acknowledge the community of people and projects that have made the XO laptop possible.", 68) + print fill("OLPC would like to take this opportunity to acknowledge the community of people and projects that have made the XO laptop possible.", int(cols)) subsystem = random.choice(table.keys()) random.choice([red, green, orange, blue, purple, cyan])() - print '\n', fill("%s: %s" % (subsystem, table[subsystem]), 68) + print '\n', fill("%s: %s" % (subsystem, table[subsystem]), int(cols)) time.sleep(3) diff --git a/library/pippy/console.py b/library/pippy/console.py index 1a00c89..3500093 100644 --- a/library/pippy/console.py +++ b/library/pippy/console.py @@ -1,10 +1,14 @@ """Console helpers for pippy.""" -import sys +import sys, commands def clear(): """Clear screen on console.""" # magic escape sequence sys.stdout.write('\x1B[H\x1B[J') +def size(): + """Return the number of rows/columns in the current VTE widget.""" + return commands.getoutput("stty size") + def red(): """Change text color to red.""" # magic escape sequence. |