module Lwt_read_line:sig
..end
exception Interrupt
Ctrl^D
typeedition_state =
Text.t * Text.t
typeprompt =
Lwt_term.styled_text
typetext_set =
Set.Make(Text).t
type
completion_result = {
|
comp_state : |
(* |
The new edition state
| *) |
|
comp_words : |
(* |
A list of possibilities
| *) |
typecompletion =
edition_state -> completion_result Lwt.t
Note: the thread launched by the completion function is
cancelled using Lwt.cancel
if the user continue typing
text.
val lookup : Text.t -> text_set -> Text.t * text_set
lookup word words
lookup for completion of word
into
words
. It returns (prefix, possibilities)
where
possibilities
are all words starting with word
and prefix
is the longest common prefix of possibilities
.val complete : ?suffix:Text.t ->
Text.t ->
Text.t -> Text.t -> text_set -> completion_result
complete ?suffix before word after words
basic completion
functions. words
is a list of possible completions for
word
.
If completion succeed suffix
is append to the resulting
text. It defaults to " "
.
val print_words : Lwt_text.output_channel -> int -> string list -> unit Lwt.t
print_words oc columns strs
pretty-prints a list of words.typehistory =
Text.t list
val add_entry : Text.t -> history -> history
add_entry line history
returns the history history
plus
line
at the beginning. If line
already appears at the
beginning or contains only spaces, it is discarded.val save_history : string -> history -> unit Lwt.t
save_history filename history
saves history
to
filename
. History is saved by separating lines with a null
character.val load_history : string -> history Lwt.t
load_history filename
loads history from filename
. Returns
the empty history if the the file does not exit.class clipboard :object
..end
val clipboard : clipboard
typecompletion_mode =
[ `classic | `none | `real_time ]
`classic
means that when the user hit Tab
a list of
possible completions is proposed,`real_time
means that possible completions are shown to
the user as he types, and he can navigate in them with
Meta+left
, Meta+right
`none
means no completion at allval read_line : ?history:history ->
?complete:completion ->
?clipboard:clipboard ->
?mode:completion_mode ->
?prompt:prompt -> unit -> Text.t Lwt.t
readline ?history ?complete ?mode ?prompt ()
inputs some text
from the user. If input is not a terminal, it defaults to
Lwt_text.read_line Lwt_text.stdin
.
If
mode
: contains the current completion mode. It defaults
to `real_time
.prompt
: defaults to Lwt_term.Text "# "
typepassword_style =
[ `clear | `empty | `text of Text.t ]
`empty
nothing is printed`clear
the password is displayed has it`text ch
all characters are replaced by ch
val read_password : ?clipboard:clipboard ->
?style:password_style ->
?prompt:prompt -> unit -> Text.t Lwt.t
read_password ?clipboard ?clear ~prompt ()
inputs a password
from the user. This function fails if input is not a terminal.style
: defaults to `text "*"
.val read_keyword : ?history:history ->
?case_sensitive:bool ->
?mode:completion_mode ->
?prompt:prompt ->
values:(Text.t * 'value) list -> unit -> 'value Lwt.t
read_keyword ?history ?case_sensitive ?mode ~prompt ~keywords
()
reads one word which is a member of words
. And returns
which keyword the user choosed.
case_sensitive
default to false
.
val read_yes_no : ?history:history ->
?mode:completion_mode ->
?prompt:prompt -> unit -> bool Lwt.t
read_yes_no ?history ?dynamic prompt ()
is the same as:
read_keyword ?history ?dynamic prompt [("yes", true); ("no", false)] ()
module Command:sig
..end
module Engine:sig
..end
module Terminal:sig
..end
module Control:sig
..end