evennia/docs/2.x/api/evennia.utils.eveditor.html
2023-12-20 18:20:52 +01:00

587 lines
No EOL
44 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>evennia.utils.eveditor &#8212; Evennia 2.x documentation</title>
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="evennia.utils.evform" href="evennia.utils.evform.html" />
<link rel="prev" title="evennia.utils.dbserialize" href="evennia.utils.dbserialize.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="evennia.utils.evform.html" title="evennia.utils.evform"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="evennia.utils.dbserialize.html" title="evennia.utils.dbserialize"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> &#187;</li>
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> &#187;</li>
<li class="nav-item nav-item-4"><a href="evennia.utils.html" accesskey="U">evennia.utils</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">evennia.utils.eveditor</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
</a></p>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
<h4>Previous topic</h4>
<p class="topless"><a href="evennia.utils.dbserialize.html"
title="previous chapter">evennia.utils.dbserialize</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="evennia.utils.evform.html"
title="next chapter">evennia.utils.evform</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/api/evennia.utils.eveditor.md.txt"
rel="nofollow">Show Page Source</a></li>
</ul>
</div><h3>Links</h3>
<ul>
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
<li><a href="http://games.evennia.com">Game Index</a> </li>
<li>
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
<a href="https://evennia.blogspot.com/">Blog</a>
</li>
</ul>
</div>
</div>
<div class="bodywrapper">
<div class="body" role="main">
<section id="module-evennia.utils.eveditor">
<span id="evennia-utils-eveditor"></span><h1>evennia.utils.eveditor<a class="headerlink" href="#module-evennia.utils.eveditor" title="Permalink to this headline"></a></h1>
<p>EvEditor (Evennia Line Editor)</p>
<p>This implements an advanced line editor for editing longer texts in-game. The
editor mimics the command mechanisms of the “VI” editor (a famous line-by-line
editor) as far as reasonable.</p>
<p>Features of the editor:</p>
<ul class="simple">
<li><p>undo/redo.</p></li>
<li><p>edit/replace on any line of the buffer.</p></li>
<li><p>search&amp;replace text anywhere in buffer.</p></li>
<li><p>formatting of buffer, or selection, to certain width + indentations.</p></li>
<li><p>allow to echo the input or not, depending on your client.</p></li>
<li><p>in-built help</p></li>
</ul>
<p>To use the editor, just import EvEditor from this module and initialize it:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.utils.eveditor</span> <span class="kn">import</span> <span class="n">EvEditor</span>
<span class="c1"># set up an editor to edit the caller&#39;s &#39;desc&#39; Attribute</span>
<span class="k">def</span> <span class="nf">_loadfunc</span><span class="p">(</span><span class="n">caller</span><span class="p">):</span>
<span class="k">return</span> <span class="n">caller</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span>
<span class="k">def</span> <span class="nf">_savefunc</span><span class="p">(</span><span class="n">caller</span><span class="p">,</span> <span class="n">buffer</span><span class="p">):</span>
<span class="n">caller</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="n">buffer</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">def</span> <span class="nf">_quitfunc</span><span class="p">(</span><span class="n">caller</span><span class="p">):</span>
<span class="n">caller</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;Custom quit message&quot;</span><span class="p">)</span>
<span class="c1"># start the editor</span>
<span class="n">EvEditor</span><span class="p">(</span><span class="n">caller</span><span class="p">,</span> <span class="n">loadfunc</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">savefunc</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">quitfunc</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="n">persistent</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">code</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</pre></div>
</div>
<p>The editor can also be used to format Python code and be made to
survive a reload. See the <strong>EvEditor</strong> class for more details.</p>
<dl class="py class">
<dt id="evennia.utils.eveditor.CmdSaveYesNo">
<em class="property">class </em><code class="sig-prename descclassname">evennia.utils.eveditor.</code><code class="sig-name descname">CmdSaveYesNo</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#CmdSaveYesNo"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.CmdSaveYesNo" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="evennia.commands.default.muxcommand.html#evennia.commands.default.muxcommand.MuxCommand" title="evennia.commands.default.muxcommand.MuxCommand"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.commands.default.muxcommand.MuxCommand</span></code></a></p>
<p>Save the editor state on quit. This catches
nomatches (defaults to Yes), and avoid saves only if
command was given specifically as “no” or “n”.</p>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdSaveYesNo.key">
<code class="sig-name descname">key</code><em class="property"> = '__nomatch_command'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdSaveYesNo.key" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdSaveYesNo.aliases">
<code class="sig-name descname">aliases</code><em class="property"> = ['__noinput_command']</em><a class="headerlink" href="#evennia.utils.eveditor.CmdSaveYesNo.aliases" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdSaveYesNo.locks">
<code class="sig-name descname">locks</code><em class="property"> = 'cmd:all()'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdSaveYesNo.locks" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdSaveYesNo.help_cateogory">
<code class="sig-name descname">help_cateogory</code><em class="property"> = 'LineEditor'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdSaveYesNo.help_cateogory" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.CmdSaveYesNo.func">
<code class="sig-name descname">func</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#CmdSaveYesNo.func"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.CmdSaveYesNo.func" title="Permalink to this definition"></a></dt>
<dd><p>Implement the yes/no choice.</p>
</dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdSaveYesNo.help_category">
<code class="sig-name descname">help_category</code><em class="property"> = 'general'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdSaveYesNo.help_category" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdSaveYesNo.lock_storage">
<code class="sig-name descname">lock_storage</code><em class="property"> = 'cmd:all()'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdSaveYesNo.lock_storage" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdSaveYesNo.search_index_entry">
<code class="sig-name descname">search_index_entry</code><em class="property"> = {'aliases': '__noinput_command', 'category': 'general', 'key': '__nomatch_command', 'no_prefix': ' __noinput_command', 'tags': '', 'text': '\n Save the editor state on quit. This catches\n nomatches (defaults to Yes), and avoid saves only if\n command was given specifically as &quot;no&quot; or &quot;n&quot;.\n '}</em><a class="headerlink" href="#evennia.utils.eveditor.CmdSaveYesNo.search_index_entry" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="py class">
<dt id="evennia.utils.eveditor.SaveYesNoCmdSet">
<em class="property">class </em><code class="sig-prename descclassname">evennia.utils.eveditor.</code><code class="sig-name descname">SaveYesNoCmdSet</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">cmdsetobj</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">key</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#SaveYesNoCmdSet"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.SaveYesNoCmdSet" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="evennia.commands.cmdset.html#evennia.commands.cmdset.CmdSet" title="evennia.commands.cmdset.CmdSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.commands.cmdset.CmdSet</span></code></a></p>
<p>Stores the yesno question</p>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.SaveYesNoCmdSet.key">
<code class="sig-name descname">key</code><em class="property"> = 'quitsave_yesno'</em><a class="headerlink" href="#evennia.utils.eveditor.SaveYesNoCmdSet.key" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.SaveYesNoCmdSet.priority">
<code class="sig-name descname">priority</code><em class="property"> = 150</em><a class="headerlink" href="#evennia.utils.eveditor.SaveYesNoCmdSet.priority" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.SaveYesNoCmdSet.mergetype">
<code class="sig-name descname">mergetype</code><em class="property"> = 'Replace'</em><a class="headerlink" href="#evennia.utils.eveditor.SaveYesNoCmdSet.mergetype" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.SaveYesNoCmdSet.at_cmdset_creation">
<code class="sig-name descname">at_cmdset_creation</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#SaveYesNoCmdSet.at_cmdset_creation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.SaveYesNoCmdSet.at_cmdset_creation" title="Permalink to this definition"></a></dt>
<dd><p>at cmdset creation</p>
</dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.SaveYesNoCmdSet.path">
<code class="sig-name descname">path</code><em class="property"> = 'evennia.utils.eveditor.SaveYesNoCmdSet'</em><a class="headerlink" href="#evennia.utils.eveditor.SaveYesNoCmdSet.path" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="py class">
<dt id="evennia.utils.eveditor.CmdEditorBase">
<em class="property">class </em><code class="sig-prename descclassname">evennia.utils.eveditor.</code><code class="sig-name descname">CmdEditorBase</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#CmdEditorBase"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="evennia.commands.default.muxcommand.html#evennia.commands.default.muxcommand.MuxCommand" title="evennia.commands.default.muxcommand.MuxCommand"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.commands.default.muxcommand.MuxCommand</span></code></a></p>
<p>Base parent for editor commands</p>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorBase.locks">
<code class="sig-name descname">locks</code><em class="property"> = 'cmd:all()'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase.locks" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorBase.help_entry">
<code class="sig-name descname">help_entry</code><em class="property"> = 'LineEditor'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase.help_entry" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorBase.editor">
<code class="sig-name descname">editor</code><em class="property"> = None</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase.editor" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.CmdEditorBase.parse">
<code class="sig-name descname">parse</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#CmdEditorBase.parse"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase.parse" title="Permalink to this definition"></a></dt>
<dd><p>Handles pre-parsing. Editor commands are on the form</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">:</span><span class="n">cmd</span> <span class="p">[</span><span class="n">li</span><span class="p">]</span> <span class="p">[</span><span class="n">w</span><span class="p">]</span> <span class="p">[</span><span class="n">txt</span><span class="p">]</span>
</pre></div>
</div>
<p>Where all arguments are optional.</p>
<ul class="simple">
<li><dl class="simple">
<dt><strong>li</strong> - line number (int), starting from 1. This could also</dt><dd><p>be a range given as &lt;l&gt;:&lt;l&gt;.</p>
</dd>
</dl>
</li>
<li><p><strong>w</strong> - word(s) (string), could be encased in quotes.</p></li>
<li><p><strong>txt</strong> - extra text (string), could be encased in quotes.</p></li>
</ul>
</dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorBase.aliases">
<code class="sig-name descname">aliases</code><em class="property"> = []</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase.aliases" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorBase.help_category">
<code class="sig-name descname">help_category</code><em class="property"> = 'general'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase.help_category" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorBase.key">
<code class="sig-name descname">key</code><em class="property"> = 'command'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase.key" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorBase.lock_storage">
<code class="sig-name descname">lock_storage</code><em class="property"> = 'cmd:all()'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase.lock_storage" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorBase.search_index_entry">
<code class="sig-name descname">search_index_entry</code><em class="property"> = {'aliases': '', 'category': 'general', 'key': 'command', 'no_prefix': ' ', 'tags': '', 'text': '\n Base parent for editor commands\n '}</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorBase.search_index_entry" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="py class">
<dt id="evennia.utils.eveditor.CmdLineInput">
<em class="property">class </em><code class="sig-prename descclassname">evennia.utils.eveditor.</code><code class="sig-name descname">CmdLineInput</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#CmdLineInput"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.CmdLineInput" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#evennia.utils.eveditor.CmdEditorBase" title="evennia.utils.eveditor.CmdEditorBase"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.utils.eveditor.CmdEditorBase</span></code></a></p>
<p>No command match - Inputs line of text into buffer.</p>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdLineInput.key">
<code class="sig-name descname">key</code><em class="property"> = '__nomatch_command'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdLineInput.key" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdLineInput.aliases">
<code class="sig-name descname">aliases</code><em class="property"> = ['__noinput_command']</em><a class="headerlink" href="#evennia.utils.eveditor.CmdLineInput.aliases" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.CmdLineInput.func">
<code class="sig-name descname">func</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#CmdLineInput.func"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.CmdLineInput.func" title="Permalink to this definition"></a></dt>
<dd><p>Adds the line without any formatting changes.</p>
<p>If the editor handles code, it might add automatic
indentation.</p>
</dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdLineInput.help_category">
<code class="sig-name descname">help_category</code><em class="property"> = 'general'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdLineInput.help_category" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdLineInput.lock_storage">
<code class="sig-name descname">lock_storage</code><em class="property"> = 'cmd:all()'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdLineInput.lock_storage" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdLineInput.search_index_entry">
<code class="sig-name descname">search_index_entry</code><em class="property"> = {'aliases': '__noinput_command', 'category': 'general', 'key': '__nomatch_command', 'no_prefix': ' __noinput_command', 'tags': '', 'text': '\n No command match - Inputs line of text into buffer.\n\n '}</em><a class="headerlink" href="#evennia.utils.eveditor.CmdLineInput.search_index_entry" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="py class">
<dt id="evennia.utils.eveditor.CmdEditorGroup">
<em class="property">class </em><code class="sig-prename descclassname">evennia.utils.eveditor.</code><code class="sig-name descname">CmdEditorGroup</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#CmdEditorGroup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorGroup" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#evennia.utils.eveditor.CmdEditorBase" title="evennia.utils.eveditor.CmdEditorBase"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.utils.eveditor.CmdEditorBase</span></code></a></p>
<p>Commands for the editor</p>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorGroup.key">
<code class="sig-name descname">key</code><em class="property"> = ':editor_command_group'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorGroup.key" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorGroup.aliases">
<code class="sig-name descname">aliases</code><em class="property"> = [':x', ':p', ':dd', ':&gt;', ':dw', ':wq', ':DD', ':h', ':UU', ':j', ':=', ':y', ':', ':uu', ':A', ':r', ':i', ':s', ':&lt;', ':fd', ':echo', ':!', ':f', ':w', ':fi', ':q', ':u', ':::', ':S', '::', ':I', ':q!']</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorGroup.aliases" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorGroup.arg_regex">
<code class="sig-name descname">arg_regex</code><em class="property"> = re.compile('\\s.*?|$', re.IGNORECASE)</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorGroup.arg_regex" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.CmdEditorGroup.func">
<code class="sig-name descname">func</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#CmdEditorGroup.func"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorGroup.func" title="Permalink to this definition"></a></dt>
<dd><p>This command handles all the in-editor :-style commands. Since
each command is small and very limited, this makes for a more
efficient presentation.</p>
</dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorGroup.help_category">
<code class="sig-name descname">help_category</code><em class="property"> = 'general'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorGroup.help_category" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorGroup.lock_storage">
<code class="sig-name descname">lock_storage</code><em class="property"> = 'cmd:all()'</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorGroup.lock_storage" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.CmdEditorGroup.search_index_entry">
<code class="sig-name descname">search_index_entry</code><em class="property"> = {'aliases': ':x :p :dd :&gt; :dw :wq :DD :h :UU :j := :y : :uu :A :r :i :s :&lt; :fd :echo :! :f :w :fi :q :u ::: :S :: :I :q!', 'category': 'general', 'key': ':editor_command_group', 'no_prefix': ' :x :p :dd :&gt; :dw :wq :DD :h :UU :j := :y : :uu :A :r :i :s :&lt; :fd :echo :! :f :w :fi :q :u ::: :S :: :I :q!', 'tags': '', 'text': '\n Commands for the editor\n '}</em><a class="headerlink" href="#evennia.utils.eveditor.CmdEditorGroup.search_index_entry" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="py class">
<dt id="evennia.utils.eveditor.EvEditorCmdSet">
<em class="property">class </em><code class="sig-prename descclassname">evennia.utils.eveditor.</code><code class="sig-name descname">EvEditorCmdSet</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">cmdsetobj</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">key</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditorCmdSet"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditorCmdSet" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="evennia.commands.cmdset.html#evennia.commands.cmdset.CmdSet" title="evennia.commands.cmdset.CmdSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.commands.cmdset.CmdSet</span></code></a></p>
<p>CmdSet for the editor commands</p>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.EvEditorCmdSet.key">
<code class="sig-name descname">key</code><em class="property"> = 'editorcmdset'</em><a class="headerlink" href="#evennia.utils.eveditor.EvEditorCmdSet.key" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.EvEditorCmdSet.mergetype">
<code class="sig-name descname">mergetype</code><em class="property"> = 'Replace'</em><a class="headerlink" href="#evennia.utils.eveditor.EvEditorCmdSet.mergetype" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditorCmdSet.at_cmdset_creation">
<code class="sig-name descname">at_cmdset_creation</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditorCmdSet.at_cmdset_creation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditorCmdSet.at_cmdset_creation" title="Permalink to this definition"></a></dt>
<dd><p>Hook method - this should be overloaded in the inheriting
class, and should take care of populating the cmdset by use of
self.add().</p>
</dd></dl>
<dl class="py attribute">
<dt id="evennia.utils.eveditor.EvEditorCmdSet.path">
<code class="sig-name descname">path</code><em class="property"> = 'evennia.utils.eveditor.EvEditorCmdSet'</em><a class="headerlink" href="#evennia.utils.eveditor.EvEditorCmdSet.path" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="py class">
<dt id="evennia.utils.eveditor.EvEditor">
<em class="property">class </em><code class="sig-prename descclassname">evennia.utils.eveditor.</code><code class="sig-name descname">EvEditor</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">caller</span></em>, <em class="sig-param"><span class="n">loadfunc</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">savefunc</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">quitfunc</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">key</span><span class="o">=</span><span class="default_value">''</span></em>, <em class="sig-param"><span class="n">persistent</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">codefunc</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>This defines a line editor object. It creates all relevant commands
and tracks the current state of the buffer. It also cleans up after
itself.</p>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.__init__">
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">caller</span></em>, <em class="sig-param"><span class="n">loadfunc</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">savefunc</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">quitfunc</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">key</span><span class="o">=</span><span class="default_value">''</span></em>, <em class="sig-param"><span class="n">persistent</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">codefunc</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Launches a full in-game line editor, mimicking the functionality of VIM.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>caller</strong> (<em>Object</em>) Who is using the editor.</p></li>
<li><p><strong>loadfunc</strong> (<em>callable</em><em>, </em><em>optional</em>) This will be called as
<strong>loadfunc(caller)</strong> when the editor is first started. Its
return will be used as the editors starting buffer.</p></li>
<li><p><strong>savefunc</strong> (<em>callable</em><em>, </em><em>optional</em>) This will be called as
<strong>savefunc(caller, buffer)</strong> when the save-command is given and
is used to actually determine where/how result is saved.
It should return <strong>True</strong> if save was successful and also
handle any feedback to the user.</p></li>
<li><p><strong>quitfunc</strong> (<em>callable</em><em>, </em><em>optional</em>) This will optionally be
called as <strong>quitfunc(caller)</strong> when the editor is
exited. If defined, it should handle all wanted feedback
to the user.</p></li>
<li><p><strong>quitfunc_args</strong> (<em>tuple</em><em>, </em><em>optional</em>) Optional tuple of arguments to
supply to <strong>quitfunc</strong>.</p></li>
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>optional</em>) An optional key for naming this
session and make it unique from other editing sessions.</p></li>
<li><p><strong>persistent</strong> (<em>bool</em><em>, </em><em>optional</em>) Make the editor survive a reboot. Note
that if this is set, all callables must be possible to pickle</p></li>
<li><p><strong>codefunc</strong> (<em>bool</em><em>, </em><em>optional</em>) If given, will run the editor in code mode.
This will be called as <strong>codefunc(caller, buf)</strong>.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>In persistent mode, all the input callables (savefunc etc)
must be possible to be <em>pickled</em>, this excludes e.g.
callables that are class methods or functions defined
dynamically or as part of another function. In
non-persistent mode no such restrictions exist.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.load_buffer">
<code class="sig-name descname">load_buffer</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.load_buffer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.load_buffer" title="Permalink to this definition"></a></dt>
<dd><p>Load the buffer using the load function hook.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.get_buffer">
<code class="sig-name descname">get_buffer</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.get_buffer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.get_buffer" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><em>buffer (str)</em> The current buffer.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.update_buffer">
<code class="sig-name descname">update_buffer</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">buf</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.update_buffer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.update_buffer" title="Permalink to this definition"></a></dt>
<dd><p>This should be called when the buffer has been changed
somehow. It will handle unsaved flag and undo updating.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>buf</strong> (<em>str</em>) The text to update the buffer with.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.quit">
<code class="sig-name descname">quit</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.quit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.quit" title="Permalink to this definition"></a></dt>
<dd><p>Cleanly exit the editor.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.save_buffer">
<code class="sig-name descname">save_buffer</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.save_buffer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.save_buffer" title="Permalink to this definition"></a></dt>
<dd><p>Saves the content of the buffer.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.update_undo">
<code class="sig-name descname">update_undo</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">step</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.update_undo"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.update_undo" title="Permalink to this definition"></a></dt>
<dd><p>This updates the undo position.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>step</strong> (<em>int</em><em>, </em><em>optional</em>) The amount of steps
to progress the undo position to. This
may be a negative value for undo and
a positive value for redo.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.display_buffer">
<code class="sig-name descname">display_buffer</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">buf</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">offset</span><span class="o">=</span><span class="default_value">0</span></em>, <em class="sig-param"><span class="n">linenums</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">options</span><span class="o">=</span><span class="default_value">{'raw': False}</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.display_buffer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.display_buffer" title="Permalink to this definition"></a></dt>
<dd><p>This displays the line editor buffer, or selected parts of it.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buf</strong> (<em>str</em><em>, </em><em>optional</em>) The buffer or part of buffer to display.</p></li>
<li><p><strong>offset</strong> (<em>int</em><em>, </em><em>optional</em>) If <strong>buf</strong> is set and is not the full buffer,
<strong>offset</strong> should define the actual starting line number, to
get the linenum display right.</p></li>
<li><p><strong>linenums</strong> (<em>bool</em><em>, </em><em>optional</em>) Show line numbers in buffer.</p></li>
<li><p><strong>options</strong> raw (bool, optional): Tell protocol to not parse
formatting information.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.display_help">
<code class="sig-name descname">display_help</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.display_help"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.display_help" title="Permalink to this definition"></a></dt>
<dd><p>Shows the help entry for the editor.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.deduce_indent">
<code class="sig-name descname">deduce_indent</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">line</span></em>, <em class="sig-param"><span class="n">buffer</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.deduce_indent"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.deduce_indent" title="Permalink to this definition"></a></dt>
<dd><p>Try to deduce the level of indentation of the given line.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.decrease_indent">
<code class="sig-name descname">decrease_indent</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.decrease_indent"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.decrease_indent" title="Permalink to this definition"></a></dt>
<dd><p>Decrease automatic indentation by 1 level.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.increase_indent">
<code class="sig-name descname">increase_indent</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.increase_indent"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.increase_indent" title="Permalink to this definition"></a></dt>
<dd><p>Increase automatic indentation by 1 level.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.utils.eveditor.EvEditor.swap_autoindent">
<code class="sig-name descname">swap_autoindent</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/eveditor.html#EvEditor.swap_autoindent"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.utils.eveditor.EvEditor.swap_autoindent" title="Permalink to this definition"></a></dt>
<dd><p>Swap automatic indentation on or off.</p>
</dd></dl>
</dd></dl>
</section>
</div>
</div>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="evennia.utils.evform.html" title="evennia.utils.evform"
>next</a> |</li>
<li class="right" >
<a href="evennia.utils.dbserialize.html" title="evennia.utils.dbserialize"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> &#187;</li>
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> &#187;</li>
<li class="nav-item nav-item-4"><a href="evennia.utils.html" >evennia.utils</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">evennia.utils.eveditor</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2023, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>