Module Lwt_read_line.​Control

module Control : sig..end

Controlling a running read-line instance


type 'a t

Type of a running read-line instance, returning a value of type 'a

Control
val result : 'a t -> 'a Lwt.t

Threads waiting for the read-line instance to terminates

val send_command : 'a t -> Lwt_read_line.Command.t -> unit

send_command instance command sends the given command to the read-line instance

val accept : 'a t -> unit

accept instance = send_command instance Command.Accept_line

val interrupt : 'a t -> unit

accept instance = send_command instance Command.Break

val hide : 'a t -> unit Lwt.t

Hides everything (prompt, user input, completion box) until Lwt_read_line.​Control.​show is called.

val show : 'a t -> unit Lwt.t

Un-hide everything

Note: in case the input is not a terminal, read-line instances are not controllable. i.e. Lwt_read_line.​Control.​accept, refresh, ... have no effect.

Creation of read-line instances
type prompt = 
  Lwt_read_line.Engine.state React.signal ->
  Lwt_term.styled_text React.signal

The prompt a signal which may depends on the engine state

type state

State of an instance

val engine_state : state -> Lwt_read_line.Engine.state

Return the engine state of the given state

val render_state : state -> Lwt_read_line.Terminal.state

Return the rendering state of the given state

val make : 
  ?history:Lwt_read_line.history ->
  ?complete:Lwt_read_line.completion ->
  ?clipboard:Lwt_read_line.clipboard ->
  ?mode:[ `classic | `none | `real_time ] ->
  ?map_text:(Text.t -> Text.t) ->
  ?filter:(state ->
   Lwt_read_line.Command.t -> Lwt_read_line.Command.t Lwt.t) ->
  map_result:(Text.t -> 'a Lwt.t) ->
  ?prompt:prompt ->
  unit -> 'a t

Creates a new read-line instance with the given parameters. filter is called to handle commands. You can return Command.Nop to drop a command.

Predefined instances
val read_line : 
  ?history:Lwt_read_line.history ->
  ?complete:Lwt_read_line.completion ->
  ?clipboard:Lwt_read_line.clipboard ->
  ?mode:Lwt_read_line.completion_mode ->
  ?prompt:prompt ->
  unit -> Text.t t Lwt.t
val read_password : 
  ?clipboard:Lwt_read_line.clipboard ->
  ?style:Lwt_read_line.password_style ->
  ?prompt:prompt ->
  unit -> Text.t t Lwt.t
val read_keyword : 
  ?history:Lwt_read_line.history ->
  ?case_sensitive:bool ->
  ?mode:Lwt_read_line.completion_mode ->
  ?prompt:prompt ->
  values:(Text.t * 'a) list -> unit -> 'a t Lwt.t
val read_yes_no : 
  ?history:Lwt_read_line.history ->
  ?mode:Lwt_read_line.completion_mode ->
  ?prompt:prompt ->
  unit -> bool t Lwt.t