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.
|
str to bytes.
|
||||||
- `evennia.MONITOR_HANDLER.all` now takes keyword argument `obj` to only retrieve monitors from that specific
|
- `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).
|
Object (rather than all monitors in the entire handler).
|
||||||
|
- Support adding `\f` in command doc strings to force where EvMore puts page breaks.
|
||||||
|
|
||||||
### Contribs
|
### Contribs
|
||||||
|
|
||||||
- The `extended_room` contrib saw some backwards-incompatible refactoring:
|
- The `extended_room` contrib saw some backwards-incompatible refactoring:
|
||||||
+ All commands now begin with `CmdExtendedRoom`. So before it was `CmdExtendedLook`, now
|
+ All commands now begin with `CmdExtendedRoom`. So before it was `CmdExtendedLook`, now
|
||||||
it's `CmdExtendedRoomLook` etc.
|
it's `CmdExtendedRoomLook` etc.
|
||||||
|
|
|
||||||
|
|
@ -2805,7 +2805,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||||
@spawn GOBLIN
|
@spawn GOBLIN
|
||||||
@spawn {"key":"goblin", "typeclass":"monster.Monster", "location":"#2"}
|
@spawn {"key":"goblin", "typeclass":"monster.Monster", "location":"#2"}
|
||||||
@spawn/save {"key": "grunt", prototype: "goblin"};;mobs;edit:all()
|
@spawn/save {"key": "grunt", prototype: "goblin"};;mobs;edit:all()
|
||||||
|
\f
|
||||||
Dictionary keys:
|
Dictionary keys:
|
||||||
|wprototype_parent |n - name of parent prototype to use. Required if typeclass is
|
|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
|
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)
|
height = max(4, session.protocol_flags.get("SCREENHEIGHT", {0: _SCREEN_HEIGHT})[0] - 4)
|
||||||
width = session.protocol_flags.get("SCREENWIDTH", {0: _SCREEN_WIDTH})[0]
|
width = session.protocol_flags.get("SCREENWIDTH", {0: _SCREEN_WIDTH})[0]
|
||||||
|
|
||||||
if justify_kwargs is False:
|
if "\f" in text:
|
||||||
# no justification. Simple division by line
|
self._pages = text.split("\f")
|
||||||
lines = text.split("\n")
|
self._npages = len(self._pages)
|
||||||
|
self._npos = 0
|
||||||
else:
|
else:
|
||||||
# we must break very long lines into multiple ones
|
if justify_kwargs is False:
|
||||||
justify_kwargs = justify_kwargs or {}
|
# no justification. Simple division by line
|
||||||
width = justify_kwargs.get("width", width)
|
lines = text.split("\n")
|
||||||
justify_kwargs["width"] = width
|
else:
|
||||||
justify_kwargs["align"] = justify_kwargs.get("align", 'l')
|
# we must break very long lines into multiple ones
|
||||||
justify_kwargs["indent"] = justify_kwargs.get("indent", 0)
|
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 = []
|
lines = []
|
||||||
for line in text.split("\n"):
|
for line in text.split("\n"):
|
||||||
if len(line) > width:
|
if len(line) > width:
|
||||||
lines.extend(justify(line, **justify_kwargs).split("\n"))
|
lines.extend(justify(line, **justify_kwargs).split("\n"))
|
||||||
else:
|
else:
|
||||||
lines.append(line)
|
lines.append(line)
|
||||||
|
|
||||||
# always limit number of chars to 10 000 per page
|
# always limit number of chars to 10 000 per page
|
||||||
height = min(10000 // max(1, width), height)
|
height = min(10000 // max(1, width), height)
|
||||||
|
|
||||||
self._pages = ["\n".join(lines[i:i + height]) for i in range(0, len(lines), height)]
|
self._pages = ["\n".join(lines[i:i + height]) for i in range(0, len(lines), height)]
|
||||||
self._npages = len(self._pages)
|
self._npages = len(self._pages)
|
||||||
self._npos = 0
|
self._npos = 0
|
||||||
|
|
||||||
if self._npages <= 1 and not always_page:
|
if self._npages <= 1 and not always_page:
|
||||||
# no need for paging; just pass-through.
|
# no need for paging; just pass-through.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue