mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-19 05:33:44 -04:00
port fixes from foot/master
This commit is contained in:
parent
eba65d430e
commit
2b17abff3d
1 changed files with 33 additions and 23 deletions
56
vimode.c
56
vimode.c
|
|
@ -489,31 +489,40 @@ static ssize_t matches_cell(const struct terminal *term,
|
||||||
const struct cell *cell, char32_t const *const buf,
|
const struct cell *cell, char32_t const *const buf,
|
||||||
size_t const len, size_t search_ofs)
|
size_t const len, size_t search_ofs)
|
||||||
{
|
{
|
||||||
assert(search_ofs < len);
|
assert(search_ofs < len);
|
||||||
|
|
||||||
char32_t base = cell->wc;
|
char32_t base = cell->wc;
|
||||||
const struct composed *composed = NULL;
|
const struct composed *composed = NULL;
|
||||||
|
|
||||||
if (base >= CELL_COMB_CHARS_LO && base <= CELL_COMB_CHARS_HI) {
|
if (base >= CELL_COMB_CHARS_LO && base <= CELL_COMB_CHARS_HI) {
|
||||||
composed = composed_lookup(term->composed, base - CELL_COMB_CHARS_LO);
|
composed = composed_lookup(term->composed, base - CELL_COMB_CHARS_LO);
|
||||||
base = composed->chars[0];
|
base = composed->chars[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (composed == NULL && base == 0 && buf[search_ofs] == U' ')
|
if (composed == NULL && base == 0 && buf[search_ofs] == U' ')
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (c32ncasecmp(&base, buf, 1) != 0)
|
// Search is case sensitive if the search buffer contains any
|
||||||
return -1;
|
// uppercase characters.
|
||||||
|
if (hasc32upper(buf)) {
|
||||||
if (composed != NULL) {
|
if (c32ncmp(&base, buf + search_ofs, 1) != 0) {
|
||||||
if (search_ofs + composed->count > len)
|
return -1;
|
||||||
return -1;
|
}
|
||||||
|
} else {
|
||||||
for (size_t j = 1; j < composed->count; j++) {
|
if (c32ncasecmp(&base, buf + search_ofs, 1) != 0) {
|
||||||
if (composed->chars[j] != buf[search_ofs + j])
|
return -1;
|
||||||
return -1;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (composed != NULL) {
|
||||||
|
if (search_ofs + composed->count > len)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (size_t j = 1; j < composed->count; j++) {
|
||||||
|
if (composed->chars[j] != buf[search_ofs + j])
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return composed != NULL ? composed->count : 1;
|
return composed != NULL ? composed->count : 1;
|
||||||
}
|
}
|
||||||
|
|
@ -1737,7 +1746,8 @@ void vimode_input(struct seat *seat, struct terminal *term,
|
||||||
count = xkb_compose_state_get_utf8(seat->kbd.xkb_compose_state,
|
count = xkb_compose_state_get_utf8(seat->kbd.xkb_compose_state,
|
||||||
(char *)buf, sizeof(buf));
|
(char *)buf, sizeof(buf));
|
||||||
xkb_compose_state_reset(seat->kbd.xkb_compose_state);
|
xkb_compose_state_reset(seat->kbd.xkb_compose_state);
|
||||||
} else if (compose_status == XKB_COMPOSE_CANCELLED) {
|
} else if (compose_status == XKB_COMPOSE_CANCELLED ||
|
||||||
|
compose_status == XKB_COMPOSE_COMPOSING) {
|
||||||
count = 0;
|
count = 0;
|
||||||
} else {
|
} else {
|
||||||
count = xkb_state_key_get_utf8(seat->kbd.xkb_state, key,
|
count = xkb_state_key_get_utf8(seat->kbd.xkb_state, key,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue