Discussion:
Reverse-Engineering Layout Format
Steven Lu
2013-07-15 22:06:12 UTC
Permalink
I am a big fan of the feature in Vim which allows you to move a vim-window
(the tmux pane equivalent) _all the way_ in a particular direction by
typing Ctrl+W, H/J/K/L.

Unfortunately tmux has no feature here, but select-layout seems promising.

However, I'd like to avoid reverse-engineering the layout format.
In addition, select-layout may be used to apply a previously used layout
- the
list-windows command displays the layout of each window in a form
suitable for use
$ tmux list-windows
0: ksh [159x48]
layout: bb62,159x48,0,0{79x48,0,0,79x48,80,0}
$ tmux select-layout bb62,159x48,0,0{79x48,0,0,79x48,80,0}
I'm on tmux 1.8 and it looks like this over here:

% tmux list-windows

1: zsh- (2 panes) [274x76] [layout
6f06,274x76,0,0{87x76,0,0,0,186x76,88,0,1}] @0
2: zsh* (3 panes) [274x76] [layout
250f,274x76,0,0{97x76,0,0[97x53,0,0,2,97x22,0,54,7],176x76,98,
0,4}] @1 (active)

3: zsh (1 panes) [274x76] [layout cc63,274x76,0,0,6] @3

4: zsh (1 panes) [274x76] [layout cc65,274x76,0,0,8] @4


I'm hoping someone in the know could give me some hints about how to parse
this so that I can compute what the result would be to warp any pane to one
of the directions.

I am particularly curious about the meaning of the first 4 characters in
the layout, it appears to be a 16 bit hex quantity. My windows 3 and 4
there are in the exact same configuration (both 274x76 single pane
windows), so I dunno why one is cc63 and the other is cc65.
Thomas Adam
2013-07-27 11:28:28 UTC
Permalink
Post by Steven Lu
I'm hoping someone in the know could give me some hints about how to parse
this so that I can compute what the result would be to warp any pane to one
of the directions.
You need to look in layout-custom.c

-- Thomas Adam
Steven Lu
2014-11-19 18:24:58 UTC
Permalink
Hi Thomas, thanks for the hint!

layout-custom.c reveals a lot of things, I am now imagining that if I can
properly replicate the computation of the layout string along with the
checksum then I'll actually be able to do processing independent of
mutating the pane sizes within tmux, so that i can e.g. resize a particular
pane to make it bigger and then apply that change in one fell swoop by
feeding a brand new layout string.

I just wanted to know if this is actually how you have designed the
"select-layout" command to work.

I was taking a quick look at the source code (just poking around on github)
but it's strange that I cannot find the actual declaration for "struct
layout_cell"...
Post by Thomas Adam
Post by Steven Lu
I'm hoping someone in the know could give me some hints about how to
parse
Post by Steven Lu
this so that I can compute what the result would be to warp any pane to
one
Post by Steven Lu
of the directions.
You need to look in layout-custom.c
-- Thomas Adam
Felix Rosencrantz
2014-11-22 08:10:18 UTC
Permalink
This post might be inappropriate. Click to display it.
Steven Lu
2014-11-22 09:20:43 UTC
Permalink
I have not had a chance to dig into this code yet but I do agree that there
is a large amount of untapped potential in this functionality and that can
only be helped by making it easier to interface with.

I can see that a set of even not very intelligent layout mutating scripts
should be able to improve usable screen real-estate by a large factor, by
effectively blurring the line between panes and windows by just
auto-expanding the focused pane, letting unfocused panes get smaller but
still remain visible. It helps that all terminal programs I have used (with
few exceptions, such as man pages) are rather robust to resizing, because
we would now be resizing on pane changes!

Anyway, I think the simple fact that it's possible at all to do such
interfacing is 90% of the engineering work, so hats off to whoever decided
to put this capability into the design.
Post by Felix Rosencrantz
I've wondered why is the checksum needed? It seems like it would be
easier for tmux users to write simple tools to tweak a custom layout
without the checksum being there. As best I can tell from a comment in the
code, it is a quick way to check if a layout is valid. I'm not familiar
enough with the format or its issues, is checking the validity something
that is hard to do from code without the checksum?
It seems like it would be useful to have a simpler format, perhaps not as
flexible as the current format, but one that was easier to parse, and
validate. For example, one that just took pane_ids and used the same
grouping via the braces and brackets like the current custom layout to
build the cells structure, evenly distributing space among the child cells
of a parent. Less control of pane placement, but easier to create more
complicated patterns than the defaults.
-FR.
Post by Steven Lu
Hi Thomas, thanks for the hint!
layout-custom.c reveals a lot of things, I am now imagining that if I can
properly replicate the computation of the layout string along with the
checksum then I'll actually be able to do processing independent of
mutating the pane sizes within tmux, so that i can e.g. resize a particular
pane to make it bigger and then apply that change in one fell swoop by
feeding a brand new layout string.
I just wanted to know if this is actually how you have designed the
"select-layout" command to work.
I was taking a quick look at the source code (just poking around on
github) but it's strange that I cannot find the actual declaration for
"struct layout_cell"...
Post by Steven Lu
Post by Steven Lu
I'm hoping someone in the know could give me some hints about how to
parse
Post by Steven Lu
this so that I can compute what the result would be to warp any pane
to one
Post by Steven Lu
of the directions.
You need to look in layout-custom.c
-- Thomas Adam
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Loading...