diff --git a/src/uifc/uifc.h b/src/uifc/uifc.h index b77c9b2181dc3d629b4561dd29685033a8e7ec1b..d40c823b3976b9dc6253603527f73d0bc5876dc3 100644 --- a/src/uifc/uifc.h +++ b/src/uifc/uifc.h @@ -204,6 +204,8 @@ typedef int64_t uifc_winmode_t; /* And ungets the mouse event. */ #define K_PASSWORD (1L<<16) /* Does not display text while editing */ #define K_FIND (1L<<17) /* Don't set the "changes" flag */ +#define K_TRIM (1L<<23) /* Don't allow leading or trailing wsp */ +#define K_NOSPACE (1L<<26) /* Don't allow any wsp chars */ /* Extra exit flags */ diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c index c6b0722f3a7a5583445c332cf8538b906eba141f..f5c36d254f80f464f9f7497b62afc1e7ff67d6ec 100644 --- a/src/uifc/uifc32.c +++ b/src/uifc/uifc32.c @@ -2258,6 +2258,10 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int pb=NULL; } } + if((mode & K_TRIM) && i < 1 && IS_WHITESPACE(ch)) + continue; + if((mode & K_NOSPACE) && IS_WHITESPACE(ch)) + continue; if(ch==CIO_KEY_MOUSE) { ch=uifc_getmouse(&mevnt); if(ch==0 || (ch==ESC && mevnt.event==CIOLIB_BUTTON_3_CLICK)) { @@ -2476,7 +2480,6 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int str[j]=0; if(mode&K_EDIT) { - truncspctrl(str); if(!(mode&K_FIND) && strcmp(outstr,str)) api->changes=1; } @@ -2485,6 +2488,8 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int if(!(mode&K_FIND) && j) api->changes=1; } + if(mode & K_TRIM) + truncspctrl(str); strcpy(outstr,str); cursor=_NOCURSOR; _setcursortype(cursor);