summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-04-01 18:21:42 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-04-01 18:21:42 +0000
commitb6450b167b089201381f02e1919f18df8881e082 (patch)
treee554848e2da982d486fa084bf2e19982b8eec894
parent6789b3367a9916d823abaeba0703e3388ffcf80a (diff)
Basic horizontal splitting and layout management. Still some redraw and other
issues - particularly, don't mix with manual pane resizing and be careful when viewing from multiple clients; generally cycling the layout a few times will fix most problems. Getting this in for testing while I think about how to deal with manual mode. Split window as normal and cycle the layouts with C-b space. Some of the layouts will work better when swap-pane comes along.
-rw-r--r--CHANGES13
-rw-r--r--GNUmakefile6
-rw-r--r--Makefile6
-rw-r--r--cmd-down-pane.c4
-rw-r--r--cmd-kill-pane.c3
-rw-r--r--cmd-new-session.c3
-rw-r--r--cmd-next-layout.c54
-rw-r--r--cmd-select-pane.c3
-rw-r--r--cmd-server-info.c6
-rw-r--r--cmd-split-window.c3
-rw-r--r--cmd-up-pane.c4
-rw-r--r--cmd.c3
-rw-r--r--key-bindings.c3
-rw-r--r--layout.c219
-rw-r--r--resize.c14
-rw-r--r--screen-redraw.c174
-rw-r--r--server.c19
-rw-r--r--tmux.c4
-rw-r--r--tmux.h21
-rw-r--r--tty.c142
-rw-r--r--window.c9
21 files changed, 516 insertions, 197 deletions
diff --git a/CHANGES b/CHANGES
index 939b1cc2..fef5a8ee 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,14 @@
+01 April 2009
+
+* Basic horizontal splitting and layout management. Still some redraw and other
+ issues - particularly, don't mix with manual pane resizing and be careful
+ when viewing from multiple clients; generally cycling the layout a few times
+ will fix most problems. Getting this in for testing while I think about how
+ to deal with manual mode.
+
+ Split window as normal and cycle the layouts with C-b space. Some of the
+ layouts will work better when swap-pane comes along.
+
31 March 2009
* AIX port, thanks to cmihai for access to a box. Only tested on 6.1 with xlc
@@ -1173,7 +1184,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.266 2009-03-31 23:14:22 nicm Exp $
+$Id: CHANGES,v 1.267 2009-04-01 18:21:12 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
diff --git a/GNUmakefile b/GNUmakefile
index d40aeaff..687817f4 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,4 +1,4 @@
-# $Id: GNUmakefile,v 1.78 2009-03-31 22:08:45 nicm Exp $
+# $Id: GNUmakefile,v 1.79 2009-04-01 18:21:22 nicm Exp $
.PHONY: clean
@@ -17,7 +17,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
grid.c grid-view.c \
window.c session.c log.c client.c client-msg.c client-fn.c cfg.c \
key-string.c key-bindings.c resize.c arg.c mode-key.c \
- cmd.c cmd-generic.c cmd-string.c cmd-list.c \
+ layout.c cmd.c cmd-generic.c cmd-string.c cmd-list.c \
cmd-detach-client.c cmd-list-sessions.c cmd-new-window.c cmd-bind-key.c \
cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
@@ -37,7 +37,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-resize-pane-up.c cmd-resize-pane-down.c cmd-kill-pane.c \
cmd-up-pane.c cmd-down-pane.c cmd-choose-window.c cmd-choose-session.c \
cmd-suspend-client.c cmd-find-window.c cmd-load-buffer.c \
- cmd-copy-buffer.c cmd-break-pane.c \
+ cmd-copy-buffer.c cmd-break-pane.c cmd-next-layout.c \
window-clock.c window-scroll.c window-more.c window-copy.c \
window-choose.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
diff --git a/Makefile b/Makefile
index 30a3d697..f2c52d2e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.116 2009-03-07 09:29:54 nicm Exp $
+# $Id: Makefile,v 1.117 2009-04-01 18:21:23 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html
@@ -19,7 +19,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
screen.c screen-write.c screen-redraw.c \
grid.c grid-view.c \
window.c session.c log.c client.c client-msg.c client-fn.c cfg.c \
- key-string.c key-bindings.c resize.c arg.c mode-key.c \
+ layout.c key-string.c key-bindings.c resize.c arg.c mode-key.c \
cmd.c cmd-generic.c cmd-string.c cmd-list.c \
cmd-detach-client.c cmd-list-sessions.c cmd-new-window.c cmd-bind-key.c \
cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
@@ -40,7 +40,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-resize-pane-up.c cmd-resize-pane-down.c cmd-kill-pane.c \
cmd-up-pane.c cmd-down-pane.c cmd-choose-window.c cmd-choose-session.c \
cmd-suspend-client.c cmd-find-window.c cmd-load-buffer.c \
- cmd-copy-buffer.c cmd-break-pane.c \
+ cmd-copy-buffer.c cmd-break-pane.c cmd-next-layout.c \
window-clock.c window-scroll.c window-more.c window-copy.c \
window-choose.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
diff --git a/cmd-down-pane.c b/cmd-down-pane.c
index 842db127..cca5303a 100644
--- a/cmd-down-pane.c
+++ b/cmd-down-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-down-pane.c,v 1.4 2009-03-28 14:08:09 nicm Exp $ */
+/* $Id: cmd-down-pane.c,v 1.5 2009-04-01 18:21:24 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -56,5 +56,7 @@ cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
w->active = TAILQ_FIRST(&w->panes);
} while (w->active->flags & PANE_HIDDEN);
+ layout_refresh(wl->window);
+
return (0);
}
diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c
index 73e36cb9..a91d7c07 100644
--- a/cmd-kill-pane.c
+++ b/cmd-kill-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-kill-pane.c,v 1.4 2009-03-07 09:29:54 nicm Exp $ */
+/* $Id: cmd-kill-pane.c,v 1.5 2009-04-01 18:21:24 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -67,5 +67,6 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
window_remove_pane(wl->window, wp);
server_redraw_window(wl->window);
+ layout_refresh(wl->window);
return (0);
}
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 537b3fe5..e5756d0d 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-new-session.c,v 1.39 2009-02-11 17:50:33 nicm Exp $ */
+/* $Id: cmd-new-session.c,v 1.40 2009-04-01 18:21:24 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -185,6 +185,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
server_write_client(c, MSG_READY, NULL, 0);
server_redraw_client(c);
}
+ recalculate_sizes();
return (1);
}
diff --git a/cmd-next-layout.c b/cmd-next-layout.c
new file mode 100644
index 00000000..f5f611f6
--- /dev/null
+++ b/cmd-next-layout.c
@@ -0,0 +1,54 @@
+/* $Id: cmd-next-layout.c,v 1.1 2009-04-01 18:21:26 nicm Exp $ */
+
+/*
+ * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include "tmux.h"
+
+/*
+ * Switch window to next layout.
+ */
+
+int cmd_next_layout_exec(struct cmd *, struct cmd_ctx *);
+
+const struct cmd_entry cmd_next_layout_entry = {
+ "next-layout", "nextl",
+ CMD_TARGET_WINDOW_USAGE,
+ 0,
+ cmd_target_init,
+ cmd_target_parse,
+ cmd_next_layout_exec,
+ cmd_target_send,
+ cmd_target_recv,
+ cmd_target_free,
+ cmd_target_print
+};
+
+int
+cmd_next_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
+{
+ struct cmd_target_data *data = self->data;
+ struct winlink *wl;
+
+ if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
+ return (-1);
+
+ layout_next(wl->window);
+
+ return (0);
+}
diff --git a/cmd-select-pane.c b/cmd-select-pane.c
index b7f4e65a..16cdc95b 100644
--- a/cmd-select-pane.c
+++ b/cmd-select-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-select-pane.c,v 1.2 2009-01-19 18:23:40 nicm Exp $ */
+/* $Id: cmd-select-pane.c,v 1.3 2009-04-01 18:21:26 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -63,6 +63,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
}
window_set_active_pane(wl->window, wp);
+ layout_refresh(wl->window);
return (0);
}
diff --git a/cmd-server-info.c b/cmd-server-info.c
index 89d3d7da..ce680485 100644
--- a/cmd-server-info.c
+++ b/cmd-server-info.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-server-info.c,v 1.12 2009-03-29 19:09:57 nicm Exp $ */
+/* $Id: cmd-server-info.c,v 1.13 2009-04-01 18:21:28 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -115,8 +115,8 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
RB_FOREACH(wl, winlinks, &s->windows) {
w = wl->window;
ctx->print(ctx, "%4u: %p/%p %s [%ux%u] [flags=0x%x, "
- "references=%u]", wl->idx, wl, w, w->name,
- w->sx, w->sy, w->flags, w->references);
+ "references=%u, layout=%u]", wl->idx, wl, w, w->name,
+ w->sx, w->sy, w->flags, w->references, w->layout);
j = 0;
TAILQ_FOREACH(wp, &w->panes, entry) {
lines = ulines = size = usize = 0;
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 53bae77f..b79bcc82 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-split-window.c,v 1.9 2009-03-04 17:24:07 nicm Exp $ */
+/* $Id: cmd-split-window.c,v 1.10 2009-04-01 18:21:28 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -178,6 +178,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
server_redraw_session(s);
} else
server_status_session(s);
+ layout_refresh(w);
return (0);
}
diff --git a/cmd-up-pane.c b/cmd-up-pane.c
index a78e140d..d70a2a24 100644
--- a/cmd-up-pane.c
+++ b/cmd-up-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-up-pane.c,v 1.4 2009-03-28 14:08:09 nicm Exp $ */
+/* $Id: cmd-up-pane.c,v 1.5 2009-04-01 18:21:29 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -56,5 +56,7 @@ cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
w->active = TAILQ_LAST(&w->panes, window_panes);
} while (w->active->flags & PANE_HIDDEN);
+ layout_refresh(wl->window);
+
return (0);
}
diff --git a/cmd.c b/cmd.c
index c4e3267d..eade9e1b 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.86 2009-03-07 09:29:34 nicm Exp $ */
+/* $Id: cmd.c,v 1.87 2009-04-01 18:21:29 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -57,6 +57,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_move_window_entry,
&cmd_new_session_entry,
&cmd_new_window_entry,
+ &cmd_next_layout_entry,
&cmd_next_window_entry,
&cmd_paste_buffer_entry,
&cmd_previous_window_entry,
diff --git a/key-bindings.c b/key-bindings.c
index 76940123..02afc1c6 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -1,4 +1,4 @@
-/* $Id: key-bindings.c,v 1.63 2009-03-28 14:08:09 nicm Exp $ */
+/* $Id: key-bindings.c,v 1.64 2009-04-01 18:21:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -79,6 +79,7 @@ key_bindings_init(void)
int can_repeat;
const struct cmd_entry *entry;
} table[] = {
+ { ' ', 0, &cmd_next_layout_entry },
{ '!', 0, &cmd_break_pane_entry },
{ '"', 0, &cmd_split_window_entry },
{ '#', 0, &cmd_list_buffers_entry },
diff --git a/layout.c b/layout.c
new file mode 100644
index 00000000..032be3b0
--- /dev/null
+++ b/layout.c
@@ -0,0 +1,219 @@
+/* $Id: layout.c,v 1.1 2009-04-01 18:21:32 nicm Exp $ */
+
+/*
+ * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include "tmux.h"
+
+void layout_manual(struct window *);
+void layout_active_only(struct window *);
+void layout_even_horizontal(struct window *);
+void layout_even_vertical(struct window *);
+void layout_left_vertical(struct window *);
+
+const struct {
+ const char *name;
+ void (*fn)(struct window *);
+} layouts[] = {
+ { "manual", layout_manual },
+ { "active-only", layout_active_only },
+ { "even-horizontal", layout_even_horizontal },
+ { "even-vertical", layout_even_vertical },
+ { "left-vertical", layout_left_vertical },
+};
+
+void
+layout_next(struct window *w)
+{
+ w->layout++;
+ if (w->layout > nitems(layouts) - 1) {
+ w->layout = 0;
+ /* XXX Special-case manual. */
+ window_fit_panes(w);
+ window_update_panes(w);
+ }
+ layout_refresh(w);
+}
+
+void
+layout_refresh(struct window *w)
+{
+ layouts[w->layout].fn(w);
+ server_redraw_window(w);
+}
+
+void
+layout_manual(unused struct window *w)
+{
+}
+
+void
+layout_active_only(struct window *w)
+{
+ struct window_pane *wp;
+
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if (wp == w->active) {
+ wp->flags &= ~PANE_HIDDEN;
+ wp->xoff = wp->yoff = 0;
+ window_pane_resize(wp, w->sx, w->sy);
+ } else
+ wp->flags |= PANE_HIDDEN;
+ }
+}
+
+void
+layout_even_horizontal(struct window *w)
+{
+ struct window_pane *wp;
+ u_int i, n, width, xoff;
+
+ /* How many can we fit? */
+ n = window_count_panes(w);
+ if (w->sx / n < PANE_MINIMUM) {
+ width = PANE_MINIMUM;
+ n = w->sx / PANE_MINIMUM;
+ } else
+ width = w->sx / n;
+
+ /* Fit the panes. */
+ i = xoff = 0;
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if (i > n) {
+ wp->flags |= PANE_HIDDEN;
+ continue;
+ }
+ wp->flags &= ~PANE_HIDDEN;
+
+ wp->xoff = xoff;
+ wp->yoff = 0;
+ if (i != n - 1)
+ window_pane_resize(wp, width - 1, w->sy);
+ else
+ window_pane_resize(wp, width, w->sy);
+
+ i++;
+ xoff += width;
+ }
+
+ /* Any space left? */
+ while (xoff++ < w->sx) {
+ wp = TAILQ_LAST(&w->panes, window_panes);
+ window_pane_resize(wp, wp->sx + 1, wp->sy);
+ }
+}
+
+void
+layout_even_vertical(struct window *w)
+{
+ struct window_pane *wp;
+ u_int i, n, height, yoff;
+
+ /* How many can we fit? */
+ n = window_count_panes(w);
+ if (w->sy / n < PANE_MINIMUM) {
+ height = PANE_MINIMUM;
+ n = w->sy / PANE_MINIMUM;
+ } else
+ height = w->sy / n;
+
+ /* Fit the panes. */
+ i = yoff = 0;
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if (i > n) {
+ wp->flags |= PANE_HIDDEN;
+ continue;
+ }
+ wp->flags &= ~PANE_HIDDEN;
+
+ wp->xoff = 0;
+ wp->yoff = yoff;
+ if (i != n - 1)
+ window_pane_resize(wp, w->sx, height - 1);
+ else
+ window_pane_resize(wp, w->sx, height);
+
+ i++;
+ yoff += height;
+ }
+
+ /* Any space left? */
+ while (yoff++ < w->sy) {
+ wp = TAILQ_LAST(&w->panes, window_panes);
+ window_pane_resize(wp, wp->sx, wp->sy + 1);
+ }
+}
+
+void
+layout_left_vertical(struct window *w)
+{
+ struct window_pane *wp;
+ u_int i, n, height, yoff;
+
+ /* Need >1 pane and minimum columns; if fewer, display active only. */
+ n = window_count_panes(w) - 1;
+ if (n == 0 || w->sx < 82 + PANE_MINIMUM) {
+ layout_active_only(w);
+ return;
+ }
+
+ /* How many can we fit, not including first? */
+ if (w->sy / n < PANE_MINIMUM) {
+ height = PANE_MINIMUM;
+ n = w->sy / PANE_MINIMUM;
+ } else
+ height = w->sy / n;
+
+ /* Fit the panes. */
+ i = yoff = 0;
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if (wp == TAILQ_FIRST(&w->panes)) {
+ wp->xoff = 0;
+ wp->yoff = 0;
+ window_pane_resize(wp, 81, w->sy);
+ wp->flags &= ~PANE_HIDDEN;
+ continue;
+ }
+
+ if (i > n) {
+ wp->flags |= PANE_HIDDEN;
+ continue;
+ }
+ wp->flags &= ~PANE_HIDDEN;
+
+ wp->xoff = 82;
+ wp->yoff = yoff;
+ if (i != n - 1)
+ window_pane_resize(wp, w->sx - 82, height - 1);
+ else
+ window_pane_resize(wp, w->sx - 82, height);
+
+ i++;
+ yoff += height;
+ }
+
+ /* Any space left? */
+ while (yoff++ < w->sy) {
+ wp = TAILQ_LAST(&w->panes, window_panes);
+ while (wp != NULL && wp == TAILQ_FIRST(&w->panes))
+ wp = TAILQ_PREV(wp, window_panes, entry);
+ if (wp == NULL)
+ break;
+ window_pane_resize(wp, wp->sx, wp->sy + 1);
+ }
+}
diff --git a/resize.c b/resize.c
index 6ed0eb71..26aabbb0 100644
--- a/resize.c
+++ b/resize.c
@@ -1,4 +1,4 @@
-/* $Id: resize.c,v 1.19 2009-02-11 17:50:33 nicm Exp $ */
+/* $Id: resize.c,v 1.20 2009-04-01 18:21:32 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -45,11 +45,12 @@
void
recalculate_sizes(void)
{
- struct session *s;
- struct client *c;
- struct window *w;
- u_int i, j, ssx, ssy, has, limit;
- int flag;
+ struct session *s;
+ struct client *c;
+ struct window *w;
+ struct window_pane *wp;
+ u_int i, j, ssx, ssy, has, limit;
+ int flag;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i);
@@ -133,5 +134,6 @@ recalculate_sizes(void)
window_resize(w, ssx, ssy);
server_redraw_window(w);
+ layout_refresh(w);
}
}
diff --git a/screen-redraw.c b/screen-redraw.c
index fc90c3a2..7c989cca 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -1,4 +1,4 @@
-/* $Id: screen-redraw.c,v 1.30 2009-03-31 18:39:45 nicm Exp $ */
+/* $Id: screen-redraw.c,v 1.31 2009-04-01 18:21:35 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -22,119 +22,115 @@
#include "tmux.h"
-void screen_redraw_blankx(struct client *, u_int, u_int);
-void screen_redraw_blanky(struct client *, u_int, u_int, char);
-void screen_redraw_line(struct client *, struct screen *, u_int, u_int);
+int screen_redraw_check_cell(struct client *, u_int, u_int);
-/* Redraw entire screen.. */
-void
-screen_redraw_screen(struct client *c, struct screen *s)
+/* Check if cell inside a pane. */
+int
+screen_redraw_check_cell(struct client *c, u_int px, u_int py)
{
struct window *w = c->session->curw->window;
struct window_pane *wp;
- u_int i, cx, cy, sy;
- int status;
- /* Override the normal screen if one is given. */
- if (s != NULL) {
- for (i = 0; i < screen_size_y(s); i++)
- screen_redraw_line(c, s, 0, i);
- screen_redraw_status(c);
- return;
- }
-
- status = options_get_number(&c->session->options, "status");
+ if (px > w->sx || py > w->sy)
+ return (0);
- /* Fill in empty space on the right. */
- if (w->sx < c->tty.sx)
- screen_redraw_blankx(c, w->sx, c->tty.sx - w->sx);
-
- /* Draw the panes. */
TAILQ_FOREACH(wp, &w->panes, entry) {
- s = wp->screen;
-
- sy = screen_size_y(s);
-
- cx = s->cx;
- cy = s->cy;
- if (wp->yoff + sy <= w->sy) {
- for (i = 0; i < sy; i++) {
- if (wp->yoff + i != c->tty.sy - 1)
- screen_redraw_line(c, s, wp->yoff, i);
- }
- if (TAILQ_NEXT(wp, entry) != NULL)
- screen_redraw_blanky(c, wp->yoff + sy, 1, '-');
+ /* Inside pane. */
+ if (px >= wp->xoff && px < wp->xoff + wp->sx &&
+ py >= wp->yoff && py < wp->yoff + wp->sy)
+ return (1);
+
+ /* Left/right borders. */
+ if (py >= wp->yoff && py < wp->yoff + wp->sy) {
+ if (wp->xoff != 0 && px == wp->xoff - 1)
+ return (1);
+ if (px == wp->xoff + wp->sx)
+ return (1);
}
- s->cx = cx;
- s->cy = cy;
- }
-
- /* Fill in empty space below. */
- if (w->sy < c->tty.sy - status)
- screen_redraw_blanky(c, w->sy, c->tty.sy - status - w->sy, '=');
- /* Draw right border line. */
- if (w->sx < c->tty.sx) {
- for (i = 0; i < c->tty.sy; i++) {
- tty_putcode2(&c->tty, TTYC_CUP, i, w->sx);
- tty_putc(&c->tty, '|');
+ /* Top/bottom borders. */
+ if (px >= wp->xoff && px < wp->xoff + wp->sx) {
+ if (wp->yoff != 0 && py == wp->yoff - 1)
+ return (1);
+ if (py == wp->yoff + wp->sy)
+ return (1);
}
}
- /* Draw the status line. */
- screen_redraw_status(c);
+ return (0);
}
-/* Draw the status line. */
+/* Redraw entire screen.. */
void
-screen_redraw_status(struct client *c)
+screen_redraw_screen(struct client *c)
{
- screen_redraw_line(c, &c->status, c->tty.sy - 1, 0);
-}
+ struct window *w = c->session->curw->window;
+ struct tty *tty = &c->tty;
+ struct window_pane *wp;
+ struct screen *s;
+ u_int i, j, sx, sy;
+ int status;
-/* Draw blank columns. */
-void
-screen_redraw_blankx(struct client *c, u_int ox, u_int nx)
-{
- u_int i, j;
+ /* Get status line, er, status. */
+ status = options_get_number(&c->session->options, "status");
- tty_putcode(&c->tty, TTYC_SGR0);
- for (j = 0; j < c->tty.sy; j++) {
- tty_putcode2(&c->tty, TTYC_CUP, j, ox);
- for (i = 0; i < nx; i++)
- tty_putc(&c->tty, ' ');
+ /* Clear the screen. */
+ tty_reset(tty);
+ for (j = 0; j < tty->sy - status; j++) {
+ for (i = 0; i < tty->sx; i++) {
+ if (!screen_redraw_check_cell(c, i, j)) {
+ tty_cursor(tty, i, j, 0, 0);
+ tty_putc(tty, '.');
+ }
+ }
}
- c->tty.cx = UINT_MAX;
- c->tty.cy = UINT_MAX;
- memcpy(&c->tty.cell, &grid_default_cell, sizeof c->tty.cell);
-}
+ /* Draw the panes. */
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ tty_reset(tty);
-/* Draw blank lines. */
-void
-screen_redraw_blanky(struct client *c, u_int oy, u_int ny, char ch)
-{
- u_int i, j;
-
- tty_putcode(&c->tty, TTYC_SGR0);
- for (j = 0; j < ny; j++) {
- tty_putcode2(&c->tty, TTYC_CUP, oy + j, 0);
- for (i = 0; i < c->tty.sx; i++) {
- if (j == 0)
- tty_putc(&c->tty, ch);
- else
- tty_putc(&c->tty, ' ');
+ s = wp->screen;
+ sx = wp->sx;
+ sy = wp->sy;
+
+ /* Draw left and right borders. */
+ if (wp->xoff > 0) {
+ for (i = wp->yoff; i < wp->yoff + sy; i++) {
+ tty_cursor(tty, wp->xoff - 1, i, 0, 0);
+ tty_putc(tty, '|');
+ }
+ }
+ if (wp->xoff + sx < tty->sx) {
+ for (i = wp->yoff; i < wp->yoff + sy; i++) {
+ tty_cursor(tty, wp->xoff + sx, i, 0, 0);
+ tty_putc(&c->tty, '|');
+ }
}
- }
- c->tty.cx = UINT_MAX;
- c->tty.cy = UINT_MAX;
- memcpy(&c->tty.cell, &grid_default_cell, sizeof c->tty.cell);
+ /* Draw top and bottom borders. */
+ if (wp->yoff > 0) {
+ tty_cursor(tty, wp->xoff, wp->yoff - 1, 0, 0);
+ for (i = 0; i < sx; i++)
+ tty_putc(tty, '-');
+ }
+ if (wp->yoff + sy < tty->sy) {
+ tty_cursor(tty, wp->xoff, wp->yoff + sy, 0, 0);
+ for (i = 0; i < sx; i++)
+ tty_putc(tty, '-');
+ }
+
+ /* Draw the pane. */
+ for (i = 0; i < sy; i++)
+ tty_draw_line(tty, s, i, wp->xoff, wp->yoff);
+ }
+
+ /* Draw the status line. */
+ screen_redraw_status(c);
}
-/* Draw a line. */
+/* Draw the status line. */
void
-screen_redraw_line(struct client *c, struct screen *s, u_int oy, u_int py)
+screen_redraw_status(struct client *c)
{
- tty_draw_line(&c->tty, s, py, oy);
+ tty_draw_line(&c->tty, &c->status, 0, 0, c->tty.sy - 1);
}
diff --git a/server.c b/server.c
index 7d5eb34f..173b1cda 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.132 2009-03-31 22:20:42 nicm Exp $ */
+/* $Id: server.c,v 1.133 2009-04-01 18:21:35 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -518,7 +518,7 @@ server_check_redraw(struct client *c)
if (server_locked)
server_redraw_locked(c);
else
- screen_redraw_screen(c, NULL);
+ screen_redraw_screen(c);
c->flags &= ~CLIENT_STATUS;
}
@@ -536,7 +536,7 @@ server_redraw_locked(struct client *c)
{
struct screen_write_ctx ctx;
struct screen screen;
- u_int colour, xx, yy;
+ u_int colour, xx, yy, i;
int style;
xx = c->tty.sx;
@@ -554,7 +554,9 @@ server_redraw_locked(struct client *c)
clock_draw(&ctx, colour, style);
screen_write_stop(&ctx);
- screen_redraw_screen(c, &screen);
+ for (i = 0; i < screen_size_y(&screen); i++)
+ tty_draw_line(&c->tty, &screen, i, 0, 0);
+ screen_redraw_status(c);
screen_free(&screen);
}
@@ -689,6 +691,7 @@ void
server_handle_client(struct client *c)
{
struct window_pane *wp;
+ struct screen *s;
struct timeval tv;
struct key_binding *bd;
int key, prefix, status, xtimeout;
@@ -776,13 +779,14 @@ server_handle_client(struct client *c)
if (c->session == NULL)
return;
wp = c->session->curw->window->active; /* could die - do each loop */
+ s = wp->screen;
/* Ensure cursor position and mode settings. */
status = options_get_number(&c->session->options, "status");
- if (wp->yoff + wp->screen->cy < c->tty.sy - status)
- tty_cursor(&c->tty, wp->screen->cx, wp->screen->cy, wp->yoff);
+ if (wp->yoff + s->cy < c->tty.sy - status)
+ tty_cursor(&c->tty, s->cx, s->cy, wp->xoff, wp->yoff);
- mode = wp->screen->mode;
+ mode = s->mode;
if (server_locked)
mode &= ~TTY_NOCURSOR;
tty_update_mode(&c->tty, mode);
@@ -912,6 +916,7 @@ server_check_window(struct window *w)
else if (!flag) {
window_remove_pane(w, wp);
server_redraw_window(w);
+ layout_refresh(w);
}
wp = wq;
}
diff --git a/tmux.c b/tmux.c
index 1dce5723..b9639812 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.110 2009-03-27 15:57:10 nicm Exp $ */
+/* $Id: tmux.c,v 1.111 2009-04-01 18:21:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -216,7 +216,7 @@ main(int argc, char **argv)
const char *shell;
struct passwd *pw;
char *path, *label, *cause, *home, *pass = NULL;
- char cwd[MAXPATHLEN];
+ char cwd[MAXPATHLEN];
int retcode, opt, flags, unlock, start_server;
unlock = flags = 0;
diff --git a/tmux.h b/tmux.h
index 2a0745c1..e9c35367 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.293 2009-03-31 22:08:45 nicm Exp $ */
+/* $Id: tmux.h,v 1.294 2009-04-01 18:21:42 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -650,6 +650,7 @@ struct window_pane {
u_int sx;
u_int sy;
+ u_int xoff;
u_int yoff;
int flags;
@@ -684,10 +685,11 @@ struct window {
struct window_pane *active;
struct window_panes panes;
+ u_int layout;
u_int sx;
u_int sy;
-
+
int flags;
#define WINDOW_BELL 0x1
#define WINDOW_HIDDEN 0x2
@@ -1064,9 +1066,11 @@ void options_set_number(struct options *, const char *, long long);
long long options_get_number(struct options *, const char *);
/* tty.c */
+void tty_emulate_repeat(struct tty *,
+ enum tty_code_code, enum tty_code_code, u_int);
void tty_reset(struct tty *);
void tty_region(struct tty *, u_int, u_int, u_int);
-void tty_cursor(struct tty *, u_int, u_int, u_int);
+void tty_cursor(struct tty *, u_int, u_int, u_int, u_int);
void tty_cell(struct tty *,
const struct grid_cell *, const struct grid_utf8 *);
void tty_putcode(struct tty *, enum tty_code_code);
@@ -1079,7 +1083,9 @@ void tty_start_tty(struct tty *);
void tty_stop_tty(struct tty *);
void tty_set_title(struct tty *, const char *);
void tty_update_mode(struct tty *, int);
-void tty_draw_line(struct tty *, struct screen *, u_int, u_int);
+void tty_draw_line(
+ struct tty *, struct screen *, u_int, u_int, u_int);
+void tty_draw_region(struct tty *, struct screen *, u_int, u_int);
int tty_open(struct tty *, char **);
void tty_close(struct tty *, int);
void tty_free(struct tty *, int);
@@ -1193,6 +1199,7 @@ extern const struct cmd_entry cmd_lock_server_entry;
extern const struct cmd_entry cmd_move_window_entry;
extern const struct