blob: 97f8f1935435398fd369f13cc95d1578cbab8676 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Editor` struct in crate `rustyline`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Editor">
<title>rustyline::Editor - Rust</title>
<link rel="stylesheet" type="text/css" href="../normalize.css">
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../main.css">
</head>
<body class="rustdoc struct">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'>Struct Editor</p><div class="block items"><ul><li><a href="#methods">Methods</a></li><li><a href="#implementations">Trait Implementations</a></li></ul></div><p class='location'><a href='index.html'>rustyline</a></p><script>window.sidebarCurrent = {name: 'Editor', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>rustyline</a>::<wbr><a class="struct" href=''>Editor</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a class='srclink' href='../src/rustyline/lib.rs.html#1140-1147' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Editor&lt;C:&nbsp;<a class="trait" href="../rustyline/completion/trait.Completer.html" title="trait rustyline::completion::Completer">Completer</a>&gt; { /* fields omitted */ }</pre><div class='docblock'><p>Line editor</p>
</div>
<h2 id='methods' class='small-section-header'>
Methods<a href='#methods' class='anchor'></a>
</h2>
<h3 class='impl'><span class='in-band'><code>impl&lt;C:&nbsp;<a class="trait" href="../rustyline/completion/trait.Completer.html" title="trait rustyline::completion::Completer">Completer</a>&gt; <a class="struct" href="../rustyline/struct.Editor.html" title="struct rustyline::Editor">Editor</a>&lt;C&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1149-1243' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>fn <a href='#method.new' class='fnname'>new</a>() -&gt; <a class="struct" href="../rustyline/struct.Editor.html" title="struct rustyline::Editor">Editor</a>&lt;C&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1150-1152' title='goto source code'>[src]</a></span></h4>
<h4 id='method.with_config' class="method"><span id='with_config.v' class='invisible'><code>fn <a href='#method.with_config' class='fnname'>with_config</a>(config: <a class="struct" href="../rustyline/config/struct.Config.html" title="struct rustyline::config::Config">Config</a>) -&gt; <a class="struct" href="../rustyline/struct.Editor.html" title="struct rustyline::Editor">Editor</a>&lt;C&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1154-1164' title='goto source code'>[src]</a></span></h4>
<h4 id='method.readline' class="method"><span id='readline.v' class='invisible'><code>fn <a href='#method.readline' class='fnname'>readline</a>(&amp;mut self, prompt: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="type" href="../rustyline/type.Result.html" title="type rustyline::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1167-1182' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>This method will read a line from STDIN and will display a <code>prompt</code></p>
</div><h4 id='method.load_history' class="method"><span id='load_history.v' class='invisible'><code>fn <a href='#method.load_history' class='fnname'>load_history</a>&lt;P:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt; + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, path: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>P) -&gt; <a class="type" href="../rustyline/type.Result.html" title="type rustyline::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">()</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1185-1187' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Load the history from the specified file.</p>
</div><h4 id='method.save_history' class="method"><span id='save_history.v' class='invisible'><code>fn <a href='#method.save_history' class='fnname'>save_history</a>&lt;P:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt; + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;self, path: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>P) -&gt; <a class="type" href="../rustyline/type.Result.html" title="type rustyline::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">()</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1189-1191' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Save the history in the specified file.</p>
</div><h4 id='method.add_history_entry' class="method"><span id='add_history_entry.v' class='invisible'><code>fn <a href='#method.add_history_entry' class='fnname'>add_history_entry</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;&gt;(&amp;mut self, line: S) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1193-1195' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Add a new entry in the history.</p>
</div><h4 id='method.clear_history' class="method"><span id='clear_history.v' class='invisible'><code>fn <a href='#method.clear_history' class='fnname'>clear_history</a>(&amp;mut self)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1197-1199' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Clear history.</p>
</div><h4 id='method.get_history' class="method"><span id='get_history.v' class='invisible'><code>fn <a href='#method.get_history' class='fnname'>get_history</a>(&amp;mut self) -&gt; &amp;mut <a class="struct" href="../rustyline/history/struct.History.html" title="struct rustyline::history::History">History</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1201-1203' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Return a mutable reference to the history object.</p>
</div><h4 id='method.get_history_const' class="method"><span id='get_history_const.v' class='invisible'><code>fn <a href='#method.get_history_const' class='fnname'>get_history_const</a>(&amp;self) -&gt; &amp;<a class="struct" href="../rustyline/history/struct.History.html" title="struct rustyline::history::History">History</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1205-1207' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Return an immutable reference to the history object.</p>
</div><h4 id='method.set_completer' class="method"><span id='set_completer.v' class='invisible'><code>fn <a href='#method.set_completer' class='fnname'>set_completer</a>(&amp;mut self, completer: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;C&gt;)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1210-1212' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Register a callback function to be called for tab-completion.</p>
</div><h4 id='method.bind_sequence' class="method"><span id='bind_sequence.v' class='invisible'><code>fn <a href='#method.bind_sequence' class='fnname'>bind_sequence</a>(&amp;mut self, key_seq: <a class="enum" href="../rustyline/enum.KeyPress.html" title="enum rustyline::KeyPress">KeyPress</a>, cmd: <a class="enum" href="../rustyline/enum.Cmd.html" title="enum rustyline::Cmd">Cmd</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="../rustyline/enum.Cmd.html" title="enum rustyline::Cmd">Cmd</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1215-1217' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Bind a sequence to a command.</p>
</div><h4 id='method.unbind_sequence' class="method"><span id='unbind_sequence.v' class='invisible'><code>fn <a href='#method.unbind_sequence' class='fnname'>unbind_sequence</a>(&amp;mut self, key_seq: <a class="enum" href="../rustyline/enum.KeyPress.html" title="enum rustyline::KeyPress">KeyPress</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="../rustyline/enum.Cmd.html" title="enum rustyline::Cmd">Cmd</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1219-1221' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Remove a binding for the given sequence.</p>
</div><h4 id='method.iter' class="method"><span id='iter.v' class='invisible'><code>fn <a href='#method.iter' class='fnname'>iter</a>&lt;'a&gt;(&amp;'a mut self, prompt: &amp;'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="struct" href="../rustyline/struct.Iter.html" title="struct rustyline::Iter">Iter</a>&lt;C&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1237-1242' title='goto source code'>[src]</a></span></h4>
<div class='docblock'>
<pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rl</span> <span class="op">=</span> <span class="ident">rustyline</span>::<span class="ident">Editor</span>::<span class="op">&lt;</span>()<span class="op">&gt;</span>::<span class="ident">new</span>();
<span class="kw">for</span> <span class="ident">readline</span> <span class="kw">in</span> <span class="ident">rl</span>.<span class="ident">iter</span>(<span class="string">&quot;&gt; &quot;</span>) {
<span class="kw">match</span> <span class="ident">readline</span> {
<span class="prelude-val">Ok</span>(<span class="ident">line</span>) <span class="op">=&gt;</span> {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;Line: {}&quot;</span>, <span class="ident">line</span>);
},
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=&gt;</span> {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;Error: {:?}&quot;</span>, <span class="ident">err</span>);
<span class="kw">break</span>
}
}
}</pre>
</div></div>
<h2 id='implementations' class='small-section-header'>
Trait Implementations<a href='#implementations' class='anchor'></a>
</h2>
<h3 class='impl'><span class='in-band'><code>impl&lt;C:&nbsp;<a class="trait" href="../rustyline/completion/trait.Completer.html" title="trait rustyline::completion::Completer">Completer</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../rustyline/struct.Editor.html" title="struct rustyline::Editor">Editor</a>&lt;C&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1245-1252' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/rustyline/lib.rs.html#1246-1251' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../";
window.currentCrate = "rustyline";
</script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>