Experimental patch to use Rubout as Backspace

This commit is contained in:
Michiel Broek 2002-09-27 17:58:24 +00:00
parent 7a26f2d5eb
commit daa714effd
4 changed files with 158 additions and 150 deletions

View File

@ -116,6 +116,10 @@ v0.35.03 06-Jul-2002
FTP server side). FTP server side).
Added setup setting for outbound queue in global setup. Added setup setting for outbound queue in global setup.
Added support for default setup of the HA archiver. Added support for default setup of the HA archiver.
Changed Rubout key to do the same as Backspace. (experimental)
mbmon:
Changed Rubout key to do the same as Backspace. (experimental)
script: script:
The bbsdoor.sh and rundoor.sh scripts are now only installed The bbsdoor.sh and rundoor.sh scripts are now only installed

1
TODO
View File

@ -167,4 +167,5 @@ mbsetup:
N: Add areas security flags. N: Add areas security flags.
N: Add backspace test and store result in global setup. N: Add backspace test and store result in global setup.
Note: experimental patch to test Rubout key as backspace.

View File

@ -252,6 +252,7 @@ char *edit_field(int y, int x, int w, int p, char *s_)
newinsert(1, YELLOW, BLUE); newinsert(1, YELLOW, BLUE);
break; break;
case KEY_BACKSPACE: case KEY_BACKSPACE:
case KEY_RUBOUT:
if (strlen(s) > 0) { if (strlen(s) > 0) {
if (curpos >= strlen(s)) { if (curpos >= strlen(s)) {
curpos--; curpos--;
@ -264,7 +265,6 @@ char *edit_field(int y, int x, int w, int p, char *s_)
} else } else
putchar(7); putchar(7);
break; break;
case KEY_RUBOUT:
case KEY_DEL: case KEY_DEL:
if (strlen(s) > 0) { if (strlen(s) > 0) {
if ((curpos) == (strlen(s) -1)) { if ((curpos) == (strlen(s) -1)) {

View File

@ -174,165 +174,168 @@ void newinsert(int i, int fg, int bg)
char *edit_field(int y, int x, int w, int p, char *s_) char *edit_field(int y, int x, int w, int p, char *s_)
{ {
int i, charok, first, curpos, AllSpaces; int i, charok, first, curpos, AllSpaces;
static char s[256]; static char s[256];
unsigned int ch; unsigned int ch;
memset((char *)s, 0, 256); memset((char *)s, 0, 256);
sprintf(s, "%s", s_); sprintf(s, "%s", s_);
curpos = 0; curpos = 0;
first = 1; first = 1;
newinsert(1, YELLOW, BLUE); newinsert(1, YELLOW, BLUE);
do {
set_color(YELLOW, BLUE);
show_field(y, x, s, w, '_');
locate(y, x + curpos);
do { do {
set_color(YELLOW, BLUE); ch = readkey(y, x + curpos, YELLOW, BLUE);
show_field(y, x, s, w, '_'); set_color(YELLOW, BLUE);
locate(y, x + curpos);
do {
ch = readkey(y, x + curpos, YELLOW, BLUE);
set_color(YELLOW, BLUE);
/* /*
* Test if the pressed key is a valid key. * Test if the pressed key is a valid key.
*/ */
charok = 0; charok = 0;
if ((ch >= ' ') && (ch <= '~')) { if ((ch >= ' ') && (ch <= '~')) {
switch(p) { switch(p) {
case '!': case '!':
ch = toupper(ch); ch = toupper(ch);
charok = 1; charok = 1;
break; break;
case 'X': case 'X':
charok = 1; charok = 1;
break; break;
case '9': case '9':
if (ch == ' ' || ch == '-' || ch == ',' || if (ch == ' ' || ch == '-' || ch == ',' || ch == '.' || isdigit(ch))
ch == '.' || isdigit(ch)) charok = 1;
charok = 1; break;
break; case 'U':
case 'U': ch = toupper(ch);
ch = toupper(ch); if (isupper(ch))
if (isupper(ch)) charok = 1;
charok = 1; break;
break; default:
default:
putchar(7);
break;
}
}
} while (charok == 0 && ch != KEY_ENTER && ch != KEY_LINEFEED &&
ch != KEY_DEL && ch != KEY_INS && ch != KEY_HOME &&
ch != KEY_LEFT && ch != KEY_RIGHT && ch != KEY_ESCAPE &&
ch != KEY_BACKSPACE && ch != KEY_RUBOUT && ch != KEY_END);
if (charok == 1) {
if (first == 1) {
first = 0;
memset((char *)s, 0, 256);
curpos = 0;
}
if (curpos < w) {
if (insertflag == 1) {
/*
* Insert mode
*/
if (strlen(s) < w) {
if (curpos < strlen(s)) {
for (i = strlen(s); i >= curpos; i--)
s[i+1] = s[i];
}
s[curpos] = ch;
if (curpos < w)
curpos++;
} else {
putchar(7);
}
} else {
/*
* Overwrite mode
*/
s[curpos] = ch;
if (curpos < w)
curpos++;
}
} else {
/*
* The field is full
*/
putchar(7); putchar(7);
} break;
} /* if charok */ }
}
} while (charok == 0 && ch != KEY_ENTER && ch != KEY_LINEFEED && ch != KEY_DEL &&
ch != KEY_INS && ch != KEY_HOME && ch != KEY_LEFT && ch != KEY_RIGHT &&
ch != KEY_ESCAPE && ch != KEY_BACKSPACE && ch != KEY_RUBOUT && ch != KEY_END);
if (charok == 1) {
if (first == 1) {
first = 0; first = 0;
switch (ch) { memset((char *)s, 0, 256);
case KEY_HOME: curpos = 0;
curpos = 0; }
break; if (curpos < w) {
case KEY_END: if (insertflag == 1) {
curpos = strlen(s); /*
break; * Insert mode
case KEY_LEFT: */
if (curpos > 0) if (strlen(s) < w) {
curpos--; if (curpos < strlen(s)) {
else for (i = strlen(s); i >= curpos; i--)
putchar(7); s[i+1] = s[i];
break; }
case KEY_RIGHT: s[curpos] = ch;
if (curpos < strlen(s)) if (curpos < w)
curpos++; curpos++;
else } else {
putchar(7); putchar(7);
break; }
case KEY_INS: } else {
if (insertflag == 1) /*
newinsert(0, YELLOW, BLUE); * Overwrite mode
else */
newinsert(1, YELLOW, BLUE); s[curpos] = ch;
break; if (curpos < w)
case KEY_BACKSPACE: curpos++;
if (strlen(s) > 0) {
if (curpos >= strlen(s)) {
curpos--;
s[curpos] = '\0';
} else {
for (i = curpos; i < strlen(s); i++)
s[i] = s[i+1];
s[i] = '\0';
}
} else
putchar(7);
break;
case KEY_RUBOUT:
case KEY_DEL:
if (strlen(s) > 0) {
if ((curpos) == (strlen(s) -1)) {
s[curpos] = '\0';
} else {
for (i = curpos; i < strlen(s); i++)
s[i] = s[i+1];
s[i] = '\0';
}
} else
putchar(7);
break;
} }
} while ((ch != KEY_ENTER) && (ch != KEY_LINEFEED) && (ch != KEY_ESCAPE)); } else {
/*
* The field is full
*/
putchar(7);
}
} /* if charok */
set_color(LIGHTGRAY, BLUE); first = 0;
mvprintw(2,36, " "); switch (ch) {
set_color(LIGHTGRAY, BLACK); case KEY_HOME:
if (strlen(s)) { curpos = 0;
AllSpaces = TRUE; break;
for (i = 0; i < strlen(s); i++) { case KEY_END:
if (s[i] != ' ') curpos = strlen(s);
AllSpaces = FALSE; break;
} case KEY_LEFT:
if (AllSpaces) if (curpos > 0)
s[0] = '\0'; curpos--;
else
putchar(7);
break;
case KEY_RIGHT:
if (curpos < strlen(s))
curpos++;
else
putchar(7);
break;
case KEY_INS:
if (insertflag == 1)
newinsert(0, YELLOW, BLUE);
else
newinsert(1, YELLOW, BLUE);
break;
case KEY_BACKSPACE:
case KEY_RUBOUT:
if (ch == KEY_RUBOUT)
Syslog('-', "Rubout pressed");
else
Syslog('-', "Backspace pressed");
if (strlen(s) > 0) {
if (curpos >= strlen(s)) {
curpos--;
s[curpos] = '\0';
} else {
for (i = curpos; i < strlen(s); i++)
s[i] = s[i+1];
s[i] = '\0';
}
} else
putchar(7);
break;
case KEY_DEL:
Syslog('-', "Delete key pressed");
if (strlen(s) > 0) {
if ((curpos) == (strlen(s) -1)) {
s[curpos] = '\0';
} else {
for (i = curpos; i < strlen(s); i++)
s[i] = s[i+1];
s[i] = '\0';
}
} else
putchar(7);
break;
} }
return s; } while ((ch != KEY_ENTER) && (ch != KEY_LINEFEED) && (ch != KEY_ESCAPE));
set_color(LIGHTGRAY, BLUE);
mvprintw(2,36, " ");
set_color(LIGHTGRAY, BLACK);
if (strlen(s)) {
AllSpaces = TRUE;
for (i = 0; i < strlen(s); i++) {
if (s[i] != ' ')
AllSpaces = FALSE;
}
if (AllSpaces)
s[0] = '\0';
}
return s;
} }