summaryrefslogtreecommitdiffhomepage
path: root/mixlib/mix_vm_command.c
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2001-07-09 22:49:55 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2001-07-09 22:49:55 +0000
commit888a3d7a8c313481de4004a5a1766f85c0dd7f20 (patch)
tree8bb257e31d058c98bda72805281185af98a47ffc /mixlib/mix_vm_command.c
parent1265e5419737a2fbd12eff899d19df706855b55e (diff)
downloadmdk-888a3d7a8c313481de4004a5a1766f85c0dd7f20.tar.gz
mdk-888a3d7a8c313481de4004a5a1766f85c0dd7f20.tar.bz2
history file
Diffstat (limited to 'mixlib/mix_vm_command.c')
-rw-r--r--mixlib/mix_vm_command.c23
1 files changed, 23 insertions, 0 deletions
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 <readline/history.h>
+#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);
}