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.
This commit is contained in:
Nicholas Marriott 2009-04-01 18:21:42 +00:00
parent 6789b3367a
commit b6450b167b
21 changed files with 518 additions and 199 deletions

13
CHANGES
View File

@ -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 31 March 2009
* AIX port, thanks to cmihai for access to a box. Only tested on 6.1 with xlc * 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 (including mutt, emacs). No status bar yet and no key remapping or other
customisation. 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: 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 LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms

View File

@ -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 .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 \ grid.c grid-view.c \
window.c session.c log.c client.c client-msg.c client-fn.c cfg.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 \ 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-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-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 \ 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-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-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-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-clock.c window-scroll.c window-more.c window-copy.c \
window-choose.c \ window-choose.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \ options.c options-cmd.c paste.c colour.c utf8.c clock.c \

View File

@ -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 .SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html .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 \ screen.c screen-write.c screen-redraw.c \
grid.c grid-view.c \ grid.c grid-view.c \
window.c session.c log.c client.c client-msg.c client-fn.c cfg.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.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-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-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-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-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-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-clock.c window-scroll.c window-more.c window-copy.c \
window-choose.c \ window-choose.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \ options.c options-cmd.c paste.c colour.c utf8.c clock.c \

View File

@ -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> * 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); w->active = TAILQ_FIRST(&w->panes);
} while (w->active->flags & PANE_HIDDEN); } while (w->active->flags & PANE_HIDDEN);
layout_refresh(wl->window);
return (0); return (0);
} }

View File

@ -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> * 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); window_remove_pane(wl->window, wp);
server_redraw_window(wl->window); server_redraw_window(wl->window);
layout_refresh(wl->window);
return (0); return (0);
} }

View File

@ -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> * 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_write_client(c, MSG_READY, NULL, 0);
server_redraw_client(c); server_redraw_client(c);
} }
recalculate_sizes();
return (1); return (1);
} }

54
cmd-next-layout.c Normal file
View File

@ -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);
}

View File

@ -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> * 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); return (-1);
} }
window_set_active_pane(wl->window, wp); window_set_active_pane(wl->window, wp);
layout_refresh(wl->window);
return (0); return (0);
} }

View File

@ -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> * 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) { RB_FOREACH(wl, winlinks, &s->windows) {
w = wl->window; w = wl->window;
ctx->print(ctx, "%4u: %p/%p %s [%ux%u] [flags=0x%x, " ctx->print(ctx, "%4u: %p/%p %s [%ux%u] [flags=0x%x, "
"references=%u]", wl->idx, wl, w, w->name, "references=%u, layout=%u]", wl->idx, wl, w, w->name,
w->sx, w->sy, w->flags, w->references); w->sx, w->sy, w->flags, w->references, w->layout);
j = 0; j = 0;
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
lines = ulines = size = usize = 0; lines = ulines = size = usize = 0;

View File

@ -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> * 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); server_redraw_session(s);
} else } else
server_status_session(s); server_status_session(s);
layout_refresh(w);
return (0); return (0);
} }

View File

@ -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> * 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); w->active = TAILQ_LAST(&w->panes, window_panes);
} while (w->active->flags & PANE_HIDDEN); } while (w->active->flags & PANE_HIDDEN);
layout_refresh(wl->window);
return (0); return (0);
} }

3
cmd.c
View File

@ -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> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -57,6 +57,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_move_window_entry, &cmd_move_window_entry,
&cmd_new_session_entry, &cmd_new_session_entry,
&cmd_new_window_entry, &cmd_new_window_entry,
&cmd_next_layout_entry,
&cmd_next_window_entry, &cmd_next_window_entry,
&cmd_paste_buffer_entry, &cmd_paste_buffer_entry,
&cmd_previous_window_entry, &cmd_previous_window_entry,

View File

