[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5591] info_end_of_line
From: |
Gavin D. Smith |
Subject: |
[5591] info_end_of_line |
Date: |
Wed, 21 May 2014 00:59:27 +0000 |
Revision: 5591
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5591
Author: gavin
Date: 2014-05-21 00:59:25 +0000 (Wed, 21 May 2014)
Log Message:
-----------
info_end_of_line
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/Makefile.am
trunk/info/session.c
trunk/info/window.c
Added Paths:
-----------
trunk/info/t/end-of-line.drib
trunk/info/t/end-of-line.sh
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-05-20 22:27:41 UTC (rev 5590)
+++ trunk/ChangeLog 2014-05-21 00:59:25 UTC (rev 5591)
@@ -4,8 +4,16 @@
allocate an object with all bytes 0.
* info/info.h (zero_mem): Removed.
- * info/t/Init-intera: Extra line of output reporting on progress.
+ * info/t/Init-intera.inc: Extra line of output reporting on progress.
+ * info/session.c (info_end_of_line): Get end of line from line_map
+ object.
+ * info/window.c (window_scan_line, window_compute_line_map):
+ Functions merged.
+ (add_line_map): Merged into the new window_compute_line_map.
+ (window_end_of_line): Removed.
+ * info/t/end-of-line.sh: New test.
+
2014-05-19 Gavin Smith <address@hidden>
* info/t/Init-intera.inc: Confirm pts file exists before redirecting
Modified: trunk/info/Makefile.am
===================================================================
--- trunk/info/Makefile.am 2014-05-20 22:27:41 UTC (rev 5590)
+++ trunk/info/Makefile.am 2014-05-21 00:59:25 UTC (rev 5591)
@@ -113,6 +113,7 @@
t/where-dir-file.sh \
t/tab.sh \
t/body-start.sh \
+ t/end-of-line.sh \
t/index.sh \
t/index-apropos.sh \
t/split-index.sh \
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-05-20 22:27:41 UTC (rev 5590)
+++ trunk/info/session.c 2014-05-21 00:59:25 UTC (rev 5591)
@@ -950,7 +950,29 @@
/* Move WINDOW's point to the end of the true line. */
DECLARE_INFO_COMMAND (info_end_of_line, _("Move to the end of the line"))
{
- int point = window_end_of_line (window);
+ long point;
+ if (!window->node)
+ return;
+
+ /* Find physical line with end of logical line in it. */
+ window_compute_line_map (window);
+ while (!_looking_at_newline (window,
+ window->line_map.map[window->line_map.used - 1]))
+ {
+ if (point_next_line (window))
+ break; /* No next line. */
+ }
+
+ if (window->line_map.used == 0)
+ return; /* This shouldn't happen. */
+
+ if (window->line_map.used == 1)
+ /* Empty line - return offset of terminating newline. */
+ point = window->line_map.map[0];
+ else
+ /* Otherwise of last character in line. */
+ point = window->line_map.map[window->line_map.used - 2];
+
if (point != window->point)
{
window->point = point;
Added: trunk/info/t/end-of-line.drib
===================================================================
(Binary files differ)
Property changes on: trunk/info/t/end-of-line.drib
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/info/t/end-of-line.sh
===================================================================
--- trunk/info/t/end-of-line.sh (rev 0)
+++ trunk/info/t/end-of-line.sh 2014-05-21 00:59:25 UTC (rev 5591)
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Copyright (C) 2014 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+srcdir=${srcdir:-.}
+. $srcdir/t/Init-test.inc
+. $t/Init-intera.inc
+
+# Check that typing C-e on an empty line doesn't go to previous line
+$GINFO -f intera --restore $t/end-of-line.drib
+
+test -f $GINFO_OUTPUT || exit 1
+# Return non-zero (test failure) if files differ
+diff $GINFO_OUTPUT $t/node-target
+RETVAL=$?
+
+. $t/Cleanup.inc
+
Property changes on: trunk/info/t/end-of-line.sh
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2014-05-20 22:27:41 UTC (rev 5590)
+++ trunk/info/window.c 2014-05-21 00:59:25 UTC (rev 5591)
@@ -1601,31 +1601,24 @@
win->line_map.used = 0;
}
-/* Scan the line number LINE in WIN. If PHYS is true, stop scanning at
- the end of physical line, i.e. at the newline character. Otherwise,
- stop it at the end of logical line.
-
- If FUN is supplied, call it for each processed multibyte character.
- Arguments of FUN are
-
- closure - Function-specific data passed as 5th argument to
- window_scan_line;
- cpos - Current point value;
- replen - Size of screen representation of this character, in
- columns. This value may be 0 (for ANSI sequences and
- info tags), or > 1 (for tabs).
- */
-int
-window_scan_line (WINDOW *win, int line, int phys,
- void (*fun) (void *closure, long cpos, size_t replen),
- void *closure)
+/* Compute the line map for the current line in WIN. */
+void
+window_compute_line_map (WINDOW *win)
{
+ int line = window_line_of_point (win);
mbi_iterator_t iter;
int delim = 0;
char *endp;
const char *cur_ptr;
-
- if (!phys && line + 1 < win->line_count)
+
+ if (win->line_map.node == win->node && win->line_map.nline == line
+ && win->line_map.used)
+ return;
+ line_map_init (&win->line_map, win->node, line);
+ if (!win->node)
+ return;
+
+ if (line + 1 < win->line_count)
endp = win->node->contents + win->line_starts[line + 1];
else
endp = win->node->contents + win->node->nodelen;
@@ -1645,46 +1638,11 @@
printed_representation (&iter, &delim, win->line_map.used,
&pchars, &pbytes);
- if (fun)
- fun (closure, cur_ptr - win->node->contents, pchars);
+ while (pchars--)
+ line_map_add (&win->line_map, cur_ptr - win->node->contents);
}
- return cur_ptr - win->node->contents;
}
-static void
-add_line_map (void *closure, long cpos, size_t replen)
-{
- WINDOW *win = closure;
-
- while (replen--)
- line_map_add (&win->line_map, cpos);
-}
-
-/* Compute the line map for the current line in WIN. */
-void
-window_compute_line_map (WINDOW *win)
-{
- int line = window_line_of_point (win);
-
- if (win->line_map.node == win->node && win->line_map.nline == line
- && win->line_map.used)
- return;
- line_map_init (&win->line_map, win->node, line);
- if (win->node)
- window_scan_line (win, line, 0, add_line_map, win);
-}
-
-/* Return offset of the end of current physical line.
- */
-long
-window_end_of_line (WINDOW *win)
-{
- int line = window_line_of_point (win);
- if (win->node)
- return window_scan_line (win, line, 1, NULL, NULL) - 1;
- return 0;
-}
-
/* Translate the value of POINT into a column number. If NP is given
store there the value of point corresponding to the beginning of a
multibyte character in this column.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5591] info_end_of_line,
Gavin D. Smith <=