* gdb.mi/mi-var-child.exp: Fix matching display of function value.
[deliverable/binutils-gdb.git] / gdb / tui / tui-io.c
index e17971fa0596f3edb221b8806063f422ef9e982a..d39b08976cd3e1905a1c4d89a66d0892b98e1651 100644 (file)
@@ -1,7 +1,7 @@
 /* TUI support I/O functions.
 
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
-   Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
+   Free Software Foundation, Inc.
 
    Contributed by Hewlett-Packard Company.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #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 "tui/tui.h"
 #include "tui/tui-data.h"
 #include "tui/tui-io.h"
 #include <signal.h>
 #include <stdio.h>
 
-#ifdef HAVE_NCURSES_H       
-#include <ncurses.h>
-#else
-#ifdef HAVE_CURSES_H
-#include <curses.h>
-#endif
-#endif
+#include "gdb_curses.h"
+
+/* This redefines CTRL if it is not already defined, so it must come
+   after terminal state releated include files like <term.h> and
+   "gdb_curses.h".  */
+#include "readline/readline.h"
+
+int
+key_is_start_sequence (int ch)
+{
+  return (ch == 27);
+}
+
+int
+key_is_end_sequence (int ch)
+{
+  return (ch == 126);
+}
+
+int
+key_is_backspace (int ch)
+{
+  return (ch == 8);
+}
+
+int
+key_is_command_char (int ch)
+{
+  return ((ch == KEY_NPAGE) || (ch == KEY_PPAGE)
+         || (ch == KEY_LEFT) || (ch == KEY_RIGHT)
+         || (ch == KEY_UP) || (ch == KEY_DOWN)
+         || (ch == KEY_SF) || (ch == KEY_SR)
+         || (ch == (int)'\f') || key_is_start_sequence (ch));
+}
 
 /* Use definition from readline 4.3.  */
 #undef CTRL_CHAR
@@ -119,7 +144,7 @@ static int tui_readline_pipe[2];
    This may be the main gdb prompt or a secondary prompt.  */
 static char *tui_rl_saved_prompt;
 
-static unsigned int _tuiHandleResizeDuringIO (unsigned int);
+static unsigned int tui_handle_resize_during_io (unsigned int);
 
 static void
 tui_putc (char c)
@@ -139,7 +164,7 @@ tui_puts (const char *string)
   char c;
   WINDOW *w;
 
-  w = cmdWin->generic.handle;
+  w = TUI_CMD_WIN->generic.handle;
   while ((c = *string++) != 0)
     {
       /* Catch annotation and discard them.  We need two \032 and
@@ -156,9 +181,9 @@ tui_puts (const char *string)
       else if (c == '\n')
         tui_skip_line = -1;
     }
-  getyx (w, cmdWin->detail.commandInfo.curLine,
-         cmdWin->detail.commandInfo.curch);
-  cmdWin->detail.commandInfo.start_line = cmdWin->detail.commandInfo.curLine;
+  getyx (w, TUI_CMD_WIN->detail.command_info.cur_line,
+         TUI_CMD_WIN->detail.command_info.curch);
+  TUI_CMD_WIN->detail.command_info.start_line = TUI_CMD_WIN->detail.command_info.cur_line;
 
   /* We could defer the following.  */
   wrefresh (w);
@@ -183,18 +208,18 @@ tui_redisplay_readline (void)
 
   /* Detect when we temporarily left SingleKey and now the readline
      edit buffer is empty, automatically restore the SingleKey mode.  */
-  if (tui_current_key_mode == tui_one_command_mode && rl_end == 0)
-    tui_set_key_mode (tui_single_key_mode);
+  if (tui_current_key_mode == TUI_ONE_COMMAND_MODE && rl_end == 0)
+    tui_set_key_mode (TUI_SINGLE_KEY_MODE);
 
-  if (tui_current_key_mode == tui_single_key_mode)
+  if (tui_current_key_mode == TUI_SINGLE_KEY_MODE)
     prompt = "";
   else
     prompt = tui_rl_saved_prompt;
   
   c_pos = -1;
   c_line = -1;
-  w = cmdWin->generic.handle;
-  start_line = cmdWin->detail.commandInfo.start_line;
+  w = TUI_CMD_WIN->generic.handle;
+  start_line = TUI_CMD_WIN->detail.command_info.start_line;
   wmove (w, start_line, 0);
   prev_col = 0;
   height = 1;
@@ -227,8 +252,8 @@ tui_redisplay_readline (void)
        }
       if (c == '\n')
         {
-          getyx (w, cmdWin->detail.commandInfo.start_line,
-                 cmdWin->detail.commandInfo.curch);
+          getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
+                 TUI_CMD_WIN->detail.command_info.curch);
         }
       getyx (w, line, col);
       if (col < prev_col)
