mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
bb94a5437d
@ -180,19 +180,14 @@ grid_reader_handle_wrap(struct grid_reader *gr, u_int *xx, u_int *yy)
|
||||
int
|
||||
grid_reader_in_set(struct grid_reader *gr, const char *set)
|
||||
{
|
||||
struct grid_cell gc;
|
||||
|
||||
grid_get_cell(gr->gd, gr->cx, gr->cy, &gc);
|
||||
if (gc.flags & GRID_FLAG_PADDING)
|
||||
return (0);
|
||||
return (utf8_cstrhas(set, &gc.data));
|
||||
return (grid_in_set(gr->gd, gr->cx, gr->cy, set));
|
||||
}
|
||||
|
||||
/* Move cursor to the start of the next word. */
|
||||
void
|
||||
grid_reader_cursor_next_word(struct grid_reader *gr, const char *separators)
|
||||
{
|
||||
u_int xx, yy;
|
||||
u_int xx, yy, width;
|
||||
|
||||
/* Do not break up wrapped words. */
|
||||
if (grid_get_line(gr->gd, gr->cy)->flags & GRID_LINE_WRAPPED)
|
||||
@ -229,8 +224,8 @@ grid_reader_cursor_next_word(struct grid_reader *gr, const char *separators)
|
||||
}
|
||||
}
|
||||
while (grid_reader_handle_wrap(gr, &xx, &yy) &&
|
||||
grid_reader_in_set(gr, WHITESPACE))
|
||||
gr->cx++;
|
||||
(width = grid_reader_in_set(gr, WHITESPACE)))
|
||||
gr->cx += width;
|
||||
}
|
||||
|
||||
/* Move cursor to the end of the next word. */
|
||||
@ -425,7 +420,9 @@ grid_reader_cursor_back_to_indentation(struct grid_reader *gr)
|
||||
xx = grid_line_length(gr->gd, py);
|
||||
for (px = 0; px < xx; px++) {
|
||||
grid_get_cell(gr->gd, px, py, &gc);
|
||||
if (gc.data.size != 1 || *gc.data.data != ' ') {
|
||||
if ((gc.data.size != 1 || *gc.data.data != ' ') &&
|
||||
~gc.flags & GRID_FLAG_TAB &&
|
||||
~gc.flags & GRID_FLAG_PADDING) {
|
||||
gr->cx = px;
|
||||
gr->cy = py;
|
||||
return;
|
||||
|
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));
|
||||
}
|
||||
|
3
tmux.h
3
tmux.h
@ -614,7 +614,7 @@ enum tty_code_code {
|
||||
};
|
||||
|
||||
/* Character classes. */
|
||||
#define WHITESPACE " "
|
||||
#define WHITESPACE "\t "
|
||||
|
||||
/* Mode keys. */
|
||||
#define MODEKEY_EMACS 0
|
||||
@ -2988,6 +2988,7 @@ void grid_reflow(struct grid *, u_int);
|
||||
void grid_wrap_position(struct grid *, u_int, u_int, u_int *, u_int *);
|
||||
void grid_unwrap_position(struct grid *, u_int *, u_int *, u_int, u_int);
|
||||
u_int grid_line_length(struct grid *, u_int);
|
||||
int grid_in_set(struct grid *, u_int, u_int, const char *);
|
||||
|
||||
/* grid-reader.c */
|
||||
void grid_reader_start(struct grid_reader *, struct grid *, u_int, u_int);
|
||||
|
@ -5033,12 +5033,8 @@ window_copy_in_set(struct window_mode_entry *wme, u_int px, u_int py,
|
||||
const char *set)
|
||||
{
|
||||
struct window_copy_mode_data *data = wme->data;
|
||||
struct grid_cell gc;
|
||||
|
||||
grid_get_cell(data->backing->grid, px, py, &gc);
|
||||
if (gc.flags & GRID_FLAG_PADDING)
|
||||
return (0);
|
||||
return (utf8_cstrhas(set, &gc.data));
|
||||
return (grid_in_set(data->backing->grid, px, py, set));
|
||||
}
|
||||
|
||||
static u_int
|
||||
|
Loading…
Reference in New Issue
Block a user