texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[5637] window_make_window arguments


From: Gavin D. Smith
Subject: [5637] window_make_window arguments
Date: Tue, 03 Jun 2014 19:38:12 +0000

Revision: 5637
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5637
Author:   gavin
Date:     2014-06-03 19:38:11 +0000 (Tue, 03 Jun 2014)
Log Message:
-----------
window_make_window arguments

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/echo-area.c
    trunk/info/footnotes.c
    trunk/info/indices.c
    trunk/info/infodoc.c
    trunk/info/nodemenu.c
    trunk/info/session.c
    trunk/info/window.c
    trunk/info/window.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-06-03 16:40:34 UTC (rev 5636)
+++ trunk/ChangeLog     2014-06-03 19:38:11 UTC (rev 5637)
@@ -1,5 +1,16 @@
 2014-06-03  Gavin Smith  <address@hidden>
 
+       * info/session.c (remember_window_and_node, info_set_node_of_window):
+       remember_window_and_node merged.
+       * info/window.c (window_make_window): Arguments changed.  Don't set
+       node of window.  All callers updated.
+       * info/session.c (info_split_window): Call info_set_node_of_window
+       instead of remember_window_and_node.
+       * info/footnotes.c (info_get_or_remove_footnotes): Reorganized,
+       Comments changed.
+
+2014-06-03  Gavin Smith  <address@hidden>
+
        * info/session.c (info_split_window): Always operate on active
        window.
        * info/window.c (window_make_window)

Modified: trunk/info/echo-area.c
===================================================================
--- trunk/info/echo-area.c      2014-06-03 16:40:34 UTC (rev 5636)
+++ trunk/info/echo-area.c      2014-06-03 19:38:11 UTC (rev 5637)
@@ -1051,8 +1051,9 @@
                 /* Perhaps we can scroll this window on redisplay. */
                 pagetop = calling_window->pagetop;
 
-                compwin =
-                  window_make_window (possible_completions_output_node);
+                compwin = window_make_window ();
+                info_set_node_of_window (compwin,
+                                         possible_completions_output_node);
                 active_window = the_echo_area;
                 window_change_window_height
                   (compwin, -(compwin->height - (iterations + 2)));
@@ -1075,8 +1076,7 @@
           }
 
         if (compwin->node != possible_completions_output_node)
-          info_set_node_of_window
-            (compwin, possible_completions_output_node);
+          info_set_node_of_window (compwin, possible_completions_output_node);
 
         display_update_display (windows);
       }

Modified: trunk/info/footnotes.c
===================================================================
--- trunk/info/footnotes.c      2014-06-03 16:40:34 UTC (rev 5636)
+++ trunk/info/footnotes.c      2014-06-03 19:38:11 UTC (rev 5637)
@@ -205,17 +205,18 @@
     /* Try to find footnotes for this window's node. */
     new_footnotes = make_footnotes_node (window->node);
 
-  /* If there was a window showing footnotes, and there are no footnotes
-     for the current window, delete the old footnote window. */
-  if (fn_win && !new_footnotes)
+  if (!new_footnotes)
     {
-      if (windows->next)
+      /* If there was a window showing footnotes, and there are no footnotes
+         for the current window, delete the old footnote window. */
+      if (fn_win && windows->next)
         info_delete_window_internal (fn_win);
+      return FN_UNFOUND;
     }
 
-  /* If there are footnotes for this window's node, but no window around
-     showing footnotes, try to make a new window. */
-  if (new_footnotes && !fn_win)
+  /* If there is no window around showing footnotes, try
+     to make a new window. */
+  if (!fn_win)
     {
       WINDOW *old_active;
       WINDOW *last, *win;
@@ -228,42 +229,32 @@
          contain the footnotes. */
       old_active = active_window;
       active_window = last;
-      fn_win = window_make_window (new_footnotes);
+      fn_win = window_make_window ();
+      active_window = old_active;
 
-      if (fn_win)
+      /* If we are hacking automatic footnotes, and there are footnotes
+         but we couldn't display them, print a message to that effect. */
+      if (!fn_win)
         {
-          fn_win->flags |= W_TempWindow;
-          active_window = old_active;
-        }
-      else
-        {
-          free (new_footnotes->contents);
-          free (new_footnotes);
-
-          /* If we are hacking automatic footnotes, and there are footnotes
-             but we couldn't display them, print a message to that effect. */
           if (auto_footnotes_p)
             inform_in_echo_area (_("Footnotes could not be displayed"));
           return FN_UNABLE;
         }
     }
 
