mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Allow \f to mark EvMore pagebreaks for cmds. Resolves #1585.
This commit is contained in:
parent
f4a1bf9bae
commit
83c6bb69d1
3 changed files with 28 additions and 22 deletions
|
|
@ -115,9 +115,10 @@ Web/Django standard initiative (@strikaco)
|
|||
str to bytes.
|
||||
- `evennia.MONITOR_HANDLER.all` now takes keyword argument `obj` to only retrieve monitors from that specific
|
||||
Object (rather than all monitors in the entire handler).
|
||||
|
||||
- Support adding `\f` in command doc strings to force where EvMore puts page breaks.
|
||||
|
||||
### Contribs
|
||||
|
||||
- The `extended_room` contrib saw some backwards-incompatible refactoring:
|
||||
+ All commands now begin with `CmdExtendedRoom`. So before it was `CmdExtendedLook`, now
|
||||
it's `CmdExtendedRoomLook` etc.
|
||||
|
|
|
|||
|
|
@ -2805,7 +2805,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
@spawn GOBLIN
|
||||
@spawn {"key":"goblin", "typeclass":"monster.Monster", "location":"#2"}
|
||||
@spawn/save {"key": "grunt", prototype: "goblin"};;mobs;edit:all()
|
||||
|
||||
\f
|
||||
Dictionary keys:
|
||||
|wprototype_parent |n - name of parent prototype to use. Required if typeclass is
|
||||
not set. Can be a path or a list for multiple inheritance (inherits
|
||||
|
|
|
|||
|
|
@ -171,30 +171,35 @@ class EvMore(object):
|
|||
height = max(4, session.protocol_flags.get("SCREENHEIGHT", {0: _SCREEN_HEIGHT})[0] - 4)
|
||||
width = session.protocol_flags.get("SCREENWIDTH", {0: _SCREEN_WIDTH})[0]
|
||||
|
||||
if justify_kwargs is False:
|
||||
# no justification. Simple division by line
|
||||
lines = text.split("\n")
|
||||
if "\f" in text:
|
||||
self._pages = text.split("\f")
|
||||
self._npages = len(self._pages)
|
||||
self._npos = 0
|
||||
else:
|
||||
# we must break very long lines into multiple ones
|
||||
justify_kwargs = justify_kwargs or {}
|
||||
width = justify_kwargs.get("width", width)
|
||||
justify_kwargs["width"] = width
|
||||
justify_kwargs["align"] = justify_kwargs.get("align", 'l')
|
||||
justify_kwargs["indent"] = justify_kwargs.get("indent", 0)
|
||||
if justify_kwargs is False:
|
||||
# no justification. Simple division by line
|
||||
lines = text.split("\n")
|
||||
else:
|
||||
# we must break very long lines into multiple ones
|
||||
justify_kwargs = justify_kwargs or {}
|
||||
width = justify_kwargs.get("width", width)
|
||||
justify_kwargs["width"] = width
|
||||
justify_kwargs["align"] = justify_kwargs.get("align", 'l')
|
||||
justify_kwargs["indent"] = justify_kwargs.get("indent", 0)
|
||||
|
||||
lines = []
|
||||
for line in text.split("\n"):
|
||||
if len(line) > width:
|
||||
lines.extend(justify(line, **justify_kwargs).split("\n"))
|
||||
else:
|
||||
lines.append(line)
|
||||
lines = []
|
||||
for line in text.split("\n"):
|
||||
if len(line) > width:
|
||||
lines.extend(justify(line, **justify_kwargs).split("\n"))
|
||||
else:
|
||||
lines.append(line)
|
||||
|
||||
# always limit number of chars to 10 000 per page
|
||||
height = min(10000 // max(1, width), height)
|
||||
# always limit number of chars to 10 000 per page
|
||||
height = min(10000 // max(1, width), height)
|
||||
|
||||
self._pages = ["\n".join(lines[i:i + height]) for i in range(0, len(lines), height)]
|
||||
self._npages = len(self._pages)
|
||||
self._npos = 0
|
||||
self._pages = ["\n".join(lines[i:i + height]) for i in range(0, len(lines), height)]
|
||||
self._npages = len(self._pages)
|
||||
self._npos = 0
|
||||
|
||||
if self._npages <= 1 and not always_page:
|
||||
# no need for paging; just pass-through.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue