texinfo-commits
[Top][All Lists]
Advanced

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

texinfo ChangeLog info/window.h info/window.c i...


From: Sergey Poznyakoff
Subject: texinfo ChangeLog info/window.h info/window.c i...
Date: Fri, 30 Nov 2012 23:58:21 +0000

CVSROOT:        /cvsroot/texinfo
Module name:    texinfo
Changes by:     Sergey Poznyakoff <gray>        12/11/30 23:58:21

Modified files:
        .              : ChangeLog 
        info           : window.h window.c display.c indices.c tag.c 
                         tag.h 

Log message:
        Fix cursor positioning after index searches (bug #37823).
        
        * info/window.h (WINDOW): Use size_t instead of int.
        (log_line_no): New member.
        (process_node_text): Change signature.
        * info/window.c (window_new_screen_size,recalculate_line_starts)
        (window_toggle_wrap,window_delete_window): Handle the
        log_line_no array.
        (calc_closure_expand): New static function.
        (_calc_line_starts): Update log_line_no. Use calc_closure_expand
        instead of the add_pointer_to_array macro.
        (calculate_line_starts): Fill in log_line_no.
        (window_log_to_phys_line): New function.
        (process_node_text): Keep track of logical line numbers.
        * info/display.c (display_node_text): Change signature.
        * info/indices.c (info_next_index_match): Convert logical line
        number to physical line.
        
        * info/tag.c (tags_expand): Remove unused variables.
        (handle_tag): Fix return type.
        * info/tag.h (handle_tag): Fix return type.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/ChangeLog?cvsroot=texinfo&r1=1.1466&r2=1.1467
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/window.h?cvsroot=texinfo&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/window.c?cvsroot=texinfo&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/display.c?cvsroot=texinfo&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/indices.c?cvsroot=texinfo&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/tag.c?cvsroot=texinfo&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/tag.h?cvsroot=texinfo&r1=1.1&r2=1.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/texinfo/texinfo/ChangeLog,v
retrieving revision 1.1466
retrieving revision 1.1467
diff -u -b -r1.1466 -r1.1467
--- ChangeLog   30 Nov 2012 20:48:38 -0000      1.1466
+++ ChangeLog   30 Nov 2012 23:58:18 -0000      1.1467
@@ -1,3 +1,27 @@
+2012-12-01  Sergey Poznyakoff  <address@hidden>
+
+       Fix cursor positioning after index searches (bug #37823).
+
+       * info/window.h (WINDOW): Use size_t instead of int.
+       (log_line_no): New member.
+       (process_node_text): Change signature.
+       * info/window.c (window_new_screen_size,recalculate_line_starts)
+       (window_toggle_wrap,window_delete_window): Handle the
+       log_line_no array.
+       (calc_closure_expand): New static function.
+       (_calc_line_starts): Update log_line_no. Use calc_closure_expand
+       instead of the add_pointer_to_array macro.
+       (calculate_line_starts): Fill in log_line_no.
+       (window_log_to_phys_line): New function.
+       (process_node_text): Keep track of logical line numbers.
+       * info/display.c (display_node_text): Change signature.
+       * info/indices.c (info_next_index_match): Convert logical line
+       number to physical line.
+
+       * info/tag.c (tags_expand): Remove unused variables.
+       (handle_tag): Fix return type.
+       * info/tag.h (handle_tag): Fix return type.
+
 2012-11-30  Patrice Dumas  <address@hidden>
 
        * doc/texinfo.txi (Invoking texi2any), tp/texi2any.pl: add -c as an

Index: info/window.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/window.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- info/window.h       18 Oct 2011 18:47:22 -0000      1.14
+++ info/window.h       30 Nov 2012 23:58:20 -0000      1.15
@@ -1,5 +1,5 @@
 /* window.h -- Structure and flags used in manipulating Info windows.
-   $Id: window.h,v 1.14 2011/10/18 18:47:22 karl Exp $
+   $Id: window.h,v 1.15 2012/11/30 23:58:20 gray Exp $
 
    This file is part of GNU Info, a program for reading online documentation
    stored in Info format.
@@ -70,16 +70,18 @@
 {
   struct window_struct *next;      /* Next window in this chain. */
   struct window_struct *prev;      /* Previous window in this chain. */
-  int width;            /* Width of this window. */
-  int height;           /* Height of this window. */
-  int first_row;        /* Offset of the first line in the_screen. */
-  int goal_column;      /* The column we would like the cursor to appear in. */
+  size_t width;         /* Width of this window. */
+  size_t height;        /* Height of this window. */
+  size_t first_row;     /* Offset of the first line in the_screen. */
+  size_t goal_column;   /* The column we would like the cursor to appear in. */
   Keymap keymap;        /* Keymap used to read commands in this window. */
   WINDOW_STATE_DECL;    /* Node, pagetop and point. */
   LINE_MAP line_map;    /* Current line map */
   char *modeline;       /* Calculated text of the modeline for this window. */
   char **line_starts;   /* Array of printed line starts for this node. */
-  int line_count;       /* Number of lines appearing in LINE_STARTS. */
+  size_t line_count;    /* Number of lines appearing in LINE_STARTS. */
+  size_t *log_line_no;  /* Number of logical line corresponding to each
+                          physical one. */
   int flags;            /* See below for details. */
 } WINDOW;
 
@@ -273,7 +275,8 @@
 
 extern size_t process_node_text
         (WINDOW *win, char *start, int do_tags,
-         int (*fun) (void *, size_t, const char *, char *, size_t, size_t),
+         int (*fun) (void *, size_t, size_t, const char *, char *,
+                    size_t, size_t),
         void *closure);
 
 void clean_manpage (char *manpage);

Index: info/window.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/window.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- info/window.c       6 Jul 2012 23:55:32 -0000       1.25
+++ info/window.c       30 Nov 2012 23:58:20 -0000      1.26
@@ -1,5 +1,5 @@
 /* window.c -- windows in Info.
-   $Id: window.c,v 1.25 2012/07/06 23:55:32 karl Exp $
+   $Id: window.c,v 1.26 2012/11/30 23:58:20 gray Exp $
 
    Copyright (C) 1993, 1997, 1998, 2001, 2002, 2003, 2004, 2007, 2008,
    2011, 2012 Free Software Foundation, Inc.
@@ -25,6 +25,7 @@
 #include "display.h"
 #include "info-utils.h"
 #include "infomap.h"
+#include "tag.h"
 
 /* The window which describes the screen. */
 WINDOW *the_screen = NULL;
@@ -137,6 +138,7 @@
         {
           windows->height = 0;
           maybe_free (windows->line_starts);
+         maybe_free (windows->log_line_no);
           windows->line_starts = NULL;
           windows->line_count = 0;
           break;
@@ -584,9 +586,11 @@
   if (window != the_echo_area)
     {
       char **old_starts;
+      size_t *old_xlat;
       int old_lines, old_pagetop;
 
       old_starts = window->line_starts;
+      old_xlat = window->log_line_no;
       old_lines = window->line_count;
       old_pagetop = window->pagetop;
 
@@ -602,6 +606,7 @@
         display_scroll_line_starts
           (window, old_pagetop, old_starts, old_lines);
       maybe_free (old_starts);
+      maybe_free (old_xlat);
     }
   window->flags |= W_UpdateWindow;
 }
@@ -645,10 +650,8 @@
   else
     prev->next = next;
 
-  if (window->line_starts)
     free (window->line_starts);
-
-  if (window->modeline)
+  free (window->log_line_no);
     free (window->modeline);
 
   if (window == active_window)
@@ -800,18 +803,36 @@
 
 struct calc_closure {
   WINDOW *win;
-  int line_starts_slots; /* FIXME: size_t */
+  size_t line_starts_slots;
 };
 
+static void
+calc_closure_expand (struct calc_closure *cp)
+{
+  if (cp->win->line_count == cp->line_starts_slots)
+    {
+      if (cp->line_starts_slots == 0)
+       cp->line_starts_slots = 100;
+      cp->win->line_starts = x2nrealloc (cp->win->line_starts,
+                                        &cp->line_starts_slots,
+                                        sizeof (cp->win->line_starts[0]));
+      cp->win->log_line_no = xrealloc (cp->win->log_line_no,
+                                    cp->line_starts_slots *
+                                    sizeof (cp->win->log_line_no[0]));
+    }
+}
+
 static int
-_calc_line_starts (void *closure, size_t line_index,
+_calc_line_starts (void *closure, size_t pline_index, size_t lline_index,
                   const char *src_line,
                   char *printed_line, size_t pl_index, size_t pl_count)
 {
   struct calc_closure *cp = closure;
-  add_pointer_to_array (src_line,
-                       cp->win->line_count, cp->win->line_starts,
-                       cp->line_starts_slots, 100, char *);
+
+  calc_closure_expand (cp);
+  cp->win->line_starts[cp->win->line_count] = (char*) src_line;
+  cp->win->log_line_no[cp->win->line_count] = lline_index;
+  cp->win->line_count++;
   return 0;
 }
 
@@ -821,6 +842,7 @@
   struct calc_closure closure;
 
   window->line_starts = NULL;
+  window->log_line_no  = NULL;
   window->line_count = 0;
 
   if (!window->node)
@@ -830,6 +852,9 @@
   closure.line_starts_slots = 0;
   process_node_text (window, window->node->contents, 0,
                     _calc_line_starts, &closure);
+  calc_closure_expand (&closure);
+  window->line_starts[window->line_count] = NULL;
+  window->log_line_no[window->line_count] = 0;
 }
 
 /* Given WINDOW, recalculate the line starts for the node it displays. */
@@ -837,9 +862,28 @@
 recalculate_line_starts (WINDOW *window)
 {
   maybe_free (window->line_starts);
+  maybe_free (window->log_line_no);
   calculate_line_starts (window);
 }
 
+/* Return the number of first physical line corresponding to the logical
+   line LN.
+
+   A logical line can occupy one or more physical lines of output.  It
+   occupies more than one physical line if its width is greater than the
+   window width and the flag W_NoWrap is not set for that window.
+ */
+size_t
+window_log_to_phys_line (WINDOW *window, size_t ln)
+{
+  size_t i;
+  
+  if (ln > window->line_count)
+    return 0;
+  for (i = ln; i < window->line_count && window->log_line_no[i] < ln; i++)
+    ;
+  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
@@ -1430,12 +1474,13 @@
 
    FUN is called for every line collected from the node. Its arguments:
 
-     int (*fun) (void *closure, size_t line_no,
+     int (*fun) (void *closure, size_t phys_line_no, size_t log_line_no,
                   const char *src_line, char *prt_line,
                  size_t prt_bytes, size_t prt_chars)
 
      closure  -- An opaque pointer passed as 5th parameter to 
process_node_text;
-     line_no  -- Number of processed line (starts from 0);
+     line_no  -- Number of processed physical line (starts from 0);
+     log_line_no -- Number of processed logical line (starts from 0);
      src_line -- Pointer to the source line (unmodified);
      prt_line -- Collected line contents, ready for output;
      prt_bytes -- Number of bytes in prt_line;
@@ -1452,14 +1497,16 @@
 size_t
 process_node_text (WINDOW *win, char *start,
                   int do_tags,
-                  int (*fun) (void *, size_t, const char *, char *, size_t, 
size_t),
+                  int (*fun) (void *, size_t, size_t,
+                              const char *, char *, size_t, size_t),
                   void *closure)
 {
   char *printed_line;      /* Buffer for a printed line. */
   size_t pl_count = 0;     /* Number of *characters* written to PRINTED_LINE */
   size_t pl_index = 0;     /* Index into PRINTED_LINE. */
   size_t in_index = 0;
-  size_t line_index = 0;   /* Number of lines done so far. */
+  size_t line_index = 0;   /* Number of physical lines done so far. */
+  size_t logline_index = 0;/* Number of logical lines */
   size_t allocated_win_width;
   mbi_iterator_t iter;
   
@@ -1493,7 +1540,7 @@
           if (*cur_ptr == '\r' || *cur_ptr == '\n')
             {
               replen = win->width - pl_count;
-             delim = 1;
+             delim = *cur_ptr;
             }
          else if (ansi_escape (iter, &cur_len))
            {
@@ -1508,7 +1555,7 @@
          else
            {
              if (*cur_ptr == '\t')
-               delim = 1;
+               delim = *cur_ptr;
               cur_ptr = printed_representation (cur_ptr, cur_len, pl_count,
                                                &cur_len);
              replen = cur_len;
@@ -1590,10 +1637,13 @@
               printed_line[pl_index] = '\0';
             }
 
-         rc = fun (closure, line_index, mbi_cur_ptr (iter) - in_index,
+         rc = fun (closure, line_index, logline_index,
+                   mbi_cur_ptr (iter) - in_index,
                    printed_line, pl_index, pl_count);
 
           ++line_index;
+         if (delim == '\r' || delim == '\n')
+           ++logline_index;
 
          /* Reset all data to the start of the line. */
          pl_index = 0;
@@ -1631,7 +1681,8 @@
     }
 
   if (pl_count)
-    fun (closure, line_index, mbi_cur_ptr (iter) - in_index,
+    fun (closure, line_index, logline_index,
+        mbi_cur_ptr (iter) - in_index,
         printed_line, pl_index, pl_count);
 
   free (printed_line);

Index: info/display.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/display.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- info/display.c      17 Nov 2012 17:16:18 -0000      1.18
+++ info/display.c      30 Nov 2012 23:58:20 -0000      1.19
@@ -1,5 +1,5 @@
 /* display.c -- How to display Info windows.
-   $Id: display.c,v 1.18 2012/11/17 17:16:18 gray Exp $
+   $Id: display.c,v 1.19 2012/11/30 23:58:20 gray Exp $
 
    Copyright (C) 1993, 1997, 2003, 2004, 2006, 2007, 2008, 2012
    Free Software Foundation, Inc.
@@ -113,14 +113,14 @@
 }
 
 int
-display_node_text(void *closure, size_t line_index,
+display_node_text(void *closure, size_t pline_index, size_t lline_index,
                  const char *src_line,
                  char *printed_line, size_t pl_index, size_t pl_count)
 {
   struct display_node_closure *dn = closure;
   WINDOW *win = dn->win;
   DISPLAY_LINE **display = dn->display;
-  DISPLAY_LINE *entry = display[win->first_row + line_index];
+  DISPLAY_LINE *entry = display[win->first_row + pline_index];
 
   /* We have the exact line as it should appear on the screen.
      Check to see if this line matches the one already appearing
@@ -139,7 +139,7 @@
          /* Need to erase the line if it has escape sequences.  */
          || (raw_escapes_p && mbschr (entry->text, '\033') != 0))
        {
-         terminal_goto_xy (0, win->first_row + line_index);
+         terminal_goto_xy (0, win->first_row + pline_index);
          terminal_clear_to_eol ();
          entry->inverse = 0;
          entry->text[0] = '\0';
@@ -154,7 +154,7 @@
       if (i != pl_count || pl_count != entry->textlen)
        {
          /* Move to the proper point on the terminal. */
-         terminal_goto_xy (i, win->first_row + line_index);
+         terminal_goto_xy (i, win->first_row + pline_index);
          /* If there is any text to print, print it. */
          if (i != pl_count)
            terminal_put_text (printed_line + i);
@@ -196,7 +196,7 @@
       return 1;
     }
 
-  if (line_index + 1 == win->height)
+  if (pline_index + 1 == win->height)
     return 1;
 
   return 0;

Index: info/indices.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/indices.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- info/indices.c      12 Apr 2012 10:38:28 -0000      1.20
+++ info/indices.c      30 Nov 2012 23:58:20 -0000      1.21
@@ -1,5 +1,5 @@
 /* indices.c -- deal with an Info file index.
-   $Id: indices.c,v 1.20 2012/04/12 10:38:28 gray Exp $
+   $Id: indices.c,v 1.21 2012/11/30 23:58:20 gray Exp $
 
    Copyright (C) 1993, 1997, 1998, 1999, 2002, 2003, 2004, 2007, 2008, 2011
    Free Software Foundation, Inc.
@@ -502,7 +502,8 @@
 
   {
     long loc;
-    long line = index_index[i]->line_number - 1;
+    long line = window_log_to_phys_line (window,
+                                        index_index[i]->line_number - 1);
 
     if (line >= 0 && line < window->line_count)
       {

Index: info/tag.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/tag.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- info/tag.c  17 Nov 2012 17:16:19 -0000      1.1
+++ info/tag.c  30 Nov 2012 23:58:20 -0000      1.2
@@ -1,5 +1,5 @@
 /* tag.c -- Functions to handle Info tags.
-   $Id: tag.c,v 1.1 2012/11/17 17:16:19 gray Exp $
+   $Id: tag.c,v 1.2 2012/11/30 23:58:20 gray Exp $
 
    Copyright (C) 2012 Free Software Foundation, Inc.
 
@@ -186,12 +186,9 @@
 
   while ((p = input + strlen (input)) < endp)
     {
-      size_t len = p - input;
       if (memcmp(p + 1, "\b[", 2) == 0)
        {
          char *q;
-         size_t len;
-         struct tag_handler *tp;
 
          p += 3;
          q = p + strlen (p);
@@ -237,7 +234,7 @@
     }
 }
   
-size_t
+void
 handle_tag (char *tag)
 {
   /* Nothing so far */

Index: info/tag.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/tag.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- info/tag.h  17 Nov 2012 17:16:19 -0000      1.1
+++ info/tag.h  30 Nov 2012 23:58:21 -0000      1.2
@@ -1,5 +1,5 @@
 /* tag.c -- Functions to handle Info tags.
-   $Id: tag.h,v 1.1 2012/11/17 17:16:19 gray Exp $
+   $Id: tag.h,v 1.2 2012/11/30 23:58:21 gray Exp $
 
    Copyright (C) 2012 Free Software Foundation, Inc.
 
@@ -20,6 +20,6 @@
 #define TAG_H
 
 void tags_expand (char **pbuf, size_t *pbuflen);
-size_t handle_tag (char *tag);
+void handle_tag (char *tag);
 
 #endif



reply via email to

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