aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-08-20 00:48:59 +0200
committerMattias Andrée <maandree@operamail.com>2012-08-20 00:48:59 +0200
commit515b4d149efb78ea00d6e9b0201f81822752e400 (patch)
tree0e8fb3524741e2feadb7eb9601debda06ef5d5a0
parentb36f6d55272ded1f742e361e7b81599c48bf44fe (diff)
downloadponysay-515b4d149efb78ea00d6e9b0201f81822752e400.tar.gz
ponysay-515b4d149efb78ea00d6e9b0201f81822752e400.tar.bz2
ponysay-515b4d149efb78ea00d6e9b0201f81822752e400.zip
just wrapping needed
-rwxr-xr-xponysay.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/ponysay.py b/ponysay.py
index a687ecc..c7af44b 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -366,7 +366,7 @@ class Ponysay():
'''
def print_pony(self, args):
if args.message == None:
- msg = ''.join(sys.stdin.readlines()).strip()
+ msg = ''.join(sys.stdin.readlines()).rstrip()
else:
msg = args.message
@@ -801,11 +801,35 @@ class Backend():
Process all data
'''
def parse(self):
+ self.__expandMessage()
self.__loadFile()
self.__processPony()
self.__truncate()
+ def __expandMessage(self):
+ lines = self.message.split('\n')
+ buf = ''
+ for line in lines:
+ (i, n, x) = (0, len(line), 0)
+ while i < n:
+ c = line[i]
+ i += 1
+ if c == '\033':
+ colour = self.__getcolour(line, i - 1)
+ i += len(colour) - 1
+ buf += colour
+ elif c == '\t':
+ nx = 8 - (x & 7)
+ buf += ' ' * nx
+ x += nx
+ else:
+ buf += c
+ x += 1
+ buf += '\n'
+ self.message = buf[:-1]
+
+
def __loadFile(self):
ponystream = None
try: