package linenoise
Lightweight readline alternative
Install
Dune Dependency
Authors
Maintainers
Sources
v1.3.0.tar.gz
md5=867d1b62c2e6705c665f1e2e9199a6e0
sha512=c1f2d8aaf9ad72a24d9a3efdaef75e191975984517ddd9265c3fa76c8d3a7d51acf65cd6be0f35601d66dd1a9506799d9e803bb796170c03e02a94934283213e
Description
Published: 07 May 2019
README
Linenoise in OCaml
Benefits
BSD licensed.
No system dependencies, no need for
readline
on your machine.Related to 2, these bindings are self-contained, the source for
linenoise
is in this repo and compiled all together with theOCaml
.Written in OCaml + C.
Pretty cool hints feature, see the gif.
Additional features compared to linenoise, such as history search
Installation
It is easy with opam
$ opam install linenoise
See the pretty documentation here
Example code
This example is also included in the repo under examples:
let rec user_input prompt cb =
match LNoise.linenoise prompt with
| None -> ()
| Some v ->
cb v;
user_input prompt cb
let () =
(* LNoise.set_multiline true; *)
LNoise.set_hints_callback (fun line ->
if line <> "git remote add " then None
else Some (" <this is the remote name> <this is the remote URL>",
LNoise.Yellow,
true)
);
LNoise.history_load ~filename:"history.txt" |> ignore;
LNoise.history_set ~max_length:100 |> ignore;
LNoise.set_completion_callback begin fun line_so_far ln_completions ->
if line_so_far <> "" && line_so_far.[0] = 'h' then
["Hey"; "Howard"; "Hughes";"Hocus"]
|> List.iter (LNoise.add_completion ln_completions);
end;
["These are OCaml bindings to linenoise";
"get tab completion with <TAB>, type h then hit <TAB>";
"type quit to exit gracefully";
"By Edgar Aroutiounian\n"]
|> List.iter print_endline;
(fun from_user ->
if from_user = "quit" then exit 0;
LNoise.history_add from_user |> ignore;
LNoise.history_save ~filename:"history.txt" |> ignore;
Printf.sprintf "Got: %s" from_user |> print_endline
)
|> user_input "test_program> "
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page