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

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>
@ -22,65 +22,108 @@
#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;
if (px > w->sx || py > w->sy)
return (0);
TAILQ_FOREACH(wp, &w->panes, entry) {
/* 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);
}
/* 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");
/* Fill in empty space on the right. */
if (w->sx < c->tty.sx)
screen_redraw_blankx(c, w->sx, c->tty.sx - w->sx);
/* 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, '.');
}
}
}
/* Draw the panes. */
TAILQ_FOREACH(wp, &w->panes, entry) {
tty_reset(tty);
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);
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 (TAILQ_NEXT(wp, entry) != NULL)
screen_redraw_blanky(c, wp->yoff + sy, 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, '|');
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, '|');
}
}
}
/* 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);
}
@ -89,52 +132,5 @@ screen_redraw_screen(struct client *c, struct screen *s)
void
screen_redraw_status(struct client *c)
{
screen_redraw_line(c, &c->status, c->tty.sy - 1, 0);
}
/* 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);
tty_draw_line(&c->tty, &c->status, 0, 0, c->tty.sy - 1);
}