bug-texinfo
[Top][All Lists]
Advanced

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

Re: [PATCH] infokeys, scrolling behavior etc.


From: Sergey Poznyakoff
Subject: Re: [PATCH] infokeys, scrolling behavior etc.
Date: Sat, 14 Jul 2007 16:54:10 +0300

Benno Schulenberg <address@hidden> ha escrit:

> The change doesn't seem fully correct, though, yet.  For example in 
> `info tar`, with CursorDown it scrolls off the intro page to the 
> last line of the Synopsis node instead of the first line.

Ah, yes, indeed. Here is the fixed version:

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 13:52:41 -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,10 @@ 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) == 0)
+       move_to_new_line (0, 0, window);
     }
 }
 
@@ -641,7 +650,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 +706,14 @@ 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) == 
0)
+           window->point = 0;
+         else
+           window->point = window->node->nodelen - 1;
+       }
+      
       info_show_point (window);
     }
 }
@@ -710,8 +728,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 +763,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 +789,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 +833,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 +892,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 +904,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 +943,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 +955,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 +1027,7 @@ forward_move_node_structure (WINDOW *win
                      (void *) (long) up_counter, NULL);
 
                   info_handle_pointer ("Next", window);
-                  return;
+                  return 0;
                 }
               else
                 {
@@ -986,28 +1049,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 +1093,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 +1158,7 @@ backward_move_node_structure (WINDOW *wi
         }
       break;
     }
+  return 0;
 }
 
 /* Move continuously forward through the node structure of this info file. */
@@ -1121,16 +1193,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 +1215,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 +1224,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 +1250,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 +1260,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 13:52:41 -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 13:52:41 -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 13:52:41 -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]