mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-29 07:27:59 +01:00
split out logic for the getting the wrapping column
Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
parent
7586505f2b
commit
42cfdfd22e
1 changed files with 20 additions and 9 deletions
|
@ -916,15 +916,7 @@ class Ponysay():
|
||||||
|
|
||||||
## Get width truncation and wrapping
|
## Get width truncation and wrapping
|
||||||
widthtruncation = self.__getWidthTruncation()
|
widthtruncation = self.__getWidthTruncation()
|
||||||
messagewrap = 60
|
messagewrap = self.__getMessageWrap(args)
|
||||||
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 = gettermsize()[1]
|
|
||||||
else:
|
|
||||||
messagewrap = int(args.opts['-W'][0])
|
|
||||||
|
|
||||||
## Get balloon object
|
## Get balloon object
|
||||||
balloonfile = self.__getBalloonPath(args.opts['-b'] if args.opts['-b'] is not None else None)
|
balloonfile = self.__getBalloonPath(args.opts['-b'] if args.opts['-b'] is not None else None)
|
||||||
|
@ -1070,3 +1062,22 @@ class Ponysay():
|
||||||
if env_width is None: env_width = 'auto'
|
if env_width is None: env_width = 'auto'
|
||||||
return gettermsize()[1] if env_width not in ('yes', 'y', '1') else None
|
return gettermsize()[1] if env_width not in ('yes', 'y', '1') else None
|
||||||
|
|
||||||
|
|
||||||
|
def __getMessageWrap(self, args):
|
||||||
|
'''
|
||||||
|
Gets the message balloon wrapping column
|
||||||
|
|
||||||
|
@param args:ArgParser Command line options
|
||||||
|
@return :int? The message balloon wrapping column, or `None` if disabled
|
||||||
|
'''
|
||||||
|
messagewrap = 60
|
||||||
|
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 = gettermsize()[1]
|
||||||
|
else:
|
||||||
|
messagewrap = int(args.opts['-W'][0])
|
||||||
|
return messagewrap
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue