Hi there fellow h4x0rz ;)
just wanted to have a comment on these, will finalize them after my exam
end of the month...

tmux-quiet-set-option.patch:
still useful, my use case is setting option window-status-fg when
splitting a window with su -l [different user]

tmux-recalculate-window-size-on-mouse-select-window.patch:
without this windows resize only by keyboard traversal (=>
cmd_select_window_exec()).
Should recalculate_sizes() not really go into server_redraw_session() ?

tmux-border-mark-active-pane-v2.patch:
Wanted to have this since long time, please comment on its implementation..
renamed screen_redraw_cell_border[1]() to
screen_redraw_cell_is_border[_of_wp]() for clarity. Still needs option -
"pane-active-indicator"?

tmux-mouse-wheel-scrolling.patch:
After the recent changes the mouse handling so my implementation of a
mouse event queue that can be used for status-line click gestures like
'ctrl+alt+middle click twice within 400ms to kill window' is postponed
for some more. However, this is split off for added pwnage :D
It emulates mouse scrolling for non-mouse-aware term apps by sending
cursor-up/down input, like in some other terminal emulators like KDE's
konsole.
SHIFT+Scroll scrolls single lines, CTRL+Scroll triples scroll speed.
Works well with less, bash history..
MOUSE_SCROLL_LINES will be made into a user option in next patch iteration.

tmux-exit-mouse-copy-mode-less-aggressively-and-adv-wheel-scroll-v3.patch:
For mode-mouse=copy-mode, do not exit copy-mode when scrolling to the
bottom or click-selecting pane in copy mode. Also has the SHIFT/CTRL
scroll modifier stuff from above patch in it.

ok that's it for now, happy hacking and thx everyone for their
contributions of my favorite desktop app ;)
#regards|marcel
--- tmux.1.orig	2011-08-19 21:32:13.965656225 +0200
+++ tmux.1	2011-08-19 22:07:20.097283462 +0200
@@ -1689,7 +1689,7 @@
 Commands which set options are as follows:
 .Bl -tag -width Ds
 .It Xo Ic set-option
-.Op Fl agsuw
+.Op Fl agqsuw
 .Op Fl t Ar target-session | Ar target-window
 .Ar option Ar value
 .Xc
@@ -1717,6 +1717,10 @@
 options.
 It is not possible to unset a global option.
 .Pp
+The
+.Fl q
+flag surpresses reporting to the status bar.
+.Pp
 Available window options are listed under
 .Ic set-window-option .
 .Pp
@@ -2246,7 +2250,7 @@
 is enabled, prints a message after the interval has expired on a given window.
 .El
 .It Xo Ic set-window-option
-.Op Fl agu
+.Op Fl agqu
 .Op Fl t Ar target-window
 .Ar option Ar value
 .Xc
@@ -2254,7 +2258,8 @@
 Set a window option.
 The
 .Fl a ,
-.Fl g
+.Fl g ,
+.Fl q
 and
 .Fl u
 flags work similarly to the
--- cmd-set-option.c.orig	2011-08-19 21:32:13.943656538 +0200
+++ cmd-set-option.c	2011-08-19 22:10:24.969744589 +0200
@@ -63,7 +63,7 @@
 
 const struct cmd_entry cmd_set_option_entry = {
 	"set-option", "set",
-	"agst:uw", 1, 2,
+	"agqst:uw", 1, 2,
 	"[-agsuw] [-t target-session|target-window] option [value]",
 	0,
 	NULL,
@@ -73,7 +73,7 @@
 
 const struct cmd_entry cmd_set_window_option_entry = {
 	"set-window-option", "setw",
-	"agt:u", 1, 2,
+	"agqt:u", 1, 2,
 	"[-agu] " CMD_TARGET_WINDOW_USAGE " option [value]",
 	0,
 	NULL,
@@ -211,7 +211,8 @@
 	}
 
 	options_remove(oo, oe->name);
-	ctx->info(ctx, "unset option: %s", oe->name);
+	if (!args_has(args, 'q'))
+		ctx->info(ctx, "unset option: %s", oe->name);
 	return (0);
 }
 
