Inline constructors and initializers
[deliverable/binutils-gdb.git] / gdb / tui / tui-win.c
index 575620f4c89e40e58c81f56afc1eebcb5c2034b1..9c4f9ad57790a9db80651b95b8751724274e6423 100644 (file)
@@ -470,125 +470,41 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
 
 
 void
-tui_scroll_forward (struct tui_win_info *win_to_scroll, 
-                   int num_to_scroll)
+tui_win_info::forward_scroll (int num_to_scroll)
 {
-  if (win_to_scroll != TUI_CMD_WIN)
-    {
-      int _num_to_scroll = num_to_scroll;
-
-      if (num_to_scroll == 0)
-       _num_to_scroll = win_to_scroll->generic.height - 3;
-
-      /* If we are scrolling the source or disassembly window, do a
-         "psuedo" scroll since not all of the source is in memory,
-         only what is in the viewport.  If win_to_scroll is the
-         command window do nothing since the term should handle
-         it.  */
-      if (win_to_scroll == TUI_SRC_WIN)
-       tui_vertical_source_scroll (FORWARD_SCROLL, _num_to_scroll);
-      else if (win_to_scroll == TUI_DISASM_WIN)
-       tui_vertical_disassem_scroll (FORWARD_SCROLL, _num_to_scroll);
-      else if (win_to_scroll == TUI_DATA_WIN)
-       tui_vertical_data_scroll (FORWARD_SCROLL, _num_to_scroll);
-    }
-}
+  if (num_to_scroll == 0)
+    num_to_scroll = generic.height - 3;
 
-void
-tui_scroll_backward (struct tui_win_info *win_to_scroll, 
-                    int num_to_scroll)
-{
-  if (win_to_scroll != TUI_CMD_WIN)
-    {
-      int _num_to_scroll = num_to_scroll;
-
-      if (num_to_scroll == 0)
-       _num_to_scroll = win_to_scroll->generic.height - 3;
-
-      /* If we are scrolling the source or disassembly window, do a
-         "psuedo" scroll since not all of the source is in memory,
-         only what is in the viewport.  If win_to_scroll is the
-         command window do nothing since the term should handle
-         it.  */
-      if (win_to_scroll == TUI_SRC_WIN)
-       tui_vertical_source_scroll (BACKWARD_SCROLL, _num_to_scroll);
-      else if (win_to_scroll == TUI_DISASM_WIN)
-       tui_vertical_disassem_scroll (BACKWARD_SCROLL, _num_to_scroll);
-      else if (win_to_scroll == TUI_DATA_WIN)
-       tui_vertical_data_scroll (BACKWARD_SCROLL, _num_to_scroll);
-    }
+  do_scroll_vertical (FORWARD_SCROLL, num_to_scroll);
 }
 
-
 void
-tui_scroll_left (struct tui_win_info *win_to_scroll,
-                int num_to_scroll)
+tui_win_info::backward_scroll (int num_to_scroll)
 {
-  if (win_to_scroll != TUI_CMD_WIN)
-    {
-      int _num_to_scroll = num_to_scroll;
-
-      if (_num_to_scroll == 0)
-       _num_to_scroll = 1;
-
-      /* If we are scrolling the source or disassembly window, do a
-         "psuedo" scroll since not all of the source is in memory,
-         only what is in the viewport. If win_to_scroll is the command
-         window do nothing since the term should handle it.  */
-      if (win_to_scroll == TUI_SRC_WIN
-         || win_to_scroll == TUI_DISASM_WIN)
-       tui_horizontal_source_scroll (win_to_scroll, LEFT_SCROLL,
-                                     _num_to_scroll);
-    }
+  if (num_to_scroll == 0)
+    num_to_scroll = generic.height - 3;
+
+  do_scroll_vertical (BACKWARD_SCROLL, num_to_scroll);
 }
 
 
 void
-tui_scroll_right (struct tui_win_info *win_to_scroll, 
-                 int num_to_scroll)
+tui_win_info::left_scroll (int num_to_scroll)
 {
-  if (win_to_scroll != TUI_CMD_WIN)
-    {
-      int _num_to_scroll = num_to_scroll;
-
-      if (_num_to_scroll == 0)
-       _num_to_scroll = 1;
-
-      /* If we are scrolling the source or disassembly window, do a
-         "psuedo" scroll since not all of the source is in memory,
-         only what is in the viewport. If win_to_scroll is the command
-         window do nothing since the term should handle it.  */
-      if (win_to_scroll == TUI_SRC_WIN
-         || win_to_scroll == TUI_DISASM_WIN)
-       tui_horizontal_source_scroll (win_to_scroll, RIGHT_SCROLL,
-                                     _num_to_scroll);
-    }
+  if (num_to_scroll == 0)
+    num_to_scroll = 1;
+
+  do_scroll_horizontal (LEFT_SCROLL, num_to_scroll);
 }
 
 
