let autocomplete cmd =
match try Parse.shlex cmd with Parse.NonTerminatedString -> Parse.shlex (cmd ^ "'") with
| ["quit"] -> ("quit", [])
+ | ["clear"] -> ("clear", [])
| ["select"] -> real_complete ["select"; ""] (List.map get_name Automata.automata)
| ["select"; n] -> real_complete ["select"; n] (List.map get_name Automata.automata)
| ["write"] -> complete_file ["write"; ""] ""
| ["write"; n] -> complete_file ["write"; n] n
| ["read"] -> complete_file ["read"; ""] ""
| ["read"; n] -> complete_file ["read"; n] n
- | [] -> real_complete [""] ["quit"; "select"; "write"; "read"]
- | [cmd] -> real_complete [cmd] ["quit"; "select"; "write"; "read"]
+ | [] -> real_complete [""] ["quit"; "clear"; "select"; "write"; "read"]
+ | [cmd] -> real_complete [cmd] ["quit"; "clear"; "select"; "write"; "read"]
| parsed -> (String.concat " " (List.map Parse.shquote parsed), [])
let run_cmd (EditorState (m, st) as estate) cmd =
| ["quit"] ->
Graphics.close_graph ();
(estate, Either.left ("", []))
+ | ["clear"] ->
+ ( EditorState ((module M), { st with board = Automata.initial (module M); pos = (0, 0) }),
+ Either.right (ModeAux.ModeAndState ((module Normal), Normal.initial ())) )
| ["select"; auto] -> (
match List.find_opt (fun m -> get_name m = auto) Automata.automata with
| Some auto ->