Merge pull request #1387 from BlauFeuer/help_more

Add setting for global CmdHelp's help_more flag
This commit is contained in:
Griatch 2017-08-08 21:28:33 +02:00 committed by GitHub
commit 7a1ed06464
2 changed files with 60 additions and 50 deletions

View file

@ -16,6 +16,7 @@ from evennia.utils.eveditor import EvEditor
from evennia.utils.utils import string_suggestions, class_from_module from evennia.utils.utils import string_suggestions, class_from_module
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS) COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
HELP_MORE = settings.HELP_MORE
# limit symbol import for API # limit symbol import for API
__all__ = ("CmdHelp", "CmdSetHelp") __all__ = ("CmdHelp", "CmdSetHelp")
@ -45,9 +46,9 @@ class CmdHelp(Command):
return_cmdset = True return_cmdset = True
# Help messages are wrapped in an EvMore call (unless using the webclient # Help messages are wrapped in an EvMore call (unless using the webclient
# with separate help popups) If you want to avoid this, simply set the # with separate help popups) If you want to avoid this, simply add
# 'help_more' flag to False. # 'HELP_MORE = False' in your settings/conf/settings.py
help_more = True help_more = HELP_MORE
# suggestion cutoff, between 0 and 1 (1 => perfect match) # suggestion cutoff, between 0 and 1 (1 => perfect match)
suggestion_cutoff = 0.6 suggestion_cutoff = 0.6
@ -197,7 +198,8 @@ class CmdHelp(Command):
# retrieve all available commands and database topics # retrieve all available commands and database topics
all_cmds = [cmd for cmd in cmdset if self.check_show_help(cmd, caller)] all_cmds = [cmd for cmd in cmdset if self.check_show_help(cmd, caller)]
all_topics = [topic for topic in HelpEntry.objects.all() if topic.access(caller, 'view', default=True)] all_topics = [topic for topic in HelpEntry.objects.all() if topic.access(caller, 'view', default=True)]
all_categories = list(set([cmd.help_category.lower() for cmd in all_cmds] + [topic.help_category.lower() for topic in all_topics])) all_categories = list(set([cmd.help_category.lower() for cmd in all_cmds] + [topic.help_category.lower()
for topic in all_topics]))
if query in ("list", "all"): if query in ("list", "all"):
# we want to list all available help entries, grouped by category # we want to list all available help entries, grouped by category
@ -221,7 +223,8 @@ class CmdHelp(Command):
if suggestion_maxnum > 0: if suggestion_maxnum > 0:
vocabulary = [cmd.key for cmd in all_cmds if cmd] + [topic.key for topic in all_topics] + all_categories vocabulary = [cmd.key for cmd in all_cmds if cmd] + [topic.key for topic in all_topics] + all_categories
[vocabulary.extend(cmd.aliases) for cmd in all_cmds] [vocabulary.extend(cmd.aliases) for cmd in all_cmds]
suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff, maxnum=suggestion_maxnum) suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff,
maxnum=suggestion_maxnum)
if sugg != query] if sugg != query]
if not suggestions: if not suggestions:
suggestions = [sugg for sugg in vocabulary if sugg != query and sugg.startswith(query)] suggestions = [sugg for sugg in vocabulary if sugg != query and sugg.startswith(query)]
@ -249,7 +252,8 @@ class CmdHelp(Command):
# try to see if a category name was entered # try to see if a category name was entered
if query in all_categories: if query in all_categories:
self.msg_help(self.format_help_list({query: [cmd.key for cmd in all_cmds if cmd.help_category == query]}, self.msg_help(self.format_help_list({query: [cmd.key for cmd in all_cmds if cmd.help_category == query]},
{query:[topic.key for topic in all_topics if topic.help_category==query]})) {query: [topic.key for topic in all_topics
if topic.help_category == query]}))
return return
# no exact matches found. Just give suggestions. # no exact matches found. Just give suggestions.
@ -263,6 +267,7 @@ def _loadhelp(caller):
else: else:
return "" return ""
def _savehelp(caller, buffer): def _savehelp(caller, buffer):
entry = caller.db._editing_help entry = caller.db._editing_help
caller.msg("Saved help entry.") caller.msg("Saved help entry.")
@ -274,6 +279,7 @@ def _quithelp(caller):
caller.msg("Closing the editor.") caller.msg("Closing the editor.")
del caller.db._editing_help del caller.db._editing_help
class CmdSetHelp(COMMAND_DEFAULT_CLASS): class CmdSetHelp(COMMAND_DEFAULT_CLASS):
""" """
Edit the help database. Edit the help database.
@ -306,7 +312,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
help_category = "Building" help_category = "Building"
def func(self): def func(self):
"Implement the function" """Implement the function"""
switches = self.switches switches = self.switches
lhslist = self.lhslist lhslist = self.lhslist

View file

@ -494,8 +494,12 @@ PERMISSION_PLAYER_DEFAULT = "Players"
# Default sizes for client window (in number of characters), if client # Default sizes for client window (in number of characters), if client
# is not supplying this on its own # is not supplying this on its own
CLIENT_DEFAULT_WIDTH = 78 CLIENT_DEFAULT_WIDTH = 78
CLIENT_DEFAULT_HEIGHT = 45 # telnet standard is 24 but does anyone use such # telnet standard height is 24; does anyone use such low-res displays anymore?
# low-res displays anymore? CLIENT_DEFAULT_HEIGHT = 45
# Help output from CmdHelp are wrapped in an EvMore call
# (excluding webclient with separate help popups). If continuous scroll
# is preferred, change 'HELP_MORE' to False. EvMORE uses CLIENT_DEFAULT_HEIGHT
HELP_MORE = True
###################################################################### ######################################################################
# Guest accounts # Guest accounts