Fix gdb/TUI behavior in response to [Enter] keypress
authorEli Zaretskii <eliz@gnu.org>
Mon, 18 Mar 2019 18:04:40 +0000 (20:04 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 18 Mar 2019 18:06:58 +0000 (20:06 +0200)
gdb/ChangeLog:
2019-03-18  Eli Zaretskii  <eliz@gnu.org>

* tui/tui-io.c (gdb_wgetch): Don't echo CR.
(tui_getc): When gdb_wgetch returns a CR, behave the same as when
it returns a newline.  This fixes a regression in TUI mode, whereby
the next line is output on the same screen line as the user input.

(cherry picked from commit b17c4cd078e2d1d8951951016815e474fb133780)

gdb/ChangeLog
gdb/tui/tui-io.c

index 63eff3b..f577f22 100644 (file)
@@ -1,3 +1,10 @@
+2019-03-18  Eli Zaretskii  <eliz@gnu.org>
+
+       * tui/tui-io.c (gdb_wgetch): Don't echo CR.
+       (tui_getc): When gdb_wgetch returns a CR, behave the same as when
+       it returns a newline.  This fixes a regression in TU mode, whereby
+       the next line is output on the same screen line as the user input.
+
 2019-03-18  Pedro Alves  <palves@redhat.com>
 
        * tui/tui-io.c (reverse_mode_p, reverse_save_bg, reverse_save_fg):
index b908773..ad47c82 100644 (file)
@@ -699,12 +699,6 @@ gdb_wgetch (WINDOW *win)
   nonl ();
   int r = wgetch (win);
   nl ();
-  /* In nonl mode, if the user types Enter, it will not be echoed
-     properly.  This will result in gdb output appearing immediately
-     after the command.  So, if we read \r, emit a \r now, after nl
-     mode has been re-entered, so that the output looks correct.  */
-  if (r == '\r')
-    puts ("\r");
   return r;
 }
 
@@ -931,7 +925,7 @@ tui_getc (FILE *fp)
 
   /* The \n must be echoed because it will not be printed by
      readline.  */
-  if (ch == '\n')
+  if (ch == '\n' || ch == '\r')
     {
       /* When hitting return with an empty input, gdb executes the last
          command.  If we emit a newline, this fills up the command window