Make incremental search more useful
Make it unanchored, as well as case-insensitive.
This commit is contained in:
parent
840c69767c
commit
48482ef2e5
2
NEWS
2
NEWS
|
@ -4,7 +4,7 @@ x.x.x (xxxx-xx-xx)
|
||||||
|
|
||||||
* Now fetching Internet stream information asynchronously
|
* Now fetching Internet stream information asynchronously
|
||||||
|
|
||||||
* Added rudimentary incremental search, normally bound to C-s, in all tabs
|
* Added basic incremental search, normally bound to C-s, in all tabs
|
||||||
|
|
||||||
* Fixed jumping to the beginning of the queue after deleting items
|
* Fixed jumping to the beginning of the queue after deleting items
|
||||||
|
|
||||||
|
|
17
nncmpp.c
17
nncmpp.c
|
@ -2350,12 +2350,17 @@ static size_t
|
||||||
incremental_search_match (const ucs4_t *needle, size_t len,
|
incremental_search_match (const ucs4_t *needle, size_t len,
|
||||||
const struct row_buffer *row)
|
const struct row_buffer *row)
|
||||||
{
|
{
|
||||||
// TODO: case-insensitive search, wilcards, regexps, something easy to use
|
// XXX: this is slow and simplistic, but unistring is awkward to use
|
||||||
size_t i = 0;
|
size_t best = 0;
|
||||||
for (; i < len && i < row->chars_len; i++)
|
for (size_t start = 0; start < row->chars_len; start++)
|
||||||
if (needle[i] != row->chars[i].c)
|
{
|
||||||
break;
|
size_t i = 0;
|
||||||
return i;
|
for (; i < len && start + i < row->chars_len; i++)
|
||||||
|
if (uc_tolower(needle[i]) != uc_tolower(row->chars[start + i].c))
|
||||||
|
break;
|
||||||
|
best = MAX (best, i);
|
||||||
|
}
|
||||||
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue