/usr/share/doc/liblwt-ocaml-dev/api/Lwt_read_line.html is in liblwt-ocaml-doc 2.4.3-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="Lwt_term.html">
<link rel="next" href="Lwt_top.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class attributes" rel=Appendix href="index_attributes.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of class types" rel=Appendix href="index_class_types.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Lwt_condition" rel="Chapter" href="Lwt_condition.html">
<link title="Lwt_list" rel="Chapter" href="Lwt_list.html">
<link title="Lwt" rel="Chapter" href="Lwt.html">
<link title="Lwt_mutex" rel="Chapter" href="Lwt_mutex.html">
<link title="Lwt_mvar" rel="Chapter" href="Lwt_mvar.html">
<link title="Lwt_pool" rel="Chapter" href="Lwt_pool.html">
<link title="Lwt_sequence" rel="Chapter" href="Lwt_sequence.html">
<link title="Lwt_stream" rel="Chapter" href="Lwt_stream.html">
<link title="Lwt_switch" rel="Chapter" href="Lwt_switch.html">
<link title="Lwt_util" rel="Chapter" href="Lwt_util.html">
<link title="Lwt_pqueue" rel="Chapter" href="Lwt_pqueue.html">
<link title="Lwt_lib" rel="Chapter" href="Lwt_lib.html">
<link title="Lwt_glib" rel="Chapter" href="Lwt_glib.html">
<link title="Lwt_preemptive" rel="Chapter" href="Lwt_preemptive.html">
<link title="Lwt_event" rel="Chapter" href="Lwt_event.html">
<link title="Lwt_signal" rel="Chapter" href="Lwt_signal.html">
<link title="Lwt_react" rel="Chapter" href="Lwt_react.html">
<link title="Lwt_ssl" rel="Chapter" href="Lwt_ssl.html">
<link title="Lwt_text" rel="Chapter" href="Lwt_text.html">
<link title="Lwt_term" rel="Chapter" href="Lwt_term.html">
<link title="Lwt_read_line" rel="Chapter" href="Lwt_read_line.html">
<link title="Lwt_top" rel="Chapter" href="Lwt_top.html">
<link title="Lwt_chan" rel="Chapter" href="Lwt_chan.html">
<link title="Lwt_daemon" rel="Chapter" href="Lwt_daemon.html">
<link title="Lwt_gc" rel="Chapter" href="Lwt_gc.html">
<link title="Lwt_io" rel="Chapter" href="Lwt_io.html">
<link title="Lwt_log" rel="Chapter" href="Lwt_log.html">
<link title="Lwt_main" rel="Chapter" href="Lwt_main.html">
<link title="Lwt_process" rel="Chapter" href="Lwt_process.html">
<link title="Lwt_throttle" rel="Chapter" href="Lwt_throttle.html">
<link title="Lwt_timeout" rel="Chapter" href="Lwt_timeout.html">
<link title="Lwt_unix" rel="Chapter" href="Lwt_unix.html">
<link title="Lwt_sys" rel="Chapter" href="Lwt_sys.html">
<link title="Lwt_engine" rel="Chapter" href="Lwt_engine.html">
<link title="Lwt_bytes" rel="Chapter" href="Lwt_bytes.html">
<link title="Pa_lwt" rel="Chapter" href="Pa_lwt.html">
<link title="Pa_lwt_log" rel="Chapter" href="Pa_lwt_log.html"><link title="Definitions" rel="Section" href="#6_Definitions">
<link title="High-level functions" rel="Section" href="#6_Highlevelfunctions">
<link title="Low-level interaction" rel="Section" href="#6_Lowlevelinteraction">
<link title="Advanced use" rel="Section" href="#6_Advanceduse">
<link title="Completion" rel="Subsection" href="#8_Completion">
<link title="History" rel="Subsection" href="#8_History">
<link title="Clipboards" rel="Subsection" href="#8_Clipboards">
<title>Lwt_read_line</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Lwt_term.html" title="Lwt_term">Previous</a>
<a class="up" href="index.html" title="Index">Up</a>
<a class="post" href="Lwt_top.html" title="Lwt_top">Next</a>
</div>
<h1>Module <a href="type_Lwt_read_line.html">Lwt_read_line</a></h1>
<pre><span class="keyword">module</span> Lwt_read_line: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_read_line.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
Interactive line input<br>
</div>
<hr width="100%">
<br>
<h6 id="6_Definitions">Definitions</h6><br>
<pre><span id="EXCEPTIONInterrupt"><span class="keyword">exception</span> Interrupt</span></pre>
<div class="info ">
Exception raised when the user press <code class="code"><span class="constructor">Ctrl</span>^<span class="constructor">D</span></code><br>
</div>
<pre><span id="TYPEedition_state"><span class="keyword">type</span> <code class="type"></code>edition_state</span> = <code class="type">Text.t * Text.t</code> </pre>
<div class="info ">
An edition state, it is a pair of two UTF-8 encoded strings:
<p>
<ul>
<li>the input before the cursor</li>
<li>the input after the cursor</li>
</ul>
<br>
</div>
<pre><span id="TYPEprompt"><span class="keyword">type</span> <code class="type"></code>prompt</span> = <code class="type"><a href="Lwt_term.html#TYPEstyled_text">Lwt_term.styled_text</a></code> </pre>
<div class="info ">
A prompt. It may contains colors.<br>
</div>
<pre><span id="TYPEtext_set"><span class="keyword">type</span> <code class="type"></code>text_set</span> = <code class="type">Set.Make(Text).t</code> </pre>
<br>
<div class="h8" id="8_Completion">Completion</div><br>
<pre><code><span id="TYPEcompletion_result"><span class="keyword">type</span> <code class="type"></code>completion_result</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcompletion_result.comp_state">comp_state</span> : <code class="type"><a href="Lwt_read_line.html#TYPEedition_state">edition_state</a></code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The new edition state</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcompletion_result.comp_words">comp_words</span> : <code class="type"><a href="Lwt_read_line.html#TYPEtext_set">text_set</a></code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A list of possibilities</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
}
<div class="info ">
Result of a completion function:<br>
</div>
<pre><span id="TYPEcompletion"><span class="keyword">type</span> <code class="type"></code>completion</span> = <code class="type"><a href="Lwt_read_line.html#TYPEedition_state">edition_state</a> -> <a href="Lwt_read_line.html#TYPEcompletion_result">completion_result</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code> </pre>
<div class="info ">
Type of a completion function. It takes as argument the
current edition state.
<p>
Note: the thread launched by the completion function is
cancelled using <a href="Lwt.html#VALcancel"><code class="code"><span class="constructor">Lwt</span>.cancel</code></a> if the user continue typing
text.<br>
</div>
<pre><span id="VALlookup"><span class="keyword">val</span> lookup</span> : <code class="type">Text.t -> <a href="Lwt_read_line.html#TYPEtext_set">text_set</a> -> Text.t * <a href="Lwt_read_line.html#TYPEtext_set">text_set</a></code></pre><div class="info ">
<code class="code">lookup word words</code> lookup for completion of <code class="code">word</code> into
<code class="code">words</code>. It returns <code class="code">(prefix, possibilities)</code> where
<code class="code">possibilities</code> are all words starting with <code class="code">word</code> and <code class="code">prefix</code>
is the longest common prefix of <code class="code">possibilities</code>.<br>
</div>
<pre><span id="VALcomplete"><span class="keyword">val</span> complete</span> : <code class="type">?suffix:Text.t -><br> Text.t -><br> Text.t -> Text.t -> <a href="Lwt_read_line.html#TYPEtext_set">text_set</a> -> <a href="Lwt_read_line.html#TYPEcompletion_result">completion_result</a></code></pre><div class="info ">
<code class="code">complete ?suffix before word after words</code> basic completion
functions. <code class="code">words</code> is a list of possible completions for
<code class="code">word</code>.
<p>
If completion succeed <code class="code">suffix</code> is append to the resulting
text. It defaults to <code class="code"><span class="string">" "</span></code>.<br>
</div>
<pre><span id="VALprint_words"><span class="keyword">val</span> print_words</span> : <code class="type"><a href="Lwt_text.html#TYPEoutput_channel">Lwt_text.output_channel</a> -> int -> string list -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">print_words oc columns strs</code> pretty-prints a list of words.<br>
</div>
<br>
<div class="h8" id="8_History">History</div><br>
<pre><span id="TYPEhistory"><span class="keyword">type</span> <code class="type"></code>history</span> = <code class="type">Text.t list</code> </pre>
<div class="info ">
Type of an history<br>
</div>
<pre><span id="VALadd_entry"><span class="keyword">val</span> add_entry</span> : <code class="type">Text.t -> <a href="Lwt_read_line.html#TYPEhistory">history</a> -> <a href="Lwt_read_line.html#TYPEhistory">history</a></code></pre><div class="info ">
<code class="code">add_entry line history</code> returns the history <code class="code">history</code> plus
<code class="code">line</code> at the beginning. If <code class="code">line</code> already appears at the
beginning or contains only spaces, it is discarded.<br>
</div>
<pre><span id="VALsave_history"><span class="keyword">val</span> save_history</span> : <code class="type">string -> <a href="Lwt_read_line.html#TYPEhistory">history</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">save_history filename history</code> saves <code class="code">history</code> to
<code class="code">filename</code>. History is saved by separating lines with a null
character.<br>
</div>
<pre><span id="VALload_history"><span class="keyword">val</span> load_history</span> : <code class="type">string -> <a href="Lwt_read_line.html#TYPEhistory">history</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">load_history filename</code> loads history from <code class="code">filename</code>. Returns
the empty history if the the file does not exit.<br>
</div>
<br>
<div class="h8" id="8_Clipboards">Clipboards</div><br>
<pre><span name="TYPEclipboard"><span class="keyword">class</span> <a href="Lwt_read_line.clipboard-c.html">clipboard</a></span> : <code class="type"></code><code class="code"><span class="keyword">object</span></code> <a href="Lwt_read_line.clipboard-c.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
Type of a clipboard.
</div>
<pre><span id="VALclipboard"><span class="keyword">val</span> clipboard</span> : <code class="type"><a href="Lwt_read_line.clipboard-c.html">clipboard</a></code></pre><div class="info ">
The global clipboard. All read-line instances which do not use a
specific clipboard use this one.<br>
</div>
<br>
<h6 id="6_Highlevelfunctions">High-level functions</h6><br>
<pre><span id="TYPEcompletion_mode"><span class="keyword">type</span> <code class="type"></code>completion_mode</span> = <code class="type">[ `classic | `none | `real_time ]</code> </pre>
<div class="info ">
The completion mode.
<p>
<ul>
<li><code class="code"><span class="keywordsign">`</span>classic</code> means that when the user hit <code class="code"><span class="constructor">Tab</span></code> a list of
possible completions is proposed,</li>
</ul>
<ul>
<li><code class="code"><span class="keywordsign">`</span>real_time</code> means that possible completions are shown to
the user as he types, and he can navigate in them with
<code class="code"><span class="constructor">Meta</span>+left</code>, <code class="code"><span class="constructor">Meta</span>+right</code></li>
</ul>
<ul>
<li><code class="code"><span class="keywordsign">`</span>none</code> means no completion at all</li>
</ul>
<br>
</div>
<pre><span id="VALread_line"><span class="keyword">val</span> read_line</span> : <code class="type">?history:<a href="Lwt_read_line.html#TYPEhistory">history</a> -><br> ?complete:<a href="Lwt_read_line.html#TYPEcompletion">completion</a> -><br> ?clipboard:<a href="Lwt_read_line.clipboard-c.html">clipboard</a> -><br> ?mode:<a href="Lwt_read_line.html#TYPEcompletion_mode">completion_mode</a> -><br> ?prompt:<a href="Lwt_read_line.html#TYPEprompt">prompt</a> -> unit -> Text.t <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">readline ?history ?complete ?mode ?prompt ()</code> inputs some text
from the user. If input is not a terminal, it defaults to
<code class="code"><span class="constructor">Lwt_text</span>.read_line <span class="constructor">Lwt_text</span>.stdin</code>.
<p>
If<br>
</div>
<div class="param_info"><code class="code">mode</code> : contains the current completion mode. It defaults
to <code class="code"><span class="keywordsign">`</span>real_time</code>.</div>
<div class="param_info"><code class="code">prompt</code> : defaults to <code class="code"><span class="constructor">Lwt_term</span>.<span class="constructor">Text</span> <span class="string">"# "</span></code></div>
<pre><span id="TYPEpassword_style"><span class="keyword">type</span> <code class="type"></code>password_style</span> = <code class="type">[ `clear | `empty | `text of Text.t ]</code> </pre>
<div class="info ">
Style which indicate how the password is echoed to the user:
<p>
<ul>
<li>with <code class="code"><span class="keywordsign">`</span>empty</code> nothing is printed</li>
<li>with <code class="code"><span class="keywordsign">`</span>clear</code> the password is displayed has it</li>
<li>with <code class="code"><span class="keywordsign">`</span>text ch</code> all characters are replaced by <code class="code">ch</code></li>
</ul>
<br>
</div>
<pre><span id="VALread_password"><span class="keyword">val</span> read_password</span> : <code class="type">?clipboard:<a href="Lwt_read_line.clipboard-c.html">clipboard</a> -><br> ?style:<a href="Lwt_read_line.html#TYPEpassword_style">password_style</a> -><br> ?prompt:<a href="Lwt_read_line.html#TYPEprompt">prompt</a> -> unit -> Text.t <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">read_password ?clipboard ?clear ~prompt ()</code> inputs a password
from the user. This function fails if input is not a terminal.<br>
</div>
<div class="param_info"><code class="code">style</code> : defaults to <code class="code"><span class="keywordsign">`</span>text <span class="string">"*"</span></code>.</div>
<pre><span id="VALread_keyword"><span class="keyword">val</span> read_keyword</span> : <code class="type">?history:<a href="Lwt_read_line.html#TYPEhistory">history</a> -><br> ?case_sensitive:bool -><br> ?mode:<a href="Lwt_read_line.html#TYPEcompletion_mode">completion_mode</a> -><br> ?prompt:<a href="Lwt_read_line.html#TYPEprompt">prompt</a> -><br> values:(Text.t * 'value) list -> unit -> 'value <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">read_keyword ?history ?case_sensitive ?mode ~prompt ~keywords
()</code> reads one word which is a member of <code class="code">words</code>. And returns
which keyword the user choosed.
<p>
<code class="code">case_sensitive</code> default to <code class="code"><span class="keyword">false</span></code>.<br>
</div>
<pre><span id="VALread_yes_no"><span class="keyword">val</span> read_yes_no</span> : <code class="type">?history:<a href="Lwt_read_line.html#TYPEhistory">history</a> -><br> ?mode:<a href="Lwt_read_line.html#TYPEcompletion_mode">completion_mode</a> -><br> ?prompt:<a href="Lwt_read_line.html#TYPEprompt">prompt</a> -> unit -> bool <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">read_yes_no ?history ?dynamic prompt ()</code> is the same as:
<p>
<pre class="codepre"><code class="code"> read_keyword ?history ?dynamic prompt [(<span class="string">"yes"</span>, <span class="keyword">true</span>); (<span class="string">"no"</span>, <span class="keyword">false</span>)] ()<br>
</code></pre><br>
</div>
<br>
<h6 id="6_Lowlevelinteraction">Low-level interaction</h6><br>
<br>
This part allow you to implements your own read-line function, or
just to use the readline engine in another context (message box,
...).<br>
<pre><span class="keyword">module</span> <a href="Lwt_read_line.Command.html">Command</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_read_line.Command.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
Readline commands
</div>
<pre><span class="keyword">module</span> <a href="Lwt_read_line.Engine.html">Engine</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_read_line.Engine.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
Engine
</div>
<pre><span class="keyword">module</span> <a href="Lwt_read_line.Terminal.html">Terminal</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_read_line.Terminal.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
Rendering to the terminal
</div>
<br>
<h6 id="6_Advanceduse">Advanced use</h6><br>
<pre><span class="keyword">module</span> <a href="Lwt_read_line.Control.html">Control</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_read_line.Control.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
Controlling a running read-line instance
</div>
</body></html>
|