aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-08-21 15:03:34 +0200
committerMattias Andrée <maandree@operamail.com>2012-08-21 15:03:34 +0200
commitef624440a8acbbbdb8ec33612aba36619b636140 (patch)
tree3fd1bfad1af8fa3ca653e59caef25127b3de1638
parent1524a8d07bd3ce583e5e5bea4b9390c52d0ef3fa (diff)
downloadponysay-ef624440a8acbbbdb8ec33612aba36619b636140.tar.gz
ponysay-ef624440a8acbbbdb8ec33612aba36619b636140.tar.bz2
ponysay-ef624440a8acbbbdb8ec33612aba36619b636140.zip
improved balloon customisation
-rwxr-xr-xponysay22
1 files changed, 16 insertions, 6 deletions
diff --git a/ponysay b/ponysay
index b1fbd27..a29a8e7 100755
--- a/ponysay
+++ b/ponysay
@@ -722,11 +722,6 @@ class Balloon():
if w < minw: w = minw
if h < minh: h = minh
- rc = []
-
- for j in range(0, len(self.n)):
- rc.append(self.nw[j] + self.n[j] * (w - len(self.nw[j]) - len(self.ne[j])) + self.ne[j])
-
if len(lines) > 1:
(ws, es) = ({0 : self.nww, len(lines) - 1 : self.sww}, {0 : self.nee, len(lines) - 1 : self.see})
for j in range(1, len(lines) - 1):
@@ -735,11 +730,26 @@ class Balloon():
else:
(ws, es) = ({0 : self.ww}, {0 : self.ee})
+ rc = []
+
+ for j in range(0, len(self.n)):
+ outer = len(self.nw[j]) + len(self.ne[j])
+ inner = len(self.nnw[j]) + len(self.nne[j])
+ if outer + inner >= w:
+ rc.append(self.nw[j] + self.nnw[j] + self.n[j] * (w - outer - inner) + self.nne[j] + self.ne[j])
+ else:
+ rc.append(self.nw[j] + self.n[j] * (w - outer) + self.ne[j])
+
for j in range(0, len(lines)):
rc.append(ws[j] + lines[j] + ' ' * (w - lencalc(lines[j]) - len(self.w) - len(self.e)) + es[j])
for j in range(0, len(self.s)):
- rc.append(self.sw[j] + self.s[j] * (w - len(self.sw[j]) - len(self.se[j])) + self.se[j])
+ outer = len(self.sw[j]) + len(self.se[j])
+ inner = len(self.ssw[j]) + len(self.sse[j])
+ if outer + inner >= w:
+ rc.append(self.sw[j] + self.ssw[j] + self.s[j] * (w - outer - inner) + self.sse[j] + self.se[j])
+ else:
+ rc.append(self.sw[j] + self.s[j] * (w - outer) + self.se[j])
return '\n'.join(rc)