@ -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> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -79,6 +79,7 @@ key_bindings_init(void)
int can_repeat; int can_repeat;
const struct cmd_entry *entry; const struct cmd_entry *entry;
} table[] = { } table[] = {
{ ' ', 0, &cmd_next_layout_entry },
{ '!', 0, &cmd_break_pane_entry }, { '!', 0, &cmd_break_pane_entry },
{ '"', 0, &cmd_split_window_entry }, { '"', 0, &cmd_split_window_entry },
{ '#', 0, &cmd_list_buffers_entry }, { '#', 0, &cmd_list_buffers_entry },

219
layout.c Normal file
View File

@ -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);
}
}

View File

@ -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> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -45,11 +45,12 @@
void void
recalculate_sizes(void) recalculate_sizes(void)
{ {
struct session *s; struct session *s;
struct client *c; struct client *c;
struct window *w; struct window *w;
u_int i, j, ssx, ssy, has, limit; struct window_pane *wp;
int flag; u_int i, j, ssx, ssy, has, limit;
int flag;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i); s = ARRAY_ITEM(&sessions, i);
@ -133,5 +134,6 @@ recalculate_sizes(void)
window_resize(w, ssx, ssy); window_resize(w, ssx, ssy);
server_redraw_window(w); server_redraw_window(w);
layout_refresh(w);
} }
} }

View File

@ -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> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -22,65 +22,108 @@
#include "tmux.h" #include "tmux.h"
void screen_redraw_blankx(struct client *, u_int, u_int); int screen_redraw_check_cell(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);
/* Redraw entire screen.. */ /* Check if cell inside a pane. */
void int
screen_redraw_screen(struct client *c, struct screen *s) screen_redraw_check_cell(struct client *c, u_int px, u_int py)
{ {
struct window *w = c->session->curw->window; struct window *w = c->session->curw->window;
struct window_pane *wp; struct window_pane *wp;
u_int i, cx, cy, sy;
int status;
/* Override the normal screen if one is given. */ if (px > w->sx || py > w->sy)
if (s != NULL) { return (0);
for (i = 0; i < screen_size_y(s); i++)
screen_redraw_line(c, s, 0, i); TAILQ_FOREACH(wp, &w->panes, entry) {
screen_redraw_status(c); /* Inside pane. */
return; 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);
}
/* 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);
}
} }
return (0);
}
/* Redraw entire screen.. */
void
screen_redraw_screen(struct client *c)
{
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;
/* Get status line, er, status. */
status = options_get_number(&c->session->options, "status"); status = options_get_number(&c->session->options, "status");
/* Fill in empty space on the right. */ /* Clear the screen. */
if (w->sx < c->tty.sx) tty_reset(tty);
screen_redraw_blankx(c, w->sx, c->tty.sx - w->sx); 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, '.');
}
}
}
/* Draw the panes. */ /* Draw the panes. */
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
tty_reset(tty);
s = wp->screen; s = wp->screen;
sx = wp->sx;
sy = screen_size_y(s); sy = wp->sy;
cx = s->cx; /* Draw left and right borders. */
cy = s->cy; if (wp->xoff > 0) {
if (wp->yoff + sy <= w->sy) { for (i = wp->yoff; i < wp->yoff + sy; i++) {
for (i = 0; i < sy; i++) { tty_cursor(tty, wp->xoff - 1, i, 0, 0);
if (wp->yoff + i != c->tty.sy - 1) tty_putc(tty, '|');
screen_redraw_line(c, s, wp->yoff, i);
} }
if (TAILQ_NEXT(wp, entry) != NULL)
screen_redraw_blanky(c, wp->yoff + sy, 1, '-');
} }
s->cx = cx; if (wp->xoff + sx < tty->sx) {
s->cy = cy; for (i = wp->yoff; i < wp->yoff + sy; i++) {
} tty_cursor(tty, wp->xoff + sx, i, 0, 0);
tty_putc(&c->tty, '|');
/* 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, '|');
} }
}
/* 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. */ /* Draw the status line. */
screen_redraw_status(c); screen_redraw_status(c);
} }
@ -89,52 +132,5 @@ screen_redraw_screen(struct client *c, struct screen *s)
void void
screen_redraw_status(struct client *c) screen_redraw_status(struct client *c)
{ {
screen_redraw_line(c, &c->status, c->tty.sy - 1, 0); tty_draw_line(&c->tty, &c->status, 0, 0, c->tty.sy - 1);
}
/* Draw blank columns. */
void
screen_redraw_blankx(struct client *c, u_int ox, u_int nx)
{
u_int i, j;
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, ' ');
}
c->tty.cx = UINT_MAX;
c->tty.cy = UINT_MAX;
memcpy(&c->tty.cell, &grid_default_cell, sizeof c->tty.cell);
}
/* 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, ' ');
}
}
c->tty.cx = UINT_MAX;
c->tty.cy = UINT_MAX;
memcpy(&c->tty.cell, &grid_default_cell, sizeof c->tty.cell);
}
/* Draw a line. */
void
screen_redraw_line(struct client *c, struct screen *s, u_int oy, u_int py)
{
tty_draw_line(&c->tty, s, py, oy);
} }

