Update of /cvsroot/tmux/tmux
In directory vz-cvs-2.sog:/tmp/cvs-serv31852
Modified Files:
layout.c options-table.c server-client.c tmux.1 tmux.h
Log Message:
Sync OpenBSD patchset 905:
Add a new option, mouse-resize-pane. When on, panes may be resized by
dragging their borders. From hsim at gmx.li.
Index: server-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-client.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- server-client.c 5 May 2011 10:12:33 -0000 1.59
+++ server-client.c 18 May 2011 20:30:14 -0000 1.60
@@ -88,6 +88,9 @@
c->prompt_buffer = NULL;
c->prompt_index = 0;
+ c->last_mouse.b = MOUSE_UP;
+ c->last_mouse.x = c->last_mouse.y = -1;
+
evtimer_set(&c->repeat_timer, server_client_repeat_timer, c);
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
@@ -343,6 +346,9 @@
return;
}
}
+ if (options_get_number(oo, "mouse-resize-pane"))
+ layout_resize_pane_mouse(c, mouse);
+ memcpy(&c->last_mouse, mouse, sizeof c->last_mouse);
window_pane_mouse(wp, c->session, mouse);
return;
}
@@ -475,14 +481,24 @@
tty_cursor(&c->tty, wp->xoff + s->cx, wp->yoff + s->cy);
/*
+ * Resizing panes with the mouse requires at least button mode to give
+ * a smooth appearance.
+ */
+ mode = s->mode;
+ if ((c->last_mouse.b & MOUSE_RESIZE_PANE) &&
+ !(mode & (MODE_MOUSE_BUTTON|MODE_MOUSE_ANY)))
+ mode |= MODE_MOUSE_BUTTON;
+
+ /*
* Any mode will do for mouse-select-pane, but set standard mode if
* none.
*/
- mode = s->mode;
if ((mode & ALL_MOUSE_MODES) == 0) {
if (TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry) != NULL &&
options_get_number(oo, "mouse-select-pane"))
mode |= MODE_MOUSE_STANDARD;
+ else if (options_get_number(oo, "mouse-resize-pane"))
+ mode |= MODE_MOUSE_STANDARD;
else if (options_get_number(oo, "mouse-select-window"))
mode |= MODE_MOUSE_STANDARD;
else if (options_get_number(wo, "mode-mouse"))
Index: layout.c
===================================================================
RCS file: /cvsroot/tmux/tmux/layout.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- layout.c 2 Jul 2010 02:54:52 -0000 1.19
+++ layout.c 18 May 2011 20:30:14 -0000 1.20
@@ -485,6 +485,53 @@
layout_fix_panes(wp->window, wp->window->sx, wp->window->sy);
}
+void
+layout_resize_pane_mouse(struct client *c, struct mouse_event *mouse)
+{
+ struct window *w;
+ struct window_pane *wp;
+ int pane_border;
+
+ w = c->session->curw->window;
+
+ pane_border = 0;
+ if ((c->last_mouse.b & MOUSE_BUTTON) != MOUSE_UP &&
+ (c->last_mouse.b & MOUSE_RESIZE_PANE)) {
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if (wp->xoff + wp->sx == c->last_mouse.x &&
+ wp->yoff <= 1 + c->last_mouse.y &&
+ wp->yoff + wp->sy >= c->last_mouse.y) {
+ layout_resize_pane(wp, LAYOUT_LEFTRIGHT,
+ mouse->x -
c->last_mouse.x);
+ pane_border = 1;
+ }
+ if (wp->yoff + wp->sy == c->last_mouse.y &&
+ wp->xoff <= 1 + c->last_mouse.x &&
+ wp->xoff + wp->sx >= c->last_mouse.x) {
+ layout_resize_pane(wp, LAYOUT_TOPBOTTOM,
+ mouse->y -
c->last_mouse.y);
+ pane_border = 1;
+ }
+ }
+ if (pane_border)
+ server_redraw_window(w);
+ } else if (mouse->b != MOUSE_UP &&
+ mouse->b == (mouse->b & MOUSE_BUTTON)) {
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if ((wp->xoff + wp->sx == mouse->x &&
+ wp->yoff <= 1 + mouse->y &&
+ wp->yoff + wp->sy >= mouse->y) ||
+ (wp->yoff + wp->sy == mouse->y &&
+ wp->xoff <= 1 + mouse->x &&
+ wp->xoff + wp->sx >= mouse->x)) {
+ pane_border = 1;
+ }
+ }
+ }
+ if (pane_border)
+ mouse->b |= MOUSE_RESIZE_PANE;
+}
+
int
layout_resize_pane_grow(
struct layout_cell *lc, enum layout_type type, int needed)
Index: options-table.c
===================================================================
RCS file: /cvsroot/tmux/tmux/options-table.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- options-table.c 18 May 2011 20:28:40 -0000 1.8
+++ options-table.c 18 May 2011 20:30:14 -0000 1.9
@@ -192,6 +192,11 @@
.default_num = 20
},
+ { .name = "mouse-resize-pane",
+ .type = OPTIONS_TABLE_FLAG,
+ .default_num = 0
+ },
+
{ .name = "mouse-select-pane",
.type = OPTIONS_TABLE_FLAG,
.default_num = 0
Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.622
retrieving revision 1.623
diff -u -d -r1.622 -r1.623
--- tmux.h 18 May 2011 20:28:41 -0000 1.622
+++ tmux.h 18 May 2011 20:30:14 -0000 1.623
@@ -1082,6 +1082,7 @@
#define MOUSE_BUTTON 3
#define MOUSE_DRAG 32
#define MOUSE_45 64
+#define MOUSE_RESIZE_PANE 128 /* marker for resizing */
u_int x;
u_int y;
};
@@ -1173,6 +1174,8 @@
struct session *session;
struct session *last_session;
+ struct mouse_event last_mouse;
+
int references;
};
ARRAY_DECL(clients, struct client *);
@@ -1921,6 +1924,8 @@
void layout_resize(struct window *, u_int, u_int);
void layout_resize_pane(
struct window_pane *, enum layout_type, int);
+void layout_resize_pane_mouse(
+ struct client *c, struct mouse_event *mouse);
void layout_assign_pane(struct layout_cell *, struct window_pane *);
struct layout_cell *layout_split_pane(
struct window_pane *, enum layout_type, int);
Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.311
retrieving revision 1.312
diff -u -d -r1.311 -r1.312
--- tmux.1 18 May 2011 20:28:40 -0000 1.311
+++ tmux.1 18 May 2011 20:30:14 -0000 1.312
@@ -1892,6 +1892,12 @@
Set the number of error or information messages to save in the message log for
each client.
The default is 20.
+.It Xo Ic mouse-resize-pane
+.Op Ic on | off
+.Xc
+If on,
+.Nm
+captures the mouse and allows panes to be resized by dragging on their borders.
.It Xo Ic mouse-select-pane
.Op Ic on | off
.Xc
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs