mirror of
https://github.com/tmux/tmux.git
synced 2025-09-01 20:57:00 +00:00
Fix word navigation on lines with tabs, from Alexander Arch.
This commit is contained in:
24
grid.c
24
grid.c
@ -1561,3 +1561,27 @@ grid_line_length(struct grid *gd, u_int py)
|
||||
}
|
||||
return (px);
|
||||
}
|
||||
|
||||
/* Check if character is in set. */
|
||||
int
|
||||
grid_in_set(struct grid *gd, u_int px, u_int py, const char *set)
|
||||
{
|
||||
struct grid_cell gc, tmp_gc;
|
||||
u_int pxx;
|
||||
|
||||
grid_get_cell(gd, px, py, &gc);
|
||||
if (strchr(set, '\t')) {
|
||||
if (gc.flags & GRID_FLAG_PADDING) {
|
||||
pxx = px;
|
||||
do
|
||||
grid_get_cell(gd, --pxx, py, &tmp_gc);
|
||||
while (pxx > 0 && tmp_gc.flags & GRID_FLAG_PADDING);
|
||||
if (tmp_gc.flags & GRID_FLAG_TAB)
|
||||
return (tmp_gc.data.width - (px - pxx));
|
||||
} else if (gc.flags & GRID_FLAG_TAB)
|
||||
return (gc.data.width);
|
||||
}
|
||||
if (gc.flags & GRID_FLAG_PADDING)
|
||||
return (0);
|
||||
return (utf8_cstrhas(set, &gc.data));
|
||||
}
|
||||
|
Reference in New Issue
Block a user