mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Merge branch 'obsd-master'
Sync from OpenBSD.
This commit is contained in:
commit
739a76634c
@ -30,7 +30,7 @@
|
||||
enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||
|
||||
void cmd_paste_buffer_filter(struct window_pane *,
|
||||
const char *, size_t, const char *, int bracket);
|
||||
const char *, size_t, const char *, int);
|
||||
|
||||
const struct cmd_entry cmd_paste_buffer_entry = {
|
||||
"paste-buffer", "pasteb",
|
||||
@ -86,9 +86,8 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
else
|
||||
sepstr = "\r";
|
||||
}
|
||||
pflag = args_has(args, 'p') &&
|
||||
(wp->screen->mode & MODE_BRACKETPASTE);
|
||||
cmd_paste_buffer_filter(wp, pb->data, pb->size, sepstr, pflag);
|
||||
pflag = (wp->screen->mode & MODE_BRACKETPASTE);
|
||||
paste_send_pane(pb, wp, sepstr, args_has(args, 'p') && pflag);
|
||||
}
|
||||
|
||||
/* Delete the buffer if -d. */
|
||||
@ -101,30 +100,3 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
/* Add bytes to a buffer and filter '\n' according to separator. */
|
||||
void
|
||||
cmd_paste_buffer_filter(struct window_pane *wp,
|
||||
const char *data, size_t size, const char *sep, int bracket)
|
||||
{
|
||||
const char *end = data + size;
|
||||
const char *lf;
|
||||
size_t seplen;
|
||||
|
||||
if (bracket)
|
||||
bufferevent_write(wp->event, "\033[200~", 6);
|
||||
|
||||
seplen = strlen(sep);
|
||||
while ((lf = memchr(data, '\n', end - data)) != NULL) {
|
||||
if (lf != data)
|
||||
bufferevent_write(wp->event, data, lf - data);
|
||||
bufferevent_write(wp->event, sep, seplen);
|
||||
data = lf + 1;
|
||||
}
|
||||
|
||||
if (end != data)
|
||||
bufferevent_write(wp->event, data, end - data);
|
||||
|
||||
if (bracket)
|
||||
bufferevent_write(wp->event, "\033[201~", 6);
|
||||
}
|
||||
|
15
input-keys.c
15
input-keys.c
@ -201,8 +201,9 @@ input_key(struct window_pane *wp, int key)
|
||||
void
|
||||
input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
|
||||
{
|
||||
char buf[10];
|
||||
size_t len;
|
||||
char buf[10];
|
||||
size_t len;
|
||||
struct paste_buffer *pb;
|
||||
|
||||
if (wp->screen->mode & ALL_MOUSE_MODES) {
|
||||
if (wp->screen->mode & MODE_MOUSE_UTF8) {
|
||||
@ -222,13 +223,19 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
|
||||
return;
|
||||
}
|
||||
|
||||
if ((m->xb & 3) != 1 &&
|
||||
if (m->button == 1 && (m->event & MOUSE_EVENT_CLICK) &&
|
||||
options_get_number(&wp->window->options, "mode-mouse") == 1) {
|
||||
pb = paste_get_top(&global_buffers);
|
||||
if (pb != NULL) {
|
||||
paste_send_pane(pb, wp, "\r",
|
||||
wp->screen->mode & MODE_BRACKETPASTE);
|
||||
}
|
||||
} else if ((m->xb & 3) != 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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
12
input.c
12
input.c
@ -1255,8 +1255,12 @@ input_csi_dispatch(struct input_ctx *ictx)
|
||||
case 1005:
|
||||
screen_write_utf8mousemode(&ictx->ctx, 0);
|
||||
break;
|
||||
case 47:
|
||||
case 1047:
|
||||
window_pane_alternate_off(wp, &ictx->cell, 0);
|
||||
break;
|
||||
case 1049:
|
||||
window_pane_alternate_off(wp, &ictx->cell);
|
||||
window_pane_alternate_off(wp, &ictx->cell, 1);
|
||||
break;
|
||||
case 2004:
|
||||
screen_write_bracketpaste(&ictx->ctx, 0);
|
||||
@ -1310,8 +1314,12 @@ input_csi_dispatch(struct input_ctx *ictx)
|
||||
case 1005:
|
||||
screen_write_utf8mousemode(&ictx->ctx, 1);
|
||||
break;
|
||||
case 47:
|
||||
case 1047:
|
||||
window_pane_alternate_on(wp, &ictx->cell, 0);
|
||||
break;
|
||||
case 1049:
|
||||
window_pane_alternate_on(wp, &ictx->cell);
|
||||
window_pane_alternate_on(wp, &ictx->cell, 1);
|
||||
break;
|
||||
case 2004:
|
||||
screen_write_bracketpaste(&ictx->ctx, 1);
|
||||
|
26
paste.c
26
paste.c
@ -166,3 +166,29 @@ paste_print(struct paste_buffer *pb, size_t width)
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/* Paste into a window pane, filtering '\n' according to separator. */
|
||||
void
|
||||
paste_send_pane (struct paste_buffer *pb, struct window_pane *wp,
|
||||
const char *sep, int bracket)
|
||||
{
|
||||
const char *data = pb->data, *end = data + pb->size, *lf;
|
||||
size_t seplen;
|
||||
|
||||
if (bracket)
|
||||
bufferevent_write(wp->event, "\033[200~", 6);
|
||||
|
||||
seplen = strlen(sep);
|
||||
while ((lf = memchr(data, '\n', end - data)) != NULL) {
|
||||
if (lf != data)
|
||||
bufferevent_write(wp->event, data, lf - data);
|
||||
bufferevent_write(wp->event, sep, seplen);
|
||||
data = lf + 1;
|
||||
}
|
||||
|
||||
if (end != data)
|
||||
bufferevent_write(wp->event, data, end - data);
|
||||
|
||||
if (bracket)
|
||||
bufferevent_write(wp->event, "\033[201~", 6);
|
||||
}
|
||||
|
17
tmux.h
17
tmux.h
@ -1678,8 +1678,8 @@ const char *tty_term_string2(
|
||||
struct tty_term *, enum tty_code_code, int, int);
|
||||
const char *tty_term_ptr1(
|
||||
struct tty_term *, enum tty_code_code, const void *);
|
||||
const char *tty_term_ptr2(
|
||||
struct tty_term *, enum tty_code_code, const void *, const void *);
|
||||
const char *tty_term_ptr2(struct tty_term *, enum tty_code_code,
|
||||
const void *, const void *);
|
||||
int tty_term_number(struct tty_term *, enum tty_code_code);
|
||||
int tty_term_flag(struct tty_term *, enum tty_code_code);
|
||||
|
||||
@ -1700,6 +1700,9 @@ int paste_free_index(struct paste_stack *, u_int);
|
||||
void paste_add(struct paste_stack *, char *, size_t, u_int);
|
||||
int paste_replace(struct paste_stack *, u_int, char *, size_t);
|
||||
char *paste_print(struct paste_buffer *, size_t);
|
||||
void paste_send_pane(struct paste_buffer *, struct window_pane *,
|
||||
const char *, int);
|
||||
|
||||
|
||||
/* clock.c */
|
||||
extern const char clock_table[14][5][5];
|
||||
@ -1902,7 +1905,7 @@ void server_unlink_window(struct session *, struct winlink *);
|
||||
void server_destroy_pane(struct window_pane *);
|
||||
void server_destroy_session_group(struct session *);
|
||||
void server_destroy_session(struct session *);
|
||||
void server_check_unattached (void);
|
||||
void server_check_unattached(void);
|
||||
void server_set_identify(struct client *);
|
||||
void server_clear_identify(struct client *);
|
||||
void server_update_event(struct client *);
|
||||
@ -2141,10 +2144,10 @@ int window_pane_spawn(struct window_pane *, const char *,
|
||||
const char *, const char *, struct environ *,
|
||||
struct termios *, char **);
|
||||
void window_pane_resize(struct window_pane *, u_int, u_int);
|
||||
void window_pane_alternate_on(
|
||||
struct window_pane *, struct grid_cell *);
|
||||
void window_pane_alternate_off(
|
||||
struct window_pane *, struct grid_cell *);
|
||||
void window_pane_alternate_on(struct window_pane *,
|
||||
struct grid_cell *, int);
|
||||
void window_pane_alternate_off(struct window_pane *,
|
||||
struct grid_cell *, int);
|
||||
int window_pane_set_mode(
|
||||
struct window_pane *, const struct window_mode *);
|
||||
void window_pane_reset_mode(struct window_pane *);
|
||||
|
18
window.c
18
window.c
@ -877,7 +877,8 @@ window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
|
||||
* history is not updated
|
||||
*/
|
||||
void
|
||||
window_pane_alternate_on(struct window_pane *wp, struct grid_cell *gc)
|
||||
window_pane_alternate_on(struct window_pane *wp, struct grid_cell *gc,
|
||||
int cursor)
|
||||
{
|
||||
struct screen *s = &wp->base;
|
||||
u_int sx, sy;
|
||||
@ -891,8 +892,10 @@ window_pane_alternate_on(struct window_pane *wp, struct grid_cell *gc)
|
||||
|
||||
wp->saved_grid = grid_create(sx, sy, 0);
|
||||
grid_duplicate_lines(wp->saved_grid, 0, s->grid, screen_hsize(s), sy);
|
||||
wp->saved_cx = s->cx;
|
||||
wp->saved_cy = s->cy;
|
||||
if (cursor) {
|
||||
wp->saved_cx = s->cx;
|
||||
wp->saved_cy = s->cy;
|
||||
}
|
||||
memcpy(&wp->saved_cell, gc, sizeof wp->saved_cell);
|
||||
|
||||
grid_view_clear(s->grid, 0, 0, sx, sy);
|
||||
@ -904,7 +907,8 @@ window_pane_alternate_on(struct window_pane *wp, struct grid_cell *gc)
|
||||
|
||||
/* Exit alternate screen mode and restore the copied grid. */
|
||||
void
|
||||
window_pane_alternate_off(struct window_pane *wp, struct grid_cell *gc)
|
||||
window_pane_alternate_off(struct window_pane *wp, struct grid_cell *gc,
|
||||
int cursor)
|
||||
{
|
||||
struct screen *s = &wp->base;
|
||||
u_int sx, sy;
|
||||
@ -925,10 +929,12 @@ window_pane_alternate_off(struct window_pane *wp, struct grid_cell *gc)
|
||||
|
||||
/* Restore the grid, cursor position and cell. */
|
||||
grid_duplicate_lines(s->grid, screen_hsize(s), wp->saved_grid, 0, sy);
|
||||
s->cx = wp->saved_cx;
|
||||
if (cursor)
|
||||
s->cx = wp->saved_cx;
|
||||
if (s->cx > screen_size_x(s) - 1)
|
||||
s->cx = screen_size_x(s) - 1;
|
||||
s->cy = wp->saved_cy;
|
||||
if (cursor)
|
||||
s->cy = wp->saved_cy;
|
||||
if (s->cy > screen_size_y(s) - 1)
|
||||
s->cy = screen_size_y(s) - 1;
|
||||
memcpy(gc, &wp->saved_cell, sizeof *gc);
|
||||
|
Loading…
Reference in New Issue
Block a user