From 89a39a84813a905e102dd2dea290ca1c007f65e8 Mon Sep 17 00:00:00 2001 From: Jonathan Piacenti Date: Thu, 26 Mar 2015 16:25:18 -0500 Subject: [PATCH] Pull line editor out of contrib and into main. --- .../{contrib => commands/default}/lineeditor.py | 16 +++++++--------- evennia/contrib/__init__.py | 2 +- evennia/settings_default.py | 5 +++++ evennia/utils/utils.py | 7 +++++++ 4 files changed, 20 insertions(+), 10 deletions(-) rename evennia/{contrib => commands/default}/lineeditor.py (98%) diff --git a/evennia/contrib/lineeditor.py b/evennia/commands/default/lineeditor.py similarity index 98% rename from evennia/contrib/lineeditor.py rename to evennia/commands/default/lineeditor.py index 10a8058eaa..73af142d91 100644 --- a/evennia/contrib/lineeditor.py +++ b/evennia/commands/default/lineeditor.py @@ -1,9 +1,6 @@ """ - Evennia Line Editor -Contribution - Griatch 2011 - This implements an advanced line editor for editing longer texts in-game. The editor mimics the command mechanisms of the VI editor as far as possible. @@ -20,7 +17,6 @@ Whereas the editor is intended to be called from other commands that requires more elaborate text editing of data, there is also a stand-alone editor command for editing Attributes at the end of this module. To use it just import and add it to your default `cmdset`. - """ import re @@ -684,8 +680,10 @@ class CmdEditor(Command): editor_key = "%s/%s" % (self.objname, self.attrname) # start editor, it will handle things from here. - self.editor = LineEditor(self.caller, - loadfunc=load_attr, - savefunc=save_attr, - quitfunc=quit_hook, - key=editor_key) + self.editor = utils.get_line_editor()( + self.caller, + loadfunc=load_attr, + savefunc=save_attr, + quitfunc=quit_hook, + key=editor_key + ) diff --git a/evennia/contrib/__init__.py b/evennia/contrib/__init__.py index f7f49437ad..d976747514 100644 --- a/evennia/contrib/__init__.py +++ b/evennia/contrib/__init__.py @@ -9,5 +9,5 @@ See README.md for more info. import evennia evennia._init() import barter, dice, extended_room, menu_login, talking_npc -import chargen, email_login, gendersub, lineeditor, menusystem, slow_exit +import chargen, email_login, gendersub, menusystem, slow_exit import tutorial_world, tutorial_examples diff --git a/evennia/settings_default.py b/evennia/settings_default.py index 963bc576f9..db5b4a56b0 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -282,6 +282,11 @@ CMDSET_PLAYER = "commands.default_cmdsets.PlayerCmdSet" # Location to search for cmdsets if full path not given CMDSET_PATHS = ["commands"] +# Line editor path. Points to a line editor class that commands may use to give +# users extended editing control. See the default path for a reference implementation +# and usage. +LINE_EDITOR = 'evennia.commands.default.lineeditor.LineEditor' + ###################################################################### # Typeclasses and other paths ###################################################################### diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index 1e31cb6fa4..caee0d94f2 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -1257,3 +1257,10 @@ def m_len(target): if inherits_from(target, basestring): return len(ANSI_PARSER.strip_mxp(target)) return len(target) + + +def get_line_editor(): + """ + Get the line editor for this game. + """ + return variable_from_module(*settings.LINE_EDITOR.rsplit('.', 1))