@@ -256,7 +257,8 @@
 		return (-1);
 
 	s = options_table_print_entry(oe, o);
-	ctx->info(ctx, "set option: %s -> %s", oe->name, s);
+	if (!args_has(self->args, 'q'))
+		ctx->info(ctx, "set option: %s -> %s", oe->name, s);
 	return (0);
 }
 
--- server-client.c.orig	2012-03-13 05:02:12.307307730 +0100
+++ server-client.c	2012-03-13 05:11:00.481854908 +0100
@@ -279,16 +279,19 @@ server_client_check_mouse(
 	    options_get_number(oo, "mouse-select-window")) {
 		if (mouse->b == MOUSE_UP && c->last_mouse.b != MOUSE_UP) {
 			status_set_window_at(c, mouse->x);
+			recalculate_sizes();
 			return;
 		}
 		if (mouse->b & MOUSE_45) {
 			if ((mouse->b & MOUSE_BUTTON) == MOUSE_1) {
 				session_previous(c->session, 0);
 				server_redraw_session(s);
+				recalculate_sizes();
 			}
 			if ((mouse->b & MOUSE_BUTTON) == MOUSE_2) {
 				session_next(c->session, 0);
 				server_redraw_session(s);
+				recalculate_sizes();
 			}
 			return;
 		}
--- screen-redraw.c.orig	2012-03-13 02:56:16.304668122 +0100
+++ screen-redraw.c	2012-03-13 03:20:32.243550871 +0100
@@ -22,8 +22,8 @@
 
 #include "tmux.h"
 
-int	screen_redraw_cell_border1(struct window_pane *, u_int, u_int);
-int	screen_redraw_cell_border(struct client *, u_int, u_int);
+int	screen_redraw_cell_is_border_of_wp(struct window_pane *, u_int, u_int);
+int	screen_redraw_cell_is_border(struct client *, u_int, u_int);
 int	screen_redraw_check_cell(struct client *, u_int, u_int);
 void	screen_redraw_draw_number(struct client *, struct window_pane *);
 
@@ -42,10 +42,16 @@ void	screen_redraw_draw_number(struct cl
 #define CELL_OUTSIDE 12
 
 #define CELL_BORDERS " xqlkmjwvtun~"
+#define CELL_MARKERS " +, .   -"
+
+#define BORDER_LEFT 1
+#define BORDER_RIGHT 2
+#define BORDER_TOP 4
+#define BORDER_BOTTOM 8
 
 /* Check if cell is on the border of a particular pane. */
 int
-screen_redraw_cell_border1(struct window_pane *wp, u_int px, u_int py)
+screen_redraw_cell_is_border_of_wp(struct window_pane *wp, u_int px, u_int py)
 {
 	/* Inside pane. */
 	if (px >= wp->xoff && px < wp->xoff + wp->sx &&
@@ -55,17 +61,17 @@ screen_redraw_cell_border1(struct window
 	/* Left/right borders. */
 	if ((wp->yoff == 0 || py >= wp->yoff - 1) && py <= wp->yoff + wp->sy) {
 		if (wp->xoff != 0 && px == wp->xoff - 1)
-			return (1);
+			return (BORDER_LEFT);
 		if (px == wp->xoff + wp->sx)
-			return (1);
+			return (BORDER_RIGHT);
 	}
 
 	/* Top/bottom borders. */
 	if ((wp->xoff == 0 || px >= wp->xoff - 1) && px <= wp->xoff + wp->sx) {
 		if (wp->yoff != 0 && py == wp->yoff - 1)
-			return (1);
+			return (BORDER_TOP);
 		if (py == wp->yoff + wp->sy)
-			return (1);
+			return (BORDER_BOTTOM);
 	}
 
 	/* Outside pane. */
@@ -74,7 +80,7 @@ screen_redraw_cell_border1(struct window
 
 /* Check if a cell is on the pane border. */
 int
-screen_redraw_cell_border(struct client *c, u_int px, u_int py)
+screen_redraw_cell_is_border(struct client *c, u_int px, u_int py)
 {
 	struct window		*w = c->session->curw->window;
 	struct window_pane	*wp;
@@ -84,7 +90,7 @@ screen_redraw_cell_border(struct client
 	TAILQ_FOREACH(wp, &w->panes, entry) {
 		if (!window_pane_visible(wp))
 			continue;
-		if ((retval = screen_redraw_cell_border1(wp, px, py)) != -1)
+		if ((retval = screen_redraw_cell_is_border_of_wp(wp, px, py)) != -1)
 			return (retval);
 	}
 
@@ -114,7 +120,7 @@ screen_redraw_check_cell(struct client *
 			continue;
 
 		/* If definitely inside, return so. */
-		if (!screen_redraw_cell_border(c, px, py))
+		if (!screen_redraw_cell_is_border(c, px, py))
 			return (CELL_INSIDE);
 
 		/*
@@ -122,13 +128,13 @@ screen_redraw_check_cell(struct client *
 		 * 4), right, top, and bottom (bit 1) of this cell are borders.
 		 */
 		borders = 0;
-		if (px == 0 || screen_redraw_cell_border(c, px - 1, py))
+		if (px == 0 || screen_redraw_cell_is_border(c, px - 1, py))
 			borders |= 8;
-		if (px <= w->sx && screen_redraw_cell_border(c, px + 1, py))
+		if (px <= w->sx && screen_redraw_cell_is_border(c, px + 1, py))
 			borders |= 4;
-		if (py == 0 || screen_redraw_cell_border(c, px, py - 1))
+		if (py == 0 || screen_redraw_cell_is_border(c, px, py - 1))
 			borders |= 2;
-		if (py <= w->sy && screen_redraw_cell_border(c, px, py + 1))
+		if (py <= w->sy && screen_redraw_cell_is_border(c, px, py + 1))
 			borders |= 1;
 
 		/*
@@ -175,7 +181,7 @@ screen_redraw_screen(struct client *c, i
 	struct window_pane	*wp;
 	struct grid_cell	 active_gc, other_gc;
 	u_int		 	 i, j, type, top;
-	int		 	 status, spos, fg, bg;
+	int		 	 status, spos, fg, bg, border, to_mark;
 
 	/* Suspended clients should not be updated. */
 	if (c->flags & CLIENT_SUSPENDED)
@@ -214,6 +220,7 @@ screen_redraw_screen(struct client *c, i
 	colour_set_fg(&active_gc, fg);
 	bg = options_get_number(oo, "pane-active-border-bg");
 	colour_set_bg(&active_gc, bg);
+	to_mark = BORDER_LEFT|BORDER_RIGHT|BORDER_TOP|BORDER_BOTTOM;
 
 	/* Draw background and borders. */
 	for (j = 0; j < tty->sy - status; j++) {
@@ -227,12 +234,16 @@ screen_redraw_screen(struct client *c, i
 			type = screen_redraw_check_cell(c, i, j);
 			if (type == CELL_INSIDE)
 				continue;
-			if (screen_redraw_cell_border1(w->active, i, j) == 1)
-				tty_attributes(tty, &active_gc);
-			else
-				tty_attributes(tty, &other_gc);
+			border = screen_redraw_cell_is_border_of_wp(w->active, i, j);
+			tty_attributes(tty, border != -1 ? &active_gc : &other_gc);
 			tty_cursor(tty, i, top + j);
-			tty_putc(tty, CELL_BORDERS[type]);
+			if (border != -1 && to_mark & border && /* is unmarked border */
+				i > 0 && top + j > 0 && /* skip edge and corner cells */
+				(type == CELL_LEFTRIGHT || type == CELL_TOPBOTTOM)) {
+				tty_putc(tty, CELL_MARKERS[border]);
+				to_mark &= ~border;
+			} else
+				tty_putc(tty, CELL_BORDERS[type]);
 		}
 	}
 
--- input-keys.c.orig	2012-03-13 05:19:52.300536950 +0100
+++ input-keys.c	2012-03-13 05:22:53.108228455 +0100
@@ -203,7 +203,7 @@ input_mouse(struct window_pane *wp, stru
 {
 	char	buf[10];
 	size_t	len;
-	int	value;
+	int	mode, i, lines;
 
 	if (wp->screen->mode & ALL_MOUSE_MODES) {
 		if (wp->screen->mode & MODE_MOUSE_UTF8) {
@@ -220,13 +220,29 @@ input_mouse(struct window_pane *wp, stru
 			buf[len++] = m->y + 33;
 		}
 		bufferevent_write(wp->event, buf, len);
-	} else if ((m->b & MOUSE_BUTTON) != MOUSE_2) {
-		value = options_get_number(&wp->window->options, "mode-mouse");
-		if (value == 1 &&
+		return;
+	}
+	if ((m->b & MOUSE_BUTTON) != MOUSE_2) {
+		mode = options_get_number(&wp->window->options, "mode-mouse");
+		if (mode == 1 &&
 		    window_pane_set_mode(wp, &window_copy_mode) == 0) {
 			window_copy_init_from_pane(wp);
 			if (wp->mode->mouse != NULL)
 				wp->mode->mouse(wp, NULL, m);
+			return;
 		}
 	}
+	/* Emulate mouse wheel scrolling. */
+	if (m->b & MOUSE_45) {
+		/* 
+		 * Wheel + shift: scroll 1 line
+		 * Wheel + ctrl: scroll at triple speed
+		 * */
+		lines = (m->b & MOUSE_SHIFT) ? 1 : MOUSE_SCROLL_LINES;
+		if (m->b & MOUSE_CTRL)
+			lines *= 3;
+
+		for (i=0; i < lines; i++)
+			input_key(wp, (m->b & MOUSE_BUTTON) == MOUSE_1 ? KEYC_UP : KEYC_DOWN);
+	}
 }
--- tmux.h.orig	2012-03-13 05:19:52.327537950 +0100
+++ tmux.h	2012-03-13 05:20:41.111343386 +0100
@@ -575,6 +575,8 @@ struct mode_key_table {
 
 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ANY)
 
+#define MOUSE_SCROLL_LINES 3
+
 /*
  * A single UTF-8 character.
  *
@@ -1101,6 +1103,9 @@ struct mouse_event {
 #define MOUSE_3 2
 #define MOUSE_UP 3
 #define MOUSE_BUTTON 3
+#define MOUSE_SHIFT 4
+#define MOUSE_ALT 8
+#define MOUSE_CTRL 16
 #define MOUSE_DRAG 32
 #define MOUSE_45 64
 #define MOUSE_RESIZE_PANE 128 /* marker for resizing */
--- window-copy.c.orig	2012-03-13 02:56:16.328669010 +0100
+++ window-copy.c	2012-03-13 02:56:54.325075218 +0100
@@ -508,6 +508,7 @@ window_copy_key(struct window_pane *wp,
 		break;
 	case MODEKEYCOPY_STARTSELECTION:
 		window_copy_start_selection(wp);
+		window_copy_update_selection(wp);
 		window_copy_redraw_screen(wp);
 		break;
 	case MODEKEYCOPY_COPYLINE:
@@ -516,6 +517,7 @@ window_copy_key(struct window_pane *wp,
 		/* FALLTHROUGH */
 	case MODEKEYCOPY_COPYENDOFLINE:
 		window_copy_start_selection(wp);
+		window_copy_update_selection(wp);
 		for (; np > 1; np--)
 			window_copy_cursor_down(wp, 0);
 		window_copy_cursor_end_of_line(wp);
@@ -822,7 +824,7 @@ window_copy_mouse(
 {
 	struct window_copy_mode_data	*data = wp->modedata;
 	struct screen			*s = &data->screen;
-	u_int				 i, old_cy;
+	u_int				 i, lines, old_cy;
 
 	if (m->x >= screen_size_x(s))
 		return;
@@ -831,14 +833,22 @@ window_copy_mouse(
 
 	/* If mouse wheel (buttons 4 and 5), scroll. */
 	if ((m->b & MOUSE_45)) {
+		/*
+		 * Wheel + shift: scroll 1 line
+		 * Wheel + ctrl: scroll at triple speed
+		 * */
+		lines = (m->b & MOUSE_SHIFT) ? 1 : MOUSE_SCROLL_LINES;
+		if (m->b & MOUSE_CTRL)
+			lines *= 3;
 		if ((m->b & MOUSE_BUTTON) == MOUSE_1) {
-			for (i = 0; i < 5; i++)
-				window_copy_cursor_up(wp, 0);
+			for (i = 0; i < lines; i++)
+				window_copy_cursor_up(wp, 1);
 		} else if ((m->b & MOUSE_BUTTON) == MOUSE_2) {
 			old_cy = data->cy;
-			for (i = 0; i < 5; i++)
-				window_copy_cursor_down(wp, 0);
-			if (old_cy == data->cy)
+			for (i = 0; i < lines; i++)
+				window_copy_cursor_down(wp, 1);
+			if (old_cy == data->cy &&
+			    options_get_number(&wp->window->options, "mode-mouse") == 1)
 				goto reset_mode;
 		}
 		return;
@@ -851,21 +861,20 @@ window_copy_mouse(
 	if (s->mode & MODE_MOUSE_BUTTON) {
 		if ((m->b & MOUSE_BUTTON) != MOUSE_UP) {
 			window_copy_update_cursor(wp, m->x, m->y);
+			if (!s->sel.flag)
+				window_copy_start_selection(wp);
 			if (window_copy_update_selection(wp))
 				window_copy_redraw_screen(wp);
 			return;
 		}
-		goto reset_mode;
+		if (s->sel.flag)
+			goto reset_mode;
 	}
 
 	/* Otherwise if other buttons pressed, start selection and motion. */
 	if ((m->b & MOUSE_BUTTON) != MOUSE_UP) {
 		s->mode &= ~MODE_MOUSE_STANDARD;
 		s->mode |= MODE_MOUSE_BUTTON;
-
-		window_copy_update_cursor(wp, m->x, m->y);
-		window_copy_start_selection(wp);
-		window_copy_redraw_screen(wp);
 	}
 
 	return;
@@ -1216,7 +1225,6 @@ window_copy_start_selection(struct windo
 	data->sely = screen_hsize(data->backing) + data->cy - data->oy;
 
 	s->sel.flag = 1;
-	window_copy_update_selection(wp);
 }
 
 int
--- tmux.h.orig	2012-03-13 02:56:16.323668825 +0100
+++ tmux.h	2012-03-13 02:57:20.640049107 +0100
@@ -575,6 +575,8 @@ struct mode_key_table {
 
 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ANY)
 
+#define MOUSE_SCROLL_LINES 3
+
 /*
  * A single UTF-8 character.
  *
@@ -1101,6 +1103,9 @@ struct mouse_event {
 #define MOUSE_3 2
 #define MOUSE_UP 3
 #define MOUSE_BUTTON 3
+#define MOUSE_SHIFT 4
+#define MOUSE_ALT 8
+#define MOUSE_CTRL 16
 #define MOUSE_DRAG 32
 #define MOUSE_45 64
 #define MOUSE_RESIZE_PANE 128 /* marker for resizing */
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to