module Completion: sig
.. end
Completion engine
This is the interface of the completion engine.
The completion engine works with Completion.source
s that returns Completion.candidate
s.
See Completion.state_machine
type
candidate = <
|
completion : string ; |
|
display : string ; |
|
doc : string ; |
|
matching_function : string -> Matching.result option ; |
|
real : string ; |
>
A candidate, as returned by sources
val mk_candidate : display:string ->
real:string ->
completion:string ->
doc:string ->
matching_function:(string -> Matching.result option) -> candidate
A constructor
Sources
The underlying representations of sources.
See Sources
for some predefined sources and sources builders.
type 'a
source = {
|
delay : bool ; |
|
default : 'a ; |
|
compute : 'a -> string -> 'a * candidate list ; |
}
type
ex_source =
type
source_state =
Engine
type
state_machine = {
}
A completion state machine: a list of current source and a way to get
the next sources depending on the current input.
val empty : state_machine
The state machine that does not offer any completion
val singleton : ex_source Lazy.t -> state_machine
val singleton' : ex_source -> state_machine
Offers the argument for completion once and then do not provide any completion
val iterate : ex_source Lazy.t list -> state_machine
iterate sources
offers completions from sources, indefinitely.
val concat : state_machine ->
state_machine -> state_machine
Concatenates two machines. The first one is considered done when it returns
[].
val sum : ex_source ->
(< display : string; real : string > -> state_machine) ->
state_machine
Dependant sum.
State
type
state = {
}
The state of the completion engine
val make_state : ?sep:string -> state_machine -> state
make_state ?sep machine
initialize the machine;
sep
will be used to mark
the end of a selection and the transition to the next sources (i.e. next
state of the automata).
The default value of sep
is a space.
val add_string : string -> state -> state
Computes the new state corresponding to the user pressing a character
Edition commands
val cursor_left : state -> state
Computes the new state corresponding to the user going left
val cursor_right : state -> state
Computes the new state corresponding to the user going right
val left : state -> state
Computes the new state corresponding to the user selecting the candidate on the left
val right : state -> state
Computes the new state corresponding to the user selecting the candidate on the right
val pageup : ((candidate * Matching.result) list ->
(candidate * Matching.result) list *
(candidate * Matching.result) list) ->
state -> state
Computes the new state corresponding to the user selecting the
first non visible candidate on the left. It expects a functions
that given a list of candidate returns the list of the candidate
visible on the screen and the rest.
val pagedown : ((candidate * Matching.result) list ->
(candidate * Matching.result) list *
(candidate * Matching.result) list) ->
state -> state
Computes the new state corresponding to the user selecting the first non visible candidate on the right
val remove : state -> state
Computes the new state corresponding to the user removing the
character to the right of the cursor
val complete : state -> state
Computes the new state corresponding to the user completing the entry