mirror of
https://github.com/tmux/tmux.git
synced 2025-01-14 20:58:53 +00:00
Sync OpenBSD patchset 373:
New option, mouse-select-pane. If on, the mouse may be used to select the current pane. Suggested by sthen@ and also by someone else ages ago who I have forgotten.
This commit is contained in:
parent
2486a36af3
commit
ea1721bcb0
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-set-option.c,v 1.82 2009-10-11 23:30:28 tcunha Exp $ */
|
/* $Id: cmd-set-option.c,v 1.83 2009-10-11 23:46:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -67,6 +67,7 @@ const struct set_option_entry set_option_table[] = {
|
|||||||
{ "message-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
{ "message-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
|
||||||
{ "message-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
{ "message-bg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
{ "message-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
{ "message-fg", SET_OPTION_COLOUR, 0, 0, NULL },
|
||||||
|
{ "mouse-select-pane", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
{ "prefix", SET_OPTION_KEYS, 0, 0, NULL },
|
{ "prefix", SET_OPTION_KEYS, 0, 0, NULL },
|
||||||
{ "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
{ "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
|
||||||
{ "set-remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
{ "set-remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
17
server.c
17
server.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server.c,v 1.198 2009-10-11 23:38:16 tcunha Exp $ */
|
/* $Id: server.c,v 1.199 2009-10-11 23:46:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -828,6 +828,7 @@ server_handle_client(struct client *c)
|
|||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct screen *s;
|
struct screen *s;
|
||||||
|
struct options *oo;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
struct keylist *keylist;
|
struct keylist *keylist;
|
||||||
@ -852,6 +853,7 @@ server_handle_client(struct client *c)
|
|||||||
c->session->activity = time(NULL);
|
c->session->activity = time(NULL);
|
||||||
w = c->session->curw->window;
|
w = c->session->curw->window;
|
||||||
wp = w->active; /* could die */
|
wp = w->active; /* could die */
|
||||||
|
oo = &c->session->options;
|
||||||
|
|
||||||
/* Special case: number keys jump to pane in identify mode. */
|
/* Special case: number keys jump to pane in identify mode. */
|
||||||
if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') {
|
if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') {
|
||||||
@ -871,6 +873,10 @@ server_handle_client(struct client *c)
|
|||||||
|
|
||||||
/* Check for mouse keys. */
|
/* Check for mouse keys. */
|
||||||
if (key == KEYC_MOUSE) {
|
if (key == KEYC_MOUSE) {
|
||||||
|
if (options_get_number(oo, "mouse-select-pane")) {
|
||||||
|
window_set_active_at(w, mouse[1], mouse[2]);
|
||||||
|
wp = w->active;
|
||||||
|
}
|
||||||
window_pane_mouse(wp, c, mouse[0], mouse[1], mouse[2]);
|
window_pane_mouse(wp, c, mouse[0], mouse[1], mouse[2]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -938,7 +944,9 @@ server_handle_client(struct client *c)
|
|||||||
}
|
}
|
||||||
if (c->session == NULL)
|
if (c->session == NULL)
|
||||||
return;
|
return;
|
||||||
wp = c->session->curw->window->active; /* could die - do each loop */
|
w = c->session->curw->window;
|
||||||
|
wp = w->active;
|
||||||
|
oo = &c->session->options;
|
||||||
s = wp->screen;
|
s = wp->screen;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -951,7 +959,7 @@ server_handle_client(struct client *c)
|
|||||||
* tty_region/tty_reset/tty_update_mode already take care of not
|
* tty_region/tty_reset/tty_update_mode already take care of not
|
||||||
* resetting things that are already in their default state.
|
* resetting things that are already in their default state.
|
||||||
*/
|
*/
|
||||||
status = options_get_number(&c->session->options, "status");
|
status = options_get_number(oo, "status");
|
||||||
tty_region(&c->tty, 0, c->tty.sy - 1, 0);
|
tty_region(&c->tty, 0, c->tty.sy - 1, 0);
|
||||||
if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - status)
|
if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - status)
|
||||||
tty_cursor(&c->tty, 0, 0, 0, 0);
|
tty_cursor(&c->tty, 0, 0, 0, 0);
|
||||||
@ -959,6 +967,9 @@ server_handle_client(struct client *c)
|
|||||||
tty_cursor(&c->tty, s->cx, s->cy, wp->xoff, wp->yoff);
|
tty_cursor(&c->tty, s->cx, s->cy, wp->xoff, wp->yoff);
|
||||||
|
|
||||||
mode = s->mode;
|
mode = s->mode;
|
||||||
|
if (TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry) != NULL &&
|
||||||
|
options_get_number(oo, "mouse-select-pane"))
|
||||||
|
mode |= MODE_MOUSE;
|
||||||
tty_update_mode(&c->tty, mode);
|
tty_update_mode(&c->tty, mode);
|
||||||
tty_reset(&c->tty);
|
tty_reset(&c->tty);
|
||||||
}
|
}
|
||||||
|
12
tmux.1
12
tmux.1
@ -1,4 +1,4 @@
|
|||||||
.\" $Id: tmux.1,v 1.183 2009-10-11 23:38:16 tcunha Exp $
|
.\" $Id: tmux.1,v 1.184 2009-10-11 23:46:02 tcunha Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
.\"
|
.\"
|
||||||
@ -1292,7 +1292,7 @@ with
|
|||||||
.Op Ic on | off
|
.Op Ic on | off
|
||||||
.Xc
|
.Xc
|
||||||
If this option is
|
If this option is
|
||||||
.Ic on
|
.Ic on
|
||||||
(the default),
|
(the default),
|
||||||
instead of each session locking individually as each has been
|
instead of each session locking individually as each has been
|
||||||
idle for
|
idle for
|
||||||
@ -1336,6 +1336,14 @@ from the 256-colour palette, or
|
|||||||
.Ic default .
|
.Ic default .
|
||||||
.It Ic message-fg Ar colour
|
.It Ic message-fg Ar colour
|
||||||
Set status line message foreground colour.
|
Set status line message foreground colour.
|
||||||
|
.It Xo Ic mouse-select-pane
|
||||||
|
.Op Ic on | off
|
||||||
|
.Xc
|
||||||
|
If on,
|
||||||
|
.Nm
|
||||||
|
captures the mouse and when a window is split into multiple panes the mouse may
|
||||||
|
be used to select the current pane.
|
||||||
|
The mouse click is also passed through to the application as normal.
|
||||||
.It Ic prefix Ar keys
|
.It Ic prefix Ar keys
|
||||||
Set the keys accepted as a prefix key.
|
Set the keys accepted as a prefix key.
|
||||||
.Ar keys
|
.Ar keys
|
||||||
|
3
tmux.c
3
tmux.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.c,v 1.177 2009-10-11 23:30:28 tcunha Exp $ */
|
/* $Id: tmux.c,v 1.178 2009-10-11 23:46:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -390,6 +390,7 @@ main(int argc, char **argv)
|
|||||||
options_set_number(so, "message-attr", 0);
|
options_set_number(so, "message-attr", 0);
|
||||||
options_set_number(so, "message-bg", 3);
|
options_set_number(so, "message-bg", 3);
|
||||||
options_set_number(so, "message-fg", 0);
|
options_set_number(so, "message-fg", 0);
|
||||||
|
options_set_number(so, "mouse-select-pane", 0);
|
||||||
options_set_number(so, "repeat-time", 500);
|
options_set_number(so, "repeat-time", 500);
|
||||||
options_set_number(so, "set-remain-on-exit", 0);
|
options_set_number(so, "set-remain-on-exit", 0);
|
||||||
options_set_number(so, "set-titles", 0);
|
options_set_number(so, "set-titles", 0);
|
||||||
|
3
tmux.h
3
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.462 2009-10-11 23:38:16 tcunha Exp $ */
|
/* $Id: tmux.h,v 1.463 2009-10-11 23:46:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -1646,6 +1646,7 @@ struct window *window_create(const char *, const char *, const char *,
|
|||||||
const char *, struct environ *, struct termios *,
|
const char *, struct environ *, struct termios *,
|
||||||
u_int, u_int, u_int, char **);
|
u_int, u_int, u_int, char **);
|
||||||
void window_destroy(struct window *);
|
void window_destroy(struct window *);
|
||||||
|
void window_set_active_at(struct window *, u_int, u_int);
|
||||||
void window_set_active_pane(struct window *, struct window_pane *);
|
void window_set_active_pane(struct window *, struct window_pane *);
|
||||||
struct window_pane *window_add_pane(struct window *, u_int);
|
struct window_pane *window_add_pane(struct window *, u_int);
|
||||||
void window_resize(struct window *, u_int, u_int);
|
void window_resize(struct window *, u_int, u_int);
|
||||||
|
19
window.c
19
window.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: window.c,v 1.111 2009-10-11 23:38:16 tcunha Exp $ */
|
/* $Id: window.c,v 1.112 2009-10-11 23:46:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -302,6 +302,23 @@ window_set_active_pane(struct window *w, struct window_pane *wp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
window_set_active_at(struct window *w, u_int x, u_int y)
|
||||||
|
{
|
||||||
|
struct window_pane *wp;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
|
if (!window_pane_visible(wp))
|
||||||
|
continue;
|
||||||
|
if (x < wp->xoff || x >= wp->xoff + wp->sx)
|
||||||
|
continue;
|
||||||
|
if (y < wp->yoff || y >= wp->yoff + wp->sy)
|
||||||
|
continue;
|
||||||
|
window_set_active_pane(w, wp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct window_pane *
|
struct window_pane *
|
||||||
window_add_pane(struct window *w, u_int hlimit)
|
window_add_pane(struct window *w, u_int hlimit)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user