From 6674197e853ddec4ab1af04ede3ebabcdcc581c5 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 8 Sep 2008 22:03:56 +0000 Subject: Fix bold/non-bold mismatch in 256 colour mode by adding an extra 8 bits (ick) onto the attributes and using two of them to mark the fg and bg as 256 colours when necessary. If only it was 255 colours we would have one value for default and wouln't need this :-/. --- screen.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'screen.c') diff --git a/screen.c b/screen.c index d20e04aa..06d34083 100644 --- a/screen.c +++ b/screen.c @@ -1,4 +1,4 @@ -/* $Id: screen.c,v 1.67 2008-09-08 17:40:51 nicm Exp $ */ +/* $Id: screen.c,v 1.68 2008-09-08 22:03:54 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -279,14 +279,18 @@ screen_expand_line(struct screen *s, u_int py, u_int nx) ox = s->grid_size[py]; s->grid_size[py] = nx; - s->grid_data[py] = xrealloc(s->grid_data[py], 1, nx); - memset(&s->grid_data[py][ox], ' ', nx - ox); - s->grid_attr[py] = xrealloc(s->grid_attr[py], 1, nx); - memset(&s->grid_attr[py][ox], 0, nx - ox); - s->grid_fg[py] = xrealloc(s->grid_fg[py], 1, nx); - memset(&s->grid_fg[py][ox], 8, nx - ox); - s->grid_bg[py] = xrealloc(s->grid_bg[py], 1, nx); - memset(&s->grid_bg[py][ox], 8, nx - ox); + s->grid_data[py] = xrealloc( + s->grid_data[py], sizeof **s->grid_data, nx); + memset(&s->grid_data[py][ox], ' ', (nx - ox) * sizeof **s->grid_data); + s->grid_attr[py] = xrealloc( + s->grid_attr[py], sizeof **s->grid_attr, nx); + memset(&s->grid_attr[py][ox], 0, (nx - ox) * sizeof **s->grid_attr); + s->grid_fg[py] = xrealloc( + s->grid_fg[py], sizeof **s->grid_fg, nx); + memset(&s->grid_fg[py][ox], 8, (nx - ox) * sizeof **s->grid_fg); + s->grid_bg[py] = xrealloc( + s->grid_bg[py], sizeof **s->grid_bg, nx); + memset(&s->grid_bg[py][ox], 8, (nx - ox) * sizeof **s->grid_bg); } /* Reduce line. */ @@ -295,16 +299,20 @@ 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_fg[py] = xrealloc(s->grid_fg[py], 1, nx); - s->grid_bg[py] = xrealloc(s->grid_bg[py], 1, nx); + s->grid_data[py] = xrealloc( + s->grid_data[py], sizeof **s->grid_data, nx); + s->grid_attr[py] = xrealloc( + s->grid_attr[py], sizeof **s->grid_attr, nx); + s->grid_fg[py] = xrealloc( + s->grid_fg[py], sizeof **s->grid_fg, nx); + s->grid_bg[py] = xrealloc( + s->grid_bg[py], sizeof **s->grid_bg, nx); } /* Get cell. */ void screen_get_cell(struct screen *s, - u_int cx, u_int cy, u_char *data, u_char *attr, u_char *fg, u_char *bg) + u_int cx, u_int cy, u_char *data, u_short *attr, u_char *fg, u_char *bg) { if (cx >= s->grid_size[cy]) { *data = ' '; @@ -325,7 +333,7 @@ screen_get_cell(struct screen *s, /* Set a cell. */ void screen_set_cell(struct screen *s, - u_int cx, u_int cy, u_char data, u_char attr, u_char fg, u_char bg) + u_int cx, u_int cy, u_char data, u_short attr, u_char fg, u_char bg) { if (cx >= s->grid_size[cy]) screen_expand_line(s, cy, cx + 1); @@ -406,7 +414,7 @@ screen_move_lines(struct screen *s, u_int dy, u_int py, u_int ny) /* Fill an area. */ void screen_fill_area(struct screen *s, u_int px, u_int py, - u_int nx, u_int ny, u_char data, u_char attr, u_char fg, u_char bg) + u_int nx, u_int ny, u_char data, u_short attr, u_char fg, u_char bg) { u_int i, j; -- cgit v1.2.3