Partial copy mode. Currently does the same as scroll mode but using a cursor. Also fix bug where resizing would leave crap lying around.

This commit is contained in:
Nicholas Marriott
2007-11-22 18:09:43 +00:00
parent 4930e894c2
commit 18d72e6928
11 changed files with 534 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: screen.c,v 1.36 2007-11-22 09:11:20 nicm Exp $ */
/* $Id: screen.c,v 1.37 2007-11-22 18:09:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -110,7 +110,7 @@ screen_create(struct screen *s, u_int dx, u_int dy)
void
screen_resize(struct screen *s, u_int sx, u_int sy)
{
u_int ox, oy, ny, my;
u_int i, ox, oy, ny, my;
if (sx < 1)
sx = 1;
@@ -126,6 +126,14 @@ screen_resize(struct screen *s, u_int sx, u_int sy)
* X dimension.
*/
if (sx != ox) {
/* If getting smaller, nuke any data in lines over the new size. */
if (sx < ox) {
for (i = s->hsize; i < s->hsize + oy; i++) {
if (s->grid_size[i] > sx)
screen_reduce_line(s, i, sx);
}
}
if (s->cx >= sx)
s->cx = sx - 1;
s->dx = sx;
@@ -201,6 +209,17 @@ screen_expand_line(struct screen *s, u_int py, u_int nx)
memset(&s->grid_colr[py][ox], SCREEN_DEFCOLR, nx - ox);
}
/* Reduce line. */
void
screen_reduce_line(struct screen *s, u_int py, u_int nx)
{
s->grid_size[py] = nx;
s->grid_data[py] = xrealloc(s->grid_data[py], 1, nx);
s->grid_attr[py] = xrealloc(s->grid_attr[py], 1, nx);
s->grid_colr[py] = xrealloc(s->grid_colr[py], 1, nx);
}
/* Get cell. */
void
screen_get_cell(struct screen *s,
@@ -263,9 +282,7 @@ screen_draw_start(struct screen_draw_ctx *ctx,
ctx->colr = s->colr;
input_store_two(b, CODE_SCROLLREGION, 1, screen_size_y(s));
if (s->mode & MODE_CURSOR)
input_store_zero(b, CODE_CURSOROFF);
input_store_zero(b, CODE_CURSOROFF);
}
/* Get cell data during drawing. */
@@ -296,9 +313,14 @@ screen_draw_stop(struct screen_draw_ctx *ctx)
if (ctx->attr != s->attr || ctx->colr != s->colr)
input_store_two(b, CODE_ATTRIBUTES, s->attr, s->colr);
if (!(s->mode & MODE_NOCURSOR) && s->mode & MODE_CURSOR)
input_store_zero(b, CODE_CURSORON);
if (s->mode & MODE_BACKGROUND) {
if (s->mode & MODE_BGCURSOR)
input_store_zero(b, CODE_CURSORON);
} else {
if (s->mode & MODE_CURSOR)
input_store_zero(b, CODE_CURSORON);
}
}
/* Move cursor. */