diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2002-04-08 00:33:40 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2002-04-08 00:33:40 +0000 |
commit | af52e59e381b2060e387528d6ba8971f985c1a42 (patch) | |
tree | 06e3735e3bfcd7e6596f970c8ea8ea7689c233f0 /mixutils | |
parent | e9a299e61c3b52905bdd0277374e49011d1b2b5e (diff) | |
download | mdk-af52e59e381b2060e387528d6ba8971f985c1a42.tar.gz mdk-af52e59e381b2060e387528d6ba8971f985c1a42.tar.bz2 |
configurable prompt support
Diffstat (limited to 'mixutils')
-rw-r--r-- | mixutils/mixvm_loop.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/mixutils/mixvm_loop.c b/mixutils/mixvm_loop.c index a158427..e3209c8 100644 --- a/mixutils/mixvm_loop.c +++ b/mixutils/mixvm_loop.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixvm_loop.c : * Implementation of mix vm command loop. * ------------------------------------------------------------------ - * $Id: mixvm_loop.c,v 1.8 2002/03/20 01:30:11 jao Exp $ + * $Id: mixvm_loop.c,v 1.9 2002/04/08 00:33:40 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. * @@ -35,6 +35,7 @@ #endif #include "mixvm_command.h" +#include "mixvm_loop.h" #ifdef HAVE_LIBHISTORY # include <readline/history.h> @@ -58,8 +59,9 @@ readline (char *prompt) /* A static variable for holding the line. */ static char *line_read = (char *)NULL; -static const char *PROMPT = N_("MIX > "); +static char *PROMPT = NULL; static const char *CONFIG_FILE_ = "mixvm.config"; +static const char *PROMPT_KEY_ = "Prompt"; /* Read a string, and return a pointer to it. Returns NULL on EOF. */ static char * @@ -92,6 +94,7 @@ init_mixvm_ (const gchar *file, gboolean use_emacs) { static const gchar *HISTORY_FILE = "mixvm.history"; static gint HISTORY_SIZE = 100; + const char *prompt = NULL; config_ = mix_config_new (NULL, CONFIG_FILE_); mix_config_set_autosave (config_, TRUE); @@ -100,9 +103,25 @@ init_mixvm_ (const gchar *file, gboolean use_emacs) if (mix_config_get_history_size (config_) == 0) mix_config_set_history_size (config_, HISTORY_SIZE); + prompt = mix_config_get (config_, PROMPT_KEY_); + if (!prompt) prompt = "MIX > "; + mix_vmloop_set_prompt (prompt); + return mixvm_cmd_init (config_, (char *)file, use_emacs); } +void +mix_vmloop_set_prompt (const gchar *prompt) +{ + if (prompt) + { + if (PROMPT) g_free (PROMPT); + if (prompt[0] == '"') prompt++; + PROMPT = g_strdup (prompt); + if (PROMPT[strlen (PROMPT) - 1] == '"') PROMPT[strlen (PROMPT) - 1] = 0; + mix_config_update (config_, PROMPT_KEY_, PROMPT); + } +} static void loop_ (int argc, char *argv[]) |