version 1.207, 2019/03/07 19:34:22 |
version 1.208, 2019/03/07 20:24:21 |
|
|
|
|
#include "tmux.h" |
#include "tmux.h" |
|
|
static const char *window_copy_key_table(struct window_pane *); |
static const char *window_copy_key_table(struct window_mode_entry *); |
static void window_copy_command(struct window_pane *, struct client *, |
static void window_copy_command(struct window_mode_entry *, struct client *, |
struct session *, struct winlink *, struct args *, |
struct session *, struct winlink *, struct args *, |
struct mouse_event *); |
struct mouse_event *); |
static struct screen *window_copy_init(struct window_pane *, |
static struct screen *window_copy_init(struct window_mode_entry *, |
struct cmd_find_state *, struct args *); |
struct cmd_find_state *, struct args *); |
static void window_copy_free(struct window_pane *); |
static void window_copy_free(struct window_mode_entry *); |
static void window_copy_resize(struct window_pane *, u_int, u_int); |
static void window_copy_resize(struct window_mode_entry *, u_int, u_int); |
static void window_copy_formats(struct window_pane *, struct format_tree *); |
static void window_copy_formats(struct window_mode_entry *, |
static int window_copy_pagedown(struct window_pane *, int, int); |
struct format_tree *); |
static void window_copy_next_paragraph(struct window_pane *); |
static void window_copy_pageup1(struct window_mode_entry *, int); |
static void window_copy_previous_paragraph(struct window_pane *); |
static int window_copy_pagedown(struct window_mode_entry *, int, int); |
|
static void window_copy_next_paragraph(struct window_mode_entry *); |
|
static void window_copy_previous_paragraph(struct window_mode_entry *); |
|
|
static void window_copy_redraw_selection(struct window_pane *, u_int); |
static void window_copy_redraw_selection(struct window_mode_entry *, u_int); |
static void window_copy_redraw_lines(struct window_pane *, u_int, u_int); |
static void window_copy_redraw_lines(struct window_mode_entry *, u_int, |
static void window_copy_redraw_screen(struct window_pane *); |
u_int); |
static void window_copy_write_line(struct window_pane *, |
static void window_copy_redraw_screen(struct window_mode_entry *); |
|
static void window_copy_write_line(struct window_mode_entry *, |
struct screen_write_ctx *, u_int); |
struct screen_write_ctx *, u_int); |
static void window_copy_write_lines(struct window_pane *, |
static void window_copy_write_lines(struct window_mode_entry *, |
struct screen_write_ctx *, u_int, u_int); |
struct screen_write_ctx *, u_int, u_int); |
|
|
static void window_copy_scroll_to(struct window_pane *, u_int, u_int); |
static void window_copy_scroll_to(struct window_mode_entry *, u_int, u_int); |
static int window_copy_search_compare(struct grid *, u_int, u_int, |
static int window_copy_search_compare(struct grid *, u_int, u_int, |
struct grid *, u_int, int); |
struct grid *, u_int, int); |
static int window_copy_search_lr(struct grid *, struct grid *, u_int *, |
static int window_copy_search_lr(struct grid *, struct grid *, u_int *, |
u_int, u_int, u_int, int); |
u_int, u_int, u_int, int); |
static int window_copy_search_rl(struct grid *, struct grid *, u_int *, |
static int window_copy_search_rl(struct grid *, struct grid *, u_int *, |
u_int, u_int, u_int, int); |
u_int, u_int, u_int, int); |
static int window_copy_search_marks(struct window_pane *, struct screen *); |
static int window_copy_search_marks(struct window_mode_entry *, |
static void window_copy_clear_marks(struct window_pane *); |
struct screen *); |
|
static void window_copy_clear_marks(struct window_mode_entry *); |
static void window_copy_move_left(struct screen *, u_int *, u_int *); |
static void window_copy_move_left(struct screen *, u_int *, u_int *); |
static void window_copy_move_right(struct screen *, u_int *, u_int *); |
static void window_copy_move_right(struct screen *, u_int *, u_int *); |
static int window_copy_is_lowercase(const char *); |
static int window_copy_is_lowercase(const char *); |
static int window_copy_search_jump(struct window_pane *, struct grid *, |
static int window_copy_search_jump(struct window_mode_entry *, |
struct grid *, u_int, u_int, u_int, int, int, int); |
struct grid *, struct grid *, u_int, u_int, u_int, int, int, |
static int window_copy_search(struct window_pane *, int); |
int); |
static int window_copy_search_up(struct window_pane *); |
static int window_copy_search(struct window_mode_entry *, int); |
static int window_copy_search_down(struct window_pane *); |
static int window_copy_search_up(struct window_mode_entry *); |
static void window_copy_goto_line(struct window_pane *, const char *); |
static int window_copy_search_down(struct window_mode_entry *); |
static void window_copy_update_cursor(struct window_pane *, u_int, u_int); |
static void window_copy_goto_line(struct window_mode_entry *, const char *); |
static void window_copy_start_selection(struct window_pane *); |
static void window_copy_update_cursor(struct window_mode_entry *, u_int, |
static int window_copy_adjust_selection(struct window_pane *, u_int *, |
u_int); |
u_int *); |
static void window_copy_start_selection(struct window_mode_entry *); |
static int window_copy_set_selection(struct window_pane *, int); |
static int window_copy_adjust_selection(struct window_mode_entry *, |
static int window_copy_update_selection(struct window_pane *, int); |
u_int *, u_int *); |
static void window_copy_synchronize_cursor(struct window_pane *); |
static int window_copy_set_selection(struct window_mode_entry *, int); |
static void *window_copy_get_selection(struct window_pane *, size_t *); |
static int window_copy_update_selection(struct window_mode_entry *, int); |
static void window_copy_copy_buffer(struct window_pane *, void *, size_t); |
static void window_copy_synchronize_cursor(struct window_mode_entry *); |
static void window_copy_copy_pipe(struct window_pane *, struct session *, |
static void *window_copy_get_selection(struct window_mode_entry *, size_t *); |
|
static void window_copy_copy_buffer(struct window_mode_entry *, void *, |
|
size_t); |
|
static void window_copy_copy_pipe(struct window_mode_entry *, |
|
struct session *, const char *); |
|
static void window_copy_copy_selection(struct window_mode_entry *); |
|
static void window_copy_append_selection(struct window_mode_entry *); |
|
static void window_copy_clear_selection(struct window_mode_entry *); |
|
static void window_copy_copy_line(struct window_mode_entry *, char **, |
|
size_t *, u_int, u_int, u_int); |
|
static int window_copy_in_set(struct window_mode_entry *, u_int, u_int, |
const char *); |
const char *); |
static void window_copy_copy_selection(struct window_pane *); |
static u_int window_copy_find_length(struct window_mode_entry *, u_int); |
static void window_copy_append_selection(struct window_pane *); |
static void window_copy_cursor_start_of_line(struct window_mode_entry *); |
static void window_copy_clear_selection(struct window_pane *); |
static void window_copy_cursor_back_to_indentation( |
static void window_copy_copy_line(struct window_pane *, char **, size_t *, |
struct window_mode_entry *); |
u_int, u_int, u_int); |
static void window_copy_cursor_end_of_line(struct window_mode_entry *); |
static int window_copy_in_set(struct window_pane *, u_int, u_int, |
static void window_copy_other_end(struct window_mode_entry *); |
|
static void window_copy_cursor_left(struct window_mode_entry *); |
|
static void window_copy_cursor_right(struct window_mode_entry *); |
|
static void window_copy_cursor_up(struct window_mode_entry *, int); |
|
static void window_copy_cursor_down(struct window_mode_entry *, int); |
|
static void window_copy_cursor_jump(struct window_mode_entry *); |
|
static void window_copy_cursor_jump_back(struct window_mode_entry *); |
|
static void window_copy_cursor_jump_to(struct window_mode_entry *); |
|
static void window_copy_cursor_jump_to_back(struct window_mode_entry *); |
|
static void window_copy_cursor_next_word(struct window_mode_entry *, |
const char *); |
const char *); |
static u_int window_copy_find_length(struct window_pane *, u_int); |
static void window_copy_cursor_next_word_end(struct window_mode_entry *, |
static void window_copy_cursor_start_of_line(struct window_pane *); |
|
static void window_copy_cursor_back_to_indentation(struct window_pane *); |
|
static void window_copy_cursor_end_of_line(struct window_pane *); |
|
static void window_copy_other_end(struct window_pane *); |
|
static void window_copy_cursor_left(struct window_pane *); |
|
static void window_copy_cursor_right(struct window_pane *); |
|
static void window_copy_cursor_up(struct window_pane *, int); |
|
static void window_copy_cursor_down(struct window_pane *, int); |
|
static void window_copy_cursor_jump(struct window_pane *); |
|
static void window_copy_cursor_jump_back(struct window_pane *); |
|
static void window_copy_cursor_jump_to(struct window_pane *); |
|
static void window_copy_cursor_jump_to_back(struct window_pane *); |
|
static void window_copy_cursor_next_word(struct window_pane *, |
|
const char *); |
const char *); |
static void window_copy_cursor_next_word_end(struct window_pane *, |
static void window_copy_cursor_previous_word(struct window_mode_entry *, |
const char *); |
const char *); |
static void window_copy_cursor_previous_word(struct window_pane *, |
static void window_copy_scroll_up(struct window_mode_entry *, u_int); |
const char *); |
static void window_copy_scroll_down(struct window_mode_entry *, u_int); |
static void window_copy_scroll_up(struct window_pane *, u_int); |
static void window_copy_rectangle_toggle(struct window_mode_entry *); |
static void window_copy_scroll_down(struct window_pane *, u_int); |
|
static void window_copy_rectangle_toggle(struct window_pane *); |
|
static void window_copy_move_mouse(struct mouse_event *); |
static void window_copy_move_mouse(struct mouse_event *); |
static void window_copy_drag_update(struct client *, struct mouse_event *); |
static void window_copy_drag_update(struct client *, struct mouse_event *); |
|
|
|
|
}; |
}; |
|
|
static struct screen * |
static struct screen * |
window_copy_init(struct window_pane *wp, __unused struct cmd_find_state *fs, |
window_copy_init(struct window_mode_entry *wme, |
__unused struct args *args) |
__unused struct cmd_find_state *fs, __unused struct args *args) |
{ |
{ |
|
struct window_pane *wp = wme->wp; |
struct window_copy_mode_data *data; |
struct window_copy_mode_data *data; |
struct screen *s; |
struct screen *s; |
|
|
wp->modedata = data = xcalloc(1, sizeof *data); |
wme->data = data = xcalloc(1, sizeof *data); |
|
|
data->cursordrag = CURSORDRAG_NONE; |
data->cursordrag = CURSORDRAG_NONE; |
data->lineflag = LINE_SEL_NONE; |
data->lineflag = LINE_SEL_NONE; |
|
|
void |
void |
window_copy_init_from_pane(struct window_pane *wp, int scroll_exit) |
window_copy_init_from_pane(struct window_pane *wp, int scroll_exit) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_mode_entry *wme = wp->mode; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
u_int i; |
u_int i; |
|
|
if (wp->mode != &window_copy_mode) |
if (wme == NULL || wme->mode != &window_copy_mode) |
fatalx("not in copy mode"); |
fatalx("not in copy mode"); |
|
|
data->backing = &wp->base; |
data->backing = &wp->base; |
|
|
|
|
screen_write_start(&ctx, NULL, s); |
screen_write_start(&ctx, NULL, s); |
for (i = 0; i < screen_size_y(s); i++) |
for (i = 0; i < screen_size_y(s); i++) |
window_copy_write_line(wp, &ctx, i); |
window_copy_write_line(wme, &ctx, i); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
} |
} |
|
|
void |
void |
window_copy_init_for_output(struct window_pane *wp) |
window_copy_init_for_output(struct window_pane *wp) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data; |
|
|
if (wp->mode == &window_copy_mode && data->backing != &wp->base) |
if (wp->mode != NULL && wp->mode->mode == &window_copy_mode) { |
return; |
data = wp->mode->data; |
|
if (data->backing != &wp->base) |
|
return; |
|
} |
window_pane_reset_mode(wp); |
window_pane_reset_mode(wp); |
|
|
window_pane_set_mode(wp, &window_copy_mode, NULL, NULL); |
window_pane_set_mode(wp, &window_copy_mode, NULL, NULL); |
|
data = wp->mode->data; |
|
|
data = wp->modedata; |
|
data->backing = xmalloc(sizeof *data->backing); |
data->backing = xmalloc(sizeof *data->backing); |
screen_init(data->backing, screen_size_x(&wp->base), |
screen_init(data->backing, screen_size_x(&wp->base), |
screen_size_y(&wp->base), UINT_MAX); |
screen_size_y(&wp->base), UINT_MAX); |
} |
} |
|
|
static void |
static void |
window_copy_free(struct window_pane *wp) |
window_copy_free(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
|
|
if (wp->fd != -1) |
if (wp->fd != -1) |
bufferevent_enable(wp->event, EV_READ|EV_WRITE); |
bufferevent_enable(wp->event, EV_READ|EV_WRITE); |
|
|
void |
void |
window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap) |
window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_mode_entry *wme = wp->mode; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *backing = data->backing; |
struct screen *backing = data->backing; |
struct screen_write_ctx back_ctx, ctx; |
struct screen_write_ctx back_ctx, ctx; |
struct grid_cell gc; |
struct grid_cell gc; |
|
|
* (If there's any history at all, it has changed.) |
* (If there's any history at all, it has changed.) |
*/ |
*/ |
if (screen_hsize(data->backing)) |
if (screen_hsize(data->backing)) |
window_copy_redraw_lines(wp, 0, 1); |
window_copy_redraw_lines(wme, 0, 1); |
|
|
/* Write the new lines. */ |
/* Write the new lines. */ |
window_copy_redraw_lines(wp, old_cy, backing->cy - old_cy + 1); |
window_copy_redraw_lines(wme, old_cy, backing->cy - old_cy + 1); |
|
|
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
} |
} |
|
|
void |
void |
window_copy_pageup(struct window_pane *wp, int half_page) |
window_copy_pageup(struct window_pane *wp, int half_page) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
window_copy_pageup1(wp->mode, half_page); |
|
} |
|
|
|
static void |
|
window_copy_pageup1(struct window_mode_entry *wme, int half_page) |
|
{ |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
u_int n, ox, oy, px, py; |
u_int n, ox, oy, px, py; |
|
|
oy = screen_hsize(data->backing) + data->cy - data->oy; |
oy = screen_hsize(data->backing) + data->cy - data->oy; |
ox = window_copy_find_length(wp, oy); |
ox = window_copy_find_length(wme, oy); |
|
|
if (data->cx != ox) { |
if (data->cx != ox) { |
data->lastcx = data->cx; |
data->lastcx = data->cx; |
|
|
|
|
if (data->screen.sel == NULL || !data->rectflag) { |
if (data->screen.sel == NULL || !data->rectflag) { |
py = screen_hsize(data->backing) + data->cy - data->oy; |
py = screen_hsize(data->backing) + data->cy - data->oy; |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
if ((data->cx >= data->lastsx && data->cx != px) || |
if ((data->cx >= data->lastsx && data->cx != px) || |
data->cx > px) |
data->cx > px) |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
} |
} |
|
|
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wme); |
} |
} |
|
|
static int |
static int |
window_copy_pagedown(struct window_pane *wp, int half_page, int scroll_exit) |
window_copy_pagedown(struct window_mode_entry *wme, int half_page, |
|
int scroll_exit) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
u_int n, ox, oy, px, py; |
u_int n, ox, oy, px, py; |
|
|
oy = screen_hsize(data->backing) + data->cy - data->oy; |
oy = screen_hsize(data->backing) + data->cy - data->oy; |
ox = window_copy_find_length(wp, oy); |
ox = window_copy_find_length(wme, oy); |
|
|
if (data->cx != ox) { |
if (data->cx != ox) { |
data->lastcx = data->cx; |
data->lastcx = data->cx; |
|
|
|
|
if (data->screen.sel == NULL || !data->rectflag) { |
if (data->screen.sel == NULL || !data->rectflag) { |
py = screen_hsize(data->backing) + data->cy - data->oy; |
py = screen_hsize(data->backing) + data->cy - data->oy; |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
if ((data->cx >= data->lastsx && data->cx != px) || |
if ((data->cx >= data->lastsx && data->cx != px) || |
data->cx > px) |
data->cx > px) |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
} |
} |
|
|
if (scroll_exit && data->oy == 0) |
if (scroll_exit && data->oy == 0) |
return (1); |
return (1); |
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wme); |
return (0); |
return (0); |
} |
} |
|
|
static void |
static void |
window_copy_previous_paragraph(struct window_pane *wp) |
window_copy_previous_paragraph(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
u_int oy; |
u_int oy; |
|
|
oy = screen_hsize(data->backing) + data->cy - data->oy; |
oy = screen_hsize(data->backing) + data->cy - data->oy; |
|
|
while (oy > 0 && window_copy_find_length(wp, oy) == 0) |
while (oy > 0 && window_copy_find_length(wme, oy) == 0) |
oy--; |
oy--; |
|
|
while (oy > 0 && window_copy_find_length(wp, oy) > 0) |
while (oy > 0 && window_copy_find_length(wme, oy) > 0) |
oy--; |
oy--; |
|
|
window_copy_scroll_to(wp, 0, oy); |
window_copy_scroll_to(wme, 0, oy); |
} |
} |
|
|
static void |
static void |
window_copy_next_paragraph(struct window_pane *wp) |
window_copy_next_paragraph(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
u_int maxy, ox, oy; |
u_int maxy, ox, oy; |
|
|
oy = screen_hsize(data->backing) + data->cy - data->oy; |
oy = screen_hsize(data->backing) + data->cy - data->oy; |
maxy = screen_hsize(data->backing) + screen_size_y(s) - 1; |
maxy = screen_hsize(data->backing) + screen_size_y(s) - 1; |
|
|
while (oy < maxy && window_copy_find_length(wp, oy) == 0) |
while (oy < maxy && window_copy_find_length(wme, oy) == 0) |
oy++; |
oy++; |
|
|
while (oy < maxy && window_copy_find_length(wp, oy) > 0) |
while (oy < maxy && window_copy_find_length(wme, oy) > 0) |
oy++; |
oy++; |
|
|
ox = window_copy_find_length(wp, oy); |
ox = window_copy_find_length(wme, oy); |
window_copy_scroll_to(wp, ox, oy); |
window_copy_scroll_to(wme, ox, oy); |
} |
} |
|
|
static void |
static void |
window_copy_formats(struct window_pane *wp, struct format_tree *ft) |
window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
|
|
format_add(ft, "selection_present", "%d", data->screen.sel != NULL); |
format_add(ft, "selection_present", "%d", data->screen.sel != NULL); |
format_add(ft, "scroll_position", "%d", data->oy); |
format_add(ft, "scroll_position", "%d", data->oy); |
|
|
} |
} |
|
|
static void |
static void |
window_copy_resize(struct window_pane *wp, u_int sx, u_int sy) |
window_copy_resize(struct window_mode_entry *wme, u_int sx, u_int sy) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
|
|
|
|
if (data->oy > screen_hsize(data->backing)) |
if (data->oy > screen_hsize(data->backing)) |
data->oy = screen_hsize(data->backing); |
data->oy = screen_hsize(data->backing); |
|
|
window_copy_clear_selection(wp); |
window_copy_clear_selection(wme); |
|
|
screen_write_start(&ctx, NULL, s); |
screen_write_start(&ctx, NULL, s); |
window_copy_write_lines(wp, &ctx, 0, screen_size_y(s) - 1); |
window_copy_write_lines(wme, &ctx, 0, screen_size_y(s) - 1); |
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
|
|
if (data->searchmark != NULL) |
if (data->searchmark != NULL) |
window_copy_search_marks(wp, NULL); |
window_copy_search_marks(wme, NULL); |
data->searchx = data->cx; |
data->searchx = data->cx; |
data->searchy = data->cy; |
data->searchy = data->cy; |
data->searcho = data->oy; |
data->searcho = data->oy; |
|
|
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wme); |
} |
} |
|
|
static const char * |
static const char * |
window_copy_key_table(struct window_pane *wp) |
window_copy_key_table(struct window_mode_entry *wme) |
{ |
{ |
|
struct window_pane *wp = wme->wp; |
|
|
if (options_get_number(wp->window->options, "mode-keys") == MODEKEY_VI) |
if (options_get_number(wp->window->options, "mode-keys") == MODEKEY_VI) |
return ("copy-mode-vi"); |
return ("copy-mode-vi"); |
return ("copy-mode"); |
return ("copy-mode"); |
} |
} |
|
|
static void |
static void |
window_copy_command(struct window_pane *wp, struct client *c, struct session *s, |
window_copy_command(struct window_mode_entry *wme, struct client *c, |
__unused struct winlink *wl, struct args *args, struct mouse_event *m) |
struct session *s, __unused struct winlink *wl, struct args *args, |
|
struct mouse_event *m) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *sn = &data->screen; |
struct screen *sn = &data->screen; |
const char *command, *argument, *ws; |
const char *command, *argument, *ws; |
u_int np = wp->modeprefix; |
u_int np = wme->prefix; |
int cancel = 0, redraw = 0, scroll_exit; |
int cancel = 0, redraw = 0, scroll_exit; |
char prefix; |
char prefix; |
|
|
|
|
if (args->argc == 1) { |
if (args->argc == 1) { |
if (strcmp(command, "append-selection") == 0) { |
if (strcmp(command, "append-selection") == 0) { |
if (s != NULL) |
if (s != NULL) |
window_copy_append_selection(wp); |
window_copy_append_selection(wme); |
window_copy_clear_selection(wp); |
window_copy_clear_selection(wme); |
redraw = 1; |
redraw = 1; |
} |
} |
if (strcmp(command, "append-selection-and-cancel") == 0) { |
if (strcmp(command, "append-selection-and-cancel") == 0) { |
if (s != NULL) |
if (s != NULL) |
window_copy_append_selection(wp); |
window_copy_append_selection(wme); |
window_copy_clear_selection(wp); |
window_copy_clear_selection(wme); |
redraw = 1; |
redraw = 1; |
cancel = 1; |
cancel = 1; |
} |
} |
if (strcmp(command, "back-to-indentation") == 0) |
if (strcmp(command, "back-to-indentation") == 0) |
window_copy_cursor_back_to_indentation(wp); |
window_copy_cursor_back_to_indentation(wme); |
if (strcmp(command, "begin-selection") == 0) { |
if (strcmp(command, "begin-selection") == 0) { |
if (m != NULL) |
if (m != NULL) |
window_copy_start_drag(c, m); |
window_copy_start_drag(c, m); |
else { |
else { |
data->lineflag = LINE_SEL_NONE; |
data->lineflag = LINE_SEL_NONE; |
window_copy_start_selection(wp); |
window_copy_start_selection(wme); |
redraw = 1; |
redraw = 1; |
} |
} |
} |
} |
|
|
if (strcmp(command, "bottom-line") == 0) { |
if (strcmp(command, "bottom-line") == 0) { |
data->cx = 0; |
data->cx = 0; |
data->cy = screen_size_y(sn) - 1; |
data->cy = screen_size_y(sn) - 1; |
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
redraw = 1; |
redraw = 1; |
} |
} |
if (strcmp(command, "cancel") == 0) |
if (strcmp(command, "cancel") == 0) |
cancel = 1; |
cancel = 1; |
if (strcmp(command, "clear-selection") == 0) { |
if (strcmp(command, "clear-selection") == 0) { |
window_copy_clear_selection(wp); |
window_copy_clear_selection(wme); |
redraw = 1; |
redraw = 1; |
} |
} |
if (strcmp(command, "copy-end-of-line") == 0) { |
if (strcmp(command, "copy-end-of-line") == 0) { |
window_copy_start_selection(wp); |
window_copy_start_selection(wme); |
for (; np > 1; np--) |
for (; np > 1; np--) |
window_copy_cursor_down(wp, 0); |
window_copy_cursor_down(wme, 0); |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
redraw = 1; |
redraw = 1; |
|
|
if (s != NULL) { |
if (s != NULL) { |
window_copy_copy_selection(wp); |
window_copy_copy_selection(wme); |
cancel = 1; |
cancel = 1; |
} |
} |
} |
} |
if (strcmp(command, "copy-line") == 0) { |
if (strcmp(command, "copy-line") == 0) { |
window_copy_cursor_start_of_line(wp); |
window_copy_cursor_start_of_line(wme); |
window_copy_start_selection(wp); |
window_copy_start_selection(wme); |
for (; np > 1; np--) |
for (; np > 1; np--) |
window_copy_cursor_down(wp, 0); |
window_copy_cursor_down(wme, 0); |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
redraw = 1; |
redraw = 1; |
|
|
if (s != NULL) { |
if (s != NULL) { |
window_copy_copy_selection(wp); |
window_copy_copy_selection(wme); |
cancel = 1; |
cancel = 1; |
} |
} |
} |
} |
if (strcmp(command, "copy-selection") == 0) { |
if (strcmp(command, "copy-selection") == 0) { |
if (s != NULL) |
if (s != NULL) |
window_copy_copy_selection(wp); |
window_copy_copy_selection(wme); |
window_copy_clear_selection(wp); |
window_copy_clear_selection(wme); |
redraw = 1; |
redraw = 1; |
} |
} |
if (strcmp(command, "copy-selection-and-cancel") == 0) { |
if (strcmp(command, "copy-selection-and-cancel") == 0) { |
if (s != NULL) |
if (s != NULL) |
window_copy_copy_selection(wp); |
window_copy_copy_selection(wme); |
window_copy_clear_selection(wp); |
window_copy_clear_selection(wme); |
redraw = 1; |
redraw = 1; |
cancel = 1; |
cancel = 1; |
} |
} |
if (strcmp(command, "cursor-down") == 0) { |
if (strcmp(command, "cursor-down") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_down(wp, 0); |
window_copy_cursor_down(wme, 0); |
} |
} |
if (strcmp(command, "cursor-left") == 0) { |
if (strcmp(command, "cursor-left") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_left(wp); |
window_copy_cursor_left(wme); |
} |
} |
if (strcmp(command, "cursor-right") == 0) { |
if (strcmp(command, "cursor-right") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_right(wp); |
window_copy_cursor_right(wme); |
} |
} |
if (strcmp(command, "cursor-up") == 0) { |
if (strcmp(command, "cursor-up") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_up(wp, 0); |
window_copy_cursor_up(wme, 0); |
} |
} |
if (strcmp(command, "end-of-line") == 0) |
if (strcmp(command, "end-of-line") == 0) |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
if (strcmp(command, "halfpage-down") == 0 || |
if (strcmp(command, "halfpage-down") == 0 || |
strcmp(command, "halfpage-down-and-cancel") == 0) { |
strcmp(command, "halfpage-down-and-cancel") == 0) { |
if (strcmp(command, "halfpage-down-and-cancel") == 0) |
if (strcmp(command, "halfpage-down-and-cancel") == 0) |
|
|
else |
else |
scroll_exit = data->scroll_exit; |
scroll_exit = data->scroll_exit; |
for (; np != 0; np--) { |
for (; np != 0; np--) { |
if (window_copy_pagedown(wp, 1, scroll_exit)) { |
if (window_copy_pagedown(wme, 1, scroll_exit)) { |
cancel = 1; |
cancel = 1; |
break; |
break; |
} |
} |
|
|
} |
} |
if (strcmp(command, "halfpage-up") == 0) { |
if (strcmp(command, "halfpage-up") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_pageup(wp, 1); |
window_copy_pageup1(wme, 1); |
} |
} |
if (strcmp(command, "history-bottom") == 0) { |
if (strcmp(command, "history-bottom") == 0) { |
data->cx = 0; |
data->cx = 0; |
data->cy = screen_size_y(sn) - 1; |
data->cy = screen_size_y(sn) - 1; |
data->oy = 0; |
data->oy = 0; |
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
redraw = 1; |
redraw = 1; |
} |
} |
if (strcmp(command, "history-top") == 0) { |
if (strcmp(command, "history-top") == 0) { |
data->cx = 0; |
data->cx = 0; |
data->cy = 0; |
data->cy = 0; |
data->oy = screen_hsize(data->backing); |
data->oy = screen_hsize(data->backing); |
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
redraw = 1; |
redraw = 1; |
} |
} |
if (strcmp(command, "jump-again") == 0) { |
if (strcmp(command, "jump-again") == 0) { |
switch (data->jumptype) { |
switch (data->jumptype) { |
case WINDOW_COPY_JUMPFORWARD: |
case WINDOW_COPY_JUMPFORWARD: |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump(wp); |
window_copy_cursor_jump(wme); |
break; |
break; |
case WINDOW_COPY_JUMPBACKWARD: |
case WINDOW_COPY_JUMPBACKWARD: |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump_back(wp); |
window_copy_cursor_jump_back(wme); |
break; |
break; |
case WINDOW_COPY_JUMPTOFORWARD: |
case WINDOW_COPY_JUMPTOFORWARD: |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump_to(wp); |
window_copy_cursor_jump_to(wme); |
break; |
break; |
case WINDOW_COPY_JUMPTOBACKWARD: |
case WINDOW_COPY_JUMPTOBACKWARD: |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump_to_back(wp); |
window_copy_cursor_jump_to_back(wme); |
break; |
break; |
} |
} |
} |
} |
|
|
switch (data->jumptype) { |
switch (data->jumptype) { |
case WINDOW_COPY_JUMPFORWARD: |
case WINDOW_COPY_JUMPFORWARD: |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump_back(wp); |
window_copy_cursor_jump_back(wme); |
break; |
break; |
case WINDOW_COPY_JUMPBACKWARD: |
case WINDOW_COPY_JUMPBACKWARD: |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump(wp); |
window_copy_cursor_jump(wme); |
break; |
break; |
case WINDOW_COPY_JUMPTOFORWARD: |
case WINDOW_COPY_JUMPTOFORWARD: |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump_to_back(wp); |
window_copy_cursor_jump_to_back(wme); |
break; |
break; |
case WINDOW_COPY_JUMPTOBACKWARD: |
case WINDOW_COPY_JUMPTOBACKWARD: |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump_to(wp); |
window_copy_cursor_jump_to(wme); |
break; |
break; |
} |
} |
} |
} |
if (strcmp(command, "middle-line") == 0) { |
if (strcmp(command, "middle-line") == 0) { |
data->cx = 0; |
data->cx = 0; |
data->cy = (screen_size_y(sn) - 1) / 2; |
data->cy = (screen_size_y(sn) - 1) / 2; |
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
redraw = 1; |
redraw = 1; |
} |
} |
if (strcmp(command, "next-paragraph") == 0) { |
if (strcmp(command, "next-paragraph") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_next_paragraph(wp); |
window_copy_next_paragraph(wme); |
} |
} |
if (strcmp(command, "next-space") == 0) { |
if (strcmp(command, "next-space") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_next_word(wp, " "); |
window_copy_cursor_next_word(wme, " "); |
} |
} |
if (strcmp(command, "next-space-end") == 0) { |
if (strcmp(command, "next-space-end") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_next_word_end(wp, " "); |
window_copy_cursor_next_word_end(wme, " "); |
} |
} |
if (strcmp(command, "next-word") == 0) { |
if (strcmp(command, "next-word") == 0) { |
ws = options_get_string(s->options, "word-separators"); |
ws = options_get_string(s->options, "word-separators"); |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_next_word(wp, ws); |
window_copy_cursor_next_word(wme, ws); |
} |
} |
if (strcmp(command, "next-word-end") == 0) { |
if (strcmp(command, "next-word-end") == 0) { |
ws = options_get_string(s->options, "word-separators"); |
ws = options_get_string(s->options, "word-separators"); |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_next_word_end(wp, ws); |
window_copy_cursor_next_word_end(wme, ws); |
} |
} |
if (strcmp(command, "other-end") == 0) { |
if (strcmp(command, "other-end") == 0) { |
if ((np % 2) != 0) |
if ((np % 2) != 0) |
window_copy_other_end(wp); |
window_copy_other_end(wme); |
} |
} |
if (strcmp(command, "page-down") == 0 || |
if (strcmp(command, "page-down") == 0 || |
strcmp(command, "page-down-and-cancel") == 0) { |
strcmp(command, "page-down-and-cancel") == 0) { |
|
|
else |
else |
scroll_exit = data->scroll_exit; |
scroll_exit = data->scroll_exit; |
for (; np != 0; np--) { |
for (; np != 0; np--) { |
if (window_copy_pagedown(wp, 0, scroll_exit)) { |
if (window_copy_pagedown(wme, 0, scroll_exit)) { |
cancel = 1; |
cancel = 1; |
break; |
break; |
} |
} |
|
|
} |
} |
if (strcmp(command, "page-up") == 0) { |
if (strcmp(command, "page-up") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_pageup(wp, 0); |
window_copy_pageup1(wme, 0); |
} |
} |
if (strcmp(command, "previous-paragraph") == 0) { |
if (strcmp(command, "previous-paragraph") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_previous_paragraph(wp); |
window_copy_previous_paragraph(wme); |
} |
} |
if (strcmp(command, "previous-space") == 0) { |
if (strcmp(command, "previous-space") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_previous_word(wp, " "); |
window_copy_cursor_previous_word(wme, " "); |
} |
} |
if (strcmp(command, "previous-word") == 0) { |
if (strcmp(command, "previous-word") == 0) { |
ws = options_get_string(s->options, "word-separators"); |
ws = options_get_string(s->options, "word-separators"); |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_previous_word(wp, ws); |
window_copy_cursor_previous_word(wme, ws); |
} |
} |
if (strcmp(command, "rectangle-toggle") == 0) { |
if (strcmp(command, "rectangle-toggle") == 0) { |
data->lineflag = LINE_SEL_NONE; |
data->lineflag = LINE_SEL_NONE; |
window_copy_rectangle_toggle(wp); |
window_copy_rectangle_toggle(wme); |
} |
} |
if (strcmp(command, "scroll-down") == 0 || |
if (strcmp(command, "scroll-down") == 0 || |
strcmp(command, "scroll-down-and-cancel") == 0) { |
strcmp(command, "scroll-down-and-cancel") == 0) { |
|
|
else |
else |
scroll_exit = data->scroll_exit; |
scroll_exit = data->scroll_exit; |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_down(wp, 1); |
window_copy_cursor_down(wme, 1); |
if (scroll_exit && data->oy == 0) |
if (scroll_exit && data->oy == 0) |
cancel = 1; |
cancel = 1; |
} |
} |
if (strcmp(command, "scroll-up") == 0) { |
if (strcmp(command, "scroll-up") == 0) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_up(wp, 1); |
window_copy_cursor_up(wme, 1); |
} |
} |
if (strcmp(command, "search-again") == 0) { |
if (strcmp(command, "search-again") == 0) { |
if (data->searchtype == WINDOW_COPY_SEARCHUP) { |
if (data->searchtype == WINDOW_COPY_SEARCHUP) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_up(wp); |
window_copy_search_up(wme); |
} else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { |
} else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_down(wp); |
window_copy_search_down(wme); |
} |
} |
} |
} |
if (strcmp(command, "search-reverse") == 0) { |
if (strcmp(command, "search-reverse") == 0) { |
if (data->searchtype == WINDOW_COPY_SEARCHUP) { |
if (data->searchtype == WINDOW_COPY_SEARCHUP) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_down(wp); |
window_copy_search_down(wme); |
} else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { |
} else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_up(wp); |
window_copy_search_up(wme); |
} |
} |
} |
} |
if (strcmp(command, "select-line") == 0) { |
if (strcmp(command, "select-line") == 0) { |
data->lineflag = LINE_SEL_LEFT_RIGHT; |
data->lineflag = LINE_SEL_LEFT_RIGHT; |
data->rectflag = 0; |
data->rectflag = 0; |
window_copy_cursor_start_of_line(wp); |
window_copy_cursor_start_of_line(wme); |
window_copy_start_selection(wp); |
window_copy_start_selection(wme); |
for (; np > 1; np--) |
for (; np > 1; np--) |
window_copy_cursor_down(wp, 0); |
window_copy_cursor_down(wme, 0); |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
redraw = 1; |
redraw = 1; |
} |
} |
if (strcmp(command, "select-word") == 0) { |
if (strcmp(command, "select-word") == 0) { |
data->lineflag = LINE_SEL_LEFT_RIGHT; |
data->lineflag = LINE_SEL_LEFT_RIGHT; |
data->rectflag = 0; |
data->rectflag = 0; |
ws = options_get_string(s->options, "word-separators"); |
ws = options_get_string(s->options, "word-separators"); |
window_copy_cursor_previous_word(wp, ws); |
window_copy_cursor_previous_word(wme, ws); |
window_copy_start_selection(wp); |
window_copy_start_selection(wme); |
window_copy_cursor_next_word_end(wp, ws); |
window_copy_cursor_next_word_end(wme, ws); |
redraw = 1; |
redraw = 1; |
} |
} |
if (strcmp(command, "start-of-line") == 0) |
if (strcmp(command, "start-of-line") == 0) |
window_copy_cursor_start_of_line(wp); |
window_copy_cursor_start_of_line(wme); |
if (strcmp(command, "top-line") == 0) { |
if (strcmp(command, "top-line") == 0) { |
data->cx = 0; |
data->cx = 0; |
data->cy = 0; |
data->cy = 0; |
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
redraw = 1; |
redraw = 1; |
} |
} |
} else if (args->argc == 2 && *args->argv[1] != '\0') { |
} else if (args->argc == 2 && *args->argv[1] != '\0') { |
argument = args->argv[1]; |
argument = args->argv[1]; |
if (strcmp(command, "copy-pipe") == 0) { |
if (strcmp(command, "copy-pipe") == 0) { |
if (s != NULL) |
if (s != NULL) |
window_copy_copy_pipe(wp, s, argument); |
window_copy_copy_pipe(wme, s, argument); |
} |
} |
if (strcmp(command, "copy-pipe-and-cancel") == 0) { |
if (strcmp(command, "copy-pipe-and-cancel") == 0) { |
if (s != NULL) { |
if (s != NULL) { |
window_copy_copy_pipe(wp, s, argument); |
window_copy_copy_pipe(wme, s, argument); |
cancel = 1; |
cancel = 1; |
} |
} |
} |
} |
if (strcmp(command, "goto-line") == 0) |
if (strcmp(command, "goto-line") == 0) |
window_copy_goto_line(wp, argument); |
window_copy_goto_line(wme, argument); |
if (strcmp(command, "jump-backward") == 0) { |
if (strcmp(command, "jump-backward") == 0) { |
data->jumptype = WINDOW_COPY_JUMPBACKWARD; |
data->jumptype = WINDOW_COPY_JUMPBACKWARD; |
data->jumpchar = *argument; |
data->jumpchar = *argument; |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump_back(wp); |
window_copy_cursor_jump_back(wme); |
} |
} |
if (strcmp(command, "jump-forward") == 0) { |
if (strcmp(command, "jump-forward") == 0) { |
data->jumptype = WINDOW_COPY_JUMPFORWARD; |
data->jumptype = WINDOW_COPY_JUMPFORWARD; |
data->jumpchar = *argument; |
data->jumpchar = *argument; |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump(wp); |
window_copy_cursor_jump(wme); |
} |
} |
if (strcmp(command, "jump-to-backward") == 0) { |
if (strcmp(command, "jump-to-backward") == 0) { |
data->jumptype = WINDOW_COPY_JUMPTOBACKWARD; |
data->jumptype = WINDOW_COPY_JUMPTOBACKWARD; |
data->jumpchar = *argument; |
data->jumpchar = *argument; |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump_to_back(wp); |
window_copy_cursor_jump_to_back(wme); |
} |
} |
if (strcmp(command, "jump-to-forward") == 0) { |
if (strcmp(command, "jump-to-forward") == 0) { |
data->jumptype = WINDOW_COPY_JUMPTOFORWARD; |
data->jumptype = WINDOW_COPY_JUMPTOFORWARD; |
data->jumpchar = *argument; |
data->jumpchar = *argument; |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_cursor_jump_to(wp); |
window_copy_cursor_jump_to(wme); |
} |
} |
if (strcmp(command, "search-backward") == 0) { |
if (strcmp(command, "search-backward") == 0) { |
data->searchtype = WINDOW_COPY_SEARCHUP; |
data->searchtype = WINDOW_COPY_SEARCHUP; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_up(wp); |
window_copy_search_up(wme); |
} |
} |
if (strcmp(command, "search-forward") == 0) { |
if (strcmp(command, "search-forward") == 0) { |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_down(wp); |
window_copy_search_down(wme); |
} |
} |
if (strcmp(command, "search-backward-incremental") == 0) { |
if (strcmp(command, "search-backward-incremental") == 0) { |
prefix = *argument++; |
prefix = *argument++; |
|
|
redraw = 1; |
redraw = 1; |
} |
} |
if (*argument == '\0') { |
if (*argument == '\0') { |
window_copy_clear_marks(wp); |
window_copy_clear_marks(wme); |
redraw = 1; |
redraw = 1; |
} else if (prefix == '=' || prefix == '-') { |
} else if (prefix == '=' || prefix == '-') { |
data->searchtype = WINDOW_COPY_SEARCHUP; |
data->searchtype = WINDOW_COPY_SEARCHUP; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
if (!window_copy_search_up(wp)) { |
if (!window_copy_search_up(wme)) { |
window_copy_clear_marks(wp); |
window_copy_clear_marks(wme); |
redraw = 1; |
redraw = 1; |
} |
} |
} else if (prefix == '+') { |
} else if (prefix == '+') { |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
if (!window_copy_search_down(wp)) { |
if (!window_copy_search_down(wme)) { |
window_copy_clear_marks(wp); |
window_copy_clear_marks(wme); |
redraw = 1; |
redraw = 1; |
} |
} |
} |
} |
|
|
redraw = 1; |
redraw = 1; |
} |
} |
if (*argument == '\0') { |
if (*argument == '\0') { |
window_copy_clear_marks(wp); |
window_copy_clear_marks(wme); |
redraw = 1; |
redraw = 1; |
} else if (prefix == '=' || prefix == '+') { |
} else if (prefix == '=' || prefix == '+') { |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
if (!window_copy_search_down(wp)) { |
if (!window_copy_search_down(wme)) { |
window_copy_clear_marks(wp); |
window_copy_clear_marks(wme); |
redraw = 1; |
redraw = 1; |
} |
} |
} else if (prefix == '-') { |
} else if (prefix == '-') { |
data->searchtype = WINDOW_COPY_SEARCHUP; |
data->searchtype = WINDOW_COPY_SEARCHUP; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
if (!window_copy_search_up(wp)) { |
if (!window_copy_search_up(wme)) { |
window_copy_clear_marks(wp); |
window_copy_clear_marks(wme); |
redraw = 1; |
redraw = 1; |
} |
} |
} |
} |
|
|
} |
} |
|
|
if (strncmp(command, "search-", 7) != 0 && data->searchmark != NULL) { |
if (strncmp(command, "search-", 7) != 0 && data->searchmark != NULL) { |
window_copy_clear_marks(wp); |
window_copy_clear_marks(wme); |
redraw = 1; |
redraw = 1; |
data->searchx = data->searchy = -1; |
data->searchx = data->searchy = -1; |
} |
} |
|
|
if (cancel) |
if (cancel) |
window_pane_reset_mode(wp); |
window_pane_reset_mode(wp); |
else if (redraw) |
else if (redraw) |
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wme); |
wp->modeprefix = 1; |
wme->prefix = 1; |
} |
} |
|
|
static void |
static void |
window_copy_scroll_to(struct window_pane *wp, u_int px, u_int py) |
window_copy_scroll_to(struct window_mode_entry *wme, u_int px, u_int py) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct grid *gd = data->backing->grid; |
struct grid *gd = data->backing->grid; |
u_int offset, gap; |
u_int offset, gap; |
|
|
|
|
data->oy = gd->hsize - offset; |
data->oy = gd->hsize - offset; |
} |
} |
|
|
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wme); |
} |
} |
|
|
static int |
static int |
|
|
* not found. |
* not found. |
*/ |
*/ |
static int |
static int |
window_copy_search_jump(struct window_pane *wp, struct grid *gd, |
window_copy_search_jump(struct window_mode_entry *wme, struct grid *gd, |
struct grid *sgd, u_int fx, u_int fy, u_int endline, int cis, int wrap, |
struct grid *sgd, u_int fx, u_int fy, u_int endline, int cis, int wrap, |
int direction) |
int direction) |
{ |
{ |
|
|
} |
} |
|
|
if (found) { |
if (found) { |
window_copy_scroll_to(wp, px, i); |
window_copy_scroll_to(wme, px, i); |
return (1); |
return (1); |
} |
} |
if (wrap) { |
if (wrap) { |
return (window_copy_search_jump(wp, gd, sgd, |
return (window_copy_search_jump(wme, gd, sgd, |
direction ? 0 : gd->sx - 1, |
direction ? 0 : gd->sx - 1, |
direction ? 0 : gd->hsize + gd->sy - 1, fy, cis, 0, |
direction ? 0 : gd->hsize + gd->sy - 1, fy, cis, 0, |
direction)); |
direction)); |
|
|
* down. |
* down. |
*/ |
*/ |
static int |
static int |
window_copy_search(struct window_pane *wp, int direction) |
window_copy_search(struct window_mode_entry *wme, int direction) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = data->backing, ss; |
struct screen *s = data->backing, ss; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
struct grid *gd = s->grid; |
struct grid *gd = s->grid; |
|
|
endline = gd->hsize + gd->sy - 1; |
endline = gd->hsize + gd->sy - 1; |
else |
else |
endline = 0; |
endline = 0; |
found = window_copy_search_jump(wp, gd, ss.grid, fx, fy, endline, cis, |
found = window_copy_search_jump(wme, gd, ss.grid, fx, fy, endline, cis, |
wrapflag, direction); |
wrapflag, direction); |
|
|
if (window_copy_search_marks(wp, &ss)) |
if (window_copy_search_marks(wme, &ss)) |
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wme); |
|
|
screen_free(&ss); |
screen_free(&ss); |
return (found); |
return (found); |
} |
} |
|
|
static int |
static int |
window_copy_search_marks(struct window_pane *wp, struct screen *ssp) |
window_copy_search_marks(struct window_mode_entry *wme, struct screen *ssp) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *s = data->backing, ss; |
struct screen *s = data->backing, ss; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
struct grid *gd = s->grid; |
struct grid *gd = s->grid; |
|
|
} |
} |
|
|
static void |
static void |
window_copy_clear_marks(struct window_pane *wp) |
window_copy_clear_marks(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
|
|
free(data->searchmark); |
free(data->searchmark); |
data->searchmark = NULL; |
data->searchmark = NULL; |
} |
} |
|
|
static int |
static int |
window_copy_search_up(struct window_pane *wp) |
window_copy_search_up(struct window_mode_entry *wme) |
{ |
{ |
return (window_copy_search(wp, 0)); |
return (window_copy_search(wme, 0)); |
} |
} |
|
|
static int |
static int |
window_copy_search_down(struct window_pane *wp) |
window_copy_search_down(struct window_mode_entry *wme) |
{ |
{ |
return (window_copy_search(wp, 1)); |
return (window_copy_search(wme, 1)); |
} |
} |
|
|
static void |
static void |
window_copy_goto_line(struct window_pane *wp, const char *linestr) |
window_copy_goto_line(struct window_mode_entry *wme, const char *linestr) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
const char *errstr; |
const char *errstr; |
int lineno; |
int lineno; |
|
|
|
|
lineno = screen_hsize(data->backing); |
lineno = screen_hsize(data->backing); |
|
|
data->oy = lineno; |
data->oy = lineno; |
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wme); |
} |
} |
|
|
static void |
static void |
window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx, |
window_copy_write_line(struct window_mode_entry *wme, |
u_int py) |
struct screen_write_ctx *ctx, u_int py) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
struct options *oo = wp->window->options; |
struct options *oo = wp->window->options; |
struct grid_cell gc; |
struct grid_cell gc; |
|
|
} |
} |
|
|
static void |
static void |
window_copy_write_lines(struct window_pane *wp, struct screen_write_ctx *ctx, |
window_copy_write_lines(struct window_mode_entry *wme, |
u_int py, u_int ny) |
struct screen_write_ctx *ctx, u_int py, u_int ny) |
{ |
{ |
u_int yy; |
u_int yy; |
|
|
for (yy = py; yy < py + ny; yy++) |
for (yy = py; yy < py + ny; yy++) |
window_copy_write_line(wp, ctx, py); |
window_copy_write_line(wme, ctx, py); |
} |
} |
|
|
static void |
static void |
window_copy_redraw_selection(struct window_pane *wp, u_int old_y) |
window_copy_redraw_selection(struct window_mode_entry *wme, u_int old_y) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
u_int new_y, start, end; |
u_int new_y, start, end; |
|
|
new_y = data->cy; |
new_y = data->cy; |
|
|
start = new_y; |
start = new_y; |
end = old_y; |
end = old_y; |
} |
} |
window_copy_redraw_lines(wp, start, end - start + 1); |
window_copy_redraw_lines(wme, start, end - start + 1); |
} |
} |
|
|
static void |
static void |
window_copy_redraw_lines(struct window_pane *wp, u_int py, u_int ny) |
window_copy_redraw_lines(struct window_mode_entry *wme, u_int py, u_int ny) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
u_int i; |
u_int i; |
|
|
screen_write_start(&ctx, wp, NULL); |
screen_write_start(&ctx, wp, NULL); |
for (i = py; i < py + ny; i++) |
for (i = py; i < py + ny; i++) |
window_copy_write_line(wp, &ctx, i); |
window_copy_write_line(wme, &ctx, i); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
} |
} |
|
|
static void |
static void |
window_copy_redraw_screen(struct window_pane *wp) |
window_copy_redraw_screen(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
|
|
window_copy_redraw_lines(wp, 0, screen_size_y(&data->screen)); |
window_copy_redraw_lines(wme, 0, screen_size_y(&data->screen)); |
} |
} |
|
|
static void |
static void |
window_copy_synchronize_cursor(struct window_pane *wp) |
window_copy_synchronize_cursor(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
u_int xx, yy; |
u_int xx, yy; |
|
|
xx = data->cx; |
xx = data->cx; |
|
|
} |
} |
|
|
static void |
static void |
window_copy_update_cursor(struct window_pane *wp, u_int cx, u_int cy) |
window_copy_update_cursor(struct window_mode_entry *wme, u_int cx, u_int cy) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
u_int old_cx, old_cy; |
u_int old_cx, old_cy; |
|
|
old_cx = data->cx; old_cy = data->cy; |
old_cx = data->cx; old_cy = data->cy; |
data->cx = cx; data->cy = cy; |
data->cx = cx; data->cy = cy; |
if (old_cx == screen_size_x(s)) |
if (old_cx == screen_size_x(s)) |
window_copy_redraw_lines(wp, old_cy, 1); |
window_copy_redraw_lines(wme, old_cy, 1); |
if (data->cx == screen_size_x(s)) |
if (data->cx == screen_size_x(s)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
else { |
else { |
screen_write_start(&ctx, wp, NULL); |
screen_write_start(&ctx, wp, NULL); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
|
|
} |
} |
|
|
static void |
static void |
window_copy_start_selection(struct window_pane *wp) |
window_copy_start_selection(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
|
|
data->selx = data->cx; |
data->selx = data->cx; |
data->sely = screen_hsize(data->backing) + data->cy - data->oy; |
data->sely = screen_hsize(data->backing) + data->cy - data->oy; |
|
|
|
|
data->cursordrag = CURSORDRAG_ENDSEL; |
data->cursordrag = CURSORDRAG_ENDSEL; |
|
|
window_copy_set_selection(wp, 1); |
window_copy_set_selection(wme, 1); |
} |
} |
|
|
static int |
static int |
window_copy_adjust_selection(struct window_pane *wp, u_int *selx, u_int *sely) |
window_copy_adjust_selection(struct window_mode_entry *wme, u_int *selx, |
|
u_int *sely) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
u_int sx, sy, ty; |
u_int sx, sy, ty; |
int relpos; |
int relpos; |
|
|
} |
} |
|
|
static int |
static int |
window_copy_update_selection(struct window_pane *wp, int may_redraw) |
window_copy_update_selection(struct window_mode_entry *wme, int may_redraw) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
|
|
if (s->sel == NULL && data->lineflag == LINE_SEL_NONE) |
if (s->sel == NULL && data->lineflag == LINE_SEL_NONE) |
return (0); |
return (0); |
return (window_copy_set_selection(wp, may_redraw)); |
return (window_copy_set_selection(wme, may_redraw)); |
} |
} |
|
|
static int |
static int |
window_copy_set_selection(struct window_pane *wp, int may_redraw) |
window_copy_set_selection(struct window_mode_entry *wme, int may_redraw) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
struct options *oo = wp->window->options; |
struct options *oo = wp->window->options; |
struct grid_cell gc; |
struct grid_cell gc; |
u_int sx, sy, cy, endsx, endsy; |
u_int sx, sy, cy, endsx, endsy; |
int startrelpos, endrelpos; |
int startrelpos, endrelpos; |
|
|
window_copy_synchronize_cursor(wp); |
window_copy_synchronize_cursor(wme); |
|
|
/* Adjust the selection. */ |
/* Adjust the selection. */ |
sx = data->selx; |
sx = data->selx; |
sy = data->sely; |
sy = data->sely; |
startrelpos = window_copy_adjust_selection(wp, &sx, &sy); |
startrelpos = window_copy_adjust_selection(wme, &sx, &sy); |
|
|
/* Adjust the end of selection. */ |
/* Adjust the end of selection. */ |
endsx = data->endselx; |
endsx = data->endselx; |
endsy = data->endsely; |
endsy = data->endsely; |
endrelpos = window_copy_adjust_selection(wp, &endsx, &endsy); |
endrelpos = window_copy_adjust_selection(wme, &endsx, &endsy); |
|
|
/* Selection is outside of the current screen */ |
/* Selection is outside of the current screen */ |
if (startrelpos == endrelpos && |
if (startrelpos == endrelpos && |
|
|
cy = data->cy; |
cy = data->cy; |
if (data->cursordrag == CURSORDRAG_ENDSEL) { |
if (data->cursordrag == CURSORDRAG_ENDSEL) { |
if (sy < cy) |
if (sy < cy) |
window_copy_redraw_lines(wp, sy, cy - sy + 1); |
window_copy_redraw_lines(wme, sy, cy - sy + 1); |
else |
else |
window_copy_redraw_lines(wp, cy, sy - cy + 1); |
window_copy_redraw_lines(wme, cy, sy - cy + 1); |
} else { |
} else { |
if (endsy < cy) |
if (endsy < cy) { |
window_copy_redraw_lines(wp, endsy, cy - endsy + 1); |
window_copy_redraw_lines(wme, endsy, |
else |
cy - endsy + 1); |
window_copy_redraw_lines(wp, cy, endsy - cy + 1); |
} else { |
|
window_copy_redraw_lines(wme, cy, |
|
endsy - cy + 1); |
|
} |
} |
} |
} |
} |
|
|
|
|
} |
} |
|
|
static void * |
static void * |
window_copy_get_selection(struct window_pane *wp, size_t *len) |
window_copy_get_selection(struct window_mode_entry *wme, size_t *len) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
char *buf; |
char *buf; |
size_t off; |
size_t off; |
|
|
} |
} |
|
|
/* Trim ex to end of line. */ |
/* Trim ex to end of line. */ |
ey_last = window_copy_find_length(wp, ey); |
ey_last = window_copy_find_length(wme, ey); |
if (ex > ey_last) |
if (ex > ey_last) |
ex = ey_last; |
ex = ey_last; |
|
|
|
|
|
|
/* Copy the lines. */ |
/* Copy the lines. */ |
for (i = sy; i <= ey; i++) { |
for (i = sy; i <= ey; i++) { |
window_copy_copy_line(wp, &buf, &off, i, |
window_copy_copy_line(wme, &buf, &off, i, |
(i == sy ? firstsx : restsx), |
(i == sy ? firstsx : restsx), |
(i == ey ? lastex : restex)); |
(i == ey ? lastex : restex)); |
} |
} |
|
|
} |
} |
|
|
static void |
static void |
window_copy_copy_buffer(struct window_pane *wp, void *buf, size_t len) |
window_copy_copy_buffer(struct window_mode_entry *wme, void *buf, size_t len) |
{ |
{ |
struct screen_write_ctx ctx; |
struct window_pane *wp = wme->wp; |
|
struct screen_write_ctx ctx; |
|
|
if (options_get_number(global_options, "set-clipboard") != 0) { |
if (options_get_number(global_options, "set-clipboard") != 0) { |
screen_write_start(&ctx, wp, NULL); |
screen_write_start(&ctx, wp, NULL); |
|
|
} |
} |
|
|
static void |
static void |
window_copy_copy_pipe(struct window_pane *wp, struct session *s, |
window_copy_copy_pipe(struct window_mode_entry *wme, struct session *s, |
const char *fmt) |
const char *fmt) |
{ |
{ |
void *buf; |
struct window_pane *wp = wme->wp; |
size_t len; |
void *buf; |
struct job *job; |
size_t len; |
char *expanded; |
struct job *job; |
|
char *expanded; |
|
|
buf = window_copy_get_selection(wp, &len); |
buf = window_copy_get_selection(wme, &len); |
if (buf == NULL) |
if (buf == NULL) |
return; |
return; |
expanded = format_single(NULL, fmt, NULL, s, NULL, wp); |
expanded = format_single(NULL, fmt, NULL, s, NULL, wp); |
|
|
bufferevent_write(job_get_event(job), buf, len); |
bufferevent_write(job_get_event(job), buf, len); |
|
|
free(expanded); |
free(expanded); |
window_copy_copy_buffer(wp, buf, len); |
window_copy_copy_buffer(wme, buf, len); |
} |
} |
|
|
static void |
static void |
window_copy_copy_selection(struct window_pane *wp) |
window_copy_copy_selection(struct window_mode_entry *wme) |
{ |
{ |
char *buf; |
char *buf; |
size_t len; |
size_t len; |
|
|
buf = window_copy_get_selection(wp, &len); |
buf = window_copy_get_selection(wme, &len); |
if (buf != NULL) |
if (buf != NULL) |
window_copy_copy_buffer(wp, buf, len); |
window_copy_copy_buffer(wme, buf, len); |
} |
} |
|
|
static void |
static void |
window_copy_append_selection(struct window_pane *wp) |
window_copy_append_selection(struct window_mode_entry *wme) |
{ |
{ |
|
struct window_pane *wp = wme->wp; |
char *buf; |
char *buf; |
struct paste_buffer *pb; |
struct paste_buffer *pb; |
const char *bufdata, *bufname; |
const char *bufdata, *bufname; |
size_t len, bufsize; |
size_t len, bufsize; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
|
|
buf = window_copy_get_selection(wp, &len); |
buf = window_copy_get_selection(wme, &len); |
if (buf == NULL) |
if (buf == NULL) |
return; |
return; |
|
|
|
|
} |
} |
|
|
static void |
static void |
window_copy_copy_line(struct window_pane *wp, char **buf, size_t *off, u_int sy, |
window_copy_copy_line(struct window_mode_entry *wme, char **buf, size_t *off, |
u_int sx, u_int ex) |
u_int sy, u_int sx, u_int ex) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct grid *gd = data->backing->grid; |
struct grid *gd = data->backing->grid; |
struct grid_cell gc; |
struct grid_cell gc; |
struct grid_line *gl; |
struct grid_line *gl; |
|
|
if (wrapped) |
if (wrapped) |
xx = gl->cellsize; |
xx = gl->cellsize; |
else |
else |
xx = window_copy_find_length(wp, sy); |
xx = window_copy_find_length(wme, sy); |
if (ex > xx) |
if (ex > xx) |
ex = xx; |
ex = xx; |
if (sx > xx) |
if (sx > xx) |
|
|
} |
} |
|
|
static void |
static void |
window_copy_clear_selection(struct window_pane *wp) |
window_copy_clear_selection(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
u_int px, py; |
u_int px, py; |
|
|
screen_clear_selection(&data->screen); |
screen_clear_selection(&data->screen); |
|
|
data->lineflag = LINE_SEL_NONE; |
data->lineflag = LINE_SEL_NONE; |
|
|
py = screen_hsize(data->backing) + data->cy - data->oy; |
py = screen_hsize(data->backing) + data->cy - data->oy; |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
if (data->cx > px) |
if (data->cx > px) |
window_copy_update_cursor(wp, px, data->cy); |
window_copy_update_cursor(wme, px, data->cy); |
} |
} |
|
|
static int |
static int |
window_copy_in_set(struct window_pane *wp, u_int px, u_int py, const char *set) |
window_copy_in_set(struct window_mode_entry *wme, u_int px, u_int py, |
|
const char *set) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct grid_cell gc; |
struct grid_cell gc; |
const struct utf8_data *ud; |
const struct utf8_data *ud; |
struct utf8_data *copy; |
struct utf8_data *copy; |
|
|
} |
} |
|
|
static u_int |
static u_int |
window_copy_find_length(struct window_pane *wp, u_int py) |
window_copy_find_length(struct window_mode_entry *wme, u_int py) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *s = data->backing; |
struct screen *s = data->backing; |
struct grid_cell gc; |
struct grid_cell gc; |
u_int px; |
u_int px; |
|
|
} |
} |
|
|
static void |
static void |
window_copy_cursor_start_of_line(struct window_pane *wp) |
window_copy_cursor_start_of_line(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *back_s = data->backing; |
struct screen *back_s = data->backing; |
struct grid *gd = back_s->grid; |
struct grid *gd = back_s->grid; |
u_int py; |
u_int py; |
|
|
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
while (py > 0 && |
while (py > 0 && |
grid_get_line(gd, py - 1)->flags & GRID_LINE_WRAPPED) { |
grid_get_line(gd, py - 1)->flags & GRID_LINE_WRAPPED) { |
window_copy_cursor_up(wp, 0); |
window_copy_cursor_up(wme, 0); |
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
} |
} |
} |
} |
window_copy_update_cursor(wp, 0, data->cy); |
window_copy_update_cursor(wme, 0, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
} |
} |
|
|
static void |
static void |
window_copy_cursor_back_to_indentation(struct window_pane *wp) |
window_copy_cursor_back_to_indentation(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
u_int px, py, xx; |
u_int px, py, xx; |
struct grid_cell gc; |
struct grid_cell gc; |
|
|
px = 0; |
px = 0; |
py = screen_hsize(data->backing) + data->cy - data->oy; |
py = screen_hsize(data->backing) + data->cy - data->oy; |
xx = window_copy_find_length(wp, py); |
xx = window_copy_find_length(wme, py); |
|
|
while (px < xx) { |
while (px < xx) { |
grid_get_cell(data->backing->grid, px, py, &gc); |
grid_get_cell(data->backing->grid, px, py, &gc); |
|
|
px++; |
px++; |
} |
} |
|
|
window_copy_update_cursor(wp, px, data->cy); |
window_copy_update_cursor(wme, px, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
} |
} |
|
|
static void |
static void |
window_copy_cursor_end_of_line(struct window_pane *wp) |
window_copy_cursor_end_of_line(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *back_s = data->backing; |
struct screen *back_s = data->backing; |
struct grid *gd = back_s->grid; |
struct grid *gd = back_s->grid; |
struct grid_line *gl; |
struct grid_line *gl; |
u_int px, py; |
u_int px, py; |
|
|
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
|
|
if (data->cx == px && data->lineflag == LINE_SEL_NONE) { |
if (data->cx == px && data->lineflag == LINE_SEL_NONE) { |
if (data->screen.sel != NULL && data->rectflag) |
if (data->screen.sel != NULL && data->rectflag) |
|
|
gl = grid_get_line(gd, py); |
gl = grid_get_line(gd, py); |
if (~gl->flags & GRID_LINE_WRAPPED) |
if (~gl->flags & GRID_LINE_WRAPPED) |
break; |
break; |
window_copy_cursor_down(wp, 0); |
window_copy_cursor_down(wme, 0); |
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
} |
} |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
} |
} |
} |
} |
window_copy_update_cursor(wp, px, data->cy); |
window_copy_update_cursor(wme, px, data->cy); |
|
|
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
} |
} |
|
|
static void |
static void |
window_copy_other_end(struct window_pane *wp) |
window_copy_other_end(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
u_int selx, sely, cy, yy, hsize; |
u_int selx, sely, cy, yy, hsize; |
|
|
|
|
} else |
} else |
data->cy = cy + sely - yy; |
data->cy = cy + sely - yy; |
|
|
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wme); |
} |
} |
|
|
static void |
static void |
window_copy_cursor_left(struct window_pane *wp) |
window_copy_cursor_left(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
u_int py, cx; |
u_int py, cx; |
struct grid_cell gc; |
struct grid_cell gc; |
|
|
|
|
cx--; |
cx--; |
} |
} |
if (cx == 0 && py > 0) { |
if (cx == 0 && py > 0) { |
window_copy_cursor_up(wp, 0); |
window_copy_cursor_up(wme, 0); |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
} else if (cx > 0) { |
} else if (cx > 0) { |
window_copy_update_cursor(wp, cx - 1, data->cy); |
window_copy_update_cursor(wme, cx - 1, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
} |
} |
} |
} |
|
|
static void |
static void |
window_copy_cursor_right(struct window_pane *wp) |
window_copy_cursor_right(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
u_int px, py, yy, cx, cy; |
u_int px, py, yy, cx, cy; |
struct grid_cell gc; |
struct grid_cell gc; |
|
|
|
|
if (data->screen.sel != NULL && data->rectflag) |
if (data->screen.sel != NULL && data->rectflag) |
px = screen_size_x(&data->screen); |
px = screen_size_x(&data->screen); |
else |
else |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
|
|
if (data->cx >= px && py < yy) { |
if (data->cx >= px && py < yy) { |
window_copy_cursor_start_of_line(wp); |
window_copy_cursor_start_of_line(wme); |
window_copy_cursor_down(wp, 0); |
window_copy_cursor_down(wme, 0); |
} else if (data->cx < px) { |
} else if (data->cx < px) { |
cx = data->cx + 1; |
cx = data->cx + 1; |
cy = screen_hsize(data->backing) + data->cy - data->oy; |
cy = screen_hsize(data->backing) + data->cy - data->oy; |
|
|
break; |
break; |
cx++; |
cx++; |
} |
} |
window_copy_update_cursor(wp, cx, data->cy); |
window_copy_update_cursor(wme, cx, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
} |
} |
} |
} |
|
|
static void |
static void |
window_copy_cursor_up(struct window_pane *wp, int scroll_only) |
window_copy_cursor_up(struct window_mode_entry *wme, int scroll_only) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
u_int ox, oy, px, py; |
u_int ox, oy, px, py; |
|
|
oy = screen_hsize(data->backing) + data->cy - data->oy; |
oy = screen_hsize(data->backing) + data->cy - data->oy; |
ox = window_copy_find_length(wp, oy); |
ox = window_copy_find_length(wme, oy); |
if (data->cx != ox) { |
if (data->cx != ox) { |
data->lastcx = data->cx; |
data->lastcx = data->cx; |
data->lastsx = ox; |
data->lastsx = ox; |
} |
} |
|
|
if (data->lineflag == LINE_SEL_LEFT_RIGHT && oy == data->sely) |
if (data->lineflag == LINE_SEL_LEFT_RIGHT && oy == data->sely) |
window_copy_other_end(wp); |
window_copy_other_end(wme); |
|
|
data->cx = data->lastcx; |
data->cx = data->lastcx; |
if (scroll_only || data->cy == 0) { |
if (scroll_only || data->cy == 0) { |
window_copy_scroll_down(wp, 1); |
window_copy_scroll_down(wme, 1); |
if (scroll_only) { |
if (scroll_only) { |
if (data->cy == screen_size_y(s) - 1) |
if (data->cy == screen_size_y(s) - 1) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
else |
else |
window_copy_redraw_lines(wp, data->cy, 2); |
window_copy_redraw_lines(wme, data->cy, 2); |
} |
} |
} else { |
} else { |
window_copy_update_cursor(wp, data->cx, data->cy - 1); |
window_copy_update_cursor(wme, data->cx, data->cy - 1); |
if (window_copy_update_selection(wp, 1)) { |
if (window_copy_update_selection(wme, 1)) { |
if (data->cy == screen_size_y(s) - 1) |
if (data->cy == screen_size_y(s) - 1) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
else |
else |
window_copy_redraw_lines(wp, data->cy, 2); |
window_copy_redraw_lines(wme, data->cy, 2); |
} |
} |
} |
} |
|
|
if (data->screen.sel == NULL || !data->rectflag) { |
if (data->screen.sel == NULL || !data->rectflag) { |
py = screen_hsize(data->backing) + data->cy - data->oy; |
py = screen_hsize(data->backing) + data->cy - data->oy; |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
if ((data->cx >= data->lastsx && data->cx != px) || |
if ((data->cx >= data->lastsx && data->cx != px) || |
data->cx > px) |
data->cx > px) |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
} |
} |
|
|
if (data->lineflag == LINE_SEL_LEFT_RIGHT) |
if (data->lineflag == LINE_SEL_LEFT_RIGHT) |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
else if (data->lineflag == LINE_SEL_RIGHT_LEFT) |
else if (data->lineflag == LINE_SEL_RIGHT_LEFT) |
window_copy_cursor_start_of_line(wp); |
window_copy_cursor_start_of_line(wme); |
} |
} |
|
|
static void |
static void |
window_copy_cursor_down(struct window_pane *wp, int scroll_only) |
window_copy_cursor_down(struct window_mode_entry *wme, int scroll_only) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
u_int ox, oy, px, py; |
u_int ox, oy, px, py; |
|
|
oy = screen_hsize(data->backing) + data->cy - data->oy; |
oy = screen_hsize(data->backing) + data->cy - data->oy; |
ox = window_copy_find_length(wp, oy); |
ox = window_copy_find_length(wme, oy); |
if (data->cx != ox) { |
if (data->cx != ox) { |
data->lastcx = data->cx; |
data->lastcx = data->cx; |
data->lastsx = ox; |
data->lastsx = ox; |
} |
} |
|
|
if (data->lineflag == LINE_SEL_RIGHT_LEFT && oy == data->endsely) |
if (data->lineflag == LINE_SEL_RIGHT_LEFT && oy == data->endsely) |
window_copy_other_end(wp); |
window_copy_other_end(wme); |
|
|
data->cx = data->lastcx; |
data->cx = data->lastcx; |
if (scroll_only || data->cy == screen_size_y(s) - 1) { |
if (scroll_only || data->cy == screen_size_y(s) - 1) { |
window_copy_scroll_up(wp, 1); |
window_copy_scroll_up(wme, 1); |
if (scroll_only && data->cy > 0) |
if (scroll_only && data->cy > 0) |
window_copy_redraw_lines(wp, data->cy - 1, 2); |
window_copy_redraw_lines(wme, data->cy - 1, 2); |
} else { |
} else { |
window_copy_update_cursor(wp, data->cx, data->cy + 1); |
window_copy_update_cursor(wme, data->cx, data->cy + 1); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy - 1, 2); |
window_copy_redraw_lines(wme, data->cy - 1, 2); |
} |
} |
|
|
if (data->screen.sel == NULL || !data->rectflag) { |
if (data->screen.sel == NULL || !data->rectflag) { |
py = screen_hsize(data->backing) + data->cy - data->oy; |
py = screen_hsize(data->backing) + data->cy - data->oy; |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
if ((data->cx >= data->lastsx && data->cx != px) || |
if ((data->cx >= data->lastsx && data->cx != px) || |
data->cx > px) |
data->cx > px) |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
} |
} |
|
|
if (data->lineflag == LINE_SEL_LEFT_RIGHT) |
if (data->lineflag == LINE_SEL_LEFT_RIGHT) |
window_copy_cursor_end_of_line(wp); |
window_copy_cursor_end_of_line(wme); |
else if (data->lineflag == LINE_SEL_RIGHT_LEFT) |
else if (data->lineflag == LINE_SEL_RIGHT_LEFT) |
window_copy_cursor_start_of_line(wp); |
window_copy_cursor_start_of_line(wme); |
} |
} |
|
|
static void |
static void |
window_copy_cursor_jump(struct window_pane *wp) |
window_copy_cursor_jump(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *back_s = data->backing; |
struct screen *back_s = data->backing; |
struct grid_cell gc; |
struct grid_cell gc; |
u_int px, py, xx; |
u_int px, py, xx; |
|
|
px = data->cx + 1; |
px = data->cx + 1; |
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
xx = window_copy_find_length(wp, py); |
xx = window_copy_find_length(wme, py); |
|
|
while (px < xx) { |
while (px < xx) { |
grid_get_cell(back_s->grid, px, py, &gc); |
grid_get_cell(back_s->grid, px, py, &gc); |
if (!(gc.flags & GRID_FLAG_PADDING) && |
if (!(gc.flags & GRID_FLAG_PADDING) && |
gc.data.size == 1 && *gc.data.data == data->jumpchar) { |
gc.data.size == 1 && *gc.data.data == data->jumpchar) { |
window_copy_update_cursor(wp, px, data->cy); |
window_copy_update_cursor(wme, px, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
return; |
return; |
} |
} |
px++; |
px++; |
|
|
} |
} |
|
|
static void |
static void |
window_copy_cursor_jump_back(struct window_pane *wp) |
window_copy_cursor_jump_back(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *back_s = data->backing; |
struct screen *back_s = data->backing; |
struct grid_cell gc; |
struct grid_cell gc; |
u_int px, py; |
u_int px, py; |
|
|
grid_get_cell(back_s->grid, px, py, &gc); |
grid_get_cell(back_s->grid, px, py, &gc); |
if (!(gc.flags & GRID_FLAG_PADDING) && |
if (!(gc.flags & GRID_FLAG_PADDING) && |
gc.data.size == 1 && *gc.data.data == data->jumpchar) { |
gc.data.size == 1 && *gc.data.data == data->jumpchar) { |
window_copy_update_cursor(wp, px, data->cy); |
window_copy_update_cursor(wme, px, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
return; |
return; |
} |
} |
if (px == 0) |
if (px == 0) |
|
|
} |
} |
|
|
static void |
static void |
window_copy_cursor_jump_to(struct window_pane *wp) |
window_copy_cursor_jump_to(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *back_s = data->backing; |
struct screen *back_s = data->backing; |
struct grid_cell gc; |
struct grid_cell gc; |
u_int px, py, xx; |
u_int px, py, xx; |
|
|
px = data->cx + 2; |
px = data->cx + 2; |
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
xx = window_copy_find_length(wp, py); |
xx = window_copy_find_length(wme, py); |
|
|
while (px < xx) { |
while (px < xx) { |
grid_get_cell(back_s->grid, px, py, &gc); |
grid_get_cell(back_s->grid, px, py, &gc); |
if (!(gc.flags & GRID_FLAG_PADDING) && |
if (!(gc.flags & GRID_FLAG_PADDING) && |
gc.data.size == 1 && *gc.data.data == data->jumpchar) { |
gc.data.size == 1 && *gc.data.data == data->jumpchar) { |
window_copy_update_cursor(wp, px - 1, data->cy); |
window_copy_update_cursor(wme, px - 1, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
return; |
return; |
} |
} |
px++; |
px++; |
|
|
} |
} |
|
|
static void |
static void |
window_copy_cursor_jump_to_back(struct window_pane *wp) |
window_copy_cursor_jump_to_back(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *back_s = data->backing; |
struct screen *back_s = data->backing; |
struct grid_cell gc; |
struct grid_cell gc; |
u_int px, py; |
u_int px, py; |
|
|
grid_get_cell(back_s->grid, px, py, &gc); |
grid_get_cell(back_s->grid, px, py, &gc); |
if (!(gc.flags & GRID_FLAG_PADDING) && |
if (!(gc.flags & GRID_FLAG_PADDING) && |
gc.data.size == 1 && *gc.data.data == data->jumpchar) { |
gc.data.size == 1 && *gc.data.data == data->jumpchar) { |
window_copy_update_cursor(wp, px + 1, data->cy); |
window_copy_update_cursor(wme, px + 1, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
return; |
return; |
} |
} |
if (px == 0) |
if (px == 0) |
|
|
} |
} |
|
|
static void |
static void |
window_copy_cursor_next_word(struct window_pane *wp, const char *separators) |
window_copy_cursor_next_word(struct window_mode_entry *wme, |
|
const char *separators) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
struct screen *back_s = data->backing; |
struct screen *back_s = data->backing; |
u_int px, py, xx, yy; |
u_int px, py, xx, yy; |
int expected = 0; |
int expected = 0; |
|
|
px = data->cx; |
px = data->cx; |
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
xx = window_copy_find_length(wp, py); |
xx = window_copy_find_length(wme, py); |
yy = screen_hsize(back_s) + screen_size_y(back_s) - 1; |
yy = screen_hsize(back_s) + screen_size_y(back_s) - 1; |
|
|
/* |
/* |
|
|
*/ |
*/ |
do { |
do { |
while (px > xx || |
while (px > xx || |
window_copy_in_set(wp, px, py, separators) == expected) { |
window_copy_in_set(wme, px, py, separators) == expected) { |
/* Move down if we're past the end of the line. */ |
/* Move down if we're past the end of the line. */ |
if (px > xx) { |
if (px > xx) { |
if (py == yy) |
if (py == yy) |
return; |
return; |
window_copy_cursor_down(wp, 0); |
window_copy_cursor_down(wme, 0); |
px = 0; |
px = 0; |
|
|
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
xx = window_copy_find_length(wp, py); |
xx = window_copy_find_length(wme, py); |
} else |
} else |
px++; |
px++; |
} |
} |
expected = !expected; |
expected = !expected; |
} while (expected == 1); |
} while (expected == 1); |
|
|
window_copy_update_cursor(wp, px, data->cy); |
window_copy_update_cursor(wme, px, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
} |
} |
|
|
static void |
static void |
window_copy_cursor_next_word_end(struct window_pane *wp, |
window_copy_cursor_next_word_end(struct window_mode_entry *wme, |
const char *separators) |
const char *separators) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct options *oo = wp->window->options; |
struct options *oo = wp->window->options; |
struct screen *back_s = data->backing; |
struct screen *back_s = data->backing; |
u_int px, py, xx, yy; |
u_int px, py, xx, yy; |
|
|
|
|
px = data->cx; |
px = data->cx; |
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
xx = window_copy_find_length(wp, py); |
xx = window_copy_find_length(wme, py); |
yy = screen_hsize(back_s) + screen_size_y(back_s) - 1; |
yy = screen_hsize(back_s) + screen_size_y(back_s) - 1; |
|
|
keys = options_get_number(oo, "mode-keys"); |
keys = options_get_number(oo, "mode-keys"); |
if (keys == MODEKEY_VI && !window_copy_in_set(wp, px, py, separators)) |
if (keys == MODEKEY_VI && !window_copy_in_set(wme, px, py, separators)) |
px++; |
px++; |
|
|
/* |
/* |
|
|
*/ |
*/ |
do { |
do { |
while (px > xx || |
while (px > xx || |
window_copy_in_set(wp, px, py, separators) == expected) { |
window_copy_in_set(wme, px, py, separators) == expected) { |
/* Move down if we're past the end of the line. */ |
/* Move down if we're past the end of the line. */ |
if (px > xx) { |
if (px > xx) { |
if (py == yy) |
if (py == yy) |
return; |
return; |
window_copy_cursor_down(wp, 0); |
window_copy_cursor_down(wme, 0); |
px = 0; |
px = 0; |
|
|
py = screen_hsize(back_s) + data->cy - data->oy; |
py = screen_hsize(back_s) + data->cy - data->oy; |
xx = window_copy_find_length(wp, py); |
xx = window_copy_find_length(wme, py); |
} else |
} else |
px++; |
px++; |
} |
} |
|
|
if (keys == MODEKEY_VI && px != 0) |
if (keys == MODEKEY_VI && px != 0) |
px--; |
px--; |
|
|
window_copy_update_cursor(wp, px, data->cy); |
window_copy_update_cursor(wme, px, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
} |
} |
|
|
/* Move to the previous place where a word begins. */ |
/* Move to the previous place where a word begins. */ |
static void |
static void |
window_copy_cursor_previous_word(struct window_pane *wp, |
window_copy_cursor_previous_word(struct window_mode_entry *wme, |
const char *separators) |
const char *separators) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
u_int px, py; |
u_int px, py; |
|
|
px = data->cx; |
px = data->cx; |
|
|
for (;;) { |
for (;;) { |
if (px > 0) { |
if (px > 0) { |
px--; |
px--; |
if (!window_copy_in_set(wp, px, py, separators)) |
if (!window_copy_in_set(wme, px, py, separators)) |
break; |
break; |
} else { |
} else { |
if (data->cy == 0 && |
if (data->cy == 0 && |
(screen_hsize(data->backing) == 0 || |
(screen_hsize(data->backing) == 0 || |
data->oy >= screen_hsize(data->backing) - 1)) |
data->oy >= screen_hsize(data->backing) - 1)) |
goto out; |
goto out; |
window_copy_cursor_up(wp, 0); |
window_copy_cursor_up(wme, 0); |
|
|
py = screen_hsize(data->backing) + data->cy - data->oy; |
py = screen_hsize(data->backing) + data->cy - data->oy; |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
} |
} |
} |
} |
|
|
/* Move back to the beginning of this word. */ |
/* Move back to the beginning of this word. */ |
while (px > 0 && !window_copy_in_set(wp, px - 1, py, separators)) |
while (px > 0 && !window_copy_in_set(wme, px - 1, py, separators)) |
px--; |
px--; |
|
|
out: |
out: |
window_copy_update_cursor(wp, px, data->cy); |
window_copy_update_cursor(wme, px, data->cy); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wme, 1)) |
window_copy_redraw_lines(wp, data->cy, 1); |
window_copy_redraw_lines(wme, data->cy, 1); |
} |
} |
|
|
static void |
static void |
window_copy_scroll_up(struct window_pane *wp, u_int ny) |
window_copy_scroll_up(struct window_mode_entry *wme, u_int ny) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
|
|
|
|
return; |
return; |
data->oy -= ny; |
data->oy -= ny; |
|
|
window_copy_update_selection(wp, 0); |
window_copy_update_selection(wme, 0); |
|
|
screen_write_start(&ctx, wp, NULL); |
screen_write_start(&ctx, wp, NULL); |
screen_write_cursormove(&ctx, 0, 0); |
screen_write_cursormove(&ctx, 0, 0); |
screen_write_deleteline(&ctx, ny, 8); |
screen_write_deleteline(&ctx, ny, 8); |
window_copy_write_lines(wp, &ctx, screen_size_y(s) - ny, ny); |
window_copy_write_lines(wme, &ctx, screen_size_y(s) - ny, ny); |
window_copy_write_line(wp, &ctx, 0); |
window_copy_write_line(wme, &ctx, 0); |
if (screen_size_y(s) > 1) |
if (screen_size_y(s) > 1) |
window_copy_write_line(wp, &ctx, 1); |
window_copy_write_line(wme, &ctx, 1); |
if (screen_size_y(s) > 3) |
if (screen_size_y(s) > 3) |
window_copy_write_line(wp, &ctx, screen_size_y(s) - 2); |
window_copy_write_line(wme, &ctx, screen_size_y(s) - 2); |
if (s->sel != NULL && screen_size_y(s) > ny) |
if (s->sel != NULL && screen_size_y(s) > ny) |
window_copy_write_line(wp, &ctx, screen_size_y(s) - ny - 1); |
window_copy_write_line(wme, &ctx, screen_size_y(s) - ny - 1); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
} |
} |
|
|
static void |
static void |
window_copy_scroll_down(struct window_pane *wp, u_int ny) |
window_copy_scroll_down(struct window_mode_entry *wme, u_int ny) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_pane *wp = wme->wp; |
|
struct window_copy_mode_data *data = wme->data; |
struct screen *s = &data->screen; |
struct screen *s = &data->screen; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
|
|
|
|
return; |
return; |
data->oy += ny; |
data->oy += ny; |
|
|
window_copy_update_selection(wp, 0); |
window_copy_update_selection(wme, 0); |
|
|
screen_write_start(&ctx, wp, NULL); |
screen_write_start(&ctx, wp, NULL); |
screen_write_cursormove(&ctx, 0, 0); |
screen_write_cursormove(&ctx, 0, 0); |
screen_write_insertline(&ctx, ny, 8); |
screen_write_insertline(&ctx, ny, 8); |
window_copy_write_lines(wp, &ctx, 0, ny); |
window_copy_write_lines(wme, &ctx, 0, ny); |
if (s->sel != NULL && screen_size_y(s) > ny) |
if (s->sel != NULL && screen_size_y(s) > ny) |
window_copy_write_line(wp, &ctx, ny); |
window_copy_write_line(wme, &ctx, ny); |
else if (ny == 1) /* nuke position */ |
else if (ny == 1) /* nuke position */ |
window_copy_write_line(wp, &ctx, 1); |
window_copy_write_line(wme, &ctx, 1); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
screen_write_cursormove(&ctx, data->cx, data->cy); |
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
} |
} |
|
|
static void |
static void |
window_copy_rectangle_toggle(struct window_pane *wp) |
window_copy_rectangle_toggle(struct window_mode_entry *wme) |
{ |
{ |
struct window_copy_mode_data *data = wp->modedata; |
struct window_copy_mode_data *data = wme->data; |
u_int px, py; |
u_int px, py; |
|
|
data->rectflag = !data->rectflag; |
data->rectflag = !data->rectflag; |
|
|
py = screen_hsize(data->backing) + data->cy - data->oy; |
py = screen_hsize(data->backing) + data->cy - data->oy; |
px = window_copy_find_length(wp, py); |
px = window_copy_find_length(wme, py); |
if (data->cx > px) |
if (data->cx > px) |
window_copy_update_cursor(wp, px, data->cy); |
window_copy_update_cursor(wme, px, data->cy); |
|
|
window_copy_update_selection(wp, 1); |
window_copy_update_selection(wme, 1); |
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wme); |
} |
} |
|
|
static void |
static void |
|
|
u_int x, y; |
u_int x, y; |
|
|
wp = cmd_mouse_pane(m, NULL, NULL); |
wp = cmd_mouse_pane(m, NULL, NULL); |
if (wp == NULL || wp->mode != &window_copy_mode) |
if (wp == NULL || |
|
wp->mode == NULL || |
|
wp->mode->mode != &window_copy_mode) |
return; |
return; |
|
|
if (cmd_mouse_at(wp, m, &x, &y, 0) != 0) |
if (cmd_mouse_at(wp, m, &x, &y, 0) != 0) |
return; |
return; |
|
|
window_copy_update_cursor(wp, x, y); |
window_copy_update_cursor(wp->mode, x, y); |
} |
} |
|
|
void |
void |
|
|
return; |
return; |
|
|
wp = cmd_mouse_pane(m, NULL, NULL); |
wp = cmd_mouse_pane(m, NULL, NULL); |
if (wp == NULL || wp->mode != &window_copy_mode) |
if (wp == NULL || |
|
wp->mode == NULL || |
|
wp->mode->mode != &window_copy_mode) |
return; |
return; |
|
|
if (cmd_mouse_at(wp, m, &x, &y, 1) != 0) |
if (cmd_mouse_at(wp, m, &x, &y, 1) != 0) |
|
|
c->tty.mouse_drag_update = window_copy_drag_update; |
c->tty.mouse_drag_update = window_copy_drag_update; |
c->tty.mouse_drag_release = NULL; /* will fire MouseDragEnd key */ |
c->tty.mouse_drag_release = NULL; /* will fire MouseDragEnd key */ |
|
|
window_copy_update_cursor(wp, x, y); |
window_copy_update_cursor(wp->mode, x, y); |
window_copy_start_selection(wp); |
window_copy_start_selection(wp->mode); |
window_copy_redraw_screen(wp); |
window_copy_redraw_screen(wp->mode); |
} |
} |
|
|
static void |
static void |
|
|
u_int x, y, old_cy; |
u_int x, y, old_cy; |
|
|
wp = cmd_mouse_pane(m, NULL, NULL); |
wp = cmd_mouse_pane(m, NULL, NULL); |
if (wp == NULL || wp->mode != &window_copy_mode) |
if (wp == NULL || |
|
wp->mode == NULL || |
|
wp->mode->mode != &window_copy_mode) |
return; |
return; |
data = wp->modedata; |
data = wp->mode->data; |
|
|
if (cmd_mouse_at(wp, m, &x, &y, 0) != 0) |
if (cmd_mouse_at(wp, m, &x, &y, 0) != 0) |
return; |
return; |
old_cy = data->cy; |
old_cy = data->cy; |
|
|
window_copy_update_cursor(wp, x, y); |
window_copy_update_cursor(wp->mode, x, y); |
if (window_copy_update_selection(wp, 1)) |
if (window_copy_update_selection(wp->mode, 1)) |
window_copy_redraw_selection(wp, old_cy); |
window_copy_redraw_selection(wp->mode, old_cy); |
} |
} |