From 18d72e69289fa3dbdb0766ea7f9c0ff8908626b9 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 22 Nov 2007 18:09:43 +0000 Subject: Partial copy mode. Currently does the same as scroll mode but using a cursor. Also fix bug where resizing would leave crap lying around. --- screen.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'screen.c') diff --git a/screen.c b/screen.c index 6df0abc1..2e1f4a86 100644 --- a/screen.c +++ b/screen.c @@ -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 @@ -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. */ -- cgit