From daa714effd9315d5328a0f652205c972fee8c6dc Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 27 Sep 2002 17:58:24 +0000 Subject: [PATCH] Experimental patch to use Rubout as Backspace --- ChangeLog | 4 + TODO | 1 + mbmon/mutil.c | 2 +- mbsetup/ledit.c | 301 ++++++++++++++++++++++++------------------------ 4 files changed, 158 insertions(+), 150 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19ac75d8..e9841435 100644 --- a/ChangeLog +++ b/ChangeLog @@ -116,6 +116,10 @@ v0.35.03 06-Jul-2002 FTP server side). Added setup setting for outbound queue in global setup. 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: The bbsdoor.sh and rundoor.sh scripts are now only installed diff --git a/TODO b/TODO index 7bdcddc5..a0a5ddfe 100644 --- a/TODO +++ b/TODO @@ -167,4 +167,5 @@ mbsetup: N: Add areas security flags. N: Add backspace test and store result in global setup. + Note: experimental patch to test Rubout key as backspace. diff --git a/mbmon/mutil.c b/mbmon/mutil.c index b0e62a44..bc89aee0 100644 --- a/mbmon/mutil.c +++ b/mbmon/mutil.c @@ -252,6 +252,7 @@ char *edit_field(int y, int x, int w, int p, char *s_) newinsert(1, YELLOW, BLUE); break; case KEY_BACKSPACE: + case KEY_RUBOUT: if (strlen(s) > 0) { if (curpos >= strlen(s)) { curpos--; @@ -264,7 +265,6 @@ char *edit_field(int y, int x, int w, int p, char *s_) } else putchar(7); break; - case KEY_RUBOUT: case KEY_DEL: if (strlen(s) > 0) { if ((curpos) == (strlen(s) -1)) { diff --git a/mbsetup/ledit.c b/mbsetup/ledit.c index 528f4c8e..9922559c 100644 --- a/mbsetup/ledit.c +++ b/mbsetup/ledit.c @@ -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_) { - int i, charok, first, curpos, AllSpaces; - static char s[256]; - unsigned int ch; + int i, charok, first, curpos, AllSpaces; + static char s[256]; + unsigned int ch; - memset((char *)s, 0, 256); - sprintf(s, "%s", s_); - curpos = 0; - first = 1; - newinsert(1, YELLOW, BLUE); + memset((char *)s, 0, 256); + sprintf(s, "%s", s_); + curpos = 0; + first = 1; + newinsert(1, YELLOW, BLUE); + do { + set_color(YELLOW, BLUE); + show_field(y, x, s, w, '_'); + locate(y, x + curpos); do { - set_color(YELLOW, BLUE); - show_field(y, x, s, w, '_'); - locate(y, x + curpos); - do { - ch = readkey(y, x + curpos, YELLOW, BLUE); - set_color(YELLOW, BLUE); + ch = readkey(y, x + curpos, YELLOW, BLUE); + set_color(YELLOW, BLUE); - /* - * Test if the pressed key is a valid key. - */ - charok = 0; - if ((ch >= ' ') && (ch <= '~')) { - switch(p) { - case '!': - ch = toupper(ch); - charok = 1; - break; - case 'X': - charok = 1; - break; - case '9': - if (ch == ' ' || ch == '-' || ch == ',' || - ch == '.' || isdigit(ch)) - charok = 1; - break; - case 'U': - ch = toupper(ch); - if (isupper(ch)) - charok = 1; - break; - 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 - */ + /* + * Test if the pressed key is a valid key. + */ + charok = 0; + if ((ch >= ' ') && (ch <= '~')) { + switch(p) { + case '!': + ch = toupper(ch); + charok = 1; + break; + case 'X': + charok = 1; + break; + case '9': + if (ch == ' ' || ch == '-' || ch == ',' || ch == '.' || isdigit(ch)) + charok = 1; + break; + case 'U': + ch = toupper(ch); + if (isupper(ch)) + charok = 1; + break; + default: putchar(7); - } - } /* if charok */ + 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; - switch (ch) { - case KEY_HOME: - curpos = 0; - break; - case KEY_END: - curpos = strlen(s); - break; - case KEY_LEFT: - if (curpos > 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: - 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; + 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++; } - } while ((ch != KEY_ENTER) && (ch != KEY_LINEFEED) && (ch != KEY_ESCAPE)); + } else { + /* + * The field is full + */ + putchar(7); + } + } /* if charok */ - 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'; + first = 0; + switch (ch) { + case KEY_HOME: + curpos = 0; + break; + case KEY_END: + curpos = strlen(s); + break; + case KEY_LEFT: + if (curpos > 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; }