[51/61] Fix flushing bug in tui_puts_internal

Message ID 20190704170311.15982-52-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey July 4, 2019, 5:03 p.m. UTC
  A while back I changed gdb not to flush in some places.  It turned out
that this broke the TUI a little.  An easy way to see it is to run
"gdb -tui -nx", then "file gdb" at the gdb prompt.  gdb will print the
usual "Reading symbols..." message -- but it won't appear on-screen
until the reading is complete.

This patch changes the TUI to do the equivalent of line buffering in
tui_puts_internal.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-io.c (tui_puts_internal): Call wrefresh is newline is
	seen.
---
 gdb/ChangeLog    | 5 +++++
 gdb/tui/tui-io.c | 6 ++++++
 2 files changed, 11 insertions(+)
  

Comments

Pedro Alves July 17, 2019, 12:37 p.m. UTC | #1
On 7/4/19 6:03 PM, Tom Tromey wrote:
> A while back I changed gdb not to flush in some places.  It turned out
> that this broke the TUI a little.  An easy way to see it is to run
> "gdb -tui -nx", then "file gdb" at the gdb prompt.  gdb will print the
> usual "Reading symbols..." message -- but it won't appear on-screen
> until the reading is complete.
> 
> This patch changes the TUI to do the equivalent of line buffering in
> tui_puts_internal.
> 
> 2019-07-04  Tom Tromey  <tom@tromey.com>
> 
> 	* tui/tui-io.c (tui_puts_internal): Call wrefresh is newline is

"if newline"

> 	seen.
Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 56d5974cb35..51f69185da3 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -461,9 +461,13 @@  tui_puts_internal (WINDOW *w, const char *string, int *height)
 {
   char c;
   int prev_col = 0;
+  bool saw_nl = false;
 
   while ((c = *string++) != 0)
     {
+      if (c == '\n')
+	saw_nl = true;
+
       if (c == '\1' || c == '\2')
 	{
 	  /* Ignore these, they are readline escape-marking
@@ -492,6 +496,8 @@  tui_puts_internal (WINDOW *w, const char *string, int *height)
 	}
     }
   update_cmdwin_start_line ();
+  if (saw_nl)
+    wrefresh (w);
 }
 
 /* Print a string in the curses command window.  The output is