mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-05-04 06:46:48 -04:00
search: search_match_to_end_of_word: rename start_{row,col} -> end_{row,col}
This commit is contained in:
parent
2a5da66e4e
commit
867cac4207
1 changed files with 10 additions and 8 deletions
18
search.c
18
search.c
|
|
@ -273,14 +273,14 @@ search_match_to_end_of_word(struct terminal *term)
|
||||||
assert(term->search.match.row != -1);
|
assert(term->search.match.row != -1);
|
||||||
assert(term->search.match.col != -1);
|
assert(term->search.match.col != -1);
|
||||||
|
|
||||||
int start_row = term->search.match.row;
|
int end_row = term->search.match.row;
|
||||||
int start_col = term->search.match.col;
|
int end_col = term->search.match.col;
|
||||||
size_t len = term->search.match_len;
|
size_t len = term->search.match_len;
|
||||||
|
|
||||||
/* Calculate end coord - note: assumed to be valid */
|
/* Calculate end coord - note: assumed to be valid */
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
if (++start_col >= term->cols)
|
if (++end_col >= term->cols)
|
||||||
start_row = (start_row + 1) % term->grid->num_rows;
|
end_row = (end_row + 1) % term->grid->num_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
tll(wchar_t) new_chars = tll_init();
|
tll(wchar_t) new_chars = tll_init();
|
||||||
|
|
@ -290,15 +290,15 @@ search_match_to_end_of_word(struct terminal *term)
|
||||||
|
|
||||||
for (size_t r = 0;
|
for (size_t r = 0;
|
||||||
r < term->grid->num_rows;
|
r < term->grid->num_rows;
|
||||||
start_row = (start_row + 1) % term->grid->num_rows, r++)
|
end_row = (end_row + 1) % term->grid->num_rows, r++)
|
||||||
{
|
{
|
||||||
const struct row *row = term->grid->rows[start_row];
|
const struct row *row = term->grid->rows[end_row];
|
||||||
if (row == NULL)
|
if (row == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
for (; start_col < term->cols; start_col++) {
|
for (; end_col < term->cols; end_col++) {
|
||||||
wchar_t wc = row->cells[start_col].wc;
|
wchar_t wc = row->cells[end_col].wc;
|
||||||
if (wc == 0 || (!first && !isword(wc, false))) {
|
if (wc == 0 || (!first && !isword(wc, false))) {
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -318,8 +318,10 @@ search_match_to_end_of_word(struct terminal *term)
|
||||||
if (!search_ensure_size(term, term->search.len + tll_length(new_chars)))
|
if (!search_ensure_size(term, term->search.len + tll_length(new_chars)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* Keep cursor at the end, but don't move it if not */
|
||||||
bool move_cursor = term->search.cursor == term->search.len;
|
bool move_cursor = term->search.cursor == term->search.len;
|
||||||
|
|
||||||
|
/* Append newly found characters to the search buffer */
|
||||||
tll_foreach(new_chars, it)
|
tll_foreach(new_chars, it)
|
||||||
term->search.buf[term->search.len++] = it->item;
|
term->search.buf[term->search.len++] = it->item;
|
||||||
term->search.buf[term->search.len] = L'\0';
|
term->search.buf[term->search.len] = L'\0';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue