[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5625] use WINDOW_STATE array for window history
From: |
Gavin D. Smith |
Subject: |
[5625] use WINDOW_STATE array for window history |
Date: |
Sun, 01 Jun 2014 20:33:12 +0000 |
Revision: 5625
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5625
Author: gavin
Date: 2014-06-01 20:33:10 +0000 (Sun, 01 Jun 2014)
Log Message:
-----------
use WINDOW_STATE array for window history
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/gc.c
trunk/info/nodemenu.c
trunk/info/session.c
trunk/info/window.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-06-01 14:48:28 UTC (rev 5624)
+++ trunk/ChangeLog 2014-06-01 20:33:10 UTC (rev 5625)
@@ -1,5 +1,25 @@
2014-06-01 Gavin Smith <address@hidden>
+ * info/window.h (WINDOW): Fields nodes, pagetops, points
+ nodes_index, nodes_slots removed. Replaced with hist, hist_index
+ and hist_slots.
+
+ * info/gc.c (gc_pointers)
+ * info/nodemenu.c (get_visited_nodes): Iterate over hist array
+ in WINDOW.
+
+ * info/session.c (set_remembered_pagetop_and_point)
+ (remember_window_and_node, forget_window_and_nodes)
+ (info_handle_pointer, kill_node, info_gc_file_buffers):
+ Access window node history in hist field of WINDOW.
+
+ (remember_window_and_node): Use add_pointer_to_array macro.
+
+ (forget_node): New function.
+ (forward_move_node_structure, kill_node): Call forget_node.
+
+2014-06-01 Gavin Smith <address@hidden>
+
* info/session.c: Some reordering of definitions and section comments.
No functional changes intended.
Modified: trunk/info/gc.c
===================================================================
--- trunk/info/gc.c 2014-06-01 14:48:28 UTC (rev 5624)
+++ trunk/info/gc.c 2014-06-01 20:33:10 UTC (rev 5625)
@@ -55,9 +55,9 @@
for (iw = windows; iw; iw = iw->next)
{
- for (j = 0; j < iw->nodes_index; j++)
+ for (j = 0; j < iw->hist_index; j++)
{
- NODE *node = iw->nodes[j];
+ NODE *node = iw->hist[j]->node;
/* If this node->contents appears in our list of gcable_pointers,
it is not gc-able, so save it. */
Modified: trunk/info/nodemenu.c
===================================================================
--- trunk/info/nodemenu.c 2014-06-01 14:48:28 UTC (rev 5624)
+++ trunk/info/nodemenu.c 2014-06-01 20:33:10 UTC (rev 5625)
@@ -140,9 +140,9 @@
for (info_win = windows; info_win; info_win = info_win->next)
{
- for (i = 0; i < info_win->nodes_index; i++)
+ for (i = 0; i < info_win->hist_index; i++)
{
- NODE *history_node = info_win->nodes[i];
+ NODE *history_node = info_win->hist[i]->node;
/* We skip mentioning "*Node Menu*" nodes. */
if (internal_info_node_p (history_node) &&
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-06-01 14:48:28 UTC (rev 5624)
+++ trunk/info/session.c 2014-06-01 20:33:10 UTC (rev 5625)
@@ -313,63 +313,64 @@
void
set_remembered_pagetop_and_point (WINDOW *win)
{
- if (win->nodes_index && win->nodes[win->nodes_index - 1] == win->node)
+ if (win->hist_index && win->hist[win->hist_index - 1]->node == win->node)
{
- win->pagetops[win->nodes_index - 1] = win->pagetop;
- win->points[win->nodes_index - 1] = win->point;
+ win->hist[win->hist_index - 1]->pagetop = win->pagetop;
+ win->hist[win->hist_index - 1]->point = win->point;
}
}
+/* Remember this node, the currently displayed pagetop, and the current
+ location of point in this window. */
void
remember_window_and_node (WINDOW *win)
{
+ WINDOW_STATE *new;
+
/* If this node, the current pagetop, and the current point are the
same as the current saved node and pagetop, don't really add this to
the list of history nodes. This may happen only at the very
beginning of the program, I'm not sure. --karl */
- if (win->nodes
- && win->nodes_index >= 1
- && win->nodes[win->nodes_index - 1]->contents == win->node->contents
- && win->pagetops[win->nodes_index - 1] == win->pagetop
- && win->points[win->nodes_index - 1] == win->point)
+ if (win->hist
+ && win->hist_index >= 1
+ && win->hist[win->hist_index - 1]->node->contents == win->node->contents
+ && win->hist[win->hist_index - 1]->pagetop == win->pagetop
+ && win->hist[win->hist_index - 1]->point == win->point)
return;
- /* Remember this node, the currently displayed pagetop, and the current
- location of point in this window. Because we are updating pagetops
- and points as well as nodes, it is more efficient to avoid the
- add_pointer_to_array macro here. */
- if (win->nodes_index + 2 >= win->nodes_slots)
- {
- win->nodes_slots += 20;
- win->nodes = (NODE **) xrealloc (win->nodes,
- win->nodes_slots * sizeof (NODE *));
- win->pagetops = (int *) xrealloc (win->pagetops,
- win->nodes_slots * sizeof (int));
- win->points = (long *) xrealloc (win->points,
- win->nodes_slots * sizeof (long));
- }
+ 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);
+}
- win->nodes[win->nodes_index] = win->node;
- win->pagetops[win->nodes_index] = win->pagetop;
- win->points[win->nodes_index] = win->point;
- win->nodes_index++;
- win->nodes[win->nodes_index] = NULL;
- win->pagetops[win->nodes_index] = 0;
- win->points[win->nodes_index] = 0;
+/* Go back one in the node history. */
+void
+forget_node (WINDOW *win)
+{
+ int i = win->hist_index;
+ if (i == 0)
+ return;
+
+ free (win->hist[i - 1]);
+ win->hist[i - 1] = 0;
+ i = --win->hist_index;
+
+ window_set_node_of_window (win, win->hist[i - 1]->node);
+ win->pagetop = win->hist[i - 1]->pagetop;
+ win->point = win->hist[i - 1]->point;
+ win->node->display_pos = win->point;
}
-/* Remove WINDOW and its associated list of nodes. */
+/* Remove associated list of nodes of WINDOW. */
void
forget_window_and_nodes (WINDOW *win)
{
- if (win->nodes)
- {
- int i;
-
- free (win->nodes);
- free (win->pagetops);
- free (win->points);
- }
+ int i;
+ for (i = 0; i < win->hist_index; i++)
+ free (win->hist[i]);
+ free (win->hist);
}
/* Set WINDOW to show NODE. Remember the new window in our list of Info
@@ -1494,9 +1495,9 @@
{
int i;
- for (i = window->nodes_index - 1; i >= 0; i--)
+ for (i = window->hist_index - 1; i >= 0; i--)
{
- NODE *p = window->nodes[i];
+ NODE *p = window->hist[i]->node;
if (p->filename && !strcmp (p->filename, node->filename)
&& p->nodename && !strcmp (p->nodename, node->nodename))
@@ -1504,7 +1505,7 @@
}
if (i >= 0)
- node->display_pos = window->points[i];
+ node->display_pos = window->hist[i]->point;
}
info_set_node_of_window (window, node);
@@ -1722,14 +1723,8 @@
register int i;
for (i = 0; i < up_counter; i++)
- {
- window->nodes_index--;
- free (window->nodes[window->nodes_index]);
- window->nodes[window->nodes_index] = NULL;
- }
- window->node = window->nodes[window->nodes_index - 1];
- window->pagetop = window->pagetops[window->nodes_index - 1];
- window->point = window->points[window->nodes_index - 1];
+ forget_node (window);
+
recalculate_line_starts (window);
window->flags |= W_UpdateWindow;
info_error ("%s", _("No more nodes within this document."));
@@ -2949,7 +2944,8 @@
return;
}
- if (strcmp (nodename, info_win->nodes[info_win->nodes_index - 1]->nodename))
+ if (strcmp (nodename,
+ info_win->hist[info_win->hist_index - 1]->node->nodename))
return;
if (!info_win)
@@ -2963,26 +2959,14 @@
}
/* If this is the last node in the window, complain and exit. */
- if (info_win->nodes_index == 1)
+ if (info_win->hist_index == 1)
{
info_error ("%s", _("Cannot kill the last node"));
return;
}
- /* INFO_WIN contains the node that the user wants to stop viewing. Delete
- this node from the list of nodes previously shown in this window. */
- for (i = info_win->nodes_index - 1; i < info_win->nodes_index; i++)
- info_win->nodes[i] = info_win->nodes[i + 1];
+ forget_node (window);
- /* There is one less node in this window's history list. */
- info_win->nodes_index--;
-
- /* Make this window show the most recent history node. */
-
- temp = info_win->nodes[info_win->nodes_index - 1];
- temp->display_pos = info_win->points[info_win->nodes_index - 1];
- window_set_node_of_window (info_win, temp);
-
if (!info_error_was_printed)
window_clear_echo_area ();
@@ -4302,11 +4286,12 @@
this file. */
for (iw = windows; iw; iw = iw->next)
{
- for (i = 0; iw->nodes && iw->nodes[i]; i++)
+ for (i = 0; iw->hist && iw->hist[i]; i++)
{
- if (iw->nodes[i]->filename &&
- ((FILENAME_CMP (fb->fullpath, iw->nodes[i]->filename) == 0) ||
- (FILENAME_CMP (fb->filename, iw->nodes[i]->filename) == 0)))
+ NODE *n = iw->hist[i]->node;
+ if (n->filename
+ && ((FILENAME_CMP (fb->fullpath, n->filename) == 0)
+ || (FILENAME_CMP (fb->filename, n->filename) == 0)))
{
fb_referenced_p = 1;
break;
@@ -4314,9 +4299,9 @@
/* If any subfile of a split file is referenced, none of
the rewritten nodes in the split file is freed. */
- if (iw->nodes[i]->parent &&
- ((FILENAME_CMP (fb->fullpath, iw->nodes[i]->parent) == 0) ||
- (FILENAME_CMP (fb->filename, iw->nodes[i]->parent) == 0)))
+ if (n->parent
+ && ((FILENAME_CMP (fb->fullpath, n->parent) == 0)
+ || (FILENAME_CMP (fb->filename, n->parent) == 0)))
{
parent_referenced_p = 1;
break;
Modified: trunk/info/window.h
===================================================================
--- trunk/info/window.h 2014-06-01 14:48:28 UTC (rev 5624)
+++ trunk/info/window.h 2014-06-01 20:33:10 UTC (rev 5625)
@@ -58,6 +58,10 @@
int pagetop; /* LINE_STARTS[PAGETOP] is first line in WINDOW. */ \
long point /* Offset within NODE of the cursor position. */
+typedef struct {
+ WINDOW_STATE_DECL; /* What gets saved. */
+} WINDOW_STATE;
+
/* Structure which defines a window. Windows are doubly linked, next
and prev. The list of windows is kept on WINDOWS. The structure member
window->height is the total height of the window. The position location
@@ -84,18 +88,12 @@
int flags; /* See below for details. */
- /* Information on which nodes have been visited in this window. */
- NODE **nodes; /* Array of nodes visited in this window. */
- int *pagetops; /* For each node in NODES, the pagetop. */
- long *points; /* For each node in NODES, the point. */
- int nodes_index; /* Index where to add the next node. */
- int nodes_slots; /* Number of slots allocated to NODES. */
+ /* History of nodes visited in this window. */
+ WINDOW_STATE **hist; /* Nodes visited in this window. */
+ int hist_index; /* Index where to add the next node. */
+ int hist_slots; /* Number of slots allocated to HIST. */
} WINDOW;
-typedef struct {
- WINDOW_STATE_DECL; /* What gets saved. */
-} WINDOW_STATE;
-
/* Structure defining the current state of an incremental search. */
typedef struct {
WINDOW_STATE_DECL; /* The node, pagetop and point. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5625] use WINDOW_STATE array for window history,
Gavin D. Smith <=