[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5768] find_diff handle lines with control sequences better
From: |
Gavin D. Smith |
Subject: |
[5768] find_diff handle lines with control sequences better |
Date: |
Thu, 21 Aug 2014 15:22:12 +0000 |
Revision: 5768
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5768
Author: gavin
Date: 2014-08-21 15:22:10 +0000 (Thu, 21 Aug 2014)
Log Message:
-----------
find_diff handle lines with control sequences better
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/display.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-08-21 14:46:11 UTC (rev 5767)
+++ trunk/ChangeLog 2014-08-21 15:22:10 UTC (rev 5768)
@@ -3,6 +3,12 @@
* info/display.c (decide_if_in_match): New function.
(display_update_window_1): Call it.
+ * info/display.c (find_diff): Return offset of first ESC in line if
+ the lines differ and there is one. Return -1 if no difference.
+ Handle multicolumn characters with wcwidth.
+ (display_node_text): Use offset into new line contents set by
+ find_diff.
+
2014-08-21 Gavin Smith <address@hidden>
* info/infomap.c (default_emacs_like_info_keys): Add ESC x key
Modified: trunk/info/display.c
===================================================================
--- trunk/info/display.c 2014-08-21 14:46:11 UTC (rev 5767)
+++ trunk/info/display.c 2014-08-21 15:22:10 UTC (rev 5768)
@@ -95,23 +95,50 @@
signal_unblock_winch ();
}
+/* Return the screen column of where to write to screen to update line to
+ match A, given that B contains the current state of the line. *PPOS gets
+ the offset into the string A to write from. */
static int
find_diff (const char *a, size_t alen, const char *b, size_t blen, int *ppos)
{
mbi_iterator_t itra, itrb;
int i;
int pos = 0;
+ int first_escape = -1;
+ int escape_pos = -1;
for (i = 0, mbi_init (itra, a, alen), mbi_init (itrb, b, blen);
mbi_avail (itra) && mbi_avail (itrb);
- i++, mbi_advance (itra), mbi_advance (itrb))
+ i += wcwidth (itra.cur.wc), mbi_advance (itra), mbi_advance (itrb))
{
if (mb_cmp (mbi_cur (itra), mbi_cur (itrb)))
- break;
+ break;
+
+ if (first_escape == -1 && *mbi_cur_ptr (itra) == '\033')
+ {
+ first_escape = i;
+ escape_pos = pos;
+ }
pos += mb_len (mbi_cur (itra));
}
- *ppos = pos;
- return i;
+
+ if (mbi_avail (itra) || mbi_avail (itrb))
+ if (first_escape != -1)
+ {
+ *ppos = escape_pos;
+ return first_escape;
+ }
+ else
+ {
+ /* If there was a difference in the line, and there was an escape
+ character, return the position of the escape character, as it could
+ start a terminal escape sequence. */
+ *ppos = pos;
+ return i;
+ }
+
+ /* Otherwise, no redrawing is required. */
+ return -1;
}
/* Update line PL_NUM of the screen to be PRINTED_LINE, which is PL_BYTES long
@@ -138,9 +165,7 @@
the line from the screen first. Why, I don't know.
(But don't do this if we have no visible entries, as can
happen if the window is shrunk very small.) */
- if (entry->inverse
- /* Need to erase the line if it has escape sequences. */
- || (raw_escapes_p && mbschr (entry->text, '\033') != 0))
+ if (entry->inverse)
{
terminal_goto_xy (0, pl_num);
terminal_clear_to_eol ();
@@ -152,15 +177,14 @@
i = find_diff (printed_line, pl_bytes,
entry->text, strlen (entry->text), &off);
- /* If the lines are not the same length, or if they differed
- at all, we must do some redrawing. */
- if (i != pl_chars || pl_chars != entry->textlen)
+ /* If the lines differed at all, we must do some redrawing. */
+ if (i != -1)
{
/* Move to the proper point on the terminal. */
terminal_goto_xy (i, pl_num);
+
/* If there is any text to print, print it. */
- if (i != pl_chars)
- terminal_put_text (printed_line + i);
+ terminal_put_text (printed_line + off);
/* If the printed text didn't extend all the way to the edge
of the screen, and text was appearing between here and the
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5768] find_diff handle lines with control sequences better,
Gavin D. Smith <=