]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/tui/tui-interp.c
gdb/tui: fix issue with handling the return character
[thirdparty/binutils-gdb.git] / gdb / tui / tui-interp.c
index 331e97ff11f20980c97747be7790d7ba40b1679d..f70e1a7b4c21b9affdb5b3ed18ff1c4a219ddf6b 100644 (file)
@@ -247,6 +247,27 @@ tui_interp::init (bool top_level)
     tui_ensure_readline_initialized ();
 }
 
+/* Used as the command handler for the tui.  */
+
+static void
+tui_command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl)
+{
+  /* When a tui enabled GDB is running in either tui mode or cli mode then
+     it is always the tui interpreter that is in use.  As a result we end
+     up in here even in standard cli mode.
+
+     We only need to do any special actions when the tui is in use
+     though.  When the tui is active the users return is not echoed to the
+     screen as a result the display will not automatically move us to the
+     next line.  Here we manually insert a newline character and move the
+     cursor.  */
+  if (tui_active)
+    tui_inject_newline_into_command_window ();
+
+  /* Now perform GDB's standard CLI command line handling.  */
+  command_line_handler (std::move (rl));
+}
+
 void
 tui_interp::resume ()
 {
@@ -266,7 +287,7 @@ tui_interp::resume ()
 
   gdb_setup_readline (1);
 
-  ui->input_handler = command_line_handler;
+  ui->input_handler = tui_command_line_handler;
 
   if (stream != NULL)
     tui_old_uiout->set_stream (gdb_stdout);