-  /* If there are footnotes, and there is a window to display them,
-     make that window be the number of lines appearing in the footnotes. */
-  if (new_footnotes && fn_win)
-    {
-      info_set_node_of_window (fn_win, new_footnotes);
-      add_gcable_pointer (new_footnotes->contents);
-      /* TODO: Make sure new_footnotes->references are freed properly. */
+  /* Note that info_set_node_of_window calls this function
+     (info_get_or_remove_footnotes), but we do not recurse indefinitely
+     because we check if we are in the footnote window above. */
+  info_set_node_of_window (fn_win, new_footnotes);
+  add_gcable_pointer (new_footnotes->contents);
+  /* TODO: Make sure new_footnotes->references are freed properly. */
+  fn_win->flags |= W_TempWindow;
 
-      window_change_window_height
-        (fn_win, fn_win->line_count - fn_win->height);
-    }
+  /* Make the height be the number of lines appearing in the footnotes. */
+  if (new_footnotes)
+    window_change_window_height (fn_win, fn_win->line_count - fn_win->height);
 
-  if (!new_footnotes)
-    return FN_UNFOUND;
-  else
-    return FN_FOUND;
+  return FN_FOUND;
 }
 
 /* Show the footnotes associated with this node in another window. */

Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c        2014-06-03 16:40:34 UTC (rev 5636)
+++ trunk/info/indices.c        2014-06-03 19:38:11 UTC (rev 5637)
@@ -682,15 +682,8 @@
         /* If we still don't have a window, make a new one to contain
            the list. */
         if (!new)
-          {
-            WINDOW *old_active;
+          new = window_make_window ();
 
-            old_active = active_window;
-            active_window = window;
-            new = window_make_window (NULL);
-            active_window = old_active;
-          }
-
         /* If we couldn't make a new window, use this one. */
         if (!new)
           new = window;
@@ -871,6 +864,7 @@
       return;
     }
 
+  /* FIXME: Copy allfiles_node so it is unique in the window history? */
   info_set_node_of_window (window, allfiles_node);
 
   if (!info_error_was_printed)

Modified: trunk/info/infodoc.c
===================================================================
--- trunk/info/infodoc.c        2014-06-03 16:40:34 UTC (rev 5636)
+++ trunk/info/infodoc.c        2014-06-03 19:38:11 UTC (rev 5637)
@@ -474,7 +474,8 @@
       if (eligible->height >= HELP_SPLIT_SIZE)
         {
           active_window = eligible;
-          help_window = window_make_window (internal_info_help_node);
+          help_window = window_make_window ();
+          info_set_node_of_window (help_window, internal_info_help_node);
         }
       else
         {

Modified: trunk/info/nodemenu.c
===================================================================
--- trunk/info/nodemenu.c       2014-06-03 16:40:34 UTC (rev 5636)
+++ trunk/info/nodemenu.c       2014-06-03 19:38:11 UTC (rev 5637)
@@ -249,15 +249,8 @@
 
   /* If we still don't have a window, make a new one to contain the list. */
   if (!new)
-    {
-      WINDOW *old_active;
+    new = window_make_window ();
 
-      old_active = active_window;
-      active_window = window;
-      new = window_make_window (NULL);
-      active_window = old_active;
-    }
-
   /* If we couldn't make a new window, use this one. */
   if (!new)
     new = window;

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-06-03 16:40:34 UTC (rev 5636)
+++ trunk/info/session.c        2014-06-03 19:38:11 UTC (rev 5637)
@@ -114,7 +114,7 @@
             }
 
           active_window = largest;
-          window = window_make_window (0);
+          window = window_make_window ();
           info_select_reference (window, references[i]);
 
           if (!window->node)
@@ -307,20 +307,6 @@
 /*                                                                  */
 /* **************************************************************** */
 
-/* Remember this node, the currently displayed pagetop, and the current
-   location of point in this window. */
-static void
-remember_window_and_node (WINDOW *win)
-{
-  WINDOW_STATE *new;
-
-  new = xmalloc (sizeof (WINDOW_STATE));
-  new->node = win->node;
-  new->pagetop = win->pagetop;
-  new->point = win->point;
-  add_pointer_to_array (new, win->hist_index, win->hist, win->hist_slots, 16);
-}
-
 /* Go back one in the node history. */
 void
 forget_node (WINDOW *win)
@@ -353,12 +339,14 @@
   free (win->hist);
 }
 
