From fed9b66ac8f4c6748fc6a1d1fbe8c89dff3b6dd9 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 23 Sep 2009 14:19:53 +0200 Subject: [PATCH] fix writing lines longer than width in textbox --- textbox.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/textbox.c b/textbox.c index ae84b74..c9dd88d 100644 --- a/textbox.c +++ b/textbox.c @@ -12,7 +12,6 @@ struct textbox { char ** lines; int numLines; - char *blankline; int linesAlloced; int doWrap; newtComponent sb_act, sb; @@ -115,9 +114,6 @@ newtComponent newtTextbox(int left, int top, int width, int height, int flags) { tb->topLine = 0; tb->textWidth = width; tb->isActive = 0; - tb->blankline = malloc(width+1); - memset(tb->blankline,' ',width); - tb->blankline[width] = '\0'; if (flags & NEWT_FLAG_SCROLL) { co->width += 2; @@ -375,9 +371,7 @@ static void textboxDraw(newtComponent c) { for (i = 0; (i + tb->topLine) < tb->numLines && i < c->height; i++) { newtGotorc(c->top + i, c->left); - SLsmg_write_string(tb->blankline); - newtGotorc(c->top + i, c->left); - SLsmg_write_string(tb->lines[i + tb->topLine]); + SLsmg_write_nstring(tb->lines[i + tb->topLine], tb->textWidth); } /* put cursor at beginning of text for better accessibility */ newtGotorc(c->top, c->left); @@ -469,7 +463,6 @@ static void textboxDestroy(newtComponent co) { for (i = 0; i < tb->numLines; i++) free(tb->lines[i]); free(tb->lines); - free(tb->blankline); free(tb); free(co); } -- 2.47.3