* tui/tui-interp.c (tui_is_toplevel): New.
authorPedro Alves <palves@redhat.com>
Tue, 30 Mar 2010 22:21:34 +0000 (22:21 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 30 Mar 2010 22:21:34 +0000 (22:21 +0000)
(tui_init): Set it.
(tui_allowed_p): New.
* tui/tui.c (tui_enable): Check if the TUI is allowed before
enabling it.
* tui/tui.h (tui_allowed_p): Declare.

gdb/ChangeLog
gdb/tui/tui-interp.c
gdb/tui/tui.c
gdb/tui/tui.h

index 17d4399d94d60ecd66714618caaf7197e3af06f2..8dc87d0432477d4bac822120389083e0062be992 100644 (file)
@@ -1,3 +1,12 @@
+2010-03-30  Pedro Alves  <pedro@codesourcery.com>
+
+       * tui/tui-interp.c (tui_is_toplevel): New.
+       (tui_init): Set it.
+       (tui_allowed_p): New.
+       * tui/tui.c (tui_enable): Check if the TUI is allowed before
+       enabling it.
+       * tui/tui.h (tui_allowed_p): Declare.
+
 2010-03-30  Ozkan Sezer  <sezeroz@gmail.com>
 
        * serial.h: Include winsock2.h before windows.h.
index 3bb8246ad9ed9b447bb523b023f6f23d1bbae036..2a6c3ce885e21a3d3f66bb0c17a0c7f1bfca7b3f 100644 (file)
@@ -45,11 +45,16 @@ tui_exit (void)
   tui_disable ();
 }
 
+/* True if TUI is the top-level interpreter.  */
+static int tui_is_toplevel = 0;
+
 /* These implement the TUI interpreter.  */
 
 static void *
 tui_init (int top_level)
 {
+  tui_is_toplevel = top_level;
+
   /* Install exit handler to leave the screen in a good shape.  */
   atexit (tui_exit);
 
@@ -63,6 +68,18 @@ tui_init (int top_level)
   return NULL;
 }
 
+/* True if enabling the TUI is allowed.  Example, if the top level
+   interpreter is MI, enabling curses will certainly lose.  */
+
+int
+tui_allowed_p (void)
+{
+  /* Only if TUI is the top level interpreter.  Also don't try to
+     setup curses (and print funny control characters) if we're not
+     outputting to a terminal.  */
+  return tui_is_toplevel && ui_file_isatty (gdb_stdout);
+}
+
 static int
 tui_resume (void *data)
 {
index 2ff5c2d219e17d8c84399fe4cbf93b856ac97834..e126d813609b3315e18e5dad007bf146dd8ad312 100644 (file)
@@ -364,6 +364,9 @@ tui_initialize_readline (void)
 void
 tui_enable (void)
 {
+  if (!tui_allowed_p ())
+    error (_("TUI mode not allowed"));
+
   if (tui_active)
     return;
 
index e9fba98fda07490c043c57671c7683869e2e59f0..7ece1b541157bd4e48800057574790e80e458d13 100644 (file)
@@ -65,6 +65,10 @@ extern int tui_get_command_dimension (unsigned int *width,
    key shortcut.  */
 extern void tui_initialize_readline (void);
 
+/* True if enabling the TUI is allowed.  Example, if the top level
+   interpreter is MI, enabling curses will certainly lose.  */
+extern int tui_allowed_p (void);
+
 /* Enter in the tui mode (curses).  */
 extern void tui_enable (void);
 
This page took 0.029126 seconds and 4 git commands to generate.