mirror of
https://github.com/evennia/evennia.git
synced 2026-03-23 00:06:30 +01:00
Fixed some errors in crop inlinefunction. Coloration does not work in nested inlinefunc outside of escaped strings ... not sure if this something worth to try to resolve or if an escaped string is just the right way to have them.
This commit is contained in:
parent
419ff1cc79
commit
786edf4677
2 changed files with 21 additions and 5 deletions
|
|
@ -388,7 +388,9 @@ INLINEFUNC_ENABLED = False
|
|||
# Only functions defined globally (and not starting with '_') in
|
||||
# these modules will be considered valid inlinefuncs. The list
|
||||
# is loaded from left-to-right, same-named functions will overload
|
||||
INLINEFUNC_MODULES = ["evennia.utils.inlinefunc", "server.conf.inlinefunc"]
|
||||
INLINEFUNC_MODULES = ["evennia.utils.inlinefunc",
|
||||
"evennia.utils.nested_inlinefuncs",
|
||||
"server.conf.inlinefunc"]
|
||||
|
||||
######################################################################
|
||||
# Default Player setup and access
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ from evennia.utils import utils
|
|||
|
||||
def pad(*args, **kwargs):
|
||||
"""
|
||||
Pad to width. pad(text, width, align, fillchar)
|
||||
Pad to width. $pad{text, width, align, fillchar}
|
||||
|
||||
"""
|
||||
text, width, align, fillchar = "", 78, 'c', ' '
|
||||
|
|
@ -85,12 +85,12 @@ def pad(*args, **kwargs):
|
|||
return utils.pad(text, width=width, align=align, fillchar=fillchar)
|
||||
|
||||
|
||||
def crop(text, *args, **kwargs):
|
||||
def crop(*args, **kwargs):
|
||||
"""
|
||||
Crop to width. crop(text, width=78, suffix='[...]')
|
||||
Crop to width. $crop{text, width=78, suffix='[...]'}
|
||||
|
||||
"""
|
||||
text = width, suffix = "", 78, "[...]"
|
||||
text, width, suffix = "", 78, "[...]"
|
||||
nargs = len(args)
|
||||
if nargs > 0:
|
||||
text = args[0]
|
||||
|
|
@ -101,6 +101,20 @@ def crop(text, *args, **kwargs):
|
|||
return utils.crop(text, width=width, suffix=suffix)
|
||||
|
||||
|
||||
def clr(*args, **kwargs):
|
||||
"""
|
||||
Colorize text. $crop{clr, text}
|
||||
|
||||
"""
|
||||
clr, text = "|n", ""
|
||||
nargs = len(args)
|
||||
if nargs > 0:
|
||||
clr = args[0]
|
||||
if nargs > 1:
|
||||
text = args[1]
|
||||
return "|" + clr.lstrip("|") + text + "|n"
|
||||
|
||||
|
||||
# we specify a default nomatch function to use if no matching func was
|
||||
# found. This will be overloaded by any nomatch function defined in
|
||||
# the imported modules.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue