mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-22 04:27:58 +01:00
environment variables PONYSAY_{TYPO_LIMIT,WRAP_HYPHEN}
This commit is contained in:
parent
0a04905912
commit
03ab06b8e1
3 changed files with 41 additions and 3 deletions
|
@ -2,6 +2,10 @@ Version 3.0
|
|||
|
||||
Renamed option -F to +f and option --F to ++f.
|
||||
|
||||
Environment variable 'PONYSAY_TYPO_LIMIT' has been added.
|
||||
|
||||
Environment variable 'PONYSAY_WRAP_HYPHEN' has been added.
|
||||
|
||||
|
||||
Version 2.9
|
||||
|
||||
|
|
|
@ -610,6 +610,29 @@ ponysay how your TTY palette looks, this feature lets you get the best images
|
|||
in TTY if you have Kernel Mode Setting (KMS) support.
|
||||
|
||||
See @ref{KMS ponies} for information on how to use this.
|
||||
|
||||
@item @env{PONYSAY_TYPO_LIMIT}
|
||||
@vindex @env{PONYSAY_TYPO_LIMIT}
|
||||
@cindex auto correction
|
||||
@cindex typo correction
|
||||
@cindex spello correction
|
||||
|
||||
ponysay is able to auto correct misspelled pony names and balloon style name.
|
||||
Without consideration for transpositioning, the distance between two words are
|
||||
measured in the number of edits needed to get from one word to the other, with
|
||||
weighting on some character changes used to favour spellos over typos.
|
||||
|
||||
By default if the weighted distance is greater than 5 for the closest words,
|
||||
auto correction ignored. This limit can be changed by exporting the limit to
|
||||
@env{PONYSAY_TYPO_LIMIT}; setting the limit to zero will disable auto correction.
|
||||
|
||||
@item @env{PONYSAY_WRAP_HYPHEN}
|
||||
@vindex @env{PONYSAY_WRAP_HYPHEN}
|
||||
@cindex wrapping
|
||||
|
||||
You can export what ponysay should use instead of a hyphen when wrapping messages.
|
||||
The hythen is red by default, if you want to change the colour or other formating,
|
||||
should should do so using the option @option{--colour-hyphen} (@option{--colour-wrap}).
|
||||
@end table
|
||||
|
||||
|
||||
|
@ -2050,6 +2073,10 @@ sequences.
|
|||
@itemize @bullet
|
||||
@item
|
||||
Renamed option @option{-F} to @option{+f} and option @option{--F} to @option{++f}.
|
||||
@item
|
||||
Environment variable @env{PONYSAY_TYPO_LIMIT} has been added.
|
||||
@item
|
||||
Environment variable @env{PONYSAY_WRAP_HYPHEN} has been added.
|
||||
@end itemize
|
||||
|
||||
|
||||
|
|
13
ponysay.py
13
ponysay.py
|
@ -334,7 +334,9 @@ class Ponysay():
|
|||
if not alt:
|
||||
autocorrect = SpelloCorrecter(ponydirs, '.pony')
|
||||
(alternatives, dist) = autocorrect.correct(pony)
|
||||
if (len(alternatives) > 0) and (dist <= 5): # TODO the limit `dist` should be configureable
|
||||
limit = os.environ['PONYSAY_TYPO_LIMIT'] if 'PONYSAY_TYPO_LIMIT' in os.environ else ''
|
||||
limit = 5 if len(limit) == 0 else int(dist)
|
||||
if (len(alternatives) > 0) and (dist <= limit):
|
||||
return self.__getponypath(alternatives, True)
|
||||
sys.stderr.write('I have never heard of anypony named %s\n' % (pony));
|
||||
exit(1)
|
||||
|
@ -691,7 +693,9 @@ class Ponysay():
|
|||
if not alt:
|
||||
autocorrect = SpelloCorrecter(balloondirs, '.think' if isthink else '.say')
|
||||
(alternatives, dist) = autocorrect.correct(balloon)
|
||||
if (len(alternatives) > 0) and (dist <= 5): # TODO the limit `dist` should be configureable
|
||||
limit = os.environ['PONYSAY_TYPO_LIMIT'] if 'PONYSAY_TYPO_LIMIT' in os.environ else ''
|
||||
limit = 5 if len(limit) == 0 else int(dist)
|
||||
if (len(alternatives) > 0) and (dist <= limit):
|
||||
return self.__getballoonpath(alternatives, True)
|
||||
sys.stderr.write('That balloon style %s does not exist\n' % (balloon));
|
||||
exit(1)
|
||||
|
@ -826,10 +830,13 @@ class Ponysay():
|
|||
balloon = self.__getballoon(balloonfile) if args.opts['-o'] is None else None
|
||||
|
||||
## Get hyphen style
|
||||
hyphen = environ['PONYSAY_BOTTOM'] if 'PONYSAY_BOTTOM' in os.environ else None
|
||||
if (hyphen is None) or (len(hyphen) == 0):
|
||||
hyphen = '-'
|
||||
hyphencolour = ''
|
||||
if args.opts['--colour-wrap'] is not None:
|
||||
hyphencolour = '\033[' + ';'.join(args.opts['--colour-wrap']) + 'm'
|
||||
hyphen = '\033[31m' + hyphencolour + '-' # TODO make configurable
|
||||
hyphen = '\033[31m' + hyphencolour + hyphen
|
||||
|
||||
## Link and balloon colouring
|
||||
linkcolour = ''
|
||||
|
|
Loading…
Reference in a new issue