summaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'input.c')
-rw-r--r--input.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/input.c b/input.c
index d11bf71ea336..c2f7a28c2c58 100644
--- a/input.c
+++ b/input.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2024 Mark Nudelman
+ * Copyright (C) 1984-2025 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -29,7 +29,6 @@ extern POSITION start_attnpos;
extern POSITION end_attnpos;
#if HILITE_SEARCH
extern int hilite_search;
-extern size_t size_linebuf;
extern int show_attn;
#endif
@@ -68,9 +67,9 @@ static void init_status_col(POSITION base_pos, POSITION disp_pos, POSITION edisp
attr = is_hilited_attr(disp_pos, edisp_pos, TRUE, NULL);
ch = '*';
} else
- {
- attr = 0;
- }
+ {
+ attr = 0;
+ }
if (attr)
set_status_col(ch, attr);
}
@@ -82,7 +81,7 @@ static void init_status_col(POSITION base_pos, POSITION disp_pos, POSITION edisp
* a line. The new position is the position of the first character
* of the NEXT line. The line obtained is the line starting at curr_pos.
*/
-public POSITION forw_line_seg(POSITION curr_pos, lbool skipeol, lbool rscroll, lbool nochop)
+public POSITION forw_line_seg(POSITION curr_pos, lbool skipeol, lbool rscroll, lbool nochop, POSITION *p_linepos, lbool *p_newline)
{
POSITION base_pos;
POSITION new_pos;
@@ -95,6 +94,9 @@ public POSITION forw_line_seg(POSITION curr_pos, lbool skipeol, lbool rscroll, l
POSITION wrap_pos;
lbool skipped_leading;
+ if (p_linepos != NULL)
+ *p_linepos = NULL_POSITION;
+
get_forw_line:
if (curr_pos == NULL_POSITION)
{
@@ -111,8 +113,7 @@ get_forw_line:
* If we're not ignoring EOI, we *could* do the same, but
* for efficiency we prepare several lines ahead at once.
*/
- prep_hilite(curr_pos, curr_pos + (POSITION) (3*size_linebuf), ignore_eoi ? 1 : -1);
- curr_pos = next_unfiltered(curr_pos);
+ prep_hilite(curr_pos, NULL_POSITION, 1);
}
#endif
if (ch_seek(curr_pos))
@@ -295,7 +296,7 @@ get_forw_line:
pappend_b(' ', ch_tell()-1, TRUE);
}
#endif
- pdone(endline, rscroll && chopped, 1);
+ pdone(endline, rscroll && chopped, TRUE);
#if HILITE_SEARCH
if (is_filtered(base_pos))
@@ -324,14 +325,16 @@ get_forw_line:
(void) ch_back_get();
new_pos = ch_tell();
}
-
+ if (p_linepos != NULL)
+ *p_linepos = curr_pos;
+ if (p_newline != NULL)
+ *p_newline = endline;
return (new_pos);
}
-public POSITION forw_line(POSITION curr_pos)
+public POSITION forw_line(POSITION curr_pos, POSITION *p_linepos, lbool *p_newline)
{
-
- return forw_line_seg(curr_pos, (chop_line() || hshift > 0), TRUE, FALSE);
+ return forw_line_seg(curr_pos, (chop_line() || hshift > 0), TRUE, FALSE, p_linepos, p_newline);
}
/*
@@ -341,7 +344,7 @@ public POSITION forw_line(POSITION curr_pos)
* a line. The new position is the position of the first character
* of the PREVIOUS line. The line obtained is the one starting at new_pos.
*/
-public POSITION back_line(POSITION curr_pos)
+public POSITION back_line(POSITION curr_pos, lbool *p_newline)
{
POSITION base_pos;
POSITION new_pos;
@@ -360,11 +363,6 @@ get_back_line:
null_line();
return (NULL_POSITION);
}
-#if HILITE_SEARCH
- if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
- prep_hilite((curr_pos < (POSITION) (3*size_linebuf)) ? 0 :
- curr_pos - (POSITION) (3*size_linebuf), curr_pos, -1);
-#endif
if (ch_seek(curr_pos-1))
{
null_line();
@@ -427,6 +425,11 @@ get_back_line:
}
}
+#if HILITE_SEARCH
+ if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
+ prep_hilite(base_pos, NULL_POSITION, 1);
+#endif
+
/*
* Now scan forwards from the beginning of this line.
* We keep discarding "printable lines" (based on screen width)
@@ -445,6 +448,8 @@ get_back_line:
endline = FALSE;
prewind();
plinestart(new_pos);
+ if (p_newline != NULL)
+ *p_newline = TRUE;
loop:
wrap_pos = NULL_POSITION;
skipped_leading = FALSE;
@@ -489,6 +494,8 @@ get_back_line:
edisp_pos = new_pos;
break;
}
+ if (p_newline != NULL)
+ *p_newline = FALSE;
shift:
if (!wordwrap)
{
@@ -550,7 +557,7 @@ get_back_line:
}
}
- pdone(endline, chopped, 0);
+ pdone(endline, chopped, FALSE);
#if HILITE_SEARCH
if (is_filtered(base_pos))
@@ -565,7 +572,6 @@ get_back_line:
if (status_col)
init_status_col(base_pos, line_position(), edisp_pos, new_pos);
#endif
-
return (begin_new_pos);
}