Skip to content
Snippets Groups Projects
Commit d366f003 authored by rswindell's avatar rswindell
Browse files

Make insert/over-write mode (for string input via uifc.input) persistant among

calls to uifc.input() - don't default to overwrite mode for every call.
This also allows external/app control of the insert/over-write mode via new
uifcapi_t element: insert_mode (default is FALSE).
parent bb1130ce
No related branches found
No related tags found
No related merge requests found
...@@ -349,6 +349,10 @@ typedef struct { ...@@ -349,6 +349,10 @@ typedef struct {
/****************************************************************************/ /****************************************************************************/
BOOL changes; BOOL changes;
/****************************************************************************/ /****************************************************************************/
/* Set to TRUE to enable insert mode by default (not overwrite) */
/****************************************************************************/
BOOL insert_mode;
/****************************************************************************/
/* The overlapped-window save buffer number. */ /* The overlapped-window save buffer number. */
/****************************************************************************/ /****************************************************************************/
uint savnum; uint savnum;
......
...@@ -2056,7 +2056,7 @@ void getstrupd(int left, int top, int width, char *outstr, int cursoffset, int * ...@@ -2056,7 +2056,7 @@ void getstrupd(int left, int top, int width, char *outstr, int cursoffset, int *
/****************************************************************************/ /****************************************************************************/
int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int *lastkey) int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int *lastkey)
{ {
char *str,ins=0; char *str;
int ch; int ch;
int i,j,k,f=0; /* i=offset, j=length */ int i,j,k,f=0; /* i=offset, j=length */
BOOL gotdecimal=FALSE; BOOL gotdecimal=FALSE;
...@@ -2073,8 +2073,7 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int ...@@ -2073,8 +2073,7 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
return(-1); return(-1);
} }
gotoxy(left,top); gotoxy(left,top);
cursor=_NORMALCURSOR; _setcursortype(cursor = api->insert_mode ? _SOLIDCURSOR : _NORMALCURSOR);
_setcursortype(cursor);
str[0]=0; str[0]=0;
if(mode&K_EDIT && outstr[0]) { if(mode&K_EDIT && outstr[0]) {
/*** /***
...@@ -2258,12 +2257,8 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int ...@@ -2258,12 +2257,8 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
pb=(unsigned char *)pastebuf; pb=(unsigned char *)pastebuf;
continue; continue;
case CIO_KEY_IC: /* insert */ case CIO_KEY_IC: /* insert */
ins=!ins; api->insert_mode = !api->insert_mode;
if(ins) _setcursortype(cursor = api->insert_mode ? _SOLIDCURSOR : _NORMALCURSOR);
cursor=_SOLIDCURSOR;
else
cursor=_NORMALCURSOR;
_setcursortype(cursor);
continue; continue;
case BS: case BS:
if(i) if(i)
...@@ -2355,16 +2350,11 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int ...@@ -2355,16 +2350,11 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
} }
if(mode&K_ALPHA && !isalpha(ch)) if(mode&K_ALPHA && !isalpha(ch))
continue; continue;
#if 0 if((ch>=' ' || (ch==1 && mode&K_MSG)) && i<max && (!api->insert_mode || j<max) && ch < 256)
/* This broke swedish chars... */
if((ch>=' ' || (ch==1 && mode&K_MSG)) && i<max && (!ins || j<max) && isprint(ch))
#else
if((ch>=' ' || (ch==1 && mode&K_MSG)) && i<max && (!ins || j<max) && ch < 256)
#endif
{ {
if(mode&K_UPPER) if(mode&K_UPPER)
ch=toupper(ch); ch=toupper(ch);
if(ins) if(api->insert_mode)
{ {
for(k=++j;k>i;k--) for(k=++j;k>i;k--)
str[k]=str[k-1]; str[k]=str[k-1];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment