bug-texinfo
[Top][All Lists]
Advanced

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

[PATCH] infokeys, scrolling behavior etc.


From: Sergey Poznyakoff
Subject: [PATCH] infokeys, scrolling behavior etc.
Date: Sat, 14 Jul 2007 13:18:24 +0300

Hello,

The following discussion on gnu-tar list:
 
  http://lists.gnu.org/archive/html/bug-tar/2007-07/msg00017.html

revealed several problems with the standalone info reader and the infokeys
utility. First of all, the information about the latter is hidden so
deeply that many users have no idea about its existence. Indeed, it is
not obvious that it is documented in info-stnd, and references to
it from the main texinfo docs are so scarce that they can be easily
overlooked.

Secondly, the variable `scroll-behavior' is documented in info-stnd, but
spelled `scroll-behaviour' elsewhere.

And finally, some users find it preferable for cursor movement commands
to cross node boundaries (e.g. `next-line' pressed at the and of a node
to move to the next node much the same way `scroll-forward' does).

The enclosed patch addresses the 2nd and the 3rd issues.

Regards,
Sergey

ChangeLog:

2007-07-14  Sergey Poznyakoff  <address@hidden>

        * doc/info-stnd.texi: Document `cursor-movement-scrolls' variable
        Document both spellings for `scroll-behaviour'

        * info/session.c (cursor_movement_scrolls_p): New variable
        (move_to_new_line,_scroll_forward)
        (_scroll_backward,forward_move_node_structure)
        (backward_move_node_structure): Return integer, indicating
        success (0) or failure (1).

        (info_next_line, info_prev_line, info_forward_char)
        (info_backward_char, info_forward_word)
        (info_backward_word): Scroll over node boundary if
        cursor_movement_scrolls_p is set.

        * info/session.h, info/variables.h (cursor_movement_scrolls_p): New
        variable. 

        * info/variables.c (scroll-behavior): Alias for
        scroll-behaviour.
        (cursor-movement-scrolls): New variable. Enables crossing of
        node boundaries for cursor movement commands.

Index: doc/info-stnd.texi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/doc/info-stnd.texi,v
retrieving revision 1.12
diff -p -u -r1.12 info-stnd.texi
--- doc/info-stnd.texi  25 Jul 2006 16:02:29 -0000      1.12
+++ doc/info-stnd.texi  14 Jul 2007 09:33:55 -0000
@@ -1852,6 +1852,13 @@ window.  There are exceptions to the aut
 windows @samp{*Completions*} and @samp{*Footnotes*} are @emph{not}
 resized through automatic tiling; they remain their original size.
 
address@hidden
address@hidden cursor-movement-scrolls
+Normally, cursor movement commands (@pxref{Cursor Commands}) stop when
+top or bottom of a node is reached.  When this variable is set to
address@hidden, cursor movement commands act as scrolling ones and their
+behavior is controlled by @code{scroll-behavior} variable (see below).
+
 @item errors-ring-bell
 @vindex errors-ring-bell
 When set to @code{On}, errors cause the bell to ring.  The default
@@ -1882,6 +1889,7 @@ character set is in use, and allows you 
 Info, as well as display them.
 
 @item scroll-behavior
address@hidden scroll-behaviour
 @vindex scroll-behavior
 Control what happens when forward scrolling is requested at the end of
 a node, or when backward scrolling is requested at the beginning of a
@@ -1905,6 +1913,9 @@ Simply give up, changing nothing.  If @c
 viewed.
 @end table
 
+This variable normally affects only scrolling commands.
address@hidden, for information on how to widen its scope.
+
 @item scroll-step
 @vindex scroll-step
 The number of lines to scroll when the cursor moves out of the window.
Index: info/session.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/session.c,v
retrieving revision 1.19
diff -p -u -r1.19 session.c
--- info/session.c      1 Jul 2007 21:20:31 -0000       1.19
+++ info/session.c      14 Jul 2007 09:33:56 -0000
@@ -592,7 +592,7 @@ info_show_point (WINDOW *window)
 }
 
 /* Move WINDOW->point from OLD line index to NEW line index. */
