From 77bed4f704db5dd6e4a7d99794142b1c7a5bc0fd Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 27 Nov 2006 14:58:59 +0000 Subject: [PATCH] * Got rid of that ugly cv->import member. --- cucul/cucul.c | 3 --- cucul/cucul_internals.h | 3 --- cucul/frame.c | 4 --- cucul/import.c | 57 ++++++++++++++++------------------------- 4 files changed, 22 insertions(+), 45 deletions(-) diff --git a/cucul/cucul.c b/cucul/cucul.c index 6265108..6f565f5 100644 --- a/cucul/cucul.c +++ b/cucul/cucul.c @@ -76,7 +76,6 @@ cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height) cv->frames[0].handlex = cv->frames[0].handley = 0; cv->frames[0].curattr = 0; cv->frames[0].name = strdup("frame#00000000"); - cv->frames[0].import = NULL; _cucul_load_frame_info(cv); cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); @@ -190,8 +189,6 @@ int cucul_free_canvas(cucul_canvas_t *cv) free(cv->frames[f].chars); free(cv->frames[f].attrs); free(cv->frames[f].name); - if(cv->frames[f].import) - free(cv->frames[f].import); } free(cv->frames); diff --git a/cucul/cucul_internals.h b/cucul/cucul_internals.h index 7122905..becff56 100644 --- a/cucul/cucul_internals.h +++ b/cucul/cucul_internals.h @@ -34,9 +34,6 @@ struct cucul_frame /* Frame name */ char *name; - - /* Private information */ - void *import; }; struct cucul_canvas diff --git a/cucul/frame.c b/cucul/frame.c index 7553de6..425f7a1 100644 --- a/cucul/frame.c +++ b/cucul/frame.c @@ -170,8 +170,6 @@ int cucul_create_frame(cucul_canvas_t *cv, unsigned int id) cv->frames[id].name = strdup("frame#--------"); sprintf(cv->frames[id].name + 6, "%.08x", ++cv->autoinc); - cv->frames[id].import = NULL; - return 0; } @@ -215,8 +213,6 @@ int cucul_free_frame(cucul_canvas_t *cv, unsigned int id) free(cv->frames[id].chars); free(cv->frames[id].attrs); free(cv->frames[id].name); - if(cv->frames[id].import) - free(cv->frames[id].import); for(f = id + 1; f < cv->framecount; f++) cv->frames[f - 1] = cv->frames[f]; diff --git a/cucul/import.c b/cucul/import.c index c1b62a1..961deb8 100644 --- a/cucul/import.c +++ b/cucul/import.c @@ -348,23 +348,13 @@ static long int import_text(cucul_canvas_t *cv, static long int import_ansi(cucul_canvas_t *cv, void const *data, unsigned int size, int utf8) { - struct import *im; + struct import im; unsigned char const *buffer = (unsigned char const*)data; - unsigned int i, j, init, skip, growx = 0, growy = 0, dummy = 0; + unsigned int i, j, skip, growx = 0, growy = 0, dummy = 0; unsigned int width, height; uint32_t savedattr; int x = 0, y = 0, save_x = 0, save_y = 0; - init = !!cv->frames[cv->frame].import; - - if(!init) - { - cv->frames[cv->frame].import = malloc(sizeof(struct import)); - memset(cv->frames[cv->frame].import, 0, sizeof(struct import)); - } - - im = (struct import *)cv->frames[cv->frame].import; - if(utf8) { width = cv->width; @@ -381,24 +371,21 @@ static long int import_ansi(cucul_canvas_t *cv, growy = 1; } - if(!init) + if(utf8) { - if(utf8) - { - im->dfg = CUCUL_DEFAULT; - im->dbg = CUCUL_TRANSPARENT; - } - else - { - im->dfg = CUCUL_LIGHTGRAY; - im->dbg = CUCUL_BLACK; - } + im.dfg = CUCUL_DEFAULT; + im.dbg = CUCUL_TRANSPARENT; + } + else + { + im.dfg = CUCUL_LIGHTGRAY; + im.dbg = CUCUL_BLACK; + } - cucul_set_color_ansi(cv, im->dfg, im->dbg); - im->clearattr = cucul_get_attr(cv, -1, -1); + cucul_set_color_ansi(cv, im.dfg, im.dbg); + im.clearattr = cucul_get_attr(cv, -1, -1); - ansi_parse_grcm(cv, im, 1, &dummy); - } + ansi_parse_grcm(cv, &im, 1, &dummy); for(i = 0; i < size; i += skip) { @@ -535,7 +522,7 @@ static long int import_ansi(cucul_canvas_t *cv, break; case 'J': /* ED (0x4a) - Erase In Page */ savedattr = cucul_get_attr(cv, -1, -1); - cucul_set_attr(cv, im->clearattr); + cucul_set_attr(cv, im.clearattr); if(!argc || argv[0] == 0) { cucul_draw_line(cv, x, y, width, y, ' '); @@ -573,7 +560,7 @@ static long int import_ansi(cucul_canvas_t *cv, } #if 0 savedattr = cucul_get_attr(cv, -1, -1); - cucul_set_attr(cv, im->clearattr); + cucul_set_attr(cv, im.clearattr); for( ; (unsigned int)j < width; j++) cucul_put_char(cv, j, y, ' '); cucul_set_attr(cv, savedattr); @@ -582,7 +569,7 @@ static long int import_ansi(cucul_canvas_t *cv, if(argc && argv[0]) { savedattr = cucul_get_attr(cv, -1, -1); - cucul_set_attr(cv, im->clearattr); + cucul_set_attr(cv, im.clearattr); cucul_draw_line(cv, x, y, x + argv[0] - 1, y, ' '); cucul_set_attr(cv, savedattr); } @@ -601,9 +588,9 @@ static long int import_ansi(cucul_canvas_t *cv, break; case 'm': /* SGR (0x6d) - Select Graphic Rendition */ if(argc) - ansi_parse_grcm(cv, im, argc, argv); + ansi_parse_grcm(cv, &im, argc, argv); else - ansi_parse_grcm(cv, im, 1, &dummy); + ansi_parse_grcm(cv, &im, 1, &dummy); break; case 's': /* Private (save cursor position) */ save_x = x; @@ -694,7 +681,7 @@ static long int import_ansi(cucul_canvas_t *cv, if(growx) { savedattr = cucul_get_attr(cv, -1, -1); - cucul_set_attr(cv, im->clearattr); + cucul_set_attr(cv, im.clearattr); cucul_set_canvas_size(cv, width = x + wch, height); cucul_set_attr(cv, savedattr); } @@ -709,7 +696,7 @@ static long int import_ansi(cucul_canvas_t *cv, if((unsigned int)y >= height) { savedattr = cucul_get_attr(cv, -1, -1); - cucul_set_attr(cv, im->clearattr); + cucul_set_attr(cv, im.clearattr); if(growy) { cucul_set_canvas_size(cv, width, height = y + 1); @@ -743,7 +730,7 @@ static long int import_ansi(cucul_canvas_t *cv, if(growy && (unsigned int)y > height) { savedattr = cucul_get_attr(cv, -1, -1); - cucul_set_attr(cv, im->clearattr); + cucul_set_attr(cv, im.clearattr); cucul_set_canvas_size(cv, width, height = y); cucul_set_attr(cv, savedattr); }