2007-08-14 Michael Snyder <msnyder@access-company.com>
[deliverable/binutils-gdb.git] / gdb / tui / tui-io.c
index c7c619c112876d51169ccfa78087c9436d79fd87..d39b08976cd3e1905a1c4d89a66d0892b98e1651 100644 (file)
@@ -1,7 +1,7 @@
 /* TUI support I/O functions.
 
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 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)
@@ -147,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)
@@ -167,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
@@ -184,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);
@@ -211,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;
@@ -255,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)
@@ -264,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);
@@ -322,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;
 
@@ -360,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;
@@ -376,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;
@@ -402,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*);
@@ -415,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. */
@@ -587,10 +580,10 @@ tui_cont_sig (int sig)
       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);
 }
@@ -598,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);
@@ -609,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
@@ -651,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.  */
@@ -659,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')
@@ -671,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.  */
@@ -681,8 +674,8 @@ 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);
         }
     }
@@ -693,11 +686,7 @@ tui_getc (FILE *fp)
     }
   
   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';
   
@@ -708,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 ())
     {
       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.028753 seconds and 4 git commands to generate.