--- sbbs/src/sbbs3/inkey.cpp 2018/04/24 16:41:23 1.1 +++ sbbs/src/sbbs3/inkey.cpp 2018/04/24 16:43:40 1.1.1.2 @@ -2,13 +2,13 @@ /* Synchronet single key input function (no wait) */ -/* $Id: inkey.cpp,v 1.1 2018/04/24 16:41:23 root Exp $ */ +/* $Id: inkey.cpp,v 1.1.1.2 2018/04/24 16:43:40 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 2011 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 * @@ -41,6 +41,20 @@ #define nosound() +int kbincom(sbbs_t* sbbs, unsigned long timeout) +{ + int ch; + + if(sbbs->keybuftop!=sbbs->keybufbot) { + ch=sbbs->keybuf[sbbs->keybufbot++]; + if(sbbs->keybufbot==KEY_BUFSIZE) + sbbs->keybufbot=0; + } else + ch=sbbs->incom(timeout); + + return ch; +} + /****************************************************************************/ /* Returns character if a key has been hit remotely and responds */ /* Called from functions getkey, msgabort and main_sec */ @@ -49,12 +63,7 @@ char sbbs_t::inkey(long mode, unsigned l { uchar ch=0; - if(keybuftop!=keybufbot) { - ch=keybuf[keybufbot++]; - if(keybufbot==KEY_BUFSIZE) - keybufbot=0; - } else - ch=incom(timeout); + ch=kbincom(this,timeout); if(ch==0) { // moved here from getkey() on AUG-29-2001 @@ -71,7 +80,7 @@ char sbbs_t::inkey(long mode, unsigned l && (!(sys_status&SS_USERON) || useron.misc&NO_EXASCII)) ch&=0x7f; - timeout=time(NULL); + this->timeout=time(NULL); /* Is this a control key */ if(ch<' ') { @@ -133,28 +142,33 @@ char sbbs_t::handle_ctrlkey(char ch, lon #endif /* Global hot key event */ - for(i=0;ikey==ch) - break; - if(i1) /* only allow so much recursion */ + if(sys_status&SS_USERON) { + for(i=0;ikey==ch) + break; + if(i1) /* only allow so much recursion */ + return(0); + hotkey_inside++; + if(mode&K_SPIN) + bputs("\b "); + if(!(sys_status&SS_SPLITP)) { + SAVELINE; + attr(LIGHTGRAY); + CRLF; + } + if(cfg.hotkey[i]->cmd[0]=='?') + js_execfile(cmdstr(cfg.hotkey[i]->cmd+1,nulstr,nulstr,NULL), /* startup_dir: */NULL, /* scope: */js_glob); + else + external(cmdstr(cfg.hotkey[i]->cmd,nulstr,nulstr,NULL),0); + if(!(sys_status&SS_SPLITP)) { + CRLF; + RESTORELINE; + } + lncntr=0; + hotkey_inside--; return(0); - hotkey_inside++; - if(mode&K_SPIN) - bputs("\b "); - if(!(sys_status&SS_SPLITP)) { - SAVELINE; - attr(LIGHTGRAY); - CRLF; } - external(cmdstr(cfg.hotkey[i]->cmd,nulstr,nulstr,NULL),0); - if(!(sys_status&SS_SPLITP)) { - CRLF; - RESTORELINE; - } - lncntr=0; - hotkey_inside--; - return(0); } switch(ch) { @@ -221,8 +235,8 @@ char sbbs_t::handle_ctrlkey(char ch, lon SAVELINE; attr(LIGHTGRAY); now=time(NULL); - bprintf(text[TiLogon],timestr(&logontime)); - bprintf(text[TiNow],timestr(&now)); + bprintf(text[TiLogon],timestr(logontime)); + bprintf(text[TiNow],timestr(now)); bprintf(text[TiTimeon] ,sectostr(now-logontime,tmp)); bprintf(text[TiTimeLeft] @@ -252,7 +266,7 @@ char sbbs_t::handle_ctrlkey(char ch, lon hotkey_inside--; return(0); case ESC: - i=incom(mode&K_GETSTR ? 3000:1000); + i=kbincom(this, (mode&K_GETSTR) ? 3000:1000); if(i==NOINP) // timed-out waiting for '[' return(ESC); ch=i; @@ -268,7 +282,7 @@ char sbbs_t::handle_ctrlkey(char ch, lon putuserrec(&cfg,useron.number,U_MISC,8,ultoa(useron.misc,str,16)); } while(i<10 && j<30) { /* up to 3 seconds */ - ch=incom(100); + ch=kbincom(this, 100); if(ch==(NOINP&0xff)) { j++; continue; @@ -288,6 +302,20 @@ char sbbs_t::handle_ctrlkey(char ch, lon case 'F': /* Xterm: cursor preceding line */ case 'K': /* ANSI: clear-to-end-of-line */ return(CTRL_E); /* ctrl-e (end line) */ + case '@': /* ANSI/ECMA-048 INSERT */ + return(CTRL_V); + case '~': /* VT-220 (XP telnet.exe) */ + switch(atoi(str)) { + case 1: + return(CTRL_B); + case 2: + return(CTRL_V); + case 3: + return(DEL); + case 4: + return(CTRL_E); + } + break; } ungetkey('['); for(j=0;j99) rows=24; + if(sscanf(str,"%u;%u",&y,&x)==2) { + lprintf(LOG_DEBUG,"Node %d received ANSI cursor position report: %ux%u" + ,cfg.node_num, x, y); + /* Sanity check the coordinates in the response: */ + if(x>=40 && x<=255) cols=x; + if(y>=10 && y<=255) rows=y; + } } return(0); }