167 lines
5.1 KiB
Diff
167 lines
5.1 KiB
Diff
Index: line.c
|
|
===================================================================
|
|
--- line.c.orig 2009-03-30 21:45:51.000000000 +0200
|
|
+++ line.c 2009-06-03 15:37:46.000000000 +0200
|
|
@@ -4,7 +4,7 @@
|
|
* You may distribute under the terms of either the GNU General Public
|
|
* License or the Less License, as specified in the README file.
|
|
*
|
|
- * For more information about less, or for information on how to
|
|
+ * For more information about less, or for information on how to
|
|
* contact the author, see the README file.
|
|
*/
|
|
|
|
@@ -66,6 +66,25 @@ static int mbc_buf_len = 0;
|
|
static int mbc_buf_index = 0;
|
|
static POSITION mbc_pos;
|
|
|
|
+
|
|
+
|
|
+/* Following define alters the "-r" switch to not throw
|
|
+ * away location information, but keep location as well
|
|
+ * as "possible" (currently only interpreting location escape
|
|
+ * sequences
|
|
+ *
|
|
+ * This benefits the user who may be operating with "-r" but
|
|
+ * is still displaying predominantly "normal" spacing characters
|
|
+ * (especially single, 8-bit characters that print "normally"
|
|
+ * but might otherwise be "undisplayable" in non "-r" mode.
|
|
+ *
|
|
+ * This is especially true using extended European characters
|
|
+ * that might be present in UTF-8 docs (among others);
|
|
+ * - lawless@tlinx.org
|
|
+ */
|
|
+#define THROW_AWAY_LOCATION 0
|
|
+
|
|
+
|
|
/*
|
|
* Initialize from environment variables.
|
|
*/
|
|
@@ -177,7 +196,7 @@ plinenum(pos)
|
|
/*
|
|
* Get the line number and put it in the current line.
|
|
* {{ Note: since find_linenum calls forw_raw_line,
|
|
- * it may seek in the input file, requiring the caller
|
|
+ * it may seek in the input file, requiring the caller
|
|
* of plinenum to re-seek if necessary. }}
|
|
* {{ Since forw_raw_line modifies linebuf, we must
|
|
* do this first, before storing anything in linebuf. }}
|
|
@@ -274,7 +293,7 @@ pshift(shift)
|
|
attr[to++] = attr[from];
|
|
if (!is_ansi_middle(linebuf[from++]))
|
|
break;
|
|
- }
|
|
+ }
|
|
continue;
|
|
}
|
|
|
|
@@ -320,7 +339,7 @@ pshift(shift)
|
|
/* Adjust width for magic cookies. */
|
|
prev_attr = (to > 0) ? attr[to-1] : AT_NORMAL;
|
|
next_attr = (from + len < curr) ? attr[from + len] : prev_attr;
|
|
- if (!is_at_equiv(attr[from], prev_attr) &&
|
|
+ if (!is_at_equiv(attr[from], prev_attr) &&
|
|
!is_at_equiv(attr[from], next_attr))
|
|
{
|
|
width += attr_swidth(attr[from]);
|
|
@@ -617,7 +636,11 @@ store_char(ch, a, rep, pos)
|
|
w = pwidth(ch, a, prev_ch);
|
|
}
|
|
|
|
- if (ctldisp != OPT_ON && column + w + attr_ewidth(a) > sc_width)
|
|
+ if (
|
|
+#if THROW_AWAY_LOCATION
|
|
+ ctldisp != OPT_ON &&
|
|
+#endif
|
|
+ column + w + attr_ewidth(a) > sc_width)
|
|
/*
|
|
* Won't fit on screen.
|
|
*/
|
|
@@ -765,7 +788,7 @@ pappend(c, pos)
|
|
}
|
|
|
|
/*
|
|
- * Don't put the CR into the buffer until we see
|
|
+ * Don't put the CR into the buffer until we see
|
|
* the next char. If the next char is a newline,
|
|
* discard the CR.
|
|
*/
|
|
@@ -874,8 +897,8 @@ do_append(ch, rep, pos)
|
|
{
|
|
/*
|
|
* Overstrike the character at the current position
|
|
- * in the line buffer. This will cause either
|
|
- * underline (if a "_" is overstruck),
|
|
+ * in the line buffer. This will cause either
|
|
+ * underline (if a "_" is overstruck),
|
|
* bold (if an identical character is overstruck),
|
|
* or just deletion of the character in the buffer.
|
|
*/
|
|
@@ -922,7 +945,7 @@ do_append(ch, rep, pos)
|
|
overstrike = 0;
|
|
}
|
|
|
|
- if (ch == '\t')
|
|
+ if (ch == '\t')
|
|
{
|
|
/*
|
|
* Expand a tab into spaces.
|
|
@@ -945,11 +968,15 @@ do_append(ch, rep, pos)
|
|
* Output as a normal character.
|
|
*/
|
|
STORE_CHAR(ch, AT_NORMAL, rep, pos);
|
|
- } else
|
|
+ } else
|
|
{
|
|
STORE_PRCHAR((char) ch, pos);
|
|
}
|
|
- } else if (utf_mode && ctldisp != OPT_ON && is_ubin_char(ch))
|
|
+ } else if (utf_mode &&
|
|
+#if THROW_AWAY_LOCATION
|
|
+ ctldisp != OPT_ON &&
|
|
+#endif
|
|
+ is_ubin_char(ch))
|
|
{
|
|
char *s;
|
|
|
|
@@ -1029,18 +1056,22 @@ pdone(endline, nextc)
|
|
* or if the terminal doesn't auto wrap,
|
|
* or if this is really the end of the line AND the terminal ignores
|
|
* a newline at the right edge.
|
|
- * (In the last case we don't want to output a newline if the terminal
|
|
+ * (In the last case we don't want to output a newline if the terminal
|
|
* doesn't ignore it since that would produce an extra blank line.
|
|
* But we do want to output a newline if the terminal ignores it in case
|
|
* the next line is blank. In that case the single newline output for
|
|
* that blank line would be ignored!)
|
|
*/
|
|
+#if THROW_AWAY_LOCATION
|
|
if (column < sc_width || !auto_wrap || (endline && ignaw) || ctldisp == OPT_ON)
|
|
+#else
|
|
+ if (column < sc_width || !auto_wrap || (endline && ignaw))
|
|
+#endif
|
|
{
|
|
linebuf[curr] = '\n';
|
|
attr[curr] = AT_NORMAL;
|
|
curr++;
|
|
- }
|
|
+ }
|
|
else if (ignaw && column >= sc_width)
|
|
{
|
|
/*
|
|
@@ -1052,12 +1083,12 @@ pdone(endline, nextc)
|
|
* instead of at the start of the next line.
|
|
* So we nudge them into wrapping by outputting the next
|
|
* character plus a backspace. (This wouldn't be right for
|
|
- * "!auto_wrap" terminals, but they always end up in the
|
|
+ * "!auto_wrap" terminals, but they always end up in the
|
|
* branch above.)
|
|
*/
|
|
linebuf[curr] = nextc;
|
|
attr[curr++] = AT_NORMAL;
|
|
- linebuf[curr] = '\b';
|
|
+ linebuf[curr] = '\b';
|
|
attr[curr++] = AT_NORMAL;
|
|
}
|
|
linebuf[curr] = '\0';
|