From 0eaa6bbfd0c723ab3d5d91a914c442ce23b0a5bf Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Mon, 2 Nov 2020 00:47:43 -0800 Subject: [PATCH] Support PETSCII terminals connected to non-PETSCII ports The reported problem (by John "Jay" Crutti) was: If autodetection of the terminal is used from the defaults menu I get stuck on the prompt to hit my Delete key because on the BBS, it keeps showing me login statistics every time I hit my delete key. Add/use new K_CTRLKEYS mode to stop inkey() from handling/eating control-keys (e.g. Ctrl-T) when asking user to hit backspace during defaults->terminal settings. Allow PETSCII_DELETE (Ctrl-T) as a valid option when asking for the backspace/delete key and set the PETSCII flag in the autoterm variable if hit by the user. --- src/sbbs3/inkey.cpp | 2 +- src/sbbs3/newuser.cpp | 2 +- src/sbbs3/sbbsdefs.h | 1 + src/sbbs3/useredit.cpp | 11 +++++++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/sbbs3/inkey.cpp b/src/sbbs3/inkey.cpp index 6e3b556e78..05b6f3c6d9 100644 --- a/src/sbbs3/inkey.cpp +++ b/src/sbbs3/inkey.cpp @@ -116,7 +116,7 @@ char sbbs_t::inkey(long mode, unsigned long timeout) this->timeout=time(NULL); /* Is this a control key */ - if(ch<' ') { + if(!(mode & K_CTRLKEYS) && ch < ' ') { if(cfg.ctrlkey_passthru&(1<<ch)) /* flagged as passthru? */ return(ch); /* do not handle here */ return(handle_ctrlkey(ch,mode)); diff --git a/src/sbbs3/newuser.cpp b/src/sbbs3/newuser.cpp index 58853c082e..c496793372 100644 --- a/src/sbbs3/newuser.cpp +++ b/src/sbbs3/newuser.cpp @@ -154,7 +154,7 @@ BOOL sbbs_t::newuser() while(text[HitYourBackspaceKey][0] && !(useron.misc&(PETSCII|SWAP_DELETE)) && online) { bputs(text[HitYourBackspaceKey]); - uchar key = getkey(K_NONE); + uchar key = getkey(K_CTRLKEYS); bprintf(text[CharacterReceivedFmt], key, key); if(key == '\b') break; diff --git a/src/sbbs3/sbbsdefs.h b/src/sbbs3/sbbsdefs.h index 7c9bcc7d58..2d475447d1 100644 --- a/src/sbbs3/sbbsdefs.h +++ b/src/sbbs3/sbbsdefs.h @@ -767,6 +767,7 @@ typedef enum { /* Values for xtrn_t.event */ #define K_NOSPIN (1L<<21) /* Do not honor the user's spinning cursor */ #define K_ANSI_CPR (1L<<22) /* Expect ANSI Cursor Position Report */ #define K_TRIM (1L<<23) /* Trimmed white-space */ +#define K_CTRLKEYS (1L<<24) /* No control-key handling/eating in inkey()*/ /* Bits in 'mode' for putmsg and printfile */ #define P_NONE 0 /* No mode flags */ diff --git a/src/sbbs3/useredit.cpp b/src/sbbs3/useredit.cpp index 406607372e..a24199d918 100644 --- a/src/sbbs3/useredit.cpp +++ b/src/sbbs3/useredit.cpp @@ -38,6 +38,7 @@ /*******************************************************************/ #include "sbbs.h" +#include "petdefs.h" #define SEARCH_TXT 0 #define SEARCH_ARS 1 @@ -974,9 +975,9 @@ void sbbs_t::maindflts(user_t* user) else user->misc&=~NO_EXASCII; user->misc &= ~SWAP_DELETE; - while(text[HitYourBackspaceKey][0] && !(user->misc&SWAP_DELETE) && online) { + while(text[HitYourBackspaceKey][0] && !(user->misc&(PETSCII|SWAP_DELETE)) && online) { bputs(text[HitYourBackspaceKey]); - uchar key = getkey(K_NONE); + uchar key = getkey(K_CTRLKEYS); bprintf(text[CharacterReceivedFmt], key, key); if(key == '\b') break; @@ -984,6 +985,12 @@ void sbbs_t::maindflts(user_t* user) if(text[SwapDeleteKeyQ][0] == 0 || yesno(text[SwapDeleteKeyQ])) user->misc |= SWAP_DELETE; } + else if(key == PETSCII_DELETE) { + autoterm |= PETSCII; + user->misc |= PETSCII; + outcom(PETSCII_UPPERLOWER); + bputs(text[PetTerminalDetected]); + } else bprintf(text[InvalidBackspaceKeyFmt], key, key); } -- GitLab