diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-07-19 13:21:40 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-07-19 13:21:40 +0000 |
commit | 6036bdd06cba9fa500098f1f17983d62955b24e5 (patch) | |
tree | f19dc96b0b6f65ca03222018df09defd585bed90 /tmux.h | |
parent | fc6a65c6207dbefcd8b5f187148978f8d4111b2b (diff) | |
download | rtmux-6036bdd06cba9fa500098f1f17983d62955b24e5.tar.gz rtmux-6036bdd06cba9fa500098f1f17983d62955b24e5.tar.bz2 rtmux-6036bdd06cba9fa500098f1f17983d62955b24e5.zip |
Improved layout code.
Each window now has a tree of layout cells associated with it. In this tree,
each node is either a horizontal or vertical cell containing a list of other
cells running from left-to-right or top-to-bottom, or a leaf cell which is
associated with a pane.
The major functional changes are:
- panes may now be split arbitrarily both horizontally (splitw -h, C-b %) and
vertically (splitw -v, C-b ");
- panes may be resized both horizontally and vertically (resizep -L/-R/-U/-D,
bound to C-b left/right/up/down and C-b M-left/right/up/down);
- layouts are now applied and then may be modified by resizing or splitting
panes, rather than being fixed and reapplied when the window is resized or
panes are added;
- manual-vertical layout is no longer necessary, and active-only layout is gone
(but may return in future);
- the main-pane layouts now reduce the size of the main pane to fit all panes
if possible.
Thanks to all who tested.
Diffstat (limited to 'tmux.h')
-rw-r--r-- | tmux.h | 83 |
1 files changed, 67 insertions, 16 deletions
@@ -47,8 +47,11 @@ extern const char *__progname; /* Default prompt history length. */ #define PROMPT_HISTORY 100 -/* Minimum pane size. */ -#define PANE_MINIMUM 5 /* includes separator line */ +/* + * Minimum layout cell size, NOT including separator line. The scroll region + * cannot be one line in height so this must be at least two. + */ +#define PANE_MINIMUM 2 /* Automatic name refresh interval, in milliseconds. */ #define NAME_INTERVAL 500 @@ -592,6 +595,7 @@ struct window_mode { /* Child window structure. */ struct window_pane { struct window *window; + struct layout_cell *layout_cell; u_int sx; u_int sy; @@ -635,7 +639,9 @@ struct window { struct window_pane *active; struct window_panes panes; + u_int layout; + struct layout_cell *layout_root; u_int sx; u_int sy; @@ -664,6 +670,34 @@ struct winlink { RB_HEAD(winlinks, winlink); SLIST_HEAD(winlink_stack, winlink); +/* Layout direction. */ +enum layout_type { + LAYOUT_LEFTRIGHT, + LAYOUT_TOPBOTTOM, + LAYOUT_WINDOWPANE +}; + +/* Layout cells queue. */ +TAILQ_HEAD(layout_cells, layout_cell); + +/* Layout cell. */ +struct layout_cell { + enum layout_type type; + + struct layout_cell *parent; + + u_int sx; + u_int sy; + + u_int xoff; + u_int yoff; + + struct window_pane *wp; + struct layout_cells cells; + + TAILQ_ENTRY(layout_cell) entry; +}; + /* Paste buffer. */ struct paste_buffer { char *data; @@ -1446,8 +1480,7 @@ struct window *window_create(const char *, const char *, void window_destroy(struct window *); int window_resize(struct window *, u_int, u_int); void window_set_active_pane(struct window *, struct window_pane *); -struct window_pane *window_add_pane(struct window *, int, - const char *, const char *, const char **, u_int, char **); +struct window_pane *window_add_pane(struct window *, u_int, char **); void window_remove_pane(struct window *, struct window_pane *); struct window_pane *window_pane_at_index(struct window *, u_int); u_int window_pane_index(struct window *, struct window_pane *); @@ -1467,20 +1500,38 @@ void window_pane_mouse(struct window_pane *, struct client *, u_char, u_char, u_char); int window_pane_visible(struct window_pane *); char *window_pane_search( - struct window_pane *, const char *, u_int *); + struct window_pane *, const char *, u_int *); /* layout.c */ -const char * layout_name(struct window *); -int layout_lookup(const char *); -void layout_refresh(struct window *, int); -int layout_resize(struct window_pane *, int); -int layout_select(struct window *, u_int); -void layout_next(struct window *); -void layout_previous(struct window *); - -/* layout-manual.c */ -void layout_manual_v_refresh(struct window *, int); -void layout_manual_v_resize(struct window_pane *, int); +struct layout_cell *layout_create_cell(struct layout_cell *); +void layout_free_cell(struct layout_cell *); +void layout_print_cell(struct layout_cell *, const char *, u_int); +void layout_set_size( + struct layout_cell *, u_int, u_int, u_int, u_int); +void layout_make_leaf( + struct layout_cell *, struct window_pane *); +void layout_make_node(struct layout_cell *, enum layout_type); +void layout_fix_offsets(struct layout_cell *); +void layout_fix_panes(struct window *, u_int, u_int); +u_int layout_resize_check(struct layout_cell *, enum layout_type); +void layout_resize_adjust( + struct layout_cell *, enum layout_type, int); +void layout_init(struct window *); +void layout_free(struct window *); +void layout_resize(struct window *, u_int, u_int); +void layout_resize_pane( + struct window_pane *, enum layout_type, int); +int layout_split_pane(struct window_pane *, + enum layout_type, int, struct window_pane *); +void layout_close_pane(struct window_pane *); + +/* layout-set.c */ +const char *layout_set_name(u_int); +int layout_set_lookup(const char *); +u_int layout_set_select(struct window *, u_int); +u_int layout_set_next(struct window *); +u_int layout_set_previous(struct window *); +void layout_set_active_changed(struct window *); /* window-clock.c */ extern const struct window_mode window_clock_mode; |