* gdb.base/display.c (do_loops): Add float variable `f'.
[deliverable/binutils-gdb.git] / gdb / tui / tuiIO.c
index c4d43a63a12e50226700030aa5056882a45fe6df..ad8a53a69c64563c7952cc715ece1501f9b7fe32 100644 (file)
@@ -37,6 +37,7 @@
 #include "ui-out.h"
 #include "cli-out.h"
 #include <fcntl.h>
+#include <signal.h>
 
 /* This file controls the IO interactions between gdb and curses.
    When the TUI is enabled, gdb has two modes a curses and a standard
@@ -116,6 +117,7 @@ tui_puts (const char *string)
     }
   getyx (w, cmdWin->detail.commandInfo.curLine,
          cmdWin->detail.commandInfo.curch);
+  cmdWin->detail.commandInfo.start_line = cmdWin->detail.commandInfo.curLine;
 
   /* We could defer the following.  */
   wrefresh (w);
@@ -143,7 +145,7 @@ tui_redisplay_readline (void)
   c_pos = -1;
   c_line = -1;
   w = cmdWin->generic.handle;
-  start_line = cmdWin->detail.commandInfo.curLine;
+  start_line = cmdWin->detail.commandInfo.start_line;
   wmove (w, start_line, 0);
   prev_col = 0;
   height = 1;
@@ -176,7 +178,7 @@ tui_redisplay_readline (void)
        }
       if (c == '\n')
         {
-          getyx (w, cmdWin->detail.commandInfo.curLine,
+          getyx (w, cmdWin->detail.commandInfo.start_line,
                  cmdWin->detail.commandInfo.curch);
         }
       getyx (w, line, col);
@@ -185,13 +187,16 @@ tui_redisplay_readline (void)
       prev_col = col;
     }
   wclrtobot (w);
-  getyx (w, cmdWin->detail.commandInfo.curLine,
+  getyx (w, cmdWin->detail.commandInfo.start_line,
          cmdWin->detail.commandInfo.curch);
   if (c_line >= 0)
-    wmove (w, c_line, c_pos);
+    {
+      wmove (w, c_line, c_pos);
+      cmdWin->detail.commandInfo.curLine = c_line;
+      cmdWin->detail.commandInfo.curch = c_pos;
+    }
+  cmdWin->detail.commandInfo.start_line -= height - 1;
 
-  cmdWin->detail.commandInfo.curLine -= height - 1;
-  
   wrefresh (w);
   fflush(stdout);
 }
@@ -267,6 +272,9 @@ tui_setup_io (int mode)
       gdb_stdlog = gdb_stdout; /* for moment */
       gdb_stdtarg = gdb_stderr;        /* for moment */
       uiout = tui_out;
+
+      /* Save tty for SIGCONT.  */
+      savetty ();
     }
   else
     {
@@ -284,13 +292,44 @@ tui_setup_io (int mode)
       rl_getc_function = tui_old_rl_getc_function;
       rl_outstream = tui_old_rl_outstream;
       readline_echoing_p = tui_old_readline_echoing_p;
+
+      /* Save tty for SIGCONT.  */
+      savetty ();
+    }
+}
+
+#ifdef SIGCONT
+/* Catch SIGCONT to restore the terminal and refresh the screen.  */
+static void
+tui_cont_sig (int sig)
+{
+  if (tui_active)
+    {
+      /* Restore the terminal setting because another process (shell)
+         might have changed it.  */
+      resetty ();
+
+      /* Force a refresh of the screen.  */
+      tuiRefreshAll ();
+
+      /* Update cursor position on the screen.  */
+      wmove (cmdWin->generic.handle,
+             cmdWin->detail.commandInfo.start_line,
+             cmdWin->detail.commandInfo.curch);
+      wrefresh (cmdWin->generic.handle);
     }
+  signal (sig, tui_cont_sig);
 }
+#endif
 
 /* Initialize the IO for gdb in curses mode.  */
 void
 tui_initialize_io ()
 {
+#ifdef SIGCONT
+  signal (SIGCONT, tui_cont_sig);
+#endif
+
   /* Create tui output streams.  */
   tui_stdout = tui_fileopen (stdout);
   tui_stderr = tui_fileopen (stderr);
This page took 0.026694 seconds and 4 git commands to generate.