Skip to content

Commit

Permalink
Tidy up mode-mouse check.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicm committed Nov 5, 2014
1 parent d24c9d7 commit 79f5282
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
4 changes: 1 addition & 3 deletions cmd-paste-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
struct session *s;
struct paste_buffer *pb;
const char *sepstr, *bufname;
int pflag;

if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
return (CMD_RETURN_ERROR);
Expand All @@ -76,8 +75,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
else
sepstr = "\r";
}
pflag = (wp->screen->mode & MODE_BRACKETPASTE);
paste_send_pane(pb, wp, sepstr, args_has(args, 'p') && pflag);
paste_send_pane(pb, wp, sepstr, args_has(args, 'p'));
}

/* Delete the buffer if -d. */
Expand Down
24 changes: 11 additions & 13 deletions input-keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
char buf[40];
size_t len;
struct paste_buffer *pb;
int event;

if (wp->screen->mode & ALL_MOUSE_MODES) {
/*
Expand Down Expand Up @@ -238,19 +239,16 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
return;
}

if (m->button == 1 && (m->event & MOUSE_EVENT_CLICK) &&
options_get_number(&wp->window->options, "mode-mouse") == 1) {
if (options_get_number(&wp->window->options, "mode-mouse") != 1)
return;
event = m->event & (MOUSE_EVENT_CLICK|MOUSE_EVENT_WHEEL);
if (wp->mode == NULL && m->button == 1 && event == MOUSE_EVENT_CLICK) {
pb = paste_get_top();
if (pb != NULL) {
paste_send_pane(pb, wp, "\r",
wp->screen->mode & MODE_BRACKETPASTE);
}
} else if (m->button != 1 &&
options_get_number(&wp->window->options, "mode-mouse") == 1) {
if (window_pane_set_mode(wp, &window_copy_mode) == 0) {
window_copy_init_from_pane(wp);
if (wp->mode->mouse != NULL)
wp->mode->mouse(wp, s, m);
}
if (pb != NULL)
paste_send_pane(pb, wp, "\r", 1);
} else if (window_pane_set_mode(wp, &window_copy_mode) == 0) {
window_copy_init_from_pane(wp);
if (wp->mode->mouse != NULL)
wp->mode->mouse(wp, s, m);
}
}
4 changes: 2 additions & 2 deletions paste.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ paste_send_pane(struct paste_buffer *pb, struct window_pane *wp,
if (wp->flags & PANE_INPUTOFF)
return;

if (bracket)
if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
bufferevent_write(wp->event, "\033[200~", 6);

seplen = strlen(sep);
Expand All @@ -315,6 +315,6 @@ paste_send_pane(struct paste_buffer *pb, struct window_pane *wp,
if (end != data)
bufferevent_write(wp->event, data, end - data);

if (bracket)
if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
bufferevent_write(wp->event, "\033[201~", 6);
}

0 comments on commit 79f5282

Please sign in to comment.