[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5651] scroll-step handling; goal column
From: |
Gavin D. Smith |
Subject: |
[5651] scroll-step handling; goal column |
Date: |
Mon, 09 Jun 2014 10:33:09 +0000 |
Revision: 5651
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5651
Author: gavin
Date: 2014-06-09 10:33:08 +0000 (Mon, 09 Jun 2014)
Log Message:
-----------
scroll-step handling; goal column
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/session.c
trunk/info/session.h
trunk/info/window.c
trunk/info/window.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-06-08 22:54:32 UTC (rev 5650)
+++ trunk/ChangeLog 2014-06-09 10:33:08 UTC (rev 5651)
@@ -1,3 +1,29 @@
+2014-06-08 Gavin Smith <address@hidden>
+
+ * info/window.c, info/session.c (window_scroll_step): Moved between
+ files.
+ * info/session.c, info/window.c (set_window_pagetop): Moved between
+ files.
+ * info/session.c (info_show_point): Handle scroll-step variable.
+ (window_adjust_pagetop): Call window_line_of_point. Call
+ set_window_pagetop to scroll display. Always centre current line
+ ignoring scroll-step variable.
+
+ * info/session.c (info_next_line, info_prev_line): Call point_next_line
+ and point_prev_line to handle traversing node hierarchy.
+
+ * info/window.c (window_initialize_windows, window_make_window):
+ Initialize goal_column fields to 0.
+ (window_get_goal_column): Removed.
+ * info/session.c (info_read_and_dispatch): Don't reset goal_column.
+ (move_to_new_line, move_to_goal_column): Renamed. Only move to goal
+ column.
+ (info_show_point): Save goal_column. Callers updated.
+ (info_move_to_prev_xref, info_move_to_next_xref): Don't call
+ move_to_new_line.
+ (info_move_to_window_line): Call info_show_point.
+ (info_end_of_node): Call info_show_point.
+
2014-06-08 Karl Berry <address@hidden>
* util/texi2dvi: use THUMBPDF_CMD instead of THUMBPDF.
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-06-08 22:54:32 UTC (rev 5650)
+++ trunk/info/session.c 2014-06-09 10:33:08 UTC (rev 5651)
@@ -185,12 +185,6 @@
{
int lk = 0;
- /* If we haven't just gone up or down a line, there is no
- goal column for this window. */
- if ((info_last_executed_command != (VFunction *) info_next_line) &&
- (info_last_executed_command != (VFunction *) info_prev_line))
- active_window->goal_column = -1;
-
if (echo_area_is_active)
{
lk = echo_area_last_command_was_kill;
@@ -389,25 +383,42 @@
/* */
/* **************************************************************** */
+static int forward_move_node_structure (WINDOW *window, int behaviour);
+static int backward_move_node_structure (WINDOW *window, int behaviour);
+
/* Controls whether scroll-behavior affects line movement commands */
int cursor_movement_scrolls_p = 1;
-/* Immediately make WINDOW->point visible on the screen, and move the
- terminal cursor there. */
+/* Variable controlling redisplay of scrolled windows. If non-zero,
+ it is the desired number of lines to scroll the window in order to
+ make point visible. A value of 1 produces smooth scrolling. If set
+ to zero, the line containing point is centered within the window. */
+int window_scroll_step = 1;
+
+/* Used after cursor movement commands. Scroll window so that point is
+ visible, and move the terminal cursor there. */
static void
info_show_point (WINDOW *window)
{
- int old_pagetop;
+ window->goal_column = window_get_cursor_column (window);
- old_pagetop = window->pagetop;
- window_adjust_pagetop (window);
- if (old_pagetop != window->pagetop)
+ if (window_scroll_step == 0)
+ window_adjust_pagetop (window);
+ else
{
- int new_pagetop;
+ int new_pagetop = window->pagetop;
+ int line = window_line_of_point (window);
+ if (line < window->pagetop)
+ new_pagetop -= window_scroll_step;
+ else if (line >= window->pagetop + window->height)
+ new_pagetop += window_scroll_step;
- new_pagetop = window->pagetop;
- window->pagetop = old_pagetop;
- set_window_pagetop (window, new_pagetop);
+ /* It's possible that moving by 'scroll-step' still won't show the
+ point. If so, call window_adjust_pagetop as a backup. */
+ if (line >= new_pagetop && line < new_pagetop + window->height)
+ set_window_pagetop (window, new_pagetop);
+ else
+ window_adjust_pagetop (window);
}
if (window->flags & W_UpdateWindow)
@@ -416,152 +427,6 @@
display_cursor_at_point (window);
}
-/* Move WINDOW->point to NEW line index, trying to place cursor in
- goal column. */
-static void
-move_to_new_line (int new, WINDOW *window)
-{
- int goal;
-
- if (new >= window->line_count || new < 0)
- return;
-
- goal = window_get_goal_column (window);
- window->goal_column = goal;
-
- window->point = window->line_starts[new];
- window->point += window_chars_to_goal (window, goal);
- info_show_point (window);
-}
-
-static int forward_move_node_structure (WINDOW *window, int behaviour);
-static int backward_move_node_structure (WINDOW *window, int behaviour);
-
-/* Move WINDOW's point down to the next line if possible. */
-DECLARE_INFO_COMMAND (info_next_line, _("Move down to the next line"))
-{
- int old_line, new_line;
-
- if (count < 0)
- info_prev_line (window, -count, key);
- else
- while (count)
- {
- int diff;
-
- old_line = window_line_of_point (window);
- diff = window->line_count - old_line;
- if (diff > count)
- diff = count;
-
- count -= diff;
- new_line = old_line + diff;
- if (new_line >= window->line_count)
- {
- if (cursor_movement_scrolls_p)
- {
- if (forward_move_node_structure (window,
- info_scroll_behaviour))
- break;
- move_to_new_line (0, window);
- }
- else
- break;
- }
- else
- move_to_new_line (new_line, window);
- }
-}
-
-/* Move WINDOW's point up to the previous line if possible. */
-DECLARE_INFO_COMMAND (info_prev_line, _("Move up to the previous line"))
-{
- int old_line, new_line;
-
- if (count < 0)
- info_next_line (window, -count, key);
- else
- while (count)
- {
- int diff;
-
- old_line = window_line_of_point (window);
- diff = old_line + 1;
- if (diff > count)
- diff = count;
-
- count -= diff;
- new_line = old_line - diff;
-
- if (new_line < 0
- && cursor_movement_scrolls_p)
- {
- if (backward_move_node_structure (window, info_scroll_behaviour))
- break;
- if (window->line_count > window->height)
- set_window_pagetop (window, window->line_count - window->height);
- move_to_new_line (window->line_count - 1, window);
- }
- else
- move_to_new_line (new_line, window);
- }
-}
-
-/* Move the cursor to the desired line of the window. */
-DECLARE_INFO_COMMAND (info_move_to_window_line,
- _("Move the cursor to a specific line of the window"))
-{
- int line;
-
- /* With no numeric argument of any kind, default to the center line. */
- if (!info_explicit_arg && count == 1)
- line = (window->height / 2) + window->pagetop;
- else
- {
- if (count < 0)
- line = (window->height + count) + window->pagetop;
- else
- line = window->pagetop + count;
- }
-
- /* If the line doesn't appear in this window, make it do so. */
- if ((line - window->pagetop) >= window->height)
- line = window->pagetop + (window->height - 1);
-
- /* If the line is too small, make it fit. */
- if (line < window->pagetop)
- line = window->pagetop;
-
- /* If the selected line is past the bottom of the node, force it back. */
- if (line >= window->line_count)
- line = window->line_count - 1;
-
- window->point = window->line_starts[line];
-}
-
-/* Return true if POINT sits on a newline character. */
-static int
-looking_at_newline (WINDOW *win, long point)
-{
- mbi_iterator_t iter;
- mbi_init (iter, win->node->contents + point,
- win->node->nodelen - point);
- mbi_avail (iter);
- return mbi_cur (iter).wc_valid && mbi_cur (iter).wc == '\n';
-}
-
-/* Return true if WIN->point sits on an alphanumeric character. */
-static int
-looking_at_alnum (WINDOW *win)
-{
- mbi_iterator_t iter;
- mbi_init (iter, win->node->contents + win->point,
- win->node->nodelen - win->point);
- mbi_avail (iter);
-
- return mbi_cur (iter).wc_valid && iswalnum (mbi_cur (iter).wc);
-}
-
/* Advance point of WIN to the beginning of the next logical line. Return
0 if we can't go any further. */
static int
@@ -613,6 +478,41 @@
return 0;
}
+/* Try to place cursor in goal column. */
+static void
+move_to_goal_column (WINDOW *window)
+{
+ int line;
+
+ line = window_line_of_point (window);
+
+ window->point = window->line_starts[line];
+ window->point += window_chars_to_goal (window, window->goal_column);
+}
+
+/* Return true if POINT sits on a newline character. */
+static int
+looking_at_newline (WINDOW *win, long point)
+{
+ mbi_iterator_t iter;
+ mbi_init (iter, win->node->contents + point,
+ win->node->nodelen - point);
+ mbi_avail (iter);
+ return mbi_cur (iter).wc_valid && mbi_cur (iter).wc == '\n';
+}
+
+/* Return true if WIN->point sits on an alphanumeric character. */
+static int
+looking_at_alnum (WINDOW *win)
+{
+ mbi_iterator_t iter;
+ mbi_init (iter, win->node->contents + win->point,
+ win->node->nodelen - win->point);
+ mbi_avail (iter);
+
+ return mbi_cur (iter).wc_valid && iswalnum (mbi_cur (iter).wc);
+}
+
/* Advance point to the next multibyte character. */
static void
point_forward_char (WINDOW *win)
@@ -732,6 +632,75 @@
}
}
+/* Move WINDOW's point down to the next line if possible. */
+DECLARE_INFO_COMMAND (info_next_line, _("Move down to the next line"))
+{
+ int old_line, new_line;
+
+ if (count < 0)
+ info_prev_line (window, -count, key);
+ else
+ {
+ long saved_goal = window->goal_column;
+ while (count--)
+ point_next_line (window);
+ info_show_point (window);
+ window->goal_column = saved_goal;
+ move_to_goal_column (window);
+ }
+}
+
+/* Move WINDOW's point up to the previous line if possible. */
+DECLARE_INFO_COMMAND (info_prev_line, _("Move up to the previous line"))
+{
+ int old_line, new_line;
+
+ if (count < 0)
+ info_next_line (window, -count, key);
+ else
+ {
+ long saved_goal = window->goal_column;
+ while (count--)
+ point_prev_line (window);
+ info_show_point (window);
+ window->goal_column = saved_goal;
+ move_to_goal_column (window);
+ }
+}
+
+/* Move the cursor to the desired line of the window. */
+DECLARE_INFO_COMMAND (info_move_to_window_line,
+ _("Move the cursor to a specific line of the window"))
+{
+ int line;
+
+ /* With no numeric argument of any kind, default to the center line. */
+ if (!info_explicit_arg && count == 1)
+ line = (window->height / 2) + window->pagetop;
+ else
+ {
+ if (count < 0)
+ line = (window->height + count) + window->pagetop;
+ else
+ line = window->pagetop + count;
+ }
+
+ /* If the line doesn't appear in this window, make it do so. */
+ if (line - window->pagetop >= window->height)
+ line = window->pagetop + (window->height - 1);
+
+ /* If the line is too small, make it fit. */
+ if (line < window->pagetop)
+ line = window->pagetop;
+
+ /* If the selected line is past the bottom of the node, force it back. */
+ if (line >= window->line_count)
+ line = window->line_count - 1;
+
+ window->point = window->line_starts[line];
+ info_show_point (window);
+}
+
/* Move WINDOW's point to the end of the logical line. */
DECLARE_INFO_COMMAND (info_end_of_line, _("Move to the end of the line"))
{
@@ -844,8 +813,8 @@
/* Move to the beginning of the node. */
DECLARE_INFO_COMMAND (info_beginning_of_node, _("Move to the start of this
node"))
{
- window->pagetop = window->point = 0;
- window->flags |= W_UpdateWindow;
+ window->point = 0;
+ info_show_point (window);
}
/* Move to the end of the node. */
@@ -883,74 +852,6 @@
static void _scroll_forward (WINDOW *window, int count, int behaviour);
static void _scroll_backward (WINDOW *window, int count, int behaviour);
-/* Change the pagetop of WINDOW to DESIRED_TOP, perhaps scrolling the screen
- to do so. */
-void
-set_window_pagetop (WINDOW *window, int desired_top)
-{
- int point_line, old_pagetop;
-
- if (desired_top < 0)
- desired_top = 0;
- else if (desired_top > window->line_count)
- desired_top = window->line_count - 1;
-
- if (window->pagetop == desired_top)
- return;
-
- old_pagetop = window->pagetop;
- window->pagetop = desired_top;
-
- /* Make sure that point appears in this window. */
- point_line = window_line_of_point (window);
- if ((point_line < window->pagetop) ||
- ((point_line - window->pagetop) > window->height - 1))
- window->point =
- window->line_starts[window->pagetop];
-
- window->flags |= W_UpdateWindow;
-
- /* Find out which direction to scroll, and scroll the window in that
- direction. Do this only if there would be a savings in redisplay
- time. This is true if the amount to scroll is less than the height
- of the window, and if the number of lines scrolled would be greater
- than 10 % of the window's height.
-
- To prevent status line blinking when keeping up or down key,
- scrolling is disabled if the amount to scroll is 1. */
- if (old_pagetop < desired_top)
- {
- int start, end, amount;
-
- amount = desired_top - old_pagetop;
-
- if (amount == 1 ||
- (amount >= window->height) ||
- (((window->height - amount) * 10) < window->height))
- return;
-
- start = amount + window->first_row;
- end = window->height + window->first_row;
-
- display_scroll_display (start, end, -amount);
- }
- else
- {
- int start, end, amount;
-
- amount = old_pagetop - desired_top;
-
- if (amount == 1 ||
- (amount >= window->height) ||
- (((window->height - amount) * 10) < window->height))
- return;
-
- start = window->first_row;
- end = (window->first_row + window->height) - amount;
- display_scroll_display (start, end, amount);
- }
-}
-
static void
_scroll_forward (WINDOW *window, int count, int behaviour)
{
@@ -2330,7 +2231,7 @@
info_error_was_printed = 0;
if (backward_move_node_structure (window, info_scroll_behaviour))
break;
- move_to_new_line (window->line_count - 1, window);
+ window->point = window->node->nodelen - 1;
}
}
}
@@ -2351,7 +2252,7 @@
info_error_was_printed = 0;
if (forward_move_node_structure (window, info_scroll_behaviour))
break;
- move_to_new_line (0, window);
+ window->point = 0;
}
}
}
Modified: trunk/info/session.h
===================================================================
--- trunk/info/session.h 2014-06-08 22:54:32 UTC (rev 5650)
+++ trunk/info/session.h 2014-06-09 10:33:08 UTC (rev 5651)
@@ -81,7 +81,6 @@
extern unsigned char info_get_input_char (void);
extern unsigned char info_get_another_input_char (void);
extern unsigned char info_input_pending_p (void);
-extern void set_window_pagetop (WINDOW *window, int desired_top);
extern void info_set_node_of_window (WINDOW *window, NODE *node);
extern void initialize_keyseq (void);
extern void add_char_to_keyseq (char character);
Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2014-06-08 22:54:32 UTC (rev 5650)
+++ trunk/info/window.c 2014-06-09 10:33:08 UTC (rev 5651)
@@ -62,11 +62,6 @@
windows = xzalloc (sizeof (WINDOW));
active_window = windows;
- /* None of these windows has a goal column yet. */
- the_echo_area->goal_column = -1;
- active_window->goal_column = -1;
- the_screen->goal_column = -1;
-
/* The active and echo_area windows are visible.
The echo_area is permanent.
The screen is permanent. */
@@ -288,7 +283,7 @@
window->first_row = active_window->first_row +
(active_window->height - window->height);
window->keymap = info_keymap;
- window->goal_column = -1;
+ window->goal_column = 0;
memset (&window->line_map, 0, sizeof (window->line_map));
window->modeline = xmalloc (1 + window->width);
window->line_starts = NULL;
@@ -567,6 +562,7 @@
window->node = node;
window->pagetop = 0;
window->point = 0;
+ window->goal_column = 0;
recalculate_line_starts (window);
window->flags |= W_UpdateWindow;
if (node)
@@ -741,59 +737,95 @@
return i;
}
-/* Global variable control redisplay of scrolled windows. If non-zero,
- it is the desired number of lines to scroll the window in order to
- make point visible. A value of 1 produces smooth scrolling. If set
- to zero, the line containing point is centered within the window. */
-int window_scroll_step = 1;
+/* Change the pagetop of WINDOW to DESIRED_TOP, perhaps scrolling the screen
+ to do so. */
+void
+set_window_pagetop (WINDOW *window, int desired_top)
+{
+ int point_line, old_pagetop;
+ if (desired_top < 0)
+ desired_top = 0;
+ else if (desired_top > window->line_count)
+ desired_top = window->line_count - 1;
+
+ if (window->pagetop == desired_top)
+ return;
+
+ old_pagetop = window->pagetop;
+ window->pagetop = desired_top;
+
+ /* Make sure that point appears in this window. */
+ point_line = window_line_of_point (window);
+ if ((point_line < window->pagetop) ||
+ ((point_line - window->pagetop) > window->height - 1))
+ window->point =
+ window->line_starts[window->pagetop];
+
+ window->flags |= W_UpdateWindow;
+
+ /* Find out which direction to scroll, and scroll the window in that
+ direction. Do this only if there would be a savings in redisplay
+ time. This is true if the amount to scroll is less than the height
+ of the window, and if the number of lines scrolled would be greater
+ than 10 % of the window's height.
+
+ To prevent status line blinking when keeping up or down key,
+ scrolling is disabled if the amount to scroll is 1. */
+ if (old_pagetop < desired_top)
+ {
+ int start, end, amount;
+
+ amount = desired_top - old_pagetop;
+
+ if (amount == 1 ||
+ (amount >= window->height) ||
+ (((window->height - amount) * 10) < window->height))
+ return;
+
+ start = amount + window->first_row;
+ end = window->height + window->first_row;
+
+ display_scroll_display (start, end, -amount);
+ }
+ else
+ {
+ int start, end, amount;
+
+ amount = old_pagetop - desired_top;
+
+ if (amount == 1 ||
+ (amount >= window->height) ||
+ (((window->height - amount) * 10) < window->height))
+ return;
+
+ start = window->first_row;
+ end = (window->first_row + window->height) - amount;
+ display_scroll_display (start, end, amount);
+ }
+}
+
/* Adjust the pagetop of WINDOW such that the cursor point will be visible. */
void
window_adjust_pagetop (WINDOW *window)
{
- register int line = 0;
+ register int line;
if (!window->node)
return;
- /* Find the first printed line start which is after WINDOW->point. */
- for (line = 0; line < window->line_count; line++)
- {
- if (window->line_starts[line] > window->point)
- break;
- }
+ line = window_line_of_point (window);
- /* The line index preceding the line start which is past point is the
- one containing point. */
- line--;
-
/* If this line appears in the current displayable page, do nothing.
Otherwise, adjust the top of the page to make this line visible. */
- if ((line < window->pagetop) ||
- (line - window->pagetop > (window->height - 1)))
+ if (line < window->pagetop
+ || line - window->pagetop > window->height - 1)
{
- /* The user-settable variable "scroll-step" is used to attempt
- to make point visible, iff it is non-zero. If that variable
- is zero, then the line containing point is centered within
- the window. */
- if (window_scroll_step < window->height)
- {
- if ((line < window->pagetop) &&
- ((window->pagetop - window_scroll_step) <= line))
- window->pagetop -= window_scroll_step;
- else if ((line - window->pagetop > (window->height - 1)) &&
- ((line - (window->pagetop + window_scroll_step)
- < window->height)))
- window->pagetop += window_scroll_step;
- else
- window->pagetop = line - ((window->height - 1) / 2);
- }
- else
- window->pagetop = line - ((window->height - 1) / 2);
+ int new_pagetop = line - ((window->height - 1) / 2);
- if (window->pagetop < 0)
- window->pagetop = 0;
- window->flags |= W_UpdateWindow;
+ if (new_pagetop < 0)
+ new_pagetop = 0;
+ set_window_pagetop (window, new_pagetop);
}
}
@@ -824,21 +856,6 @@
return 0;
}
-/* Get and return the goal column for this window. */
-int
-window_get_goal_column (WINDOW *window)
-{
- if (!window->node)
- return -1;
-
- if (window->goal_column != -1)
- return window->goal_column;
-
- /* Okay, do the work. Find the printed offset of the cursor
- in this window. */
- return window_get_cursor_column (window);
-}
-
/* Get and return the printed column offset of the cursor in this window. */
int
window_get_cursor_column (WINDOW *window)
Modified: trunk/info/window.h
===================================================================
--- trunk/info/window.h 2014-06-08 22:54:32 UTC (rev 5650)
+++ trunk/info/window.h 2014-06-09 10:33:08 UTC (rev 5651)
@@ -154,6 +154,8 @@
window, then no change takes place. */
extern void window_change_window_height (WINDOW *window, int amount);
+extern void set_window_pagetop (WINDOW *window, int desired_top);
+
/* Adjust the pagetop of WINDOW such that the cursor point will be visible. */
extern void window_adjust_pagetop (WINDOW *window);
@@ -229,9 +231,6 @@
/* Return the index of the line containing point. */
extern int window_line_of_point (WINDOW *window);
-/* Get and return the goal column for this window. */
-extern int window_get_goal_column (WINDOW *window);
-
/* Get and return the printed column offset of the cursor in this window. */
extern int window_get_cursor_column (WINDOW *window);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5651] scroll-step handling; goal column,
Gavin D. Smith <=