-static void
+static int
 move_to_new_line (int old, int new, WINDOW *window)
 {
   if (old == -1)
@@ -604,8 +604,8 @@ move_to_new_line (int old, int new, WIND
       int goal;
 
       if (new >= window->line_count || new < 0)
-        return;
-
+       return 1;
+      
       goal = window_get_goal_column (window);
       window->goal_column = goal;
 
@@ -613,8 +613,14 @@ move_to_new_line (int old, int new, WIND
       window->point += window_chars_to_goal (window->line_starts[new], goal);
       info_show_point (window);
     }
+  return 0;
 }
 
+static int _scroll_forward(WINDOW *window, int count,
+    unsigned char key, int behaviour);
+static int _scroll_backward(WINDOW *window, int count,
+    unsigned char key, 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"))
 {
@@ -626,7 +632,9 @@ DECLARE_INFO_COMMAND (info_next_line, _(
     {
       old_line = window_line_of_point (window);
       new_line = old_line + count;
-      move_to_new_line (old_line, new_line, window);
+      if (move_to_new_line (old_line, new_line, window)
+         && cursor_movement_scrolls_p)
+       _scroll_forward (window, count, key, info_scroll_behaviour);
     }
 }
 
@@ -641,7 +649,10 @@ DECLARE_INFO_COMMAND (info_prev_line, _(
     {
       old_line = window_line_of_point (window);
       new_line = old_line - count;
-      move_to_new_line (old_line, new_line, window);
+      if (move_to_new_line (old_line, new_line, window)
+         && cursor_movement_scrolls_p
+         && _scroll_backward (window, count, key, info_scroll_behaviour) == 0)
+       move_to_new_line (window->line_count, window->line_count - 1, window);
     }
 }
 
@@ -694,8 +705,13 @@ DECLARE_INFO_COMMAND (info_forward_char,
       window->point += count;
 
       if (window->point >= window->node->nodelen)
-        window->point = window->node->nodelen - 1;
-
+       {
+         if (cursor_movement_scrolls_p)
+           _scroll_forward (window, count, key, info_scroll_behaviour);
+         else
+           window->point = window->node->nodelen - 1;
+       }
+      
       info_show_point (window);
     }
 }
@@ -710,8 +726,15 @@ DECLARE_INFO_COMMAND (info_backward_char
       window->point -= count;
 
       if (window->point < 0)
-        window->point = 0;
-
+       {
+         if (cursor_movement_scrolls_p
+             && _scroll_backward (window, count, key,
+                                  info_scroll_behaviour) == 0)
+           window->point = window->node->nodelen - 1;
+         else
+           window->point = 0;
+       }
+      
       info_show_point (window);
     }
 }
@@ -738,8 +761,18 @@ DECLARE_INFO_COMMAND (info_forward_word,
   while (count)
     {
       if (point + 1 >= end)
-        return;
-
+       {
+         if (cursor_movement_scrolls_p)
+           {
+             _scroll_forward (window, 1, key, info_scroll_behaviour);
+             point = 0;
+             buffer = window->node->contents;
+             end = window->node->nodelen;
+           }
+         else
+           return;
+       }
+      
       /* If we are not in a word, move forward until we are in one.
          Then, move forward until we hit a non-alphabetic character. */
       c = buffer[point];
@@ -754,7 +787,19 @@ DECLARE_INFO_COMMAND (info_forward_word,
             }
         }
 
-      if (point >= end) return;
+      if (point >= end)
+       {
+         if (cursor_movement_scrolls_p)
+           {
+             _scroll_forward (window, 1, key, info_scroll_behaviour);
+             point = 0;
+             buffer = window->node->contents;
+             end = window->node->nodelen;
+           }
+         else
+           return;
+       }
+
 
       while (++point < end)
         {
@@ -786,8 +831,18 @@ DECLARE_INFO_COMMAND (info_backward_word
   while (count)
     {
       if (point == 0)
-        break;
-
+       {
+         if (cursor_movement_scrolls_p
+             && _scroll_backward (window, count, key,
+                                  info_scroll_behaviour) == 0)
+           {
+             buffer = window->node->contents;
+             point = window->node->nodelen - 1;
+           }
+         else
+           break;
+       }
+      
       /* Like info_forward_word (), except that we look at the
          characters just before point. */
 
@@ -835,6 +890,9 @@ char *info_scroll_choices[] = {
   "Continuous", "Next Only", "Page Only", (char *)NULL
 };
 
+/* Controls whether scroll-behavior affects line movement commands */
+int cursor_movement_scrolls_p = 0;
+
 /* Default window sizes for scrolling commands.  */
 int default_window_size = -1;  /* meaning 1 window-full */
 int default_scroll_size = -1;  /* meaning half screen size */
@@ -844,19 +902,22 @@ int default_scroll_size = -1;     /* meaning
                             && !is_dir_name (info_parsed_filename)))
 
 /* Move to 1st menu item, Next, Up/Next, or error in this window. */
-static void
+static int
 forward_move_node_structure (WINDOW *window, int behaviour)
 {
   switch (behaviour)
     {
     case IS_PageOnly:
       info_error ((char *) msg_at_node_bottom, NULL, NULL);
-      break;
+      return 1;
 
     case IS_NextOnly:
       info_next_label_of_node (window->node);
       if (!info_parsed_nodename && !info_parsed_filename)
-        info_error ((char *) msg_no_pointer, (char *) _("Next"), NULL);
+       {
+         info_error ((char *) msg_no_pointer, (char *) _("Next"), NULL);
+         return 1;
+       }
       else
         {
           window_message_in_echo_area ((char *) _("Following Next node..."),
@@ -880,7 +941,7 @@ forward_move_node_structure (WINDOW *win
               window_message_in_echo_area ((char *) _("Selecting first menu 
item..."),
                   NULL, NULL);
               info_menu_digit (window, 1, '1');
-              return;
+              return 0;
             }
         }
 
@@ -892,7 +953,7 @@ forward_move_node_structure (WINDOW *win
             window_message_in_echo_area ((char *) _("Selecting Next node..."),
                 NULL, NULL);
             info_handle_pointer ("Next", window);
-            return;
+            return 0;
           }
 
         /* Okay, there wasn't a "Next:" for this node.  Move "Up:" until we
@@ -964,7 +1025,7 @@ forward_move_node_structure (WINDOW *win
                      (void *) (long) up_counter, NULL);
 
                   info_handle_pointer ("Next", window);
-                  return;
+                  return 0;
                 }
               else
                 {
@@ -986,28 +1047,33 @@ forward_move_node_structure (WINDOW *win
                   window->flags |= W_UpdateWindow;
                   info_error ((char *) _("No more nodes within this 
document."),
                       NULL, NULL);
+                 return 1;
                 }
             }
         }
         break;
       }
     }
+  return 0;
 }
 
 /* Move Prev, Up or error in WINDOW depending on BEHAVIOUR. */
-static void
+static int
 backward_move_node_structure (WINDOW *window, int behaviour)
 {
   switch (behaviour)
     {
     case IS_PageOnly:
       info_error ((char *) msg_at_node_top, NULL, NULL);
-      break;
+      return 1;
 
     case IS_NextOnly:
       info_prev_label_of_node (window->node);
       if (!info_parsed_nodename && !info_parsed_filename)
-        info_error ((char *) _("No `Prev' for this node."), NULL, NULL);
+       {
+         info_error ((char *) _("No `Prev' for this node."), NULL, NULL);
+         return 1;
+       }
       else
         {
           window_message_in_echo_area ((char *) _("Moving Prev in this 
window."),
@@ -1025,9 +1091,12 @@ backward_move_node_structure (WINDOW *wi
           info_up_label_of_node (window->node);
           if (!info_parsed_nodename && (!info_parsed_filename
                                         || is_dir_name (info_parsed_filename)))
-            info_error ((char *)
-                _("No `Prev' or `Up' for this node within this document."),
-                NULL, NULL);
+           {
+             info_error ((char *)
+                   _("No `Prev' or `Up' for this node within this document."),
+                         NULL, NULL);
+             return 1;
+           }
           else
             {
               window_message_in_echo_area ((char *) _("Moving Up in this 
window."),
@@ -1087,6 +1156,7 @@ backward_move_node_structure (WINDOW *wi
         }
       break;
     }
+  return 0;
 }
 
 /* Move continuously forward through the node structure of this info file. */
@@ -1121,16 +1191,11 @@ DECLARE_INFO_COMMAND (info_global_prev_n
     }
 }
 
-static void _scroll_forward(WINDOW *window, int count,
-    unsigned char key, int behaviour);
-static void _scroll_backward(WINDOW *window, int count,
-    unsigned char key, int behaviour);
-
-static void
+static int
 _scroll_forward(WINDOW *window, int count, unsigned char key, int behaviour)
 {
   if (count < 0)
-    _scroll_backward (window, -count, key, behaviour);
+    return _scroll_backward (window, -count, key, behaviour);
   else
     {
       int desired_top;
@@ -1148,10 +1213,7 @@ _scroll_forward(WINDOW *window, int coun
           /* If there are no more lines to scroll here, error, or get
              another node, depending on BEHAVIOUR. */
           if (desired_top > window->line_count)
-            {
-              forward_move_node_structure (window, behaviour);
-              return;
-            }
+           return forward_move_node_structure (window, behaviour);
         }
       else
         desired_top = window->pagetop + count;
@@ -1160,17 +1222,18 @@ _scroll_forward(WINDOW *window, int coun
         desired_top = window->line_count - 2;
 
       if (window->pagetop > desired_top)
-        return;
+        return 1;
       else
         set_window_pagetop (window, desired_top);
     }
+  return 0;
 }
 
-static void
+static int
 _scroll_backward(WINDOW *window, int count, unsigned char key, int behaviour)
 {
   if (count < 0)
-    _scroll_forward (window, -count, key, behaviour);
+    return _scroll_forward (window, -count, key, behaviour);
   else
     {
       int desired_top;
@@ -1185,10 +1248,7 @@ _scroll_backward(WINDOW *window, int cou
           desired_top = window->pagetop - (window->height - 2);
 
           if ((desired_top < 0) && (window->pagetop == 0))
-            {
-              backward_move_node_structure (window, behaviour);
-              return;
-            }
+           return backward_move_node_structure (window, behaviour);
         }
       else
         desired_top = window->pagetop - count;
@@ -1198,6 +1258,7 @@ _scroll_backward(WINDOW *window, int cou
 
       set_window_pagetop (window, desired_top);
     }
+  return 0;
 }
 
 /* Show the next screen of WINDOW's node. */
Index: info/session.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/session.h,v
retrieving revision 1.6
diff -p -u -r1.6 session.h
--- info/session.h      1 Jul 2007 21:20:31 -0000       1.6
+++ info/session.h      14 Jul 2007 09:33:56 -0000
@@ -59,6 +59,8 @@ extern char *info_scroll_choices[];
 #define IS_NextOnly   1 /* Try to get "Next:" menu item. */
 #define IS_PageOnly   2 /* Simply give up at the bottom of a node. */
 
+extern int cursor_movement_scrolls_p;
+
 /* Utility functions found in session.c */
 extern void info_dispatch_on_key (unsigned char key, Keymap map);
 extern unsigned char info_get_input_char (void);
Index: info/variables.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/variables.c,v
retrieving revision 1.6
diff -p -u -r1.6 variables.c
--- info/variables.c    1 Jul 2007 21:20:31 -0000       1.6
+++ info/variables.c    14 Jul 2007 09:33:56 -0000
@@ -60,10 +60,19 @@ VARIABLE_ALIST info_variables[] = {
       N_("Controls what happens when scrolling is requested at the end of a 
node"),
       &info_scroll_behaviour, (char **)info_scroll_choices },
 
+  /* Alternate spelling */
+  { "scroll-behavior",
+      N_("Same as scroll-behaviour"),
+      &info_scroll_behaviour, (char **)info_scroll_choices },
+
   { "scroll-step",
       N_("The number lines to scroll when the cursor moves out of the window"),
       &window_scroll_step, (char **)NULL },
 
+  { "cursor-movement-scrolls",
+    N_("Controls whether scroll-behavior affects cursor movement commands"),
+    &cursor_movement_scrolls_p, (char **)on_off_choices },
+  
   { "ISO-Latin",
       N_("When \"On\", Info accepts and displays ISO Latin characters"),
       &ISO_Latin_p, (char **)on_off_choices },
Index: info/variables.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/variables.h,v
retrieving revision 1.6
diff -p -u -r1.6 variables.h
--- info/variables.h    1 Jul 2007 21:20:31 -0000       1.6
+++ info/variables.h    14 Jul 2007 09:33:56 -0000
@@ -60,6 +60,7 @@ extern int gc_compressed_files;
 extern int show_index_match;
 extern int info_scroll_behaviour;
 extern int window_scroll_step;
+extern int cursor_movement_scrolls_p;
 extern int ISO_Latin_p;
 
 #endif /* not INFO_VARIABLES_H */




reply via email to

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