Move the presentation part of the 'look' command out to the new scripting system. You can now make different scripted objects appear vastly different by overriding basicobject's return_appearance (or any of its submethods). Also fixed word wrapping, and we are now wrapping descriptions to 78 characters by default. We'll see how gracefully it handles this, and we might eventually apply it to all output.
This commit is contained in:
parent
fa4cc4cab3
commit
fadf3933af
4 changed files with 57 additions and 49 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import textwrap
|
||||
from twisted.python import log
|
||||
|
||||
import session_mgr
|
||||
|
|
@ -132,17 +133,9 @@ def announce_all(message, with_ann_prefix=True):
|
|||
|
||||
def word_wrap(text, width=78):
|
||||
"""
|
||||
A word-wrap function that preserves existing line breaks
|
||||
and most spaces in the text. Expects that existing line
|
||||
breaks are posix newlines (\n).
|
||||
|
||||
Function originally by Mike Brown
|
||||
Wrap text to a certain number of characters.
|
||||
|
||||
text: (str) The text to wrap.
|
||||
width: (int) The number of characters to wrap to.
|
||||
"""
|
||||
return reduce(lambda line, word, width=width: '%s%s%s' %
|
||||
(line,
|
||||
' \n'[(len(line)-line.rfind('\n')-1
|
||||
+ len(word.split('\n',1)[0]
|
||||
) >= width)],
|
||||
word),
|
||||
text.split(' ')
|
||||
)
|
||||
return '\r\n'.join(textwrap.wrap(text, width))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue