Re: [PATCH] Restore zoom when selecting a previously zoomed pane

2013-11-25 Thread Maykel Moya
On 24/11/13 12:36, Nicholas Marriott wrote:

 Hi
 
 I tried this and honestly I don't like it, I think it is unexpected that
 if I do splitw and the pane unzooms it then zooms again when I select
 it. It's better for the pane not to secretly stay zoomed - it isn't so
 hard to zoom it again if that's what you want.

Hello Nicholas

First of all thank you for taking the time to test the patch.

I admit that autozooming on enter is not much aligned with the principle
of least surprise. In fact I wasn't displaying the window flags in the
status bar and after aplying the patch I added it so I can know if the
current window is zoomed or not.

That said, I still find useful this behaviour. Typical use case is
editor+shell. You go from your maximized editor pane to the shell, try
something and then go back to edit, and then again to the shell and so on.

It can be done manually, of course, in fact my first take was the one I
commented in my first mail: bind h select-pane -L and bind H
select-pane -L \; resize-pane -Z.

I find some equivalence between this autozoom and the GUI's popular
metaphor in which you push a window toward a lateral side and the window
is resized to take that lateral half of the screen. If you drag the
window again to the center, it it resized back to its previous size
instead of keeping it half-screen size.

Outside of tmux the only way I can think of to know if a pane was
previously zoomed is to have an app listening for %layout-change
messages an keeping it's own internal state. Any other idea is welcomed.

Question aside: is there any plan for a libtmux ?

Thanks

Regards,
maykel


--
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311iu=/4140/ostg.clktrk
___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users


Restore zoom state

2013-11-16 Thread Maykel Moya
Hello

I just began to use the recently added zoom feature and came across an
anoying thing.

You have panes A and B. A is zoomed, if you switch to pane B, then A is
forcibly unzoomed. This is expected, of course, otherwise B would remain
invisible.

If you switch back to pane A I expect to get A zoomed again because it
wasn't me who unzoomed it.

First I started to play with these binding (hjkl and HJKL):

bind h select-pane -L
bind j select-pane -D
...
bind H select-pane -L \; resize-pane -Z
bind J select-pane -D \; resize-pane -Z
...

and yes, they worked but I had to mentally keep track of the previous
pane state and use the corresponding key combination when returning to
pane A.

Find attached a patch implementing zoom restoration. The feature is
controlled by window setting restore-zoom, which is 0 by default so the
current behaviour is not altered.

I first submitted a PR to github[1] but I'm not sure if PRs are being
looked at.

Would appreciate some feedback on this, specially if you consider that
restoring zoom should (not) be the expected behaviour.

Needless to say how cool tmux is.

Kind regards,
maykel

[1] https://github.com/ThomasAdam/tmux/pull/5/files
commit 81bd6465a52e818343d776212cae780e73762f5b
Author: Maykel Moya mm...@mmoya.org
Date:   Sat Nov 16 02:54:28 2013 +0100

Add option for restoring window zoom

diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c
index d31f886..d8ee076 100644
--- a/cmd-resize-pane.c
+++ b/cmd-resize-pane.c
@@ -101,10 +101,13 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
 	w = wl-window;
 
 	if (args_has(args, 'Z')) {
-		if (w-flags  WINDOW_ZOOMED)
+		if (w-flags  WINDOW_ZOOMED) {
 			window_unzoom(w);
-		else
+			wp-flags = ~PANE_ZOOMED;
+		} else {
 			window_zoom(wp);
+			wp-flags |= PANE_ZOOMED;
+		}
 		server_redraw_window(w);
 		server_status_window(w);
 		return (CMD_RETURN_NORMAL);
diff --git a/cmd-select-pane.c b/cmd-select-pane.c
index c342fef..e23a8da 100644
--- a/cmd-select-pane.c
+++ b/cmd-select-pane.c
@@ -67,6 +67,8 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
 	struct args		*args = self-args;
 	struct winlink		*wl;
 	struct window_pane	*wp;
+	struct window		*w;
+	int			restore_zoom;
 
 	if (self-entry == cmd_last_pane_entry || args_has(args, 'l')) {
 		wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
@@ -108,9 +110,18 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
 		return (CMD_RETURN_ERROR);
 	}
 
-	window_set_active_pane(wl-window, wp);
-	server_status_window(wl-window);
-	server_redraw_window_borders(wl-window);
+	w = wl-window;
+	restore_zoom = options_get_number(w-options, restore-zoom);
+
+	window_set_active_pane(w, wp);
+	if (restore_zoom  wp-flags  PANE_ZOOMED) {
+		window_zoom(wp);
+		server_redraw_window(w);
+		server_status_window(w);
+	} else {
+		server_status_window(w);
+		server_redraw_window_borders(w);
+	}
 
 	return (CMD_RETURN_NORMAL);
 }
