From: ewt Date: Wed, 31 Jul 1996 16:49:48 +0000 (+0000) Subject: 1) when you enter a hidden field, don't put the cursor at the end X-Git-Tag: v0-9~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fec0af067945cd61ffca51059507730bfad39fe0;p=thirdparty%2Fnewt.git 1) when you enter a hidden field, don't put the cursor at the end 2) clear the text buffer in newtEntrySetText() --- diff --git a/entry.c b/entry.c index f10a987..22032f8 100644 --- a/entry.c +++ b/entry.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "newt.h" #include "newt_pr.h" @@ -39,6 +40,7 @@ void newtEntrySet(newtComponent co, char * value, int cursorAtEnd) { en->buf = malloc(en->bufAlloced); *en->resultPtr = en->buf; } + memset(en->buf, 0, en->bufAlloced); /* clear the buffer */ strcpy(en->buf, value); en->bufUsed = strlen(value); en->firstChar = 0; @@ -141,7 +143,10 @@ static void entryDraw(newtComponent co) { SLsmg_write_nstring(chptr, co->width); } - newtGotorc(co->top, co->left + (en->cursorPosition - en->firstChar)); + if (en->flags & NEWT_ENTRY_HIDDEN) + newtGotorc(co->top, co->left); + else + newtGotorc(co->top, co->left + (en->cursorPosition - en->firstChar)); } static void entryDestroy(newtComponent co) { @@ -161,8 +166,11 @@ static struct eventResult entryEvent(struct newtComponent * co, switch (ev.event) { case EV_FOCUS: /*SLtt_set_cursor_visibility(0);*/ - newtGotorc(co->top, co->left + - (en->cursorPosition - en->firstChar)); + if (en->flags & NEWT_ENTRY_HIDDEN) + newtGotorc(co->top, co->left); + else + newtGotorc(co->top, co->left + + (en->cursorPosition - en->firstChar)); er.result = ER_SWALLOWED; break;