From b8c5447d0ce85368bbd64224fe3241e9568480e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Am=C3=A9lia=20Coutard-Sander?= Date: Sun, 5 Jan 2025 01:59:41 +0100 Subject: [PATCH] Commande pour vider la grille --- bin/modes.ml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 -> -- 2.46.0