From: mlichvar Date: Wed, 11 Oct 2006 15:19:39 +0000 (+0000) Subject: - fix double width character handling more X-Git-Tag: r0-52-4~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f423597b8d3ba5239c44505430590e8c0a4cc7c4;p=thirdparty%2Fnewt.git - fix double width character handling more --- diff --git a/entry.c b/entry.c index 383eaf9..db8f310 100644 --- a/entry.c +++ b/entry.c @@ -171,15 +171,6 @@ static void entryDraw(newtComponent co) { return; } - /* workaround for double width characters */ - if (co->width > 1) { - newtGotorc(co->top, co->left + co->width - 2); - SLsmg_write_char('_'); - SLsmg_write_char('_'); - } - - newtGotorc(co->top, co->left); - if (en->cursorPosition < en->firstChar) { /* scroll to the left */ en->firstChar = en->cursorPosition; @@ -201,6 +192,17 @@ static void entryDraw(newtComponent co) { len = wstrlen(chptr, -1); + /* workaround for double width characters */ + if (co->width > 1) { + i = len < co->width ? len : co->width; + i = i > 2 ? i - 2 : 0; + newtGotorc(co->top, co->left + i); + SLsmg_write_char('_'); + SLsmg_write_char('_'); + } + + newtGotorc(co->top, co->left); + if (len <= co->width) { i = len; SLsmg_write_string(chptr); @@ -216,10 +218,7 @@ static void entryDraw(newtComponent co) { free(tmp); } - if (en->flags & NEWT_FLAG_HIDDEN) - newtGotorc(co->top, co->left); - else - newtGotorc(co->top, co->left + wstrlen(en->buf+en->firstChar, en->cursorPosition - en->firstChar)); + newtGotorc(co->top, co->left + wstrlen(en->buf+en->firstChar, en->cursorPosition - en->firstChar)); } void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense) {