tConsolidate code - ve - a minimal text editor (work in progress)
(HTM) git clone git://src.adamsgaard.dk/ve
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 8455a8714673d14e2e3b04e3072bab9bb26c7329
(DIR) parent eb81dcd6d14223042118a1d85ae90f4eaf2f53cf
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 7 Aug 2019 10:48:29 +0200
Consolidate code
Diffstat:
M find.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
---
(DIR) diff --git a/find.c b/find.c
t@@ -16,7 +16,7 @@
void
editor_find_next_occurence(int opposite_direction)
{
- int y, y_end, y_inc;
+ int y, y_end, y_inc, x_offset;
eRow *row;
char *match;
t@@ -32,17 +32,19 @@ editor_find_next_occurence(int opposite_direction)
y_inc = -1;
}
+ x_offset = 0;
/* from cursor until end of document */
for (y = E.cursor_y; y != y_end; y += y_inc) {
row = &E.row[y];
if (y == E.cursor_y)
- match = strstr(row->rchars + 1 +
- editor_row_cursor_x_to_rx(&E.row[E.cursor_y],
- E.cursor_x),
- E.find_query);
+ x_offset = y_inc + editor_row_cursor_x_to_rx(&E.row[E.cursor_y],
+ E.cursor_x);
else
- match = strstr(row->rchars, E.find_query);
+ x_offset = 0;
+
+ /* TODO: lines are not searched in reverse with opposite_direction */
+ match = strstr(row->rchars + x_offset, E.find_query);
if (match)
break;
}