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 23:49:02 +0300

Benno Schulenberg <address@hidden> ha escrit:

> It's... not quite there yet.  If the node is longer than the height 
> of the terminal, scrolling off the end of a node restarts at the 
> beginning of that node.  This happens here with `info tar` for the 
> second node, with `info info` for the third node.

Thank you. Here comes the fix. This version also works correctly when
argument count is specified (e.g. C-U 3 4 <down>). 

Regards,
Sergey

Index: info/info-utils.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/info-utils.c,v
retrieving revision 1.7
diff -p -u -r1.7 info-utils.c
--- info/info-utils.c   1 Jul 2007 21:20:30 -0000       1.7
+++ info/info-utils.c   14 Jul 2007 20:44:29 -0000
@@ -289,7 +289,8 @@ info_references_internal (char *label, S
       strncpy (entry->label, refdef, offset - 1);
       entry->label[offset - 1] = '\0';
       canonicalize_whitespace (entry->label);
-
+      entry->line_number = 0;
+      
       refdef += offset;
       entry->start = start;
       entry->end = refdef - binding->buffer;
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 20:44:30 -0000
@@ -604,8 +604,8 @@ move_to_new_line (int old, int new, WIND
       int goal;
 
       if (new >= window->line_count || new < 0)
-        return;
-
+       return;
+      
       goal = window_get_goal_column (window);
       window->goal_column = goal;
 
@@ -615,6 +615,9 @@ move_to_new_line (int old, int new, WIND
     }
 }
 
+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"))
 {
@@ -623,11 +626,27 @@ DECLARE_INFO_COMMAND (info_next_line, _(
   if (count < 0)
     info_prev_line (window, -count, key);
   else
-    {
-      old_line = window_line_of_point (window);
-      new_line = old_line + count;
-      move_to_new_line (old_line, new_line, window);
-    }
+    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
+           && cursor_movement_scrolls_p)
+         {
+           if (forward_move_node_structure (window, info_scroll_behaviour))
+             break;
+           move_to_new_line (0, 0, window);
+         }
+       else
+         move_to_new_line (old_line, new_line, window);
+      }
 }
 
 /* Move WINDOW's point up to the previous line if possible. */
@@ -638,11 +657,29 @@ DECLARE_INFO_COMMAND (info_prev_line, _(
   if (count < 0)
     info_next_line (window, -count, key);
   else
-    {
-      old_line = window_line_of_point (window);
-      new_line = old_line - count;
-      move_to_new_line (old_line, new_line, window);
-    }
+    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;
+           move_to_new_line (window->line_count,
+                             window->line_count - 1, window);
+         }
+       else
+         move_to_new_line (old_line, new_line, window);
+      }
 }
 
 /* Move WINDOW's point to the end of the true line. */
@@ -691,11 +728,28 @@ DECLARE_INFO_COMMAND (info_forward_char,
     info_backward_char (window, -count, key);
   else
     {
-      window->point += count;
-
-      if (window->point >= window->node->nodelen)
-        window->point = window->node->nodelen - 1;
-
+      while (count)
+       {
+         int diff = window->node->nodelen - window->point;
+         
+         if (diff > count)
+           diff = count;
+         window->point += diff;
+         count -= diff;
+         if (window->point >= window->node->nodelen)
+           {
+             if (cursor_movement_scrolls_p
+                 && forward_move_node_structure (window,
+                                                 info_scroll_behaviour) == 0)
+               window->point = 0;
+             else
+               {
+                 window->point = window->node->nodelen - 1;
+                 break;
+               }
+           }
+       }
+      
       info_show_point (window);
     }
 }
@@ -707,11 +761,30 @@ DECLARE_INFO_COMMAND (info_backward_char
     info_forward_char (window, -count, key);
   else
     {
-      window->point -= count;
+      while (count)
+       {
+         int diff = count;
 
-      if (window->point < 0)
-        window->point = 0;
+         if (window->point < diff)
+           diff = window->point + 1;
+         
+         window->point -= diff;
+         count -= diff;
 
+         if (window->point < 0)
+           {
+             if (cursor_movement_scrolls_p
+                 && backward_move_node_structure (window,
+                                                  info_scroll_behaviour) == 0)
+               window->point = window->node->nodelen - 1;
+             else
+               {
+                 window->point = 0;
+                 break;
+               }
+           }
+       }
+      
       info_show_point (window);
     }
 }
@@ -738,8 +811,19 @@ DECLARE_INFO_COMMAND (info_forward_word,
   while (count)
     {
       if (point + 1 >= end)
-        return;
-
+       {
+         if (cursor_movement_scrolls_p
+             && forward_move_node_structure (window,
+                                             info_scroll_behaviour) == 0)
+           {
+             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 +838,20 @@ DECLARE_INFO_COMMAND (info_forward_word,
             }
         }
 
-      if (point >= end) return;
+      if (point >= end)
+       {
+         if (cursor_movement_scrolls_p
+             && forward_move_node_structure (window,
+                                             info_scroll_behaviour) == 0)
+           {
+             point = 0;
+             buffer = window->node->contents;
+             end = window->node->nodelen;
+           }
+         else
+           return;
+       }
+
 
       while (++point < end)
         {
@@ -786,8 +883,18 @@ DECLARE_INFO_COMMAND (info_backward_word
   while (count)
     {
       if (point == 0)
-        break;
-
+       {
+         if (cursor_movement_scrolls_p
+             && backward_move_node_structure (window,
+                                              info_scroll_behaviour) == 0)
+           {
+             buffer = window->node->contents;
+             point = window->node->nodelen;
+           }
+         else
+           break;
+       }
+      
       /* Like info_forward_word (), except that we look at the
          characters just before point. */
 
@@ -835,6 +942,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 +954,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 +993,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 +1005,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 +1077,7 @@ forward_move_node_structure (WINDOW *win
                      (void *) (long) up_counter, NULL);
 
                   info_handle_pointer ("Next", window);
-                  return;
+                  return 0;
                 }
               else
                 {
@@ -986,28 +1099,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 +1143,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 +1208,7 @@ backward_move_node_structure (WINDOW *wi
         }
       break;
     }
+  return 0;
 }
 
 /* Move continuously forward through the node structure of this info file. */
@@ -1148,10 +1270,10 @@ _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;
-            }
+           {
+             forward_move_node_structure (window, behaviour);
+             return;
+           }
         }
       else
         desired_top = window->pagetop + count;
@@ -1185,10 +1307,10 @@ _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;
-            }
+           {
+             backward_move_node_structure (window, behaviour);
+             return;
+           }
         }
       else
         desired_top = window->pagetop - count;
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 20:44:30 -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 20:44:30 -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 20:44:30 -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]