From: Amélia Coutard-Sander Date: Sun, 5 Jan 2025 00:59:41 +0000 (+0100) Subject: Commande pour vider la grille X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=b8c5447d0ce85368bbd64224fe3241e9568480e2;p=cells.git Commande pour vider la grille --- diff --git a/bin/modes.ml b/bin/modes.ml index a0c47ee..d52df7f 100644 --- a/bin/modes.ml +++ b/bin/modes.ml @@ -146,14 +146,15 @@ module rec Command : (Mode with type initer = string) = struct 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 = @@ -163,6 +164,9 @@ module rec Command : (Mode with type initer = string) = struct | ["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 ->