2002-08-31 Stephane Carrez <stcarrez@nerim.fr>
[deliverable/binutils-gdb.git] / gdb / tui / tuiIO.c
index a0899292715381ec2a055952624ff59dff97a200..c48565ceb1f959568b5a9354b3a97eb292ba95b3 100644 (file)
@@ -1,5 +1,8 @@
 /* TUI support I/O functions.
-   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
+   Inc.
+
    Contributed by Hewlett-Packard Company.
 
    This file is part of GDB.
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+/* FIXME: cagney/2002-02-28: The GDB coding standard indicates that
+   "defs.h" should be included first.  Unfortunatly some systems
+   (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h>
+   and they clash with "bfd.h"'s definiton of true/false.  The correct
+   fix is to remove true/false from "bfd.h", however, until that
+   happens, hack around it by including "config.h" and <curses.h>
+   first.  */
+
+#include "config.h"
+#ifdef HAVE_NCURSES_H       
+#include <ncurses.h>
+#else
+#ifdef HAVE_CURSES_H
+#include <curses.h>
+#endif
+#endif
+
 #include <stdio.h>
 #include "defs.h"
 #include "terminal.h"
 #include "target.h"
 #include "event-loop.h"
+#include "event-top.h"
 #include "command.h"
 #include "top.h"
 #include "readline/readline.h"
 #include <fcntl.h>
 #include <signal.h>
 
+/* Use definition from readline 4.3.  */
+#undef CTRL_CHAR
+#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
+
 /* This file controls the IO interactions between gdb and curses.
    When the TUI is enabled, gdb has two modes a curses and a standard
    mode.
@@ -117,6 +142,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);
@@ -126,7 +152,7 @@ tui_puts (const char *string)
 /* Readline callback.
    Redisplay the command line with its prompt after readline has
    changed the edited text.  */
-static void
+void
 tui_redisplay_readline (void)
 {
   int prev_col;
@@ -139,12 +165,15 @@ tui_redisplay_readline (void)
   char *prompt;
   int start_line;
   
-  prompt = get_prompt ();
+  if (tui_current_key_mode == tui_single_key_mode)
+    prompt = "";
+  else
+    prompt = get_prompt ();
   
   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;
@@ -177,7 +206,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);
@@ -186,13 +215,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);
 }
@@ -307,6 +339,12 @@ tui_cont_sig (int sig)
 
       /* 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);
 }
This page took 0.025344 seconds and 4 git commands to generate.