diff --git a/options-table.c b/options-table.c
index 5da095b..a16e6c1 100644
--- a/options-table.c
+++ b/options-table.c
@@ -604,6 +604,11 @@ const struct options_table_entry window_options_table[] = {
 	  .default_num = 0
 	},
 
+	{ .name = restore-zoom,
+	  .type = OPTIONS_TABLE_FLAG,
+	  .default_num = 0
+	},
+
 	{ .name = synchronize-panes,
 	  .type = OPTIONS_TABLE_FLAG,
 	  .default_num = 0
diff --git a/tmux.1 b/tmux.1
index 1146faf..e9e4f04 100644
--- a/tmux.1
+++ b/tmux.1
@@ -2861,6 +2861,12 @@ The window may be reactivated with the
 .Ic respawn-window
 command.
 .Pp
+.It Xo Ic restore-zoom
+.Op Ic on | off
+.Xc
+A window with this flag set will autozoom after selecting a previously zoomed
+pane.
+.Pp
 .It Xo Ic synchronize-panes
 .Op Ic on | off
 .Xc
diff --git a/tmux.h b/tmux.h
index dbc2c49..425e000 100644
--- a/tmux.h
+++ b/tmux.h
@@ -904,6 +904,7 @@ struct window_pane {
 #define PANE_FOCUSED 0x4
 #define PANE_RESIZE 0x8
 #define PANE_FOCUSPUSH 0x10
+#define PANE_ZOOMED 0x20
 
 	char		*cmd;
 	char		*shell;
--
DreamFactory - Open Source REST  JSON Services for HTML5  Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users


[PATCH] Restore zoom when selecting a previously zoomed pane

2013-11-16 Thread Maykel Moya
Signed-off-by: Maykel Moya mm...@mmoya.org
---
 cmd-resize-pane.c |  7 +--
 cmd-select-pane.c | 10 --
 tmux.h|  1 +
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c
index d31f886..d8ee076 100644
--- a/cmd-resize-pane.c
+++ b/cmd-resize-pane.c
@@ -101,10 +101,13 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
w = wl-window;
 
if (args_has(args, 'Z')) {
-   if (w-flags  WINDOW_ZOOMED)
+   if (w-flags  WINDOW_ZOOMED) {
window_unzoom(w);
-   else
+   wp-flags = ~PANE_ZOOMED;
+   } else {
window_zoom(wp);
+   wp-flags |= PANE_ZOOMED;
+   }
server_redraw_window(w);
server_status_window(w);
return (CMD_RETURN_NORMAL);
diff --git a/cmd-select-pane.c b/cmd-select-pane.c
index c342fef..89cfb82 100644
--- a/cmd-select-pane.c
+++ b/cmd-select-pane.c
@@ -109,8 +109,14 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
}
 
window_set_active_pane(wl-window, wp);
-   server_status_window(wl-window);
-   server_redraw_window_borders(wl-window);
+   if (wp-flags  PANE_ZOOMED) {
+   window_zoom(wp);
+   server_redraw_window(wl-window);
+   server_status_window(wl-window);
+   } else {
+   server_status_window(wl-window);
+   server_redraw_window_borders(wl-window);
+   }
 
return (CMD_RETURN_NORMAL);
 }
diff --git a/tmux.h b/tmux.h
index dbc2c49..425e000 100644
--- a/tmux.h
+++ b/tmux.h
@@ -904,6 +904,7 @@ struct window_pane {
 #define PANE_FOCUSED 0x4
 #define PANE_RESIZE 0x8
 #define PANE_FOCUSPUSH 0x10
+#define PANE_ZOOMED 0x20
 
char*cmd;
char*shell;
-- 
1.8.3.2


--
DreamFactory - Open Source REST  JSON Services for HTML5  Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk
___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users