@@ -236,15 +261,15 @@ tui_redisplay_readline (void)
       prev_col = col;
     }
   wclrtobot (w);
-  getyx (w, cmdWin->detail.commandInfo.start_line,
-         cmdWin->detail.commandInfo.curch);
+  getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
+         TUI_CMD_WIN->detail.command_info.curch);
   if (c_line >= 0)
     {
       wmove (w, c_line, c_pos);
-      cmdWin->detail.commandInfo.curLine = c_line;
-      cmdWin->detail.commandInfo.curch = c_pos;
+      TUI_CMD_WIN->detail.command_info.cur_line = c_line;
+      TUI_CMD_WIN->detail.command_info.curch = c_pos;
     }
-  cmdWin->detail.commandInfo.start_line -= height - 1;
+  TUI_CMD_WIN->detail.command_info.start_line -= height - 1;
 
   wrefresh (w);
   fflush(stdout);
@@ -294,8 +319,7 @@ tui_readline_output (int code, gdb_client_data data)
 
    Comes from readline/complete.c  */
 static char *
-printable_part (pathname)
-     char *pathname;
+printable_part (char *pathname)
 {
   char *temp;
 
@@ -332,8 +356,7 @@ printable_part (pathname)
     } while (0)
 
 static int
-print_filename (to_print, full_pathname)
-     char *to_print, *full_pathname;
+print_filename (char *to_print, char *full_pathname)
 {
   int printed_len = 0;
   char *s;
@@ -348,7 +371,7 @@ print_filename (to_print, full_pathname)
 /* The user must press "y" or "n".  Non-zero return means "y" pressed.
    Comes from readline/complete.c  */
 static int
-get_y_or_n ()
+get_y_or_n (void)
 {
   extern int _rl_abort_internal ();
   int c;
@@ -374,9 +397,7 @@ get_y_or_n ()
    Comes from readline/complete.c and modified to write in
    the TUI command window using tui_putc/tui_puts.  */
 static void
-tui_rl_display_match_list (matches, len, max)
-     char **matches;
-     int len, max;
+tui_rl_display_match_list (char **matches, int len, int max)
 {
   typedef int QSFUNC (const void *, const void *);
   extern int _rl_qsort_string_compare (const void*, const void*);
@@ -387,7 +408,7 @@ tui_rl_display_match_list (matches, len, max)
   char *temp;
 
   /* Screen dimension correspond to the TUI command window.  */
-  int screenwidth = cmdWin->generic.width;
+  int screenwidth = TUI_CMD_WIN->generic.width;
 
   /* If there are many items, then ask the user if she really wants to
      see them all. */
@@ -556,13 +577,13 @@ tui_cont_sig (int sig)
       resetty ();
 
       /* Force a refresh of the screen.  */
-      tuiRefreshAll ();
+      tui_refresh_all_win ();
 
       /* Update cursor position on the screen.  */
-      wmove (cmdWin->generic.handle,
-             cmdWin->detail.commandInfo.start_line,
-             cmdWin->detail.commandInfo.curch);
-      wrefresh (cmdWin->generic.handle);
+      wmove (TUI_CMD_WIN->generic.handle,
+             TUI_CMD_WIN->detail.command_info.start_line,
+             TUI_CMD_WIN->detail.command_info.curch);
+      wrefresh (TUI_CMD_WIN->generic.handle);
     }
   signal (sig, tui_cont_sig);
 }
@@ -570,7 +591,7 @@ tui_cont_sig (int sig)
 
 /* Initialize the IO for gdb in curses mode.  */
 void
-tui_initialize_io ()
+tui_initialize_io (void)
 {
 #ifdef SIGCONT
   signal (SIGCONT, tui_cont_sig);
@@ -581,8 +602,8 @@ tui_initialize_io ()
   tui_stderr = tui_fileopen (stderr);
   tui_out = tui_out_new (tui_stdout);
 
-  /* Create the default UI.  It is not created because we installed
-     init_ui_hook.  */
+  /* Create the default UI.  It is not created because we installed a
+     deprecated_init_ui_hook.  */
   tui_old_uiout = uiout = cli_out_new (gdb_stdout);
 
 #ifdef TUI_USE_PIPE_FOR_READLINE
@@ -623,7 +644,7 @@ tui_getc (FILE *fp)
   int ch;
   WINDOW *w;
 
-  w = cmdWin->generic.handle;
+  w = TUI_CMD_WIN->generic.handle;
 
 #ifdef TUI_USE_PIPE_FOR_READLINE
   /* Flush readline output.  */
@@ -631,7 +652,7 @@ tui_getc (FILE *fp)
 #endif
 
   ch = wgetch (w);
-  ch = _tuiHandleResizeDuringIO (ch);
+  ch = tui_handle_resize_during_io (ch);
 
   /* The \n must be echoed because it will not be printed by readline.  */
   if (ch == '\n')
@@ -643,7 +664,7 @@ tui_getc (FILE *fp)
          user we recognized the command.  */
       if (rl_end == 0)
         {
-          wmove (w, cmdWin->detail.commandInfo.curLine, 0);
+          wmove (w, TUI_CMD_WIN->detail.command_info.cur_line, 0);
 
           /* Clear the line.  This will blink the gdb prompt since
              it will be redrawn at the same line.  */
@@ -653,23 +674,19 @@ tui_getc (FILE *fp)
         }
       else
         {
-          wmove (w, cmdWin->detail.commandInfo.curLine,
-                 cmdWin->detail.commandInfo.curch);
+          wmove (w, TUI_CMD_WIN->detail.command_info.cur_line,
+                 TUI_CMD_WIN->detail.command_info.curch);
           waddch (w, ch);
         }
     }
   
-  if (m_isCommandChar (ch))
+  if (key_is_command_char (ch))
     {                          /* Handle prev/next/up/down here */
-      ch = tuiDispatchCtrlChar (ch);
+      ch = tui_dispatch_ctrl_char (ch);
     }
   
   if (ch == '\n' || ch == '\r' || ch == '\f')
-    cmdWin->detail.commandInfo.curch = 0;
-#if 0
-  else
-    tuiIncrCommandCharCountBy (1);
-#endif
+    TUI_CMD_WIN->detail.command_info.curch = 0;
   if (ch == KEY_BACKSPACE)
     return '\b';
   
@@ -680,15 +697,15 @@ tui_getc (FILE *fp)
 /* Cleanup when a resize has occured.
    Returns the character that must be processed.  */
 static unsigned int
-_tuiHandleResizeDuringIO (unsigned int originalCh)
+tui_handle_resize_during_io (unsigned int original_ch)
 {
-  if (tuiWinResized ())
+  if (tui_win_resized ())
     {
-      tuiRefreshAll ();
+      tui_refresh_all_win ();
       dont_repeat ();
-      tuiSetWinResizedTo (FALSE);
+      tui_set_win_resized_to (FALSE);
       return '\n';
     }
   else
-    return originalCh;
+    return original_ch;
 }
This page took 0.029643 seconds and 4 git commands to generate.