G, what the rush^^
have been working on this and here's what i have in tree right now.

These are somewhat untested, will test and report back later... C:
>From a824632d2fb794fbc0e64d47fc15ef6e9e219b47 Mon Sep 17 00:00:00 2001
From: Marcel Partap <mpar...@gmx.net>
Date: Wed, 20 Jun 2012 15:48:27 +0200
Subject: [PATCH 1/4] Don't exit copy-mode by scrolling with
 mode-mouse==copy-mode

---
 trunk/window-copy.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/trunk/window-copy.c b/trunk/window-copy.c
index 7b2a8ae..05e2f74 100644
--- a/trunk/window-copy.c
+++ b/trunk/window-copy.c
@@ -837,7 +837,8 @@ window_copy_mouse(
 		} else if ((m->b & MOUSE_BUTTON) == MOUSE_2) {
 			for (i = 0; i < 5; i++)
 				window_copy_cursor_down(wp, 0);
-			if (data->oy == 0)
+			if (data->oy == 0 &&
+			    options_get_number(&wp->window->options, "mode-mouse") == 1)
 				goto reset_mode;
 		}
 		return;
-- 
1.7.10.4

>From bc6da733b9a9a77337607e2b01ca3873953625a8 Mon Sep 17 00:00:00 2001
From: Marcel Partap <mpar...@gmx.net>
Date: Wed, 20 Jun 2012 20:59:54 +0200
Subject: [PATCH 2/4] =?UTF-8?q?Add=20pane-active-border-mark=20option=20for=20?=
 =?UTF-8?q?arrows=20=E2=86=92=E2=86=90=E2=86=91=E2=86=93=20indicating=20curr?=
 =?UTF-8?q?ent=20pane.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 trunk/examples/tmux.vim |    2 +-
 trunk/options-table.c   |    5 +++++
 trunk/screen-redraw.c   |   38 +++++++++++++++++++++++++++-----------
 trunk/tmux.1            |    4 ++++
 trunk/tty-term.c        |    2 +-
 5 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/trunk/examples/tmux.vim b/trunk/examples/tmux.vim
index e12428a..e10fa94 100644
--- a/trunk/examples/tmux.vim
+++ b/trunk/examples/tmux.vim
@@ -58,7 +58,7 @@ syn keyword tmuxOptsSet status-right-fg update-environment base-index
 syn keyword tmuxOptsSet display-panes-colour display-panes-time default-shell
 syn keyword tmuxOptsSet set-titles-string lock-command lock-server
 syn keyword tmuxOptsSet mouse-select-pane message-limit quiet escape-time
-syn keyword tmuxOptsSet pane-active-border-bg pane-active-border-fg
+syn keyword tmuxOptsSet pane-active-border-bg pane-active-border-fg pane-active-border-mark
 syn keyword tmuxOptsSet pane-border-bg pane-border-fg message-[command-]fg
 syn keyword tmuxOptsSet display-panes-active-colour alternate-screen
 syn keyword tmuxOptsSet detach-on-destroy word-separators
diff --git a/trunk/options-table.c b/trunk/options-table.c
index 8ce838a..f67f679 100644
--- a/trunk/options-table.c
+++ b/trunk/options-table.c
@@ -248,6 +248,11 @@ const struct options_table_entry session_options_table[] = {
 	  .default_num = 8
 	},
 
+	{ .name = "pane-active-border-mark",
+	  .type = OPTIONS_TABLE_FLAG,
+	  .default_num = 0
+	},
+
 	{ .name = "pane-active-border-fg",
 	  .type = OPTIONS_TABLE_COLOUR,
 	  .default_num = 2
diff --git a/trunk/screen-redraw.c b/trunk/screen-redraw.c
index 899f741..75f7238 100644
--- a/trunk/screen-redraw.c
+++ b/trunk/screen-redraw.c
@@ -42,6 +42,13 @@ void	screen_redraw_draw_number(struct client *, struct window_pane *);
 #define CELL_OUTSIDE 12
 
 #define CELL_BORDERS " xqlkmjwvtun~"
+#define CELL_MARKERS " +, .   -"
+
+#define BORDER_NONE 0
+#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
@@ -55,21 +62,21 @@ screen_redraw_cell_border1(struct window_pane *wp, u_int px, u_int py)
 	/* 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. */
-	return (-1);
+	return (BORDER_NONE);
 }
 
 /* Check if a cell is on the pane border. */
