--- sbbs/src/sbbs3/getstr.cpp 2018/04/24 16:41:23 1.1.1.1 +++ sbbs/src/sbbs3/getstr.cpp 2018/04/24 16:43:35 1.1.1.2 @@ -2,13 +2,13 @@ /* Synchronet string input routines */ -/* $Id: getstr.cpp,v 1.1.1.1 2018/04/24 16:41:23 root Exp $ */ +/* $Id: getstr.cpp,v 1.1.1.2 2018/04/24 16:43:35 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -81,8 +81,8 @@ size_t sbbs_t::getstr(char *strout, size i|=(cfg.color[clr_inputline]&0x77)>>4; attr(i); } - rputs(str1); - if(mode&K_EDIT && !(mode&(K_LINE|K_AUTODEL)) && term_supports(ANSI)) + column+=rputs(str1); + if(mode&K_EDIT && !(mode&(K_LINE|K_AUTODEL))) cleartoeol(); /* destroy to eol */ } @@ -99,7 +99,7 @@ size_t sbbs_t::getstr(char *strout, size else { for(i=0;ii;x--) str1[x]=str1[x-1]; - rprintf("%.*s",l-i,str1+i); + column+=rprintf("%.*s",l-i,str1+i); cursor_left(l-i); #if 0 if(i==maxlen-1) @@ -163,7 +163,7 @@ size_t sbbs_t::getstr(char *strout, size outchar(str1[i++]=1); break; case CTRL_B: /* Ctrl-B Beginning of Line */ - if(term_supports(ANSI) && i && !(mode&K_NOECHO)) { + if(i && !(mode&K_NOECHO)) { cursor_left(i); i=0; } @@ -344,7 +344,7 @@ size_t sbbs_t::getstr(char *strout, size redrwstr(str1,i,l,0); break; case CTRL_V: /* Ctrl-V Toggles Insert/Overwrite */ - if(!term_supports(ANSI) || mode&K_NOECHO) + if(mode&K_NOECHO) break; console^=CON_INSERT; insert_indicator(); @@ -388,7 +388,7 @@ size_t sbbs_t::getstr(char *strout, size break; case CTRL_Y: /* Ctrl-Y Delete to end of line */ if(i!=l) { /* if not at EOL */ - if(term_supports(ANSI) && !(mode&K_NOECHO)) + if(!(mode&K_NOECHO)) cleartoeol(); l=i; break; @@ -398,20 +398,9 @@ size_t sbbs_t::getstr(char *strout, size if(mode&K_NOECHO) l=0; else { - if(term_supports(ANSI)) { - cursor_left(i); - cleartoeol(); - l=0; - } else { - while(ii;x--) str1[x]=str1[x-1]; - rprintf("%.*s",l-i,str1+i); + column+=rprintf("%.*s",l-i,str1+i); cursor_left(l-i); #if 0 if(i==maxlen-1) { @@ -581,7 +569,7 @@ size_t sbbs_t::getstr(char *strout, size /* Returns a valid number between 1 and max, 0 if no number entered, or -1 */ /* if the user hit 'Q' or ctrl-c */ /****************************************************************************/ -long sbbs_t::getnum(ulong max) +long sbbs_t::getnum(ulong max, ulong dflt) { uchar ch,n=0; long i=0; @@ -610,6 +598,8 @@ long sbbs_t::getnum(ulong max) else if(ch==CR) { CRLF; lncntr=0; + if(!n) + return(dflt); return(i); } else if((ch==BS || ch==DEL) && n) { @@ -617,7 +607,7 @@ long sbbs_t::getnum(ulong max) i/=10; n--; } - else if(isdigit(ch) && (i*10UL)+(ch&0xf)<=max && (ch!='0' || n)) { + else if(isdigit(ch) && (i*10UL)+(ch&0xf)<=max && (dflt || ch!='0' || n)) { i*=10L; n++; i+=ch&0xf; @@ -634,16 +624,18 @@ long sbbs_t::getnum(ulong max) void sbbs_t::insert_indicator(void) { - ANSI_SAVE(); - GOTOXY(cols,1); - uchar z=curatr; /* and go to EOL */ - if(console&CON_INSERT) { - attr(BLINK|BLACK|(LIGHTGRAY<<4)); - outchar('I'); - } else { - attr(LIGHTGRAY); - outchar(' '); + if(term_supports(ANSI)) { + ansi_save(); + ansi_gotoxy(cols,1); + uchar z=curatr; /* and go to EOL */ + if(console&CON_INSERT) { + attr(BLINK|BLACK|(LIGHTGRAY<<4)); + outchar('I'); + } else { + attr(LIGHTGRAY); + outchar(' '); + } + attr(z); + ansi_restore(); } - attr(z); - ANSI_RESTORE(); }