Skip to content
Snippets Groups Projects
Commit 3a2c90b2 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add input K_TRIM and K_NOSPACE mode flags

K_TRIM causes leading and trailing whitespace to be trimmed.
K_NOSPACE disallows any whitespace characters to be added to the string.

Previously, trailing whitespace was always trimmed. Now, only do that
if/when K_TRIM is specified.
parent c47b2a79
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -204,6 +204,8 @@ typedef int64_t uifc_winmode_t; ...@@ -204,6 +204,8 @@ typedef int64_t uifc_winmode_t;
/* And ungets the mouse event. */ /* And ungets the mouse event. */
#define K_PASSWORD (1L<<16) /* Does not display text while editing */ #define K_PASSWORD (1L<<16) /* Does not display text while editing */
#define K_FIND (1L<<17) /* Don't set the "changes" flag */ #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 */ /* Extra exit flags */
......
...@@ -2258,6 +2258,10 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int ...@@ -2258,6 +2258,10 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
pb=NULL; 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) { if(ch==CIO_KEY_MOUSE) {
ch=uifc_getmouse(&mevnt); ch=uifc_getmouse(&mevnt);
if(ch==0 || (ch==ESC && mevnt.event==CIOLIB_BUTTON_3_CLICK)) { 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 ...@@ -2476,7 +2480,6 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
str[j]=0; str[j]=0;
if(mode&K_EDIT) if(mode&K_EDIT)
{ {
truncspctrl(str);
if(!(mode&K_FIND) && strcmp(outstr,str)) if(!(mode&K_FIND) && strcmp(outstr,str))
api->changes=1; api->changes=1;
} }
...@@ -2485,6 +2488,8 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int ...@@ -2485,6 +2488,8 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
if(!(mode&K_FIND) && j) if(!(mode&K_FIND) && j)
api->changes=1; api->changes=1;
} }
if(mode & K_TRIM)
truncspctrl(str);
strcpy(outstr,str); strcpy(outstr,str);
cursor=_NOCURSOR; cursor=_NOCURSOR;
_setcursortype(cursor); _setcursortype(cursor);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment