Warning: Reason support is experimental. We are looking for beta-tester and contributors.

Module Lwt_read_line.Terminal

module Terminal : sig..end

Rendering to the terminal


type state

State of rendering

val init : state

Initial state

The following functions are the one used by read-line functions of this module.

type box =  | Box_none(* No box at all *) | Box_empty(* An empty box *) | Box_words of Lwt_read_line.text_set * int(* BM_words(words, position) is a box with the given list
of words. position is the position of the selected word
in the list.. *) | Box_message of string(* A box containing only the given message *)

Box for the completion:

val draw : 
  columns:int ->
  ?map_text:(Text.t -> Text.t) ->
  ?box:box ->
  render_state:state ->
  engine_state:Lwt_read_line.Engine.state ->
  prompt:Lwt_read_line.prompt ->
  unit -> Lwt_term.styled_text * state

draw ~column ?map_text ?bar ~render_state ~engine_state prompt () returns (text, state) where state is the new rendering state, and text is a text containing escape sequences. When printed, it will update the displayed state.

map_text : is a function used to map user input before printing it, for example to hide passwords.

box : defaults to Box_none.

val last_draw : 
  columns:int ->
  ?map_text:(Text.t -> Text.t) ->
  render_state:state ->
  engine_state:Lwt_read_line.Engine.state ->
  prompt:Lwt_read_line.prompt -> unit -> Lwt_term.styled_text

Draw for the last time, i.e. the cursor is left after the text and not at current position.

val erase : 
  columns:int ->
  render_state:state ->
  unit -> Lwt_term.styled_text

erase ~columns ~render_state () returns a text which will erase everything (the prompt, user input, completion, ...).

After an erase, the rendering state is init.