|
From: Jérémie D. <Ba...@us...> - 2010-02-17 10:53:50
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "krobot".
The branch, master has been updated
via f8512130a8770901d89f22a2498e67ac6f704ea2 (commit)
from d69354ad74e6873b0ace333f84262823423a22f5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f8512130a8770901d89f22a2498e67ac6f704ea2
Author: Jérémie Dimino <je...@di...>
Date: Wed Feb 17 11:53:22 2010 +0100
[controller] add history saving/loading
-----------------------------------------------------------------------
Changes:
diff --git a/PC_Mainboard/clients/controller.ml b/PC_Mainboard/clients/controller.ml
index ac3f1ad..7ed5956 100644
--- a/PC_Mainboard/clients/controller.ml
+++ b/PC_Mainboard/clients/controller.ml
@@ -217,16 +217,22 @@ let () =
let logs, set_logs = React.S.create []
+let history_file_name =
+ Filename.concat (try Unix.getenv "HOME" with _ -> "") ".krobot-controller-history"
+
+let save_history history =
+ Lwt_read_line.save_history history_file_name history
+
let rec loop krobot history =
lwt key = read_key () in
if key = key_escape then
- return ()
+ save_history history
else
match Command.of_key key with
| Command.Accept_line ->
let line = Text.strip (Engine.all_input (React.S.value engine_state)) in
if line = "exit" then
- return ()
+ save_history history
else begin
let history = Lwt_read_line.add_entry line history in
set_engine_state (Engine.init history);
@@ -300,6 +306,8 @@ lwt () =
in
(* Make the compiler happy: *)
ignore signal;
- Lwt_term.with_raw_mode (fun () -> loop krobot [])
+ lwt history = Lwt_read_line.load_history history_file_name in
+ set_engine_state (Engine.init history);
+ Lwt_term.with_raw_mode (fun () -> loop krobot history)
finally
restore_state ()
hooks/post-receive
--
krobot
|