From 888a3d7a8c313481de4004a5a1766f85c0dd7f20 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 9 Jul 2001 22:49:55 +0000 Subject: history file --- mixlib/mix_vm_command.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'mixlib/mix_vm_command.c') diff --git a/mixlib/mix_vm_command.c b/mixlib/mix_vm_command.c index afabc55..bb4b67f 100644 --- a/mixlib/mix_vm_command.c +++ b/mixlib/mix_vm_command.c @@ -33,6 +33,11 @@ #include "mix_eval.h" #include "mix_vm_command.h" +#ifdef HAVE_LIBHISTORY +# include +#endif + + /* hooks */ typedef struct { @@ -253,6 +258,7 @@ mix_vm_cmd_dispatcher_new_with_config (FILE *out, FILE *err, mix_vm_cmd_dispatcher_t *result = mix_vm_cmd_dispatcher_new (out, err); if (result != NULL && (result->config = config) != NULL) { + gint hsize = 0; const gchar *val = mix_config_get (result->config, TRACING_KEY_); if (val) cmd_tracing_ (result, val); val = mix_config_get (result->config, EDITOR_KEY_); @@ -270,6 +276,17 @@ mix_vm_cmd_dispatcher_new_with_config (FILE *out, FILE *err, } else cmd_devdir_ (result, val); +#ifdef HAVE_LIBHISTORY + val = mix_config_get_history_file (result->config); + hsize = mix_config_get_history_size (result->config); + using_history (); + stifle_history (hsize); + if (val) + { + read_history ((char *)val); + history_set_pos (history_base + history_length - 1); + } +#endif } return result; } @@ -279,12 +296,18 @@ mix_vm_cmd_dispatcher_new_with_config (FILE *out, FILE *err, void mix_vm_cmd_dispatcher_delete (mix_vm_cmd_dispatcher_t *dis) { + const gchar *hfile = NULL; g_return_if_fail (dis != NULL); mix_eval_delete (dis->eval); mix_dump_context_delete (dis->dump); mix_vm_delete (dis->vm); if (dis->editor) g_free (dis->editor); if (dis->editor) g_free (dis->assembler); +#ifdef HAVE_LIBHISTORY + if (dis->config && (hfile = mix_config_get_history_file + (dis->config))) + write_history ((char *)hfile); +#endif g_free (dis); } -- cgit v1.2.3