View File

@ -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> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -518,7 +518,7 @@ server_check_redraw(struct client *c)
if (server_locked) if (server_locked)
server_redraw_locked(c); server_redraw_locked(c);
else else
screen_redraw_screen(c, NULL); screen_redraw_screen(c);
c->flags &= ~CLIENT_STATUS; c->flags &= ~CLIENT_STATUS;
} }
@ -536,7 +536,7 @@ server_redraw_locked(struct client *c)
{ {
struct screen_write_ctx ctx; struct screen_write_ctx ctx;
struct screen screen; struct screen screen;
u_int colour, xx, yy; u_int colour, xx, yy, i;
int style; int style;
xx = c->tty.sx; xx = c->tty.sx;
@ -554,7 +554,9 @@ server_redraw_locked(struct client *c)
clock_draw(&ctx, colour, style); clock_draw(&ctx, colour, style);
screen_write_stop(&ctx); 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); screen_free(&screen);
} }
@ -689,6 +691,7 @@ void
server_handle_client(struct client *c) server_handle_client(struct client *c)
{ {
struct window_pane *wp; struct window_pane *wp;
struct screen *s;
struct timeval tv; struct timeval tv;
struct key_binding *bd; struct key_binding *bd;
int key, prefix, status, xtimeout; int key, prefix, status, xtimeout;
@ -776,13 +779,14 @@ server_handle_client(struct client *c)
if (c->session == NULL) if (c->session == NULL)
return; return;
wp = c->session->curw->window->active; /* could die - do each loop */ wp = c->session->curw->window->active; /* could die - do each loop */
s = wp->screen;
/* Ensure cursor position and mode settings. */ /* Ensure cursor position and mode settings. */
status = options_get_number(&c->session->options, "status"); status = options_get_number(&c->session->options, "status");
if (wp->yoff + wp->screen->cy < c->tty.sy - status) if (wp->yoff + s->cy < c->tty.sy - status)
tty_cursor(&c->tty, wp->screen->cx, wp->screen->cy, wp->yoff); tty_cursor(&c->tty, s->cx, s->cy, wp->xoff, wp->yoff);
mode = wp->screen->mode; mode = s->mode;
if (server_locked) if (server_locked)
mode &= ~TTY_NOCURSOR; mode &= ~TTY_NOCURSOR;
tty_update_mode(&c->tty, mode); tty_update_mode(&c->tty, mode);
@ -912,6 +916,7 @@ server_check_window(struct window *w)
else if (!flag) { else if (!flag) {
window_remove_pane(w, wp); window_remove_pane(w, wp);
server_redraw_window(w); server_redraw_window(w);
layout_refresh(w);
} }
wp = wq; wp = wq;
} }

4
tmux.c
View File

