<!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_text.html"> <link rel="next" href="Lwt_read_line.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="Terminal informations" rel="Section" href="#6_Terminalinformations"> <link title="Keys" rel="Section" href="#6_Keys"> <link title="Styles" rel="Section" href="#6_Styles"> <link title="Rendering" rel="Section" href="#6_Rendering"> <link title="Drawing" rel="Section" href="#6_Drawing"> <link title="Standard colors" rel="Subsection" href="#8_Standardcolors"> <link title="Light colors" rel="Subsection" href="#8_Lightcolors"> <link title="Text with styles" rel="Subsection" href="#8_Textwithstyles"> <title>Lwt_term</title> </head> <body> <div class="navbar"><a class="pre" href="Lwt_text.html" title="Lwt_text">Previous</a> <a class="up" href="index.html" title="Index">Up</a> <a class="post" href="Lwt_read_line.html" title="Lwt_read_line">Next</a> </div> <h1>Module <a href="type_Lwt_term.html">Lwt_term</a></h1> <pre><span class="keyword">module</span> Lwt_term: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_term.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Terminal control<br> </div> <hr width="100%"> <br> This modules allow you to write interactive programs using the terminal.<br> <pre><span id="VALwith_raw_mode"><span class="keyword">val</span> with_raw_mode</span> : <code class="type">(unit -> 'a <a href="Lwt.html#TYPEt">Lwt.t</a>) -> 'a <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">with_raw_mode f</code> executes <code class="code">f</code> while the terminal is in ``raw mode''. Raw mode means that character are returned as the user type them (otherwise only complete line are returned to the program). <p> If the terminal is already in raw mode, it just calls <code class="code">f</code>.<br> </div> <pre><span id="VALraw_mode"><span class="keyword">val</span> raw_mode</span> : <code class="type">unit -> bool</code></pre><div class="info"> Returns wether the terminal is currently in raw mode<br> </div> <pre><span id="VALenter_drawing_mode"><span class="keyword">val</span> enter_drawing_mode</span> : <code class="type">unit -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> Put the terminal into drawing mode<br> </div> <pre><span id="VALleave_drawing_mode"><span class="keyword">val</span> leave_drawing_mode</span> : <code class="type">unit -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> Restore the state of the terminal<br> </div> <pre><span id="VALshow_cursor"><span class="keyword">val</span> show_cursor</span> : <code class="type">unit -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">show_cursor ()</code> makes the cursor visible<br> </div> <pre><span id="VALhide_cursor"><span class="keyword">val</span> hide_cursor</span> : <code class="type">unit -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">hide_cursor ()</code> makes the cursor invisible<br> </div> <pre><span id="VALclear_screen"><span class="keyword">val</span> clear_screen</span> : <code class="type">unit -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">clear_screen ()</code> clears the entire screen<br> </div> <pre><span id="VALclear_line"><span class="keyword">val</span> clear_line</span> : <code class="type">unit -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">clear_line ()</code> clears the current line<br> </div> <pre><span id="VALgoto_beginning_of_line"><span class="keyword">val</span> goto_beginning_of_line</span> : <code class="type">int -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">goto_beginning_of_line n</code> put the cursor at the beginning of the <code class="code">n</code>th previous line. <p> <ul> <li><code class="code">goto_beginning_of_line 0</code> goes to the beginning of the current line</li> <li><code class="code">goto_beginning_of_line 1</code> goes to the beginning of the previous line</li> <li>...</li> </ul> <br> </div> <br> <h6 id="6_Terminalinformations">Terminal informations</h6><br> <pre><code><span id="TYPEsize"><span class="keyword">type</span> <code class="type"></code>size</span> = {</code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTsize.lines">lines</span> :<code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTsize.columns">columns</span> :<code class="type">int</code>;</code></td> </tr></table> } <div class="info"> Terminal sizes:<br> </div> <pre><span id="VALsize"><span class="keyword">val</span> size</span> : <code class="type"><a href="Lwt_term.html#TYPEsize">size</a> React.signal</code></pre><div class="info"> Size of the terminal.<br> </div> <pre><span id="VALcolumns"><span class="keyword">val</span> columns</span> : <code class="type">int React.signal</code></pre><div class="info"> Number of columns of the terminal<br> </div> <pre><span id="VALlines"><span class="keyword">val</span> lines</span> : <code class="type">int React.signal</code></pre><div class="info"> Number of lines of the terminal<br> </div> <br> <h6 id="6_Keys">Keys</h6><br> <pre><span id="VALparse_key_raw"><span class="keyword">val</span> parse_key_raw</span> : <code class="type">Text.t <a href="Lwt_stream.html#TYPEt">Lwt_stream.t</a> -> Text.t <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">parse_key_raw st</code> recognize escape sequence in a stream of unicode character. <p> It returns either:<ul> <li>either single characters, like <code class="code"><span class="string">"a"</span></code>, <code class="code"><span class="string">"é"</span></code>, ...</li> <li>either escape sequences</li> </ul> <br> </div> <pre><code><span id="TYPEkey"><span class="keyword">type</span> <code class="type"></code>key</span> = </code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key"><span class="constructor">Key</span></span> <span class="keyword">of</span> <code class="type">Text.t</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A unicode character or an uninterpreted sequence</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_up"><span class="constructor">Key_up</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_down"><span class="constructor">Key_down</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_left"><span class="constructor">Key_left</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_right"><span class="constructor">Key_right</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_f"><span class="constructor">Key_f</span></span> <span class="keyword">of</span> <code class="type">int</code></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_next_page"><span class="constructor">Key_next_page</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_previous_page"><span class="constructor">Key_previous_page</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_home"><span class="constructor">Key_home</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_end"><span class="constructor">Key_end</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_insert"><span class="constructor">Key_insert</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_delete"><span class="constructor">Key_delete</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTkey.Key_control"><span class="constructor">Key_control</span></span> <span class="keyword">of</span> <code class="type">char</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A control key</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <div class="info"> Type of ``decoded'' keys. <p> This list is not exhaustive, but at least it should works on all terminals:<br> </div> <pre><span id="VALstring_of_key"><span class="keyword">val</span> string_of_key</span> : <code class="type"><a href="Lwt_term.html#TYPEkey">key</a> -> string</code></pre><div class="info"> <code class="code">string_of_key key</code> string representation of a key<br> </div> <pre><span id="VALcontrol_mapping"><span class="keyword">val</span> control_mapping</span> : <code class="type">(int * char) list</code></pre><div class="info"> Mapping from control key codes to character codes. <p> Here is the list of control keys: <p> <pre class="codepre"><code class="code"> +------+-------+------+------+------+-------+------------------------------------------------+ | Char | Oct | Dec | Name | Hex | Key | Comment | +------+-------+------+------+------+-------+------------------------------------------------+ | '@' | 0o00 | 0 | NUL | 0x00 | ^@ \0 | Null byte | | 'a' | 0o01 | 1 | SOH | 0x01 | ^A | Start of heading | | 'b' | 0o02 | 2 | STX | 0x02 | ^B | Start of text | | 'c' | 0o03 | 3 | ETX | 0x03 | ^C | End of text | | 'd' | 0o04 | 4 | EOT | 0x04 | ^D | End of transmission | | 'e' | 0o05 | 5 | ENQ | 0x05 | ^E | Enquiry | | 'f' | 0o06 | 6 | ACK | 0x06 | ^F | Acknowledge | | 'g' | 0o07 | 7 | BEL | 0x07 | ^G | Ring terminal bell | | 'h' | 0o10 | 8 | BS | 0x08 | ^H \b | Backspace | | 'i' | 0o11 | 9 | HT | 0x09 | ^I \t | Horizontal tab | | 'j' | 0o12 | 10 | LF | 0x0a | ^J \n | Line feed | | 'k' | 0o13 | 11 | VT | 0x0b | ^K | Vertical tab | | 'l' | 0o14 | 12 | FF | 0x0c | ^L \f | Form feed | | 'm' | 0o15 | 13 | CR | 0x0d | ^M \r | Carriage return | | 'n' | 0o16 | 14 | SO | 0x0e | ^N | Shift out | | 'o' | 0o17 | 15 | SI | 0x0f | ^O | Shift in | | 'p' | 0o20 | 16 | DLE | 0x10 | ^P | Data link escape | | 'q' | 0o21 | 17 | DC1 | 0x11 | ^Q | Device control 1 (XON) | | 'r' | 0o22 | 18 | DC2 | 0x12 | ^R | Device control 2 | | 's' | 0o23 | 19 | DC3 | 0x13 | ^S | Device control 3 (XOFF) | | 't' | 0o24 | 20 | DC4 | 0x14 | ^T | Device control 4 | | 'u' | 0o25 | 21 | NAK | 0x15 | ^U | Negative acknowledge | | 'v' | 0o26 | 22 | SYN | 0x16 | ^V | Synchronous idle | | 'w' | 0o27 | 23 | ETB | 0x17 | ^W | End of transmission block | | 'x' | 0o30 | 24 | CAN | 0x18 | ^X | Cancel | | 'y' | 0o31 | 25 | EM | 0x19 | ^Y | End of medium | | 'z' | 0o32 | 26 | SUB | 0x1a | ^Z | Substitute character | | '[' | 0o33 | 27 | ESC | 0x1b | ^[ | Escape | | '\' | 0o34 | 28 | FS | 0x1c | ^\ | File separator, Information separator four | | ']' | 0o35 | 29 | GS | 0x1d | ^] | Group separator, Information separator three | | '^' | 0o36 | 30 | RS | 0x1e | ^^ | Record separator, Information separator two | | '_' | 0o37 | 31 | US | 0x1f | ^_ | Unit separator, Information separator one | | '?' | 0o177 | 127 | DEL | 0x7f | ^? | Delete | +------+-------+------+------+------+-------+------------------------------------------------+ </code></pre><br> </div> <pre><span id="VALkey_enter"><span class="keyword">val</span> key_enter</span> : <code class="type"><a href="Lwt_term.html#TYPEkey">key</a></code></pre><div class="info"> <code class="code">key_enter = <span class="constructor">Key_control</span> <span class="string">'j'</span></code><br> </div> <pre><span id="VALkey_escape"><span class="keyword">val</span> key_escape</span> : <code class="type"><a href="Lwt_term.html#TYPEkey">key</a></code></pre><div class="info"> <code class="code">key_escape = <span class="constructor">Key_control</span> <span class="string">'['</span></code><br> </div> <pre><span id="VALkey_tab"><span class="keyword">val</span> key_tab</span> : <code class="type"><a href="Lwt_term.html#TYPEkey">key</a></code></pre><div class="info"> <code class="code">key_escape = <span class="constructor">Key_control</span> <span class="string">'i'</span></code><br> </div> <pre><span id="VALkey_backspace"><span class="keyword">val</span> key_backspace</span> : <code class="type"><a href="Lwt_term.html#TYPEkey">key</a></code></pre><div class="info"> <code class="code">key_backspace = <span class="constructor">Key_control</span> <span class="string">'?'</span></code><br> </div> <pre><span id="VALsequence_mapping"><span class="keyword">val</span> sequence_mapping</span> : <code class="type">(Text.t * <a href="Lwt_term.html#TYPEkey">key</a>) list</code></pre><div class="info"> Mapping from sequence to keys<br> </div> <pre><span id="VALdecode_key"><span class="keyword">val</span> decode_key</span> : <code class="type">Text.t -> <a href="Lwt_term.html#TYPEkey">key</a></code></pre><div class="info"> Decode a key.<br> </div> <pre><span id="VALstandard_input"><span class="keyword">val</span> standard_input</span> : <code class="type">Text.t <a href="Lwt_stream.html#TYPEt">Lwt_stream.t</a></code></pre><div class="info"> The input stream used by <a href="Lwt_term.html#VALread_key"><code class="code"><span class="constructor">Lwt_term</span>.read_key</code></a><br> </div> <pre><span id="VALread_key"><span class="keyword">val</span> read_key</span> : <code class="type">unit -> <a href="Lwt_term.html#TYPEkey">key</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> Get and decode a key from <a href="Lwt_term.html#VALstandard_input"><code class="code"><span class="constructor">Lwt_term</span>.standard_input</code></a><br> </div> <br> <h6 id="6_Styles">Styles</h6><br> <pre><span id="TYPEcolor"><span class="keyword">type</span> <code class="type"></code>color</span> = <code class="type">int</code> </pre> <div class="info"> Type of a color. Most modern terminals support either 88 or 256 colors.<br> </div> <pre><span id="VALset_color"><span class="keyword">val</span> set_color</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a> -> int * int * int -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">set_color num (red, green, blue)</code> sets the three components of the color number <code class="code">num</code><br> </div> <br> <div class="h8" id="8_Standardcolors">Standard colors</div><br> <pre><span id="VALdefault"><span class="keyword">val</span> default</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALblack"><span class="keyword">val</span> black</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALred"><span class="keyword">val</span> red</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALgreen"><span class="keyword">val</span> green</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALyellow"><span class="keyword">val</span> yellow</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALblue"><span class="keyword">val</span> blue</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALmagenta"><span class="keyword">val</span> magenta</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALcyan"><span class="keyword">val</span> cyan</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALwhite"><span class="keyword">val</span> white</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><br> <div class="h8" id="8_Lightcolors">Light colors</div><br> <br> Note: these colors are not supposed to works on all terminals, but in practice it works with all modern ones. By the way, using standard colors + bold mode will give the same result as using a light color.<br> <pre><span id="VALlblack"><span class="keyword">val</span> lblack</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALlred"><span class="keyword">val</span> lred</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALlgreen"><span class="keyword">val</span> lgreen</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALlyellow"><span class="keyword">val</span> lyellow</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALlblue"><span class="keyword">val</span> lblue</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALlmagenta"><span class="keyword">val</span> lmagenta</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALlcyan"><span class="keyword">val</span> lcyan</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><pre><span id="VALlwhite"><span class="keyword">val</span> lwhite</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></pre><br> <div class="h8" id="8_Textwithstyles">Text with styles</div><br> <pre><code><span id="TYPEstyled_text_instruction"><span class="keyword">type</span> <code class="type"></code>styled_text_instruction</span> = </code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyled_text_instruction.Text"><span class="constructor">Text</span></span> <span class="keyword">of</span> <code class="type">Text.t</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Some text</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyled_text_instruction.Reset"><span class="constructor">Reset</span></span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Resets all styles to default</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyled_text_instruction.Bold"><span class="constructor">Bold</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyled_text_instruction.Underlined"><span class="constructor">Underlined</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyled_text_instruction.Blink"><span class="constructor">Blink</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyled_text_instruction.Inverse"><span class="constructor">Inverse</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyled_text_instruction.Hidden"><span class="constructor">Hidden</span></span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyled_text_instruction.Foreground"><span class="constructor">Foreground</span></span> <span class="keyword">of</span> <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyled_text_instruction.Background"><span class="constructor">Background</span></span> <span class="keyword">of</span> <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code></code></td> </tr></table> <div class="info"> Elmement of a styled-text<br> </div> <pre><span id="TYPEstyled_text"><span class="keyword">type</span> <code class="type"></code>styled_text</span> = <code class="type"><a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a> list</code> </pre> <div class="info"> A styled text is a list of instructions<br> </div> <pre><span id="VALtextf"><span class="keyword">val</span> textf</span> : <code class="type">('a, unit, string, <a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a>) Pervasives.format4 -> 'a</code></pre><div class="info"> <code class="code">textf fmt</code> formats a texts with <code class="code">fmt</code> and returns <code class="code"><span class="constructor">Text</span> txt</code><br> </div> <pre><span id="VALtext"><span class="keyword">val</span> text</span> : <code class="type">Text.t -> <a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a></code></pre><pre><span id="VALreset"><span class="keyword">val</span> reset</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a></code></pre><pre><span id="VALbold"><span class="keyword">val</span> bold</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a></code></pre><pre><span id="VALunderlined"><span class="keyword">val</span> underlined</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a></code></pre><pre><span id="VALblink"><span class="keyword">val</span> blink</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a></code></pre><pre><span id="VALinverse"><span class="keyword">val</span> inverse</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a></code></pre><pre><span id="VALhidden"><span class="keyword">val</span> hidden</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a></code></pre><pre><span id="VALfg"><span class="keyword">val</span> fg</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a> -> <a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a></code></pre><div class="info"> <code class="code">fg col = <span class="constructor">Foreground</span> col</code><br> </div> <pre><span id="VALbg"><span class="keyword">val</span> bg</span> : <code class="type"><a href="Lwt_term.html#TYPEcolor">color</a> -> <a href="Lwt_term.html#TYPEstyled_text_instruction">styled_text_instruction</a></code></pre><div class="info"> <code class="code">bg col = <span class="constructor">Background</span> col</code><br> </div> <pre><span id="VALstrip_styles"><span class="keyword">val</span> strip_styles</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text">styled_text</a> -> Text.t</code></pre><div class="info"> Drop all styles<br> </div> <pre><span id="VALstyled_length"><span class="keyword">val</span> styled_length</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text">styled_text</a> -> int</code></pre><div class="info"> Returns the length (in unicode character) of the given styled text. The following equality holds for all styled-texts: <p> <code class="code">styled_length st = <span class="constructor">Text</span>.length (strip_styles st)</code><br> </div> <pre><span id="VALwrite_styled"><span class="keyword">val</span> write_styled</span> : <code class="type"><a href="Lwt_text.html#TYPEoutput_channel">Lwt_text.output_channel</a> -> <a href="Lwt_term.html#TYPEstyled_text">styled_text</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">write_styled oc st</code> writes <code class="code">st</code> on <code class="code">oc</code> using escape sequences.<br> </div> <pre><span id="VALprintc"><span class="keyword">val</span> printc</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text">styled_text</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">printc st</code> prints the given styled text on standard output. If stdout is not a tty, then styles are stripped. <p> The text is encoded to the system encoding before being output.<br> </div> <pre><span id="VALeprintc"><span class="keyword">val</span> eprintc</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text">styled_text</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> Same as <code class="code">printc</code> but prints on stderr.<br> </div> <pre><span id="VALprintlc"><span class="keyword">val</span> printlc</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text">styled_text</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">printlc st</code> prints <code class="code">st</code>, then reset styles and prints a newline<br> </div> <pre><span id="VALeprintlc"><span class="keyword">val</span> eprintlc</span> : <code class="type"><a href="Lwt_term.html#TYPEstyled_text">styled_text</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> Same as <code class="code">printlc</code> but prints on stderr<br> </div> <br> <h6 id="6_Rendering">Rendering</h6><br> <pre><code><span id="TYPEstyle"><span class="keyword">type</span> <code class="type"></code>style</span> = {</code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyle.bold">bold</span> :<code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyle.underlined">underlined</span> :<code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyle.blink">blink</span> :<code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyle.inverse">inverse</span> :<code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyle.hidden">hidden</span> :<code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyle.foreground">foreground</span> :<code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTstyle.background">background</span> :<code class="type"><a href="Lwt_term.html#TYPEcolor">color</a></code>;</code></td> </tr></table> } <div class="info"> Character styles<br> </div> <pre><code><span id="TYPEpoint"><span class="keyword">type</span> <code class="type"></code>point</span> = {</code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTpoint.char">char</span> :<code class="type">Text.t</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The character.</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="TYPEELTpoint.style">style</span> :<code class="type"><a href="Lwt_term.html#TYPEstyle">style</a></code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The character style</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> } <div class="info"> A character on the screen:<br> </div> <pre><span id="VALblank"><span class="keyword">val</span> blank</span> : <code class="type"><a href="Lwt_term.html#TYPEpoint">point</a></code></pre><div class="info"> A space with default color and styles<br> </div> <pre><span id="VALrender"><span class="keyword">val</span> render</span> : <code class="type"><a href="Lwt_term.html#TYPEpoint">point</a> array array -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> Render an offscreen array to the terminal.<br> </div> <pre><span id="VALrender_update"><span class="keyword">val</span> render_update</span> : <code class="type"><a href="Lwt_term.html#TYPEpoint">point</a> array array -> <a href="Lwt_term.html#TYPEpoint">point</a> array array -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info"> <code class="code">render_update displayed to_display</code> does the same as <code class="code">render to_display</code> but assumes that <code class="code">displayed</code> contains the current displayed text. This reduces the amount of text sent to the terminal.<br> </div> <br> <h6 id="6_Drawing">Drawing</h6><br> <pre><span class="keyword">module</span> <a href="Lwt_term.Zone.html">Zone</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_term.Zone.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Off-screen zones </div> <pre><span class="keyword">module</span> <a href="Lwt_term.Draw.html">Draw</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_term.Draw.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Drawing helpers </div> </body></html>