2009-03-28 11:15:01 +01:00
|
|
|
/* $Id: screen-redraw.c,v 1.29 2009-03-28 10:15:01 nicm Exp $ */
|
2007-12-06 10:46:23 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 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 <string.h>
|
|
|
|
|
|
|
|
#include "tmux.h"
|
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
void screen_redraw_blankx(struct client *, u_int, u_int);
|
2009-01-14 20:29:32 +01:00
|
|
|
void screen_redraw_blanky(struct client *, u_int, u_int, char);
|
2009-01-12 00:31:46 +01:00
|
|
|
void screen_redraw_line(struct client *, struct screen *, u_int, u_int);
|
2007-12-06 10:46:23 +01:00
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
/* Redraw entire screen.. */
|
2007-12-06 10:46:23 +01:00
|
|
|
void
|
2009-01-12 00:31:46 +01:00
|
|
|
screen_redraw_screen(struct client *c, struct screen *s)
|
2007-12-06 10:46:23 +01:00
|
|
|
{
|
2009-01-12 19:22:47 +01:00
|
|
|
struct window *w = c->session->curw->window;
|
|
|
|
struct window_pane *wp;
|
|
|
|
u_int i, cx, cy, sy;
|
|
|
|
int status;
|
2007-12-06 10:46:23 +01:00
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
/* Override the normal screen if one is given. */
|
|
|
|
if (s != NULL) {
|
|
|
|
for (i = 0; i < screen_size_y(s); i++)
|
2009-02-21 18:52:25 +01:00
|
|
|
screen_redraw_line(c, s, 0, i);
|
|
|
|
screen_redraw_status(c);
|
2009-01-12 00:31:46 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-12-06 10:46:23 +01:00
|
|
|
|
2009-01-14 20:29:32 +01:00
|
|
|
status = options_get_number(&c->session->options, "status");
|
|
|
|
|
2009-01-14 22:00:41 +01:00
|
|
|
/* Fill in empty space on the right. */
|
2009-02-11 18:50:36 +01:00
|
|
|
if (w->sx < c->tty.sx)
|
|
|
|
screen_redraw_blankx(c, w->sx, c->tty.sx - w->sx);
|
2009-01-14 22:00:41 +01:00
|
|
|
|
2009-01-14 20:29:32 +01:00
|
|
|
/* Draw the panes. */
|
|
|
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
2009-01-12 19:22:47 +01:00
|
|
|
s = wp->screen;
|
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
sy = screen_size_y(s);
|
2009-01-14 20:29:32 +01:00
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
cx = s->cx;
|
|
|
|
cy = s->cy;
|
2009-01-14 20:29:32 +01:00
|
|
|
if (wp->yoff + sy <= w->sy) {
|
2009-01-19 21:14:55 +01:00
|
|
|
for (i = 0; i < sy; i++) {
|
2009-02-11 18:50:36 +01:00
|
|
|
if (wp->yoff + i != c->tty.sy - 1)
|
2009-01-19 21:14:55 +01:00
|
|
|
screen_redraw_line(c, s, wp->yoff, i);
|
|
|
|
}
|
2009-01-14 20:29:32 +01:00
|
|
|
if (TAILQ_NEXT(wp, entry) != NULL)
|
|
|
|
screen_redraw_blanky(c, wp->yoff + sy, 1, '-');
|
|
|
|
}
|
2009-01-12 00:31:46 +01:00
|
|
|
s->cx = cx;
|
|
|
|
s->cy = cy;
|
|
|
|
}
|
2007-12-06 10:46:23 +01:00
|
|
|
|
2009-01-14 22:00:41 +01:00
|
|
|
/* Fill in empty space below. */
|
2009-02-11 18:50:36 +01:00
|
|
|
if (w->sy < c->tty.sy - status)
|
|
|
|
screen_redraw_blanky(c, w->sy, c->tty.sy - status - w->sy, '=');
|
2007-12-06 10:46:23 +01:00
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
/* Draw the status line. */
|
|
|
|
screen_redraw_status(c);
|
2007-12-06 10:46:23 +01:00
|
|
|
}
|
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
/* Draw the status line. */
|
2007-12-06 10:46:23 +01:00
|
|
|
void
|
2009-01-12 00:31:46 +01:00
|
|
|
screen_redraw_status(struct client *c)
|
2007-12-06 10:46:23 +01:00
|
|
|
{
|
2009-02-11 18:50:36 +01:00
|
|
|
screen_redraw_line(c, &c->status, c->tty.sy - 1, 0);
|
2007-12-06 10:46:23 +01:00
|
|
|
}
|
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
/* Draw blank columns. */
|
2007-12-06 10:46:23 +01:00
|
|
|
void
|
2009-01-12 00:31:46 +01:00
|
|
|
screen_redraw_blankx(struct client *c, u_int ox, u_int nx)
|
2007-12-06 10:46:23 +01:00
|
|
|
{
|
2009-01-12 00:31:46 +01:00
|
|
|
u_int i, j;
|
2007-12-06 10:46:23 +01:00
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
tty_putcode(&c->tty, TTYC_SGR0);
|
2009-02-11 18:50:36 +01:00
|
|
|
for (j = 0; j < c->tty.sy; j++) {
|
2009-01-12 00:31:46 +01:00
|
|
|
tty_putcode2(&c->tty, TTYC_CUP, j, ox);
|
|
|
|
for (i = 0; i < nx; i++)
|
|
|
|
tty_putc(&c->tty, ' ');
|
2008-09-25 22:08:57 +02:00
|
|
|
}
|
2007-12-06 10:46:23 +01:00
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
c->tty.cx = UINT_MAX;
|
|
|
|
c->tty.cy = UINT_MAX;
|
|
|
|
memcpy(&c->tty.cell, &grid_default_cell, sizeof c->tty.cell);
|
2007-12-06 10:46:23 +01:00
|
|
|
}
|
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
/* Draw blank lines. */
|
2007-12-06 10:46:23 +01:00
|
|
|
void
|
2009-01-14 20:29:32 +01:00
|
|
|
screen_redraw_blanky(struct client *c, u_int oy, u_int ny, char ch)
|
2007-12-06 10:46:23 +01:00
|
|
|
{
|
|
|
|
u_int i, j;
|
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
tty_putcode(&c->tty, TTYC_SGR0);
|
|
|
|
for (j = 0; j < ny; j++) {
|
|
|
|
tty_putcode2(&c->tty, TTYC_CUP, oy + j, 0);
|
2009-02-11 18:50:36 +01:00
|
|
|
for (i = 0; i < c->tty.sx; i++) {
|
2009-01-12 00:31:46 +01:00
|
|
|
if (j == 0)
|
2009-01-14 20:29:32 +01:00
|
|
|
tty_putc(&c->tty, ch);
|
2009-01-12 00:31:46 +01:00
|
|
|
else
|
|
|
|
tty_putc(&c->tty, ' ');
|
|
|
|
}
|
2007-12-06 10:46:23 +01:00
|
|
|
}
|
2009-01-12 00:31:46 +01:00
|
|
|
|
|
|
|
c->tty.cx = UINT_MAX;
|
|
|
|
c->tty.cy = UINT_MAX;
|
|
|
|
memcpy(&c->tty.cell, &grid_default_cell, sizeof c->tty.cell);
|
2007-12-06 10:46:23 +01:00
|
|
|
}
|
|
|
|
|
2009-01-12 00:31:46 +01:00
|
|
|
/* Draw a line. */
|
2008-06-14 18:47:20 +02:00
|
|
|
void
|
2009-01-12 00:31:46 +01:00
|
|
|
screen_redraw_line(struct client *c, struct screen *s, u_int oy, u_int py)
|
2008-06-14 18:47:20 +02:00
|
|
|
{
|
2009-03-28 11:15:01 +01:00
|
|
|
tty_draw_line(&c->tty, s, py, oy);
|
2007-12-06 10:46:23 +01:00
|
|
|
}
|