Re: "even" layouts not quite even.

2010-12-06 Thread Nicholas Marriott
Can I put on my style Nazi hat and have spaces around the - in "n-1"?

Otherwise looks fine. I didn't test it but I assume you did :-).



On Thu, Dec 02, 2010 at 08:52:13PM -0800, Micah Cowan wrote:
> Currently, "even-horizontal" will split a 161-column terminal into 79
> and 81, rather than 80/80; and "even-vertical" will split 44 lines into
> 20 and 22. The attached patch fixes this. Let me know if it looks
> alright, and I'll commit it.
> 
> I noticed the default value for main-pane-width is set to 81, which
> seems an odd value for me; why isn't it the more usual 80?
> 
> -- 
> Micah J. Cowan
> http://micah.cowan.name/


> --
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev

> ___
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users


--
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users


"even" layouts not quite even.

2010-12-02 Thread Micah Cowan
Currently, "even-horizontal" will split a 161-column terminal into 79
and 81, rather than 80/80; and "even-vertical" will split 44 lines into
20 and 22. The attached patch fixes this. Let me know if it looks
alright, and I'll commit it.

I noticed the default value for main-pane-width is set to 81, which
seems an odd value for me; why isn't it the more usual 80?

-- 
Micah J. Cowan
http://micah.cowan.name/
Index: sf/layout-set.c
===
--- sf.orig/layout-set.c	2010-12-02 20:33:38.93560 -0800
+++ sf/layout-set.c	2010-12-02 20:39:31.80360 -0800
@@ -135,10 +135,9 @@ layout_set_even_h(struct window *w)
 		return;
 
 	/* How many can we fit? */
-	if (w->sx / n < PANE_MINIMUM + 1)
+	width = (w->sx - (n-1)) / n;
+	if (width < PANE_MINIMUM + 1)
 		width = PANE_MINIMUM + 1;
-	else
-		width = w->sx / n;
 
 	/* Free the old root and construct a new. */
 	layout_free(w);
@@ -151,12 +150,12 @@ layout_set_even_h(struct window *w)
 	TAILQ_FOREACH(wp, &w->panes, entry) {
 		/* Create child cell. */
 		lcnew = layout_create_cell(lc);
-		layout_set_size(lcnew, width - 1, w->sy, xoff, 0);
+		layout_set_size(lcnew, width, w->sy, xoff, 0);
 		layout_make_leaf(lcnew, wp);
 		TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry);
 
 		i++;
-		xoff += width;
+		xoff += width + 1;
 	}
 
 	/* Allocate any remaining space. */
@@ -189,10 +188,9 @@ layout_set_even_v(struct window *w)
 		return;
 
 	/* How many can we fit? */
-	if (w->sy / n < PANE_MINIMUM + 1)
+	height = (w->sy - (n-1)) / n
+	if (height < PANE_MINIMUM + 1)
 		height = PANE_MINIMUM + 1;
-	else
-		height = w->sy / n;
 
 	/* Free the old root and construct a new. */
 	layout_free(w);
@@ -205,12 +203,12 @@ layout_set_even_v(struct window *w)
 	TAILQ_FOREACH(wp, &w->panes, entry) {
 		/* Create child cell. */
 		lcnew = layout_create_cell(lc);
-		layout_set_size(lcnew, w->sx, height - 1, 0, yoff);
+		layout_set_size(lcnew, w->sx, height, 0, yoff);
 		layout_make_leaf(lcnew, wp);
 		TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry);
 
 		i++;
-		yoff += height;
+		yoff += height + 1;
 	}
 
 	/* Allocate any remaining space. */
--
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users