aboutsummaryrefslogtreecommitdiff
path: root/ponysay
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-08-27 01:26:03 +0200
committerMattias Andrée <maandree@operamail.com>2012-08-27 01:26:03 +0200
commitf1e66558e478e84b4a4a3d8bf39464093d9a4876 (patch)
tree68291616136938281f2b63a00f37f83e1caf08a6 /ponysay
parent42f8d256e551c527a8d1962dddf694487cd5b36d (diff)
downloadponysay-f1e66558e478e84b4a4a3d8bf39464093d9a4876.tar.gz
ponysay-f1e66558e478e84b4a4a3d8bf39464093d9a4876.tar.bz2
ponysay-f1e66558e478e84b4a4a3d8bf39464093d9a4876.zip
message can coloured
Diffstat (limited to 'ponysay')
-rwxr-xr-xponysay18
1 files changed, 16 insertions, 2 deletions
diff --git a/ponysay b/ponysay
index 45e1d33..b0bc98b 100755
--- a/ponysay
+++ b/ponysay
@@ -1371,9 +1371,23 @@ class Backend():
msg = self.message
if wrap is not None:
msg = self.__wrapMessage(msg, wrap)
- lines = msg.split('\n')
- return self.balloon.get(width, height, lines, self.__len)
+ if '\033' in msg:
+ AUTO_PUSH = '\033[01010~'
+ AUTO_POP = '\033[10101~'
+ cstack = ColourStack(AUTO_PUSH, AUTO_POP)
+ buf = ''
+ for c in msg:
+ if c == '\n':
+ for cc in ('%s\n%s' % (AUTO_PUSH, AUTO_POP)):
+ buf += cc
+ buf += cstack.feed(cc)
+ else:
+ buf += c
+ buf += cstack.feed(c)
+ msg = buf
+
+ return self.balloon.get(width, height, msg.split('\n'), self.__len)
'''