less/less-409-save_line_position.patch

70 lines
1.8 KiB
Diff
Raw Normal View History

--- line.c
+++ line.c
@@ -68,6 +68,25 @@
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.
*/
@@ -620,7 +639,11 @@
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.
*/
@@ -952,7 +975,11 @@
{
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;
@@ -1038,9 +1065,12 @@
* that blank line would be ignored!)
*/
if (!oldbot)
- nl = (column < sc_width || !auto_wrap || (endline && ignaw) || ctldisp == OPT_ON);
+ nl = (column < sc_width || !auto_wrap || (endline && ignaw));
else
- nl = (column < sc_width || !auto_wrap || ignaw || ctldisp == OPT_ON);
+ nl = (column < sc_width || !auto_wrap || ignaw);
+#if THROW_AWAY_LOCATION
+ nl = nl || ctldisp == OPT_ON;
+#endif
if (nl)
{
linebuf[curr] = '\n';