From f0c07e0cbc98ffc01b59d15a0e9854b04ebc8a78 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Sun, 5 May 2019 16:20:48 +0000 Subject: [PATCH] Add a prompt generator method Move the retrieval and assembly of the prompt string fragment for active state users into its own method, paving the way for more dynamic and extensible prompts. --- mudpy/misc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mudpy/misc.py b/mudpy/misc.py index 0e7e561..b4009c9 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -661,6 +661,10 @@ class User: self.error = False self.adjust_echoing() + def prompt(self): + """"Generate and return an input prompt.""" + return self.account.get("prompt", ">") + " " + def adjust_echoing(self): """Adjust echoing to match state menu requirements.""" if mudpy.telnet.is_enabled(self, mudpy.telnet.TELOPT_ECHO, @@ -723,7 +727,7 @@ class User: if not just_prompt: output += "$(eol)" if add_prompt: - output += self.account.get("prompt", ">") + " " + output += self.prompt() mode = self.avatar.get("mode") if mode: output += "(" + mode + ") " -- 2.11.0