@ -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> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -216,7 +216,7 @@ main(int argc, char **argv)
const char *shell; const char *shell;
struct passwd *pw; struct passwd *pw;
char *path, *label, *cause, *home, *pass = NULL; char *path, *label, *cause, *home, *pass = NULL;
char cwd[MAXPATHLEN]; char cwd[MAXPATHLEN];
int retcode, opt, flags, unlock, start_server; int retcode, opt, flags, unlock, start_server;
unlock = flags = 0; unlock = flags = 0;

21
tmux.h
View File

@ -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> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -650,6 +650,7 @@ struct window_pane {
u_int sx; u_int sx;
u_int sy; u_int sy;
u_int xoff;
u_int yoff; u_int yoff;
int flags; int flags;
@ -684,10 +685,11 @@ struct window {
struct window_pane *active; struct window_pane *active;
struct window_panes panes; struct window_panes panes;
u_int layout;
u_int sx; u_int sx;
u_int sy; u_int sy;
int flags; int flags;
#define WINDOW_BELL 0x1 #define WINDOW_BELL 0x1
#define WINDOW_HIDDEN 0x2 #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 *); long long options_get_number(struct options *, const char *);
/* tty.c */ /* 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_reset(struct tty *);
void tty_region(struct tty *, u_int, u_int, u_int); 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 *, void tty_cell(struct tty *,
const struct grid_cell *, const struct grid_utf8 *); const struct grid_cell *, const struct grid_utf8 *);
void tty_putcode(struct tty *, enum tty_code_code); 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_stop_tty(struct tty *);
void tty_set_title(struct tty *, const char *); void tty_set_title(struct tty *, const char *);
void tty_update_mode(struct tty *, int); 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 **); int tty_open(struct tty *, char **);
void tty_close(struct tty *, int); void tty_close(struct tty *, int);
void tty_free(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 cmd_entry cmd_move_window_entry;
extern const struct cmd_entry cmd_new_session_entry; extern const struct cmd_entry cmd_new_session_entry;
extern const struct cmd_entry cmd_new_window_entry; extern const struct cmd_entry cmd_new_window_entry;
extern const struct cmd_entry cmd_next_layout_entry;
extern const struct cmd_entry cmd_next_window_entry; extern const struct cmd_entry cmd_next_window_entry;
extern const struct cmd_entry cmd_paste_buffer_entry; extern const struct cmd_entry cmd_paste_buffer_entry;
extern const struct cmd_entry cmd_previous_window_entry; extern const struct cmd_entry cmd_previous_window_entry;
@ -1457,7 +1464,7 @@ void screen_write_cell(
struct screen_write_ctx *, const struct grid_cell *, u_char *); struct screen_write_ctx *, const struct grid_cell *, u_char *);
/* screen-redraw.c */ /* screen-redraw.c */
void screen_redraw_screen(struct client *, struct screen *); void screen_redraw_screen(struct client *);
void screen_redraw_status(struct client *); void screen_redraw_status(struct client *);
/* screen.c */ /* screen.c */
@ -1519,6 +1526,10 @@ void window_pane_key(struct window_pane *, struct client *, int);
void window_pane_mouse(struct window_pane *, void window_pane_mouse(struct window_pane *,
struct client *, u_char, u_char, u_char); struct client *, u_char, u_char, u_char);
/* layout.c */
void layout_refresh(struct window *);
void layout_next(struct window *);
/* window-clock.c */ /* window-clock.c */
extern const struct window_mode window_clock_mode; extern const struct window_mode window_clock_mode;

142
tty.c
View File

@ -1,4 +1,4 @@
/* $Id: tty.c,v 1.89 2009-03-31 22:20:42 nicm Exp $ */ /* $Id: tty.c,v 1.90 2009-04-01 18:21:42 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -30,9 +30,6 @@
void tty_fill_acs(struct tty *); void tty_fill_acs(struct tty *);
u_char tty_get_acs(struct tty *, u_char); u_char tty_get_acs(struct tty *, u_char);
void tty_emulate_repeat(
struct tty *, enum tty_code_code, enum tty_code_code, u_int);
void tty_raw(struct tty *, const char *); void tty_raw(struct tty *, const char *);
int tty_try_256(struct tty *, u_char, const char *); int tty_try_256(struct tty *, u_char, const char *);
@ -383,7 +380,21 @@ tty_emulate_repeat(
} }
void void
tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int oy) tty_draw_region(struct tty *tty, struct screen *s, u_int ox, u_int oy)
{
u_int i;
if (s->old_cy < s->old_rupper || s->old_cy > s->old_rlower) {
for (i = s->old_cy; i < screen_size_y(s); i++)
tty_draw_line(tty, s, i, ox, oy);
} else {
for (i = s->old_rupper; i <= s->old_rlower; i++)
tty_draw_line(tty, s, i, ox, oy);
}
}
void
tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy)
{ {
const struct grid_cell *gc; const struct grid_cell *gc;
const struct grid_utf8 *gu; const struct grid_utf8 *gu;
@ -395,6 +406,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int oy)
if (sx > tty->sx) if (sx > tty->sx)
sx = tty->sx; sx = tty->sx;
tty_cursor(tty, 0, py, ox, oy);
for (i = 0; i < sx; i++) { for (i = 0; i < sx; i++) {
gc = grid_view_peek_cell(s->grid, i, py); gc = grid_view_peek_cell(s->grid, i, py);
@ -402,7 +414,6 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int oy)
if (gc->flags & GRID_FLAG_UTF8) if (gc->flags & GRID_FLAG_UTF8)
gu = grid_view_peek_utf8(s->grid, i, py); gu = grid_view_peek_utf8(s->grid, i, py);
tty_cursor(tty, i, py, oy);
if (screen_check_selection(s, i, py)) { if (screen_check_selection(s, i, py)) {
s->sel.cell.data = gc->data; s->sel.cell.data = gc->data;
tty_cell(tty, &s->sel.cell, gu); tty_cell(tty, &s->sel.cell, gu);
@ -414,7 +425,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int oy)
return; return;
tty_reset(tty); tty_reset(tty);
tty_cursor(tty, sx, py, oy); tty_cursor(tty, sx, py, ox, oy);
if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL))
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
else { else {
@ -449,8 +460,8 @@ tty_cmd_insertcharacter(struct tty *tty, struct window_pane *wp, va_list ap)
struct screen *s = wp->screen; struct screen *s = wp->screen;
u_int ua; u_int ua;
if (screen_size_x(s) < tty->sx) { if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
tty_draw_line(tty, wp->screen, s->old_cy, wp->yoff); tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff);
return; return;
} }
@ -458,7 +469,7 @@ tty_cmd_insertcharacter(struct tty *tty, struct window_pane *wp, va_list ap)
tty_reset(tty); tty_reset(tty);
tty_cursor(tty, s->old_cx, s->old_cy, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
if (tty_term_has(tty->term, TTYC_ICH) || if (tty_term_has(tty->term, TTYC_ICH) ||
tty_term_has(tty->term, TTYC_ICH1)) tty_term_has(tty->term, TTYC_ICH1))
tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ua); tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ua);
@ -476,8 +487,8 @@ tty_cmd_deletecharacter(struct tty *tty, struct window_pane *wp, va_list ap)
struct screen *s = wp->screen; struct screen *s = wp->screen;
u_int ua; u_int ua;
if (screen_size_x(s) < tty->sx) { if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
tty_draw_line(tty, wp->screen, s->old_cy, wp->yoff); tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff);
return; return;
} }
@ -485,7 +496,7 @@ tty_cmd_deletecharacter(struct tty *tty, struct window_pane *wp, va_list ap)
tty_reset(tty); tty_reset(tty);
tty_cursor(tty, s->old_cx, s->old_cy, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ua); tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ua);
} }
@ -493,20 +504,15 @@ void
tty_cmd_insertline(struct tty *tty, struct window_pane *wp, va_list ap) tty_cmd_insertline(struct tty *tty, struct window_pane *wp, va_list ap)
{ {
struct screen *s = wp->screen; struct screen *s = wp->screen;
u_int ua, i; u_int ua;
if (screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
!tty_term_has(tty->term, TTYC_CSR)) {
/* /*
* Scroll region unsupported. Redraw using data from screen * Scroll region unsupported. Redraw using data from screen
* (already updated). * (already updated).
*/ */
if (s->old_cy < s->old_rupper || s->old_cy > s->old_rlower) { tty_draw_region(tty, s, wp->xoff, wp->yoff);
for (i = s->old_cy; i < screen_size_y(s); i++)
tty_draw_line(tty, wp->screen, i, wp->yoff);
} else {
for (i = s->old_rupper; i <= s->old_rlower; i++)
tty_draw_line(tty, wp->screen, i, wp->yoff);
}
return; return;
} }
@ -516,7 +522,7 @@ tty_cmd_insertline(struct tty *tty, struct window_pane *wp, va_list ap)
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
tty_cursor(tty, s->old_cx, s->old_cy, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ua); tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ua);
} }
@ -524,20 +530,15 @@ void
tty_cmd_deleteline(struct tty *tty, struct window_pane *wp, va_list ap) tty_cmd_deleteline(struct tty *tty, struct window_pane *wp, va_list ap)
{ {
struct screen *s = wp->screen; struct screen *s = wp->screen;
u_int ua, i; u_int ua;
if (screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
!tty_term_has(tty->term, TTYC_CSR)) {
/* /*
* Scroll region unsupported. Redraw using data from screen * Scroll region unsupported. Redraw using data from screen
* (already updated). * (already updated).
*/ */
if (s->old_cy < s->old_rupper || s->old_cy > s->old_rlower) { tty_draw_region(tty, s, wp->xoff, wp->yoff);
for (i = s->old_cy; i < screen_size_y(s); i++)
tty_draw_line(tty, wp->screen, i, wp->yoff);
} else {
for (i = s->old_rupper; i <= s->old_rlower; i++)
tty_draw_line(tty, wp->screen, i, wp->yoff);
}
return; return;
} }
@ -547,7 +548,7 @@ tty_cmd_deleteline(struct tty *tty, struct window_pane *wp, va_list ap)
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
tty_cursor(tty, s->old_cx, s->old_cy, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ua); tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ua);
} }
@ -559,8 +560,9 @@ tty_cmd_clearline(struct tty *tty, struct window_pane *wp, unused va_list ap)
tty_reset(tty); tty_reset(tty);
tty_cursor(tty, 0, s->old_cy, wp->yoff); tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff);
if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
} else { } else {
for (i = 0; i < screen_size_x(s); i++) for (i = 0; i < screen_size_x(s); i++)
@ -577,8 +579,9 @@ tty_cmd_clearendofline(
tty_reset(tty); tty_reset(tty);
tty_cursor(tty, s->old_cx, s->old_cy, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL))
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
else { else {
for (i = s->old_cx; i < screen_size_x(s); i++) for (i = s->old_cx; i < screen_size_x(s); i++)
@ -595,11 +598,11 @@ tty_cmd_clearstartofline(
tty_reset(tty); tty_reset(tty);
if (tty_term_has(tty->term, TTYC_EL1)) { if (wp->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) {
tty_cursor(tty, s->old_cx, s->old_cy, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
tty_putcode(tty, TTYC_EL1); tty_putcode(tty, TTYC_EL1);
} else { } else {
tty_cursor(tty, 0, s->old_cy, wp->yoff); tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff);
for (i = 0; i < s->old_cx + 1; i++) for (i = 0; i < s->old_cx + 1; i++)
tty_putc(tty, ' '); tty_putc(tty, ' ');
} }
@ -611,15 +614,16 @@ tty_cmd_reverseindex(struct tty *tty, struct window_pane *wp, unused va_list ap)
struct screen *s = wp->screen; struct screen *s = wp->screen;
u_int i; u_int i;
if (screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
!tty_term_has(tty->term, TTYC_CSR)) {
/* /*
* Scroll region unsupported. If would have scrolled, redraw * Scroll region unsupported. If would have scrolled, redraw
* scroll region from already updated window screen. * scroll region from already updated window screen.
*/ */
if (s->old_cy == s->old_rupper) { if (s->old_cy != s->old_rupper)
for (i = s->old_rupper; i <= s->old_rlower; i++) return;
tty_draw_line(tty, wp->screen, i, wp->yoff); for (i = s->old_rupper; i <= s->old_rlower; i++)
} tty_draw_line(tty, wp->screen, i, wp->xoff, wp->yoff);
return; return;
} }
@ -628,7 +632,7 @@ tty_cmd_reverseindex(struct tty *tty, struct window_pane *wp, unused va_list ap)
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
if (s->old_cy == s->old_rupper) { if (s->old_cy == s->old_rupper) {
tty_cursor(tty, s->old_cx, s->old_rupper, wp->yoff); tty_cursor(tty, s->old_cx, s->old_rupper, wp->xoff, wp->yoff);
tty_putcode(tty, TTYC_RI); tty_putcode(tty, TTYC_RI);
} }
} }
@ -639,23 +643,24 @@ tty_cmd_linefeed(struct tty *tty, struct window_pane *wp, unused va_list ap)
struct screen *s = wp->screen; struct screen *s = wp->screen;
u_int i; u_int i;
if (screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
!tty_term_has(tty->term, TTYC_CSR)) {
/* /*
* Scroll region unsupported. If would have scrolled, redraw * Scroll region unsupported. If would have scrolled, redraw
* scroll region from already updated window screen. * scroll region from already updated window screen.
*/ */
if (s->old_cy == s->old_rlower) { if (s->old_cy != s->old_rlower)
for (i = s->old_rupper; i <= s->old_rlower; i++)
tty_draw_line(tty, wp->screen, i, wp->yoff);
return; return;
} for (i = s->old_rupper; i <= s->old_rlower; i++)
tty_draw_line(tty, wp->screen, i, wp->xoff, wp->yoff);
return;
} }
tty_reset(tty); tty_reset(tty);
tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
tty_cursor(tty, s->old_cx, s->old_cy, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
tty_putc(tty, '\n'); tty_putc(tty, '\n');
tty->cy++; tty->cy++;
@ -672,12 +677,13 @@ tty_cmd_clearendofscreen(
tty_reset(tty); tty_reset(tty);
tty_cursor(tty, s->old_cx, s->old_cy, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff); tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff);
if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
if (s->old_cy != screen_size_y(s) - 1) { if (s->old_cy != screen_size_y(s) - 1) {
tty_cursor(tty, 0, s->old_cy + 1, wp->yoff); tty_cursor(tty, 0, s->old_cy + 1, wp->xoff, wp->yoff);
for (i = s->old_cy + 1; i < screen_size_y(s); i++) { for (i = s->old_cy + 1; i < screen_size_y(s); i++) {
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
if (i == screen_size_y(s) - 1) if (i == screen_size_y(s) - 1)
@ -690,7 +696,7 @@ tty_cmd_clearendofscreen(
for (i = s->old_cx; i < screen_size_x(s); i++) for (i = s->old_cx; i < screen_size_x(s); i++)
tty_putc(tty, ' '); tty_putc(tty, ' ');
for (j = s->old_cy; j < screen_size_y(s); j++) { for (j = s->old_cy; j < screen_size_y(s); j++) {
tty_cursor(tty, 0, j, wp->yoff); tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
for (i = 0; i < screen_size_x(s); i++) for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, ' '); tty_putc(tty, ' ');
} }
@ -706,9 +712,10 @@ tty_cmd_clearstartofscreen(
tty_reset(tty); tty_reset(tty);
tty_cursor(tty, 0, 0, wp->yoff); tty_cursor(tty, 0, 0, wp->xoff, wp->yoff);
tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff); tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff);
if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
for (i = 0; i < s->old_cy; i++) { for (i = 0; i < s->old_cy; i++) {
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1); tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1);
@ -716,7 +723,7 @@ tty_cmd_clearstartofscreen(
} }
} else { } else {
for (j = 0; j < s->old_cy; j++) { for (j = 0; j < s->old_cy; j++) {
tty_cursor(tty, 0, j, wp->yoff); tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
for (i = 0; i < screen_size_x(s); i++) for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, ' '); tty_putc(tty, ' ');
} }
@ -734,9 +741,10 @@ tty_cmd_clearscreen(
tty_reset(tty); tty_reset(tty);
tty_cursor(tty, 0, 0, wp->yoff); tty_cursor(tty, 0, 0, wp->xoff, wp->yoff);
tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff); tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff);
if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
for (i = 0; i < screen_size_y(s); i++) { for (i = 0; i < screen_size_y(s); i++) {
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
if (i != screen_size_y(s) - 1) { if (i != screen_size_y(s) - 1) {
@ -746,7 +754,7 @@ tty_cmd_clearscreen(
} }
} else { } else {
for (j = 0; j < screen_size_y(s); j++) { for (j = 0; j < screen_size_y(s); j++) {
tty_cursor(tty, 0, j, wp->yoff); tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
for (i = 0; i < screen_size_x(s); i++) for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, ' '); tty_putc(tty, ' ');
} }
@ -763,7 +771,7 @@ tty_cmd_cell(struct tty *tty, struct window_pane *wp, va_list ap)
gc = va_arg(ap, struct grid_cell *); gc = va_arg(ap, struct grid_cell *);
gu = va_arg(ap, struct grid_utf8 *); gu = va_arg(ap, struct grid_utf8 *);
tty_cursor(tty, s->old_cx, s->old_cy, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
tty_cell(tty, gc, gu); tty_cell(tty, gc, gu);
} }
@ -851,13 +859,13 @@ tty_region(struct tty *tty, u_int rupper, u_int rlower, u_int oy)
} }
void void
tty_cursor(struct tty *tty, u_int cx, u_int cy, u_int oy) tty_cursor(struct tty *tty, u_int cx, u_int cy, u_int ox, u_int oy)
{ {
if (cx == 0 && tty->cx != 0 && tty->cy == oy + cy) { if (ox + cx == 0 && tty->cx != 0 && tty->cy == oy + cy) {
tty->cx = 0; tty->cx = 0;
tty_putc(tty, '\r'); tty_putc(tty, '\r');
} else if (tty->cx != cx || tty->cy != oy + cy) { } else if (tty->cx != ox + cx || tty->cy != oy + cy) {
tty->cx = cx; tty->cx = ox + cx;
tty->cy = oy + cy; tty->cy = oy + cy;
tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx); tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx);
} }

View File

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.70 2009-03-07 09:29:54 nicm Exp $ */ /* $Id: window.c,v 1.71 2009-04-01 18:21:42 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -212,6 +212,7 @@ window_create1(u_int sx, u_int sy)
TAILQ_INIT(&w->panes); TAILQ_INIT(&w->panes);
w->active = NULL; w->active = NULL;
w->layout = 0;
w->sx = sx; w->sx = sx;
w->sy = sy; w->sy = sy;
@ -375,6 +376,7 @@ window_update_panes(struct window *w)
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp->flags & PANE_HIDDEN) if (wp->flags & PANE_HIDDEN)
continue; continue;
wp->xoff = 0;
wp->yoff = yoff; wp->yoff = yoff;
yoff += wp->sy + 1; yoff += wp->sy + 1;
} }
@ -512,11 +514,12 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
wp->mode = NULL; wp->mode = NULL;
wp->xoff = 0;
wp->yoff = 0;
wp->sx = sx; wp->sx = sx;
wp->sy = sy; wp->sy = sy;
wp->yoff = 0;
screen_init(&wp->base, sx, sy, hlimit); screen_init(&wp->base, sx, sy, hlimit);
wp->screen = &wp->base; wp->screen = &wp->base;