-/* Set WINDOW to show NODE.  Remember the new window in our list of Info
-   windows.  If we are doing automatic footnote display, also try to display
+/* Set WINDOW to show NODE.  Remember the new window in our list of
+   Info windows.  If we are doing automatic footnote display, try to display
    the footnotes for this window. */
 void
 info_set_node_of_window (WINDOW *win, NODE *node)
 {
+  WINDOW_STATE *new;
+
   /* Remember the current values of pagetop and point if the remembered node
      is the same as the current one being displayed. */
   if (win->hist_index && win->hist[win->hist_index - 1]->node == win->node)
@@ -370,8 +358,13 @@
   /* Put this node into the window. */
   window_set_node_of_window (win, node);
 
-  /* Remember this node and window in our list of info windows. */
-  remember_window_and_node (win);
+  /* Remember this node, the currently displayed pagetop, and the current
+     location of point in this window. */
+  new = xmalloc (sizeof (WINDOW_STATE));
+  new->node = win->node;
+  new->pagetop = win->pagetop;
+  new->point = win->point;
+  add_pointer_to_array (new, win->hist_index, win->hist, win->hist_slots, 16);
 
   /* If doing auto-footnote display/undisplay, show the footnotes belonging
      to this window's node. */
@@ -1279,12 +1272,13 @@
   copy = xmalloc (sizeof (NODE));
   *copy = *window->node; /* Field-by-field copy of structure. */
   /* Make the new window. */
-  split = window_make_window (copy);
+  split = window_make_window ();
 
   if (!split)
     info_error ("%s", msg_win_too_small);
   else
     {
+      info_set_node_of_window (split, copy);
       /* Make sure point still appears in the active window. */
       info_show_point (window);
 
@@ -1294,8 +1288,6 @@
         window_tile_windows (DONT_TILE_INTERNALS);
       else
         window_adjust_pagetop (split);
-
-      remember_window_and_node (split);
     }
 }
 
@@ -2262,7 +2254,8 @@
 
       if (entry->type != REFERENCE_MENU_ITEM) continue;
 
-      new = window_make_window (window->node);
+      new = window_make_window ();
+      info_set_node_of_window (new, window->node);
       window_tile_windows (TILE_INTERNALS);
 
       if (!new)

Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2014-06-03 16:40:34 UTC (rev 5636)
+++ trunk/info/window.c 2014-06-03 19:38:11 UTC (rev 5637)
@@ -263,18 +263,13 @@
     }
 }
 
-/* Make a new window showing NODE, and return that window structure.
-   If NODE is passed as NULL, then show the node showing in the active
-   window.  If the window could not be made return a NULL pointer.  The
-   active window is not changed.*/
+/* Make a new window by splitting an existing one. If the window could
+   not be made return a null pointer.  The active window is not changed .*/
 WINDOW *
-window_make_window (NODE *node)
+window_make_window (void)
 {
   WINDOW *window;
 
-  if (!node)
-    node = active_window->node;
-
   /* If there isn't enough room to make another window, return now. */
   if ((active_window->height / 2) < WINDOW_MIN_SIZE)
     return NULL;
@@ -295,7 +290,6 @@
   window->modeline = xmalloc (1 + window->width);
   window->line_starts = NULL;
   window->flags = W_UpdateWindow | W_WindowVisible;
-  window_set_node_of_window (window, node);
 
   /* Adjust the height of the old active window. */
   active_window->height -= (window->height + 1);

Modified: trunk/info/window.h
===================================================================
--- trunk/info/window.h 2014-06-03 16:40:34 UTC (rev 5636)
+++ trunk/info/window.h 2014-06-03 19:38:11 UTC (rev 5637)
@@ -131,12 +131,9 @@
    You pass WIDTH and HEIGHT; the dimensions of the total screen size. */
 extern void window_initialize_windows (int width, int height);
 
-/* Make a new window showing NODE, and return that window structure.
-   The new window is made to be the active window.  If NODE is passed
-   as NULL, then show the node showing in the active window.  If the
-   window could not be made return a NULL pointer.  The active window
-   is not changed.*/
-extern WINDOW *window_make_window (NODE *node);
+/* Make a new window by splitting an existing one. If the window could
+   not be made return a null pointer.  The active window is not changed .*/
+extern WINDOW *window_make_window (void);
 
 /* Delete WINDOW from the list of known windows.  If this window was the
    active window, make the next window in the chain be the active window,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]