aboutsummaryrefslogtreecommitdiff
path: root/ponysay.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-10-27 22:50:17 +0200
committerMattias Andrée <maandree@operamail.com>2012-10-27 22:50:17 +0200
commit4d27b0a8733980577811ff79ca217a11c5c15ac6 (patch)
treecf6d2faeaff8e3c1297a714bd408647b30920598 /ponysay.py
parent994b19712a5f9fb1cb870ebd4f583e05a08f1c32 (diff)
downloadponysay-4d27b0a8733980577811ff79ca217a11c5c15ac6.tar.gz
ponysay-4d27b0a8733980577811ff79ca217a11c5c15ac6.tar.bz2
ponysay-4d27b0a8733980577811ff79ca217a11c5c15ac6.zip
wrapping options from issue #108
Diffstat (limited to 'ponysay.py')
-rwxr-xr-xponysay.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/ponysay.py b/ponysay.py
index 51f8c72..64b835c 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -806,11 +806,19 @@ class Ponysay():
if linuxvt:
print('\033[H\033[2J', end='')
- ## Width Get truncation and wrapping
+ ## Get width truncation and wrapping
env_width = os.environ['PONYSAY_FULL_WIDTH'] if 'PONYSAY_FULL_WIDTH' in os.environ else None
if env_width is None: env_width = ''
widthtruncation = self.__gettermsize()[1] if env_width not in ('yes', 'y', '1') else None
- messagewrap = int(args.opts['-W'][0]) if args.opts['-W'] is not None else None
+ messagewrap = 40
+ if (args.opts['-W'] is not None) and (len(args.opts['-W'][0]) > 0):
+ messagewrap = args.opts['-W'][0]
+ if messagewrap[0] in 'nmsNMS': # m is left to n on QWERTY and s is left to n on Dvorak
+ messagewrap = None
+ elif messagewrap[0] in 'iouIOU': # o is left to i on QWERTY and u is right to i on Dvorak
+ messagewrap = self.__gettermsize()[1]
+ else:
+ messagewrap = int(args.opts['-W'][0])
## Get balloon object
balloonfile = self.__getballoonpath(args.opts['-b'])
@@ -833,8 +841,8 @@ class Ponysay():
## Run cowsay replacement
- backend = Backend(message = msg, ponyfile = pony, wrapcolumn = messagewrap if messagewrap is not None else 40,
- width = widthtruncation, balloon = balloon, hyphen = hyphen, linkcolour = linkcolour, ballooncolour = ballooncolour)
+ backend = Backend(message = msg, ponyfile = pony, wrapcolumn = messagewrap, width = widthtruncation,
+ balloon = balloon, hyphen = hyphen, linkcolour = linkcolour, ballooncolour = ballooncolour)
backend.parse()
output = backend.output
if output.endswith('\n'):