-/* Scroll a window.  Arguments are passed through a va_list.  */
 void
-tui_scroll (enum tui_scroll_direction direction,
-           struct tui_win_info *win_to_scroll,
-           int num_to_scroll)
+tui_win_info::right_scroll (int num_to_scroll)
 {
-  switch (direction)
-    {
-    case FORWARD_SCROLL:
-      tui_scroll_forward (win_to_scroll, num_to_scroll);
-      break;
-    case BACKWARD_SCROLL:
-      tui_scroll_backward (win_to_scroll, num_to_scroll);
-      break;
-    case LEFT_SCROLL:
-      tui_scroll_left (win_to_scroll, num_to_scroll);
-      break;
-    case RIGHT_SCROLL:
-      tui_scroll_right (win_to_scroll, num_to_scroll);
-      break;
-    default:
-      break;
-    }
+  if (num_to_scroll == 0)
+    num_to_scroll = 1;
+
+  do_scroll_horizontal (RIGHT_SCROLL, num_to_scroll);
 }
 
 
@@ -686,7 +602,7 @@ tui_resize_all (void)
        {
        case SRC_COMMAND:
        case DISASSEM_COMMAND:
-         first_win = tui_source_windows ()->list[0];
+         first_win = tui_source_windows ()[0];
          first_win->generic.width += width_diff;
          locator->width += width_diff;
          /* Check for invalid heights.  */
@@ -723,7 +639,7 @@ tui_resize_all (void)
            {
              first_win = TUI_DATA_WIN;
              first_win->generic.width += width_diff;
-             second_win = tui_source_windows ()->list[0];
+             second_win = tui_source_windows ()[0];
              second_win->generic.width += width_diff;
            }
          /* Change the first window's height/width.  */
@@ -785,7 +701,7 @@ tui_resize_all (void)
              && (tui_win_list[win_type] != NULL)
              && !tui_win_list[win_type]->generic.is_visible)
            {
-             tui_free_window (tui_win_list[win_type]);
+             delete tui_win_list[win_type];
              tui_win_list[win_type] = NULL;
            }
        }
@@ -877,10 +793,10 @@ tui_scroll_forward_command (const char *arg, int from_tty)
   /* Make sure the curses mode is enabled.  */
   tui_enable ();
   if (arg == NULL)
-    parse_scrolling_args (arg, &win_to_scroll, (int *) NULL);
+    parse_scrolling_args (arg, &win_to_scroll, NULL);
   else
     parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
-  tui_scroll (FORWARD_SCROLL, win_to_scroll, num_to_scroll);
+  win_to_scroll->forward_scroll (num_to_scroll);
 }
 
 
@@ -893,10 +809,10 @@ tui_scroll_backward_command (const char *arg, int from_tty)
   /* Make sure the curses mode is enabled.  */
   tui_enable ();
   if (arg == NULL)
-    parse_scrolling_args (arg, &win_to_scroll, (int *) NULL);
+    parse_scrolling_args (arg, &win_to_scroll, NULL);
   else
     parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
-  tui_scroll (BACKWARD_SCROLL, win_to_scroll, num_to_scroll);
+  win_to_scroll->backward_scroll (num_to_scroll);
 }
 
 
@@ -909,7 +825,7 @@ tui_scroll_left_command (const char *arg, int from_tty)
   /* Make sure the curses mode is enabled.  */
   tui_enable ();
   parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
-  tui_scroll (LEFT_SCROLL, win_to_scroll, num_to_scroll);
+  win_to_scroll->left_scroll (num_to_scroll);
 }
 
 
@@ -922,7 +838,7 @@ tui_scroll_right_command (const char *arg, int from_tty)
   /* Make sure the curses mode is enabled.  */
   tui_enable ();
   parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
-  tui_scroll (RIGHT_SCROLL, win_to_scroll, num_to_scroll);
+  win_to_scroll->right_scroll (num_to_scroll);
 }
 
 
@@ -946,8 +862,7 @@ tui_set_focus (const char *arg, int from_tty)
       else
        win_info = tui_partial_win_by_name (buf_ptr);
 
-      if (win_info == (struct tui_win_info *) NULL
-         || !win_info->generic.is_visible)
+      if (win_info == NULL || !win_info->generic.is_visible)
        warning (_("Invalid window specified. \n\
 The window name specified must be valid and visible.\n"));
       else
@@ -1116,8 +1031,7 @@ tui_set_win_height (const char *arg, int from_tty)
            wname[i] = tolower (wname[i]);
          win_info = tui_partial_win_by_name (wname);
 
-         if (win_info == (struct tui_win_info *) NULL
-             || !win_info->generic.is_visible)
+         if (win_info == NULL || !win_info->generic.is_visible)
            warning (_("Invalid window specified. \n\
 The window name specified must be valid and visible.\n"));
          else
