autodoc.git/
traditional_manual/
chapter_9.html
Branch:
Tag:
Non-build tags
All tags
No tags
2022-07-25
2022-07-25 08:34:21 by Henrik Grubbström (Grubba) <grubba@grubba.org>
c19f5e3215c1d4fe140fd938c28d753b2b3ff1a3 (
31
lines) (+
30
/-
1
)
[
Show
|
Annotate
]
Branch:
master
Documentation
[Readline]
: Added an example of how to use.
2097:
<dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Terminfo database for a single directory.</p> </dd></dl></dd></dl></dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Readline</b></h2>
-
</dt><dd>
+
</dt><dd>
<dl class='group--doc'>
+
<dt class='head--doc'>Description</dt>
+
<dd class='body--doc'><p>Terminal-aware line-based input.</p>
+
</dd>
+
<dt class='head--doc'>Example</dt>
+
<dd class='example'><pre><p>// Get a Readline object connected to Stdio.stdin/Stdio.stdout.
+
Stdio.Readline readline = Stdio.Readline();</p>
+
<p> // Enable history.
+
string|zero history_dump = Stdio.read_file(history_file);
+
if (history_dump) {
+
readline->enable_history(history_dump/"\n");
+
} else {
+
readline->enable_history(512); // 512 lines of history.
+
}</p>
+
<p> // Add a completion handler.
+
readline->get_input_controller()->bind("\t", handle_completions);</p>
+
<p> // Output some message.
+
readline->message("Welcome to some application.\n");</p>
+
<p> // Set a prompt.
+
readline->set_prompt("> ");</p>
+
<p> // Read some input.
+
string command = readline->read();</p>
+
<p> // Save the history.
+
Stdio.write_file(history_file, readline->get_history()->encode());</p>
+
</pre></dd>
+
<dt class='head--doc'>See also</dt>
+
<dd class='body--doc'><p><code>enable_history()</code>, <code>get_history()</code>, <code>get_input_controller()</code>,
+
<code>message()</code>, <code>read()</code>, <code>set_prompt()</code></p>
+
</dd></dl>
<hr /> <dl class='group--doc'>