@@ -78,14 +85,13 @@ screen_redraw_cell_border(struct client *c, u_int px, u_int py)
 {
 	struct window		*w = c->session->curw->window;
 	struct window_pane	*wp;
-	int			 retval;
 
 	/* Check all the panes. */
 	TAILQ_FOREACH(wp, &w->panes, entry) {
 		if (!window_pane_visible(wp))
 			continue;
-		if ((retval = screen_redraw_cell_border1(wp, px, py)) != -1)
-			return (retval);
+		if (screen_redraw_cell_border1(wp, px, py) != BORDER_NONE)
+			return (1);
 	}
 
 	return (0);
@@ -175,7 +181,7 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
 	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, marks;
 
 	/* Suspended clients should not be updated. */
 	if (c->flags & CLIENT_SUSPENDED)
@@ -215,6 +221,8 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
 	colour_set_bg(&active_gc, bg);
 
 	/* Draw background and borders. */
+	marks = options_get_number(oo, "pane-active-border-mark") ?
+		BORDER_LEFT|BORDER_RIGHT|BORDER_TOP|BORDER_BOTTOM : BORDER_NONE;
 	for (j = 0; j < tty->sy - status; j++) {
 		if (status_only) {
 			if (spos == 1 && j != tty->sy - 1)
@@ -226,12 +234,20 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
 			type = screen_redraw_check_cell(c, i, j);
 			if (type == CELL_INSIDE)
 				continue;
-			if (screen_redraw_cell_border1(w->active, i, j) == 1)
+			border = screen_redraw_cell_border1(w->active, i, j);
+			if (border != BORDER_NONE)
 				tty_attributes(tty, &active_gc);
 			else
 				tty_attributes(tty, &other_gc);
 			tty_cursor(tty, i, top + j);
-			tty_putc(tty, CELL_BORDERS[type]);
+
+			if (border != BORDER_NONE &&
+			    (type == CELL_LEFTRIGHT || type == CELL_TOPBOTTOM) &&
+			    (marks & border) && i > 0 && top + j > 0) {
+				tty_putc(tty, CELL_MARKERS[border]);
+				marks &= ~border;
+			} else
+				tty_putc(tty, CELL_BORDERS[type]);
 		}
 	}
 
diff --git a/trunk/tmux.1 b/trunk/tmux.1
index 7062890..0ca4b60 100644
--- a/trunk/tmux.1
+++ b/trunk/tmux.1
@@ -2154,6 +2154,10 @@ If enabled, request mouse input as UTF-8 on UTF-8 terminals.
 .It Ic pane-active-border-bg Ar colour
 .It Ic pane-active-border-fg Ar colour
 Set the pane border colour for the currently active pane.
+.It Xo Ic pane-active-mark
+.Op Ic on | off
+.Xc
+If on, the current pane will be indicated by arrow marks on its border.
 .It Ic pane-border-bg Ar colour
 .It Ic pane-border-fg Ar colour
 Set the pane border colour for panes aside from the active pane.
diff --git a/trunk/tty-term.c b/trunk/tty-term.c
index 64aced0..fc56090 100644
--- a/trunk/tty-term.c
+++ b/trunk/tty-term.c
@@ -433,7 +433,7 @@ tty_term_find(char *name, int fd, const char *overrides, char **cause)
 	if (tty_term_has(term, TTYC_ACSC))
 		acs = tty_term_string(term, TTYC_ACSC);
 	else
-		acs = "a#j+k+l+m+n+o-p-q-r-s-t+u+v+w+x|y<z>~.";
+		acs = "+>,<-^.va#j+k+l+m+n+o-p-q-r-s-t+u+v+w+x|y<z>~.";
 	for (; acs[0] != '\0' && acs[1] != '\0'; acs += 2)
 		term->acs[(u_char) acs[0]][0] = acs[1];
 
-- 
1.7.10.4

>From eec51acbb01ced976e63153608c46180f4aa7073 Mon Sep 17 00:00:00 2001
From: Marcel Partap <mpar...@gmx.net>
Date: Wed, 20 Jun 2012 23:37:10 +0200
Subject: [PATCH 3/4] Show how VT100 ACS (alternate character set) should
 actually render

---
 trunk/screen-redraw.c |    4 ++--
 trunk/tty-acs.c       |   64 ++++++++++++++++++++++++-------------------------
 2 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/trunk/screen-redraw.c b/trunk/screen-redraw.c
index 75f7238..4d4899d 100644
--- a/trunk/screen-redraw.c
+++ b/trunk/screen-redraw.c
@@ -41,8 +41,8 @@ void	screen_redraw_draw_number(struct client *, struct window_pane *);
 #define CELL_JOIN 11
 #define CELL_OUTSIDE 12
 
-#define CELL_BORDERS " xqlkmjwvtun~"
-#define CELL_MARKERS " +, .   -"
+#define CELL_BORDERS " xqlkmjwvtun~" /* " │─┌┐└┘┬┴├┤┼·" */
+#define CELL_MARKERS " +, .   -"     /* " →← ↑   ↓" */
 
 #define BORDER_NONE 0
 #define BORDER_LEFT 1
diff --git a/trunk/tty-acs.c b/trunk/tty-acs.c
index e85888c..c909978 100644
--- a/trunk/tty-acs.c
+++ b/trunk/tty-acs.c
@@ -30,38 +30,38 @@ struct tty_acs_entry {
 	const char	*string;
 };
 const struct tty_acs_entry tty_acs_table[] = {
-	{ '+', "\342\206\222" },
-	{ ',', "\342\206\220" },
-	{ '-', "\342\206\221" },
-	{ '.', "\342\206\223" },
-	{ '0', "\342\226\256" },
-	{ '`', "\342\227\206" },
-	{ 'a', "\342\226\222" },
-	{ 'f', "\302\260" },
-	{ 'g', "\302\261" },
-	{ 'h', "\342\226\222" },
-	{ 'i', "\342\230\203" },
-	{ 'j', "\342\224\230" },
-	{ 'k', "\342\224\220" },
-	{ 'l', "\342\224\214" },
-	{ 'm', "\342\224\224" },
-	{ 'n', "\342\224\274" },
-	{ 'o', "\342\216\272" },
-	{ 'p', "\342\216\273" },
-	{ 'q', "\342\224\200" },
-	{ 'r', "\342\216\274" },
-	{ 's', "\342\216\275" },
-	{ 't', "\342\224\234" },
-	{ 'u', "\342\224\244" },
-	{ 'v', "\342\224\264" },
-	{ 'w', "\342\224\254" },
-	{ 'x', "\342\224\202" },
-	{ 'y', "\342\211\244" },
-	{ 'z', "\342\211\245" },
-	{ '{', "\317\200" },
-	{ '|', "\342\211\240" },
-	{ '}', "\302\243" },
-	{ '~', "\302\267" }
+	{ '+', "\342\206\222" }, /* → */
+	{ ',', "\342\206\220" }, /* ← */
+	{ '-', "\342\206\221" }, /* ↑ */
+	{ '.', "\342\206\223" }, /* ↓ */
+	{ '0', "\342\226\256" }, /* ▮ */
+	{ '`', "\342\227\206" }, /* ◆ */
+	{ 'a', "\342\226\222" }, /* ▒ */
+	{ 'f', "\302\260" },     /* ° */
+	{ 'g', "\302\261" },     /* ± */
+	{ 'h', "\342\226\222" }, /* ▒ */
+	{ 'i', "\342\230\203" }, /* ☃ */
+	{ 'j', "\342\224\230" }, /* ┘ */
+	{ 'k', "\342\224\220" }, /* ┐ */
+	{ 'l', "\342\224\214" }, /* ┌ */
+	{ 'm', "\342\224\224" }, /* └ */
+	{ 'n', "\342\224\274" }, /* ┼ */
+	{ 'o', "\342\216\272" }, /* ⎺ */
+	{ 'p', "\342\216\273" }, /* ⎻ */
+	{ 'q', "\342\224\200" }, /* ─ */
+	{ 'r', "\342\216\274" }, /* ⎼ */
+	{ 's', "\342\216\275" }, /* ⎽ */
+	{ 't', "\342\224\234" }, /* ├ */
+	{ 'u', "\342\224\244" }, /* ┤ */
+	{ 'v', "\342\224\264" }, /* ┴ */
+	{ 'w', "\342\224\254" }, /* ┬ */
+	{ 'x', "\342\224\202" }, /* │ */
+	{ 'y', "\342\211\244" }, /* ≤ */
+	{ 'z', "\342\211\245" }, /* ≥ */
+	{ '{', "\317\200" },     /* π */
+	{ '|', "\342\211\240" }, /* ≠ */
+	{ '}', "\302\243" },     /* £ */
+	{ '~', "\302\267" }      /* · */
 };
 
 int
-- 
1.7.10.4

>From 7f588c64242b3c1d8a31d3bc6aaa1b590027b776 Mon Sep 17 00:00:00 2001
From: Marcel Partap <mpar...@gmx.net>
Date: Thu, 21 Jun 2012 12:01:55 +0200
Subject: [PATCH 4/4] Cleaned up implementation of mouse wheel scrolling
 emulation.

---
 trunk/examples/tmux.vim |    2 +-
 trunk/input-keys.c      |   29 ++++++++++++++++++++++-------
 trunk/options-table.c   |    5 +++++
 trunk/tmux.1            |    5 +++++
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/trunk/examples/tmux.vim b/trunk/examples/tmux.vim
index e10fa94..2d62de5 100644
--- a/trunk/examples/tmux.vim
+++ b/trunk/examples/tmux.vim
@@ -63,7 +63,7 @@ syn keyword tmuxOptsSet pane-border-bg pane-border-fg message-[command-]fg
 syn keyword tmuxOptsSet display-panes-active-colour alternate-screen
 syn keyword tmuxOptsSet detach-on-destroy word-separators
 syn keyword tmuxOptsSet destroy-unattached exit-unattached set-clipboard
-syn keyword tmuxOptsSet bell-on-alert mouse-select-window mouse-utf8
+syn keyword tmuxOptsSet bell-on-alert mouse-select-window mouse-utf8 mouse-scroll-lines
 
 syn keyword tmuxOptsSetw monitor-activity aggressive-resize force-width
 syn keyword tmuxOptsSetw force-height remain-on-exit uft8 mode-fg mode-bg
diff --git a/trunk/input-keys.c b/trunk/input-keys.c
index ea1fb92..7330837 100644
--- a/trunk/input-keys.c
+++ b/trunk/input-keys.c
@@ -201,8 +201,10 @@ input_key(struct window_pane *wp, int key)
 void
 input_mouse(struct window_pane *wp, struct mouse_event *m)
 {
-	char	buf[10];
-	size_t	len;
+	struct options	*oo = &wp->window->options;
+	char		 buf[10];
+	size_t		 len;
+	int		 mode, i, lines;
 
 	if (wp->screen->mode & ALL_MOUSE_MODES) {
 		if (wp->screen->mode & MODE_MOUSE_UTF8) {
@@ -221,14 +223,27 @@ input_mouse(struct window_pane *wp, struct mouse_event *m)
 		bufferevent_write(wp->event, buf, len);
 		return;
 	}
-
-	if ((m->b & 3) != 1 &&
-	    options_get_number(&wp->window->options, "mode-mouse") == 1) {
-		if (window_pane_set_mode(wp, &window_copy_mode) == 0) {
+	if ((m->b & MOUSE_BUTTON) != MOUSE_2) {
+		mode = options_get_number(oo, "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;
 		}
-		return;
+	}
+	/* Emulate mouse wheel scrolling. */
+	if (m->b & MOUSE_45) {
+		/*
+		 * Wheel + shift: always scroll 1 line
+		 * Wheel + ctrl:  scroll at triple speed
+		 * */
+		lines = (m->b & MOUSE_SHIFT) ? 1 : options_get_number(oo, "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);
 	}
 }
diff --git a/trunk/options-table.c b/trunk/options-table.c
index f67f679..1247474 100644
--- a/trunk/options-table.c
+++ b/trunk/options-table.c
@@ -238,6 +238,11 @@ const struct options_table_entry session_options_table[] = {
 	  .default_num = 0
 	},
 
+	{ .name = "mouse-scroll-lines",
+	  .type = OPTIONS_TABLE_FLAG,
+	  .default_num = 3
+	},
+
 	{ .name = "mouse-utf8",
 	  .type = OPTIONS_TABLE_FLAG,
 	  .default_num = 0
diff --git a/trunk/tmux.1 b/trunk/tmux.1
index 0ca4b60..83e1c1e 100644
--- a/trunk/tmux.1
+++ b/trunk/tmux.1
@@ -2147,6 +2147,11 @@ The mouse click is also passed through to the application as normal.
 .Xc
 If on, clicking the mouse on a window name in the status line will select that
 window.
+.It Ic mouse-scroll-lines Ar number
+How many lines each mouse wheel event will scroll. Like in many terminal
+emulators, fake key up/down sequences are sent to non-mouse aware programs.
+Shift modifier overrides this to 1, Ctrl modifier triples the scrolling speed.
+The default is 3.
 .It Xo Ic mouse-utf8
 .Op Ic on | off
 .Xc
-- 
1.7.10.4

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to