@@ -1206,7 +1120,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
              make_invisible_and_set_new_height (primary_win_info, new_height);
              if (primary_win_info->generic.type == CMD_WIN)
                {
-                 win_info = (tui_source_windows ())->list[0];
+                 win_info = tui_source_windows ()[0];
                  src_win_info = win_info;
                }
              else
@@ -1235,7 +1149,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
              else
                {
                  first_win = TUI_DATA_WIN;
-                 second_win = (tui_source_windows ())->list[0];
+                 second_win = tui_source_windows ()[0];
                }
              if (primary_win_info == TUI_CMD_WIN)
                { /* Split the change in height accross the 1st & 2nd
@@ -1354,11 +1268,13 @@ make_invisible_and_set_new_height (struct tui_win_info *win_info,
     win_info->generic.viewport_height--;
 
   /* Now deal with the auxillary windows associated with win_info.  */
+  tui_source_window_base *base;
   switch (win_info->generic.type)
     {
     case SRC_WIN:
     case DISASSEM_WIN:
-      gen_win_info = win_info->detail.source_info.execution_info;
+      base = (tui_source_window_base *) win_info;
+      gen_win_info = base->execution_info;
       tui_make_invisible (gen_win_info);
       gen_win_info->height = height;
       gen_win_info->origin.y = win_info->generic.origin.y;
@@ -1369,7 +1285,7 @@ make_invisible_and_set_new_height (struct tui_win_info *win_info,
       if (win_info != TUI_CMD_WIN)
        gen_win_info->viewport_height--;
 
-      if (tui_win_has_locator (win_info))
+      if (win_info->has_locator ())
        {
          gen_win_info = tui_locator_win_info_ptr ();
          tui_make_invisible (gen_win_info);
@@ -1402,20 +1318,22 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 
   tui_make_visible (&win_info->generic);
   tui_check_and_display_highlight_if_needed (win_info);
+  tui_source_window_base *base;
   switch (win_info->generic.type)
     {
     case SRC_WIN:
     case DISASSEM_WIN:
-      tui_free_win_content (win_info->detail.source_info.execution_info);
-      tui_make_visible (win_info->detail.source_info.execution_info);
+      base = (tui_source_window_base *) win_info;
+      tui_free_win_content (base->execution_info);
+      tui_make_visible (base->execution_info);
       if (win_info->generic.content != NULL)
        {
-         struct gdbarch *gdbarch = win_info->detail.source_info.gdbarch;
+         struct gdbarch *gdbarch = base->gdbarch;
          struct tui_line_or_address line_or_addr;
          struct symtab_and_line cursal
            = get_current_source_symtab_and_line ();
 
-         line_or_addr = win_info->detail.source_info.start_line_or_addr;
+         line_or_addr = base->start_line_or_addr;
          tui_free_win_content (&win_info->generic);
          tui_update_source_window (win_info, gdbarch,
                                    cursal.symtab, line_or_addr, TRUE);
@@ -1441,7 +1359,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
            }
          tui_update_source_window (win_info, gdbarch, s, line, TRUE);
        }
-      if (tui_win_has_locator (win_info))
+      if (win_info->has_locator ())
        {
          tui_make_visible (tui_locator_win_info_ptr ());
          tui_show_locator_content ();
@@ -1492,7 +1410,7 @@ new_height_ok (struct tui_win_info *primary_win_info,
              struct tui_win_info *win_info;
 
              if (primary_win_info == TUI_CMD_WIN)
-               win_info = (tui_source_windows ())->list[0];
+               win_info = tui_source_windows ()[0];
              else
                win_info = TUI_CMD_WIN;
              ok = ((new_height +
@@ -1513,7 +1431,7 @@ new_height_ok (struct tui_win_info *primary_win_info,
          else
            {
              first_win = TUI_DATA_WIN;
-             second_win = (tui_source_windows ())->list[0];
+             second_win = tui_source_windows ()[0];
            }
          /* We could simply add all the heights to obtain the same
             result but below is more explicit since we subtract 1 for
@@ -1634,12 +1552,12 @@ parse_scrolling_args (const char *arg,
          
          *win_to_scroll = tui_partial_win_by_name (wname);
 
-         if (*win_to_scroll == (struct tui_win_info *) NULL
+         if (*win_to_scroll == NULL
              || !(*win_to_scroll)->generic.is_visible)
            error (_("Invalid window specified. \n\
 The window name specified must be valid and visible.\n"));
          else if (*win_to_scroll == TUI_CMD_WIN)
-           *win_to_scroll = (tui_source_windows ())->list[0];
+           *win_to_scroll = tui_source_windows ()[0];
        }
     }
 }
This page took 0.027657 seconds and 4 git commands to generate.