This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH]: Fix gdb secondary prompts in TUI
- From: Stephane Carrez <stcarrez at nerim dot fr>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 26 Oct 2002 14:41:10 +0200
- Subject: [PATCH]: Fix gdb secondary prompts in TUI
Hi!
As reported by Ton van Overbeek in [PATCH]: TUI, secondary prompts do not work
http://sources.redhat.com/ml/gdb-patches/2002-10/msg00000.html
the gdb secondary prompts are never printed in TUI mode.
They used to be printed correctly in the past by readline itself.
But since I introduced the use of rl_startup_hook()/rl_already_prompted to avoid
to have readline to write directly on the rl_outstream, the TUI must now obtain
the good prompt and print it correctly.
This must be done by saving the rl_prompt when readline configures itself
(tui_prep_terminal is a good place for that), and using that prompt when we
redisplay the readline buffer.
I committed this patch on 5_3-branch and mainline.
Stephane
2002-10-26 Stephane Carrez <stcarrez@nerim.fr>
* tuiIO.c (tui_prep_terminal): Save the prompt registered in readline.
(tui_redisplay_readline): Use the last saved prompt.
(tui_rl_saved_prompt): New.
Index: tuiIO.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiIO.c,v
retrieving revision 1.15.2.4
diff -u -p -r1.15.2.4 tuiIO.c
--- tuiIO.c 25 Oct 2002 19:24:29 -0000 1.15.2.4
+++ tuiIO.c 26 Oct 2002 10:01:56 -0000
@@ -124,6 +124,10 @@ static FILE *tui_old_rl_outstream;
static int tui_readline_pipe[2];
#endif
+/* The last gdb prompt that was registered in readline.
+ This may be the main gdb prompt or a secondary prompt. */
+static char *tui_rl_saved_prompt;
+
static unsigned int _tuiHandleResizeDuringIO (unsigned int);
static void
@@ -194,7 +198,7 @@ tui_redisplay_readline (void)
if (tui_current_key_mode == tui_single_key_mode)
prompt = "";
else
- prompt = get_prompt ();
+ prompt = tui_rl_saved_prompt;
c_pos = -1;
c_line = -1;
@@ -256,10 +260,15 @@ tui_redisplay_readline (void)
}
/* Readline callback to prepare the terminal. It is called once
- each time we enter readline. There is nothing to do in curses mode. */
+ each time we enter readline. Terminal is already setup in curses mode. */
static void
tui_prep_terminal (void)
{
+ /* Save the prompt registered in readline to correctly display it.
+ (we can't use gdb_prompt() due to secondary prompts and can't use
+ rl_prompt because it points to an alloca buffer). */
+ xfree (tui_rl_saved_prompt);
+ tui_rl_saved_prompt = xstrdup (rl_prompt);
}
/* Readline callback to restore the terminal. It is called once