mirror of
https://github.com/evennia/evennia.git
synced 2026-03-29 20:17:16 +02:00
Added inlinefunc, an inline text parser for custom dynamic functions,
as per #520.
This commit is contained in:
parent
ed52a0c101
commit
46edc6eef6
4 changed files with 207 additions and 1 deletions
|
|
@ -53,7 +53,7 @@ def make_iter(obj):
|
|||
return not hasattr(obj, '__iter__') and [obj] or obj
|
||||
|
||||
|
||||
def fill(text, width=78, indent=0):
|
||||
def wrap(text, width=78, indent=0):
|
||||
"""
|
||||
Safely wrap text to a certain number of characters.
|
||||
|
||||
|
|
@ -67,7 +67,22 @@ def fill(text, width=78, indent=0):
|
|||
text = to_unicode(text)
|
||||
indent = " " * indent
|
||||
return to_str(textwrap.fill(text, width, subsequent_indent=indent))
|
||||
# alias - fill
|
||||
fill = wrap
|
||||
|
||||
def pad(text, width=78, align="c", fillchar=" "):
|
||||
"""
|
||||
Pads to a given width, align is one of c,l,r
|
||||
and fillchar defaults to the empty string
|
||||
"""
|
||||
align = align if align in ('c', 'l', 'r') else 'c'
|
||||
fillchar = fillchar[0] if fillchar else " "
|
||||
if align == 'l':
|
||||
return text.ljust(width, fillchar)
|
||||
elif align == 'r':
|
||||
return text.rjust(width, fillchar)
|
||||
else:
|
||||
return text.center(width, fillchar)
|
||||
|
||||
def crop(text, width=78, suffix="[...]"):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue