mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-25 13:57:59 +01:00
wrapping options from issue #108
This commit is contained in:
parent
994b19712a
commit
4d27b0a873
7 changed files with 32 additions and 12 deletions
|
@ -14,6 +14,8 @@ Version 2.9
|
|||
|
||||
If file descriptor 3 is definied when ponysay is executed, extra information is printed to it.
|
||||
|
||||
Arguments starting with n or i is allowed for -W.
|
||||
|
||||
|
||||
Version 2.8
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ _ponysay()
|
|||
|
||||
elif [ $prev = "-W" ] || [ $prev = "--wrap" ]; then
|
||||
cols=$(( `stty size | cut -d ' ' -f 2` - 10 ))
|
||||
COMPREPLY=( $cols $(( $cols / 2 )) 100 60 )
|
||||
COMPREPLY=( $cols $(( $cols / 2 )) 100 60 none inherit )
|
||||
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# FISH completions for ponysay
|
||||
# https://github.com/erkin/ponysay/
|
||||
#
|
||||
# fish completion for ponysay -*- shell-script -*-
|
||||
# Author: Elis Axelsson <etu AT elis DOT nu>
|
||||
|
||||
set -g ponies ('/usr/bin/ponysay' --onelist)
|
||||
|
@ -19,7 +17,7 @@ complete --command ponysay --short-option f --long-option pony --argument
|
|||
complete --command ponysay --short-option F --arguments "$xponies" --description 'extra pony'
|
||||
complete --command ponysay --short-option q --long-option quote --arguments "$quoters" --no-files --description 'pony'
|
||||
complete --command ponysay --short-option b --long-option balloon --arguments "$balloons" --no-files --description 'balloon style'
|
||||
complete --command ponysay --short-option W --long-option wrap --arguments 'Integer' --description 'specify the column when the message should be wrapped'
|
||||
complete --command ponysay --short-option W --long-option wrap --arguments 'Integer' --description 'specify the column when the message should be wrapped' ## TODO arguments `none` and `inherit` should be suggested
|
||||
complete --command ponysay --arguments 'MESSAGE'
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# zsh completion for ponysay -*- shell-script -*-
|
||||
#compdef ponysay ponythink
|
||||
_opts=(
|
||||
'(--version -v)'{-v,--version}'[Show version and exit]'
|
||||
|
@ -9,7 +10,7 @@ _opts=(
|
|||
'(-B --balloonlist)'{-B,--balloonlist}'[list balloon style names]'
|
||||
'(-b --ballon)'{-b,--balloon}'[Selecy a balloon style]: :_path_files -W '/usr/share/ponysay/balloons' -g "*(\:r)"'
|
||||
'(-c --compact)'{-c,--compat}'[Compress messages.]'
|
||||
'(-W --wrap)'{-W,--wrap}'[The screen column where the message should be wrapped]'
|
||||
'(-W --wrap)'{-W,--wrap}'[The screen column where the message should be wrapped]' # TODO arguments `none` and `inherit` should be suggested
|
||||
)
|
||||
_tty_select=(
|
||||
'(-q --quite)'{-q,--quote}'[Select ponies for MLP:FiM quotes]: :_path_files -W '/usr/share/ponysay/ttyponies' -g "*(\:r)"'
|
||||
|
|
|
@ -80,7 +80,9 @@ is added as an argument to \fI-q\fP. If one or more ponies are added as an argum
|
|||
to \fI-q\fP the pony will be selected randomly from that set of ponies.
|
||||
.TP
|
||||
.B \-W, \-\-wrap \fIcolumn\fP
|
||||
The screen column where the message should be wrapped.
|
||||
The screen column where the message should be wrapped, the balloons extra width is taken
|
||||
into consideration. If the argument is not an integer, but starts instead with \fIn\fP,
|
||||
no wrapping is done, and if it starts with \fIi\fP the width of the terminal is used.
|
||||
.TP
|
||||
.B \-A, \-\-all
|
||||
List all pony files, MLP-FiM and non-MLP-FiM, in this case the first list are MLP:FiM
|
||||
|
|
|
@ -248,7 +248,14 @@ balloon style is specified a fallback style will be used.
|
|||
@opindex @option{-W}
|
||||
@opindex @option{--wrap}
|
||||
Specify the screen column where the message should be wrapped, this is by default 40,
|
||||
as with @command{cowsay}.
|
||||
as with @command{cowsay}. If the argument is not an integer, but starts instead with
|
||||
@code{n} (for ‘none’ or ‘no’), no wrapping is done, and if it starts with @code{i}
|
||||
(for ‘inherit’) the width of the terminal is used.
|
||||
|
||||
@code{n} and @code{i} is case insensitive, so you may use @code{N} and @code{I}
|
||||
instead. Additionally, typo correction is for QWERTY and Dvorak is built in to
|
||||
@command{ponysay}; the nearest key, either to the left or to the right, depending
|
||||
on which hand is used to press the key, is also allowed.
|
||||
|
||||
@item -c
|
||||
@itemx --compress
|
||||
|
@ -2054,6 +2061,8 @@ than unlimited. Currently this cannot be modified (without editing the source co
|
|||
@item
|
||||
If file descriptor 3 is definied when @command{ponysay} is executed, extra information is
|
||||
printed to it.
|
||||
@item
|
||||
Arguments starting with @code{n} or @code{i} is allowed for @option{-W}.
|
||||
@end itemize
|
||||
|
||||
|
||||
|
|
16
ponysay.py
16
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'):
|
||||
|
|
Loading…
Reference in a new issue