From 99ddfe9cd38bdfd6ba9f66d69dbf92cbb0afb627 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 21 Aug 2012 03:51:34 +0200 Subject: separate colouring for pony, balloon and link --- ponysay | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/ponysay b/ponysay index 3a4efa3..a843572 100755 --- a/ponysay +++ b/ponysay @@ -1092,27 +1092,76 @@ class ColourStack(): self.bufproto = ' ' * (self.lenpush if self.lenpush > self.lenpop else self.lenpop) self.stack = [] self.push() + self.seq = None def push(self): - self.stack = [[self.bufproto]] + self.stack + self.stack = [[self.bufproto, None, None, [False] * 9]] + self.stack if len(self.stack) == 1: - return '' - return '' + return None + old = self.stack[1] + rc = '\033[' + if old[1] is not None: rc += '39;' + if old[2] is not None: rc += '49;' + for i in range(0, 9): + if old[3][i]: + rc += '2%i;' % (i + 1) + return '' if len(rc) == 2 else (rc[:-1] + 'm') def pop(self): - return '' + old = self.stack[0] + self.stack = self.stack[1:] + rc = '\033[' + if old[1] is not None: rc += '39;' + if old[2] is not None: rc += '49;' + for i in range(0, 9): + if old[3][i]: + rc += str(i + 21) + ';' + new = self.stack[0] + if new[1] is not None: rc += new[1] + ';' + if new[2] is not None: rc += new[2] + ';' + for i in range(0, 9): + if new[3][i]: + rc += str(i + 1) + ';' + return '' if len(rc) == 2 else (rc[:-1] + 'm') def feed(self, char): + if self.seq is not None: + self.seq += char + if (char == '~') or (('a' <= char) and (char <= 'z')) or (('A' <= char) and (char <= 'Z')): + if (self.seq[0] == '[') and (self.seq[-1] == 'm'): + self.seq = self.seq[1:-1].split(';') + (i, n) = (0, len(self.seq)) + while i < n: + part = self.seq[i] + p = 0 if part == '' else int(part) + i += 1 + if p == '': self.stack[0][1:] = [None, None, [False] * 9] + elif (1 <= p) and (p <= 9): self.stack[0][3][p - 1] = True + elif (21 <= p) and (p <= 29): self.stack[0][3][p - 21] = False + elif p == 39: self.stack[0][1] = None + elif p == 40: self.stack[0][2] = None + elif (30 <= p) and (p <= 37): self.stack[0][1] = part + elif (90 <= p) and (p <= 97): self.stack[0][1] = part + elif (40 <= p) and (p <= 47): self.stack[0][2] = part + elif (100 <= p) and (p <= 107): self.stack[0][2] = part + elif p == 38: + self.stack[0][1] = '%s;%s;%s' % (part, self.seq[i], self.seq[i + 1]) + i += 2 + elif p == 48: + self.stack[0][2] = '%s;%s;%s' % (part, self.seq[i], self.seq[i + 1]) + i += 2 + self.seq = None + elif char == '\033': + self.seq = '' buf = self.stack[0][0] + buf = buf[1:] + char rc = '' - if buf[:-self.lenpush] == self.autopush: - rc = self.push() - elif buf[:-self.lenpop] == self.autopop: - rc = self.pop() - self.stack[0][0] = buf[1:] + char + if buf[-self.lenpush:] == self.autopush: rc = self.push() + elif buf[-self.lenpop:] == self.autopop: rc = self.pop() + self.stack[0][0] = buf return rc -- cgit From 24a3c06ea4ca7ebdbb709b226482ff7a5739f48a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 21 Aug 2012 03:55:51 +0200 Subject: change log update --- CHANGELOG | 8 ++++++++ manuals/ponysay.texinfo | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 1c473c9..f87bb6f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +Version 2.2 + + Full support for arbitrary positioning of balloon in pony files. + + ANSI colour sequences in pony files are applied only to the pony image, + not the balloon link or the balloon itself. + + Version 2.1.1 Nothing worth mentioning. diff --git a/manuals/ponysay.texinfo b/manuals/ponysay.texinfo index bc2989b..cbf63b1 100644 --- a/manuals/ponysay.texinfo +++ b/manuals/ponysay.texinfo @@ -8,7 +8,7 @@ @documentlanguage en @finalout @c %**end of header -@set VERSION 2.1.1 +@set VERSION 2.2 @copying This manual is for ponysay @@ -1033,6 +1033,16 @@ first pony file in common. @cindex versions @cindex previous releases +@heading Version 2.2 + +@itemize @bullet +@item +Full support for arbitrary positioning of balloon in pony files. +@item +ANSI colour sequences in pony files are applied only to the pony image, +not the balloon link or the balloon itself. +@end itemize + @heading Version 2.1.1 Nothing worth mention. -- cgit From 52fe45889ad432917336d2eb72397aa6ebd11c82 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 21 Aug 2012 04:34:56 +0200 Subject: balloon style files --- balloons/ascii.say | 30 ++++++++++++++++++++++++++++++ balloons/ascii.think | 30 ++++++++++++++++++++++++++++++ balloons/cowsay.say | 25 +++++++++++++++++++++++++ balloons/cowsay.think | 25 +++++++++++++++++++++++++ balloons/linux-vt.say | 35 +++++++++++++++++++++++++++++++++++ balloons/round.say | 35 +++++++++++++++++++++++++++++++++++ balloons/unicode.say | 35 +++++++++++++++++++++++++++++++++++ balloons/unicode.think | 25 +++++++++++++++++++++++++ 8 files changed, 240 insertions(+) create mode 100644 balloons/ascii.say create mode 100644 balloons/ascii.think create mode 100644 balloons/cowsay.say create mode 100644 balloons/cowsay.think create mode 100644 balloons/linux-vt.say create mode 100644 balloons/round.say create mode 100644 balloons/unicode.say create mode 100644 balloons/unicode.think diff --git a/balloons/ascii.say b/balloons/ascii.say new file mode 100644 index 0000000..1a9d014 --- /dev/null +++ b/balloons/ascii.say @@ -0,0 +1,30 @@ +/:/ +\:\ + +n:_ +: +s:_ +w:| +e: | + +ww:| +ee: | + +nw: +:/ +ne: +:\ +sw:\ +se:/ + +nnw:_ +: +nne:_ +: +ssw:_ +sse:_ + +nww:| +nee: | +sww:| +see: | diff --git a/balloons/ascii.think b/balloons/ascii.think new file mode 100644 index 0000000..56591d2 --- /dev/null +++ b/balloons/ascii.think @@ -0,0 +1,30 @@ +/:o +\:o + +n:_ +: +s:_ +w:( +e: ) + +ww:( +ee: ) + +nw: +:( +ne: +:) +sw:( +se:) + +nnw:_ +: +nne:_ +: +ssw:_ +sse:_ + +nww:( +nee: ) +sww:( +see: ) diff --git a/balloons/cowsay.say b/balloons/cowsay.say new file mode 100644 index 0000000..827183e --- /dev/null +++ b/balloons/cowsay.say @@ -0,0 +1,25 @@ +/:/ +\:\ + +n:_ +s:- +w:| +e: | + +ww:< +ee:> + +nw: _ +ne:_ +sw: - +se:- + +nnw:_ +nne:_ +ssw:- +sse:- + +nww:/ +nee:\ +sww:\ +see:/ diff --git a/balloons/cowsay.think b/balloons/cowsay.think new file mode 100644 index 0000000..1450bc7 --- /dev/null +++ b/balloons/cowsay.think @@ -0,0 +1,25 @@ +/:o +\:o + +n:_ +s:- +w:( +e: ) + +ww:( +ee: ) + +nw: _ +ne:_ +sw: - +se:- + +nnw:_ +nne:_ +ssw:- +sse:- + +nww:( +nee: ) +sww:( +see: ) diff --git a/balloons/linux-vt.say b/balloons/linux-vt.say new file mode 100644 index 0000000..69a14ae --- /dev/null +++ b/balloons/linux-vt.say @@ -0,0 +1,35 @@ +/:/ +\:\ + +n:─ +: +s: +:─ +w:│ +e: │ + +ww:│ +ee: │ + +nw:┌ +:│ +ne:┐ +:│ +sw:│ +:└ +se:│ +:┘ + +nnw:─ +: +nne:─ +: +ssw: +:─ +sse: +:─ + +nww:│ +nee: │ +sww:│ +see: │ diff --git a/balloons/round.say b/balloons/round.say new file mode 100644 index 0000000..01ef456 --- /dev/null +++ b/balloons/round.say @@ -0,0 +1,35 @@ +/:╱ +\:╲ + +n:─ +: +s: +:─ +w:│ +e: │ + +ww:│ +ee: │ + +nw:╭ +:│ +ne:╮ +:│ +sw:│ +:╰ +se:│ +:╯ + +nnw:─ +: +nne:─ +: +ssw: +:─ +sse: +:─ + +nww:│ +nee: │ +sww:│ +see: │ diff --git a/balloons/unicode.say b/balloons/unicode.say new file mode 100644 index 0000000..a67a7f8 --- /dev/null +++ b/balloons/unicode.say @@ -0,0 +1,35 @@ +/:╱ +\:╲ + +n:─ +: +s: +:─ +w:│ +e: │ + +ww:│ +ee: │ + +nw:┌ +:│ +ne:┐ +:│ +sw:│ +:└ +se:│ +:┘ + +nnw:─ +: +nne:─ +: +ssw: +:─ +sse: +:─ + +nww:│ +nee: │ +sww:│ +see: │ diff --git a/balloons/unicode.think b/balloons/unicode.think new file mode 100644 index 0000000..fba4c51 --- /dev/null +++ b/balloons/unicode.think @@ -0,0 +1,25 @@ +/:o +\:o + +n:⁀ +s:‿ +w:( +e: ) + +ww:( +ee: ) + +nw:) +ne:( +sw:) +se:( + +nnw:⁀ +nne:⁀ +ssw:‿ +sse:‿ + +nww:( +nee: ) +sww:( +see: ) -- cgit From 6088f793691f22c5308e9435f91a12c4c3869f7e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 21 Aug 2012 04:45:05 +0200 Subject: never wrap less than 8 --- ponysay | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ponysay b/ponysay index a843572..1f99579 100755 --- a/ponysay +++ b/ponysay @@ -958,6 +958,8 @@ class Backend(): wrap = None if self.wrapcolumn is not None: wrap = self.wrapcolumn - left + if wrap < 8: + wrap = 8 msg = self.message if wrap is not None: -- cgit From 4a55d12917eea7edb0d9d49c8d9b0564a9cbbcba Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 21 Aug 2012 13:15:01 +0200 Subject: change log update --- CHANGELOG | 2 ++ manuals/ponysay.texinfo | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index f87bb6f..3a747ec 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,8 @@ Version 2.2 ANSI colour sequences in pony files are applied only to the pony image, not the balloon link or the balloon itself. + Support for colours in the message. + Version 2.1.1 diff --git a/manuals/ponysay.texinfo b/manuals/ponysay.texinfo index cbf63b1..17ba615 100644 --- a/manuals/ponysay.texinfo +++ b/manuals/ponysay.texinfo @@ -1041,6 +1041,8 @@ Full support for arbitrary positioning of balloon in pony files. @item ANSI colour sequences in pony files are applied only to the pony image, not the balloon link or the balloon itself. +@item +Support for colours in the message. @end itemize @heading Version 2.1.1 -- cgit