Something went wrong. Try again.
OCaml port of Linenoise forked from patrick.sirref.org/bruit
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031let h = ref []
let history prefix = if prefix <> "" then List.filter (fun s -> String.starts_with ~prefix s) !h else !h
let complete s = match String.get s 0 with | 'h' -> [ "hello"; "hello there" ] | _ | (exception Invalid_argument _) -> []
let main env = Fmt_tty.setup_std_outputs (); let rec loop sys_break = let prompt = if sys_break then "[\x1b[31m130\x1b[0m] \x1b[33m>>\x1b[0m " else "\x1b[33m>>\x1b[0m " in let backend = Bruit_terminal_backend.make_default env in match Bruit.bruit_eio ~history ~complete ~backend prompt with | String (Some s) -> Fmt.pr "\n%s\n%!" s; h := s :: !h; loop false | String None -> () | Ctrl_c -> loop true in loop false
let () = Eio_main.run main