#include "ui-out.h"
#include "cli-out.h"
+#define PROMPT(X) the_prompts.prompt_stack[the_prompts.top + X].prompt
+#define PREFIX(X) the_prompts.prompt_stack[the_prompts.top + X].prefix
+#define SUFFIX(X) the_prompts.prompt_stack[the_prompts.top + X].suffix
+
/* Default command line prompt. This is overriden in some configs. */
#ifndef DEFAULT_PROMPT
while (instream && !feof (instream))
{
if (window_hook && instream == stdin)
- (*window_hook) (instream, get_prompt ());
+ (*window_hook) (instream, get_prompt (0));
quit_flag = 0;
if (instream == stdin && stdin_is_tty)
/* Get a command-line. This calls the readline package. */
command = command_line_input (instream == stdin ?
- get_prompt () : (char *) NULL,
+ get_prompt (0) : (char *) NULL,
instream == stdin, "prompt");
if (command == 0)
{
}
}
\f
-/* get_prompt: access method for the GDB prompt string. */
+
+/* get_prefix: access method for the GDB prefix string. */
char *
-get_prompt (void)
+get_prefix (int level)
{
- return PROMPT (0);
+ return PREFIX (level);
}
+/* set_prefix: set method for the GDB prefix string. */
+
void
-set_prompt (const char *s)
+set_prefix (const char *s, int level)
+{
+ /* If S is NULL, just free the PREFIX at level LEVEL and set to
+ NULL. */
+ if (s == NULL)
+ {
+ xfree (PREFIX (level));
+ PREFIX (level) = NULL;
+ }
+ else
+ {
+ char *p = xstrdup (s);
+
+ xfree (PREFIX (level));
+ PREFIX (level) = p;
+ }
+}
+
+/* get_suffix: access method for the GDB suffix string. */
+
+char *
+get_suffix (int level)
{
- char *p = xstrdup (s);
+ return SUFFIX (level);
+}
- xfree (PROMPT (0));
- PROMPT (0) = p;
+/* set_suffix: set method for the GDB suffix string. */
- /* Also, free and set new_async_prompt so prompt changes sync up
- with set/show prompt. */
- xfree (new_async_prompt);
- new_async_prompt = xstrdup (PROMPT (0));
+void
+set_suffix (const char *s, int level)
+{
+ /* If S is NULL, just free the SUFFIX at level LEVEL and set to
+ NULL. */
+ if (s == NULL)
+ {
+ xfree (SUFFIX (level));
+ SUFFIX (level) = NULL;
+ }
+ else
+ {
+ char *p = xstrdup (s);
+
+ xfree (SUFFIX (level));
+ SUFFIX (level) = p;
+ }
+}
+
+ /* get_prompt: access method for the GDB prompt string. */
+
+char *
+get_prompt (int level)
+{
+ return PROMPT (level);
+}
+
+void
+set_prompt (const char *s, int level)
+{
+ /* If S is NULL, just free the PROMPT at level LEVEL and set to
+ NULL. */
+ if (s == NULL)
+ {
+ xfree (PROMPT (level));
+ PROMPT (level) = NULL;
+ }
+ else
+ {
+ char *p = xstrdup (s);
+
+ xfree (PROMPT (0));
+ PROMPT (0) = p;
+
+ if (level == 0)
+ {
+ /* Also, free and set new_async_prompt so prompt changes sync up
+ with set/show prompt. */
+ xfree (new_async_prompt);
+ new_async_prompt = xstrdup (PROMPT (0));
+ }
+ }
}
\f
whatever the DEFAULT_PROMPT is. */
the_prompts.top = 0;
PREFIX (0) = "";
- PROMPT (0) = xstrdup (DEFAULT_PROMPT);
+ set_prompt (DEFAULT_PROMPT, 0);
SUFFIX (0) = "";
/* Set things up for annotation_level > 1, if the user ever decides
to use it. */
async_annotation_suffix = "prompt";
- /* Set the variable associated with the setshow prompt command. */
- new_async_prompt = xstrdup (PROMPT (0));
/* If gdb was started with --annotate=2, this is equivalent to the
user entering the command 'set annotate 2' at the gdb prompt, so