Commit d8daa9c7 authored by rswindell's avatar rswindell
Browse files

Added macros for ctrl key constants.

parent b1576816
...@@ -51,6 +51,35 @@ ...@@ -51,6 +51,35 @@
#define CR '\r' /* Carriage return ^M */ #define CR '\r' /* Carriage return ^M */
#define SP ' ' /* Space */ #define SP ' ' /* Space */
enum {
CTRL_A=1
,CTRL_B
,CTRL_C
,CTRL_D
,CTRL_E
,CTRL_F
,CTRL_G
,CTRL_H
,CTRL_I
,CTRL_J
,CTRL_K
,CTRL_L
,CTRL_M
,CTRL_N
,CTRL_O
,CTRL_P
,CTRL_Q
,CTRL_R
,CTRL_S
,CTRL_T
,CTRL_U
,CTRL_V
,CTRL_W
,CTRL_X
,CTRL_Y
,CTRL_Z
};
#ifndef MAX_PATH #ifndef MAX_PATH
#ifdef MAXPATHLEN #ifdef MAXPATHLEN
#define MAX_PATH MAXPATHLEN /* clib.h */ #define MAX_PATH MAXPATHLEN /* clib.h */
......
...@@ -316,7 +316,7 @@ void sbbs_t::mnemonics(char *str) ...@@ -316,7 +316,7 @@ void sbbs_t::mnemonics(char *str)
if(!ctrl_a_codes) if(!ctrl_a_codes)
attr(cfg.color[clr_mnelow]); } attr(cfg.color[clr_mnelow]); }
else { else {
if(str[l]==1) { /* ctrl-a */ if(str[l]==CTRL_A) { /* ctrl-a */
ctrl_a(str[++l]); /* skip the ctrl-a */ ctrl_a(str[++l]); /* skip the ctrl-a */
l++; } /* skip the attribute code */ l++; } /* skip the attribute code */
else else
......
...@@ -111,7 +111,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -111,7 +111,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
"8 DATA BITS, and 1 STOP BIT (N-8-1).\7\r\n"); "8 DATA BITS, and 1 STOP BIT (N-8-1).\7\r\n");
return(0); } } return(0); } }
switch(ch) { switch(ch) {
case 1: /* Ctrl-A for ANSI */ case CTRL_A: /* Ctrl-A for ANSI */
if(!(mode&K_MSG) || useron.rest&FLAG('A') || i>maxlen-3) if(!(mode&K_MSG) || useron.rest&FLAG('A') || i>maxlen-3)
break; break;
if(ins) { if(ins) {
...@@ -125,12 +125,12 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -125,12 +125,12 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
ins=0; } ins=0; }
outchar(str1[i++]=1); outchar(str1[i++]=1);
break; break;
case 2: /* Ctrl-B Beginning of Line */ case CTRL_B: /* Ctrl-B Beginning of Line */
if(useron.misc&ANSI && i && !(mode&K_NOECHO)) { if(useron.misc&ANSI && i && !(mode&K_NOECHO)) {
bprintf("\x1b[%dD",i); bprintf("\x1b[%dD",i);
i=0; } i=0; }
break; break;
case 4: /* Ctrl-D Delete word right */ case CTRL_D: /* Ctrl-D Delete word right */
if(i<l) { if(i<l) {
x=i; x=i;
while(x<l && str1[x]!=SP) { while(x<l && str1[x]!=SP) {
...@@ -150,17 +150,17 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -150,17 +150,17 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
bprintf("\x1b[%dD",z-i); bprintf("\x1b[%dD",z-i);
l-=x-i; } /* l=new length */ l-=x-i; } /* l=new length */
break; break;
case 5: /* Ctrl-E End of line */ case CTRL_E: /* Ctrl-E End of line */
if(useron.misc&ANSI && i<l) { if(useron.misc&ANSI && i<l) {
bprintf("\x1b[%dC",l-i); /* move cursor to eol */ bprintf("\x1b[%dC",l-i); /* move cursor to eol */
i=l; } i=l; }
break; break;
case 6: /* Ctrl-F move cursor forewards */ case CTRL_F: /* Ctrl-F move cursor forewards */
if(i<l && (useron.misc&ANSI)) { if(i<l && (useron.misc&ANSI)) {
bputs("\x1b[C"); /* move cursor right one */ bputs("\x1b[C"); /* move cursor right one */
i++; } i++; }
break; break;
case 7: /* Ctrl-G */ case CTRL_G: /* Bell */
if(!(mode&K_MSG)) if(!(mode&K_MSG))
break; break;
if(useron.rest&FLAG('B')) { if(useron.rest&FLAG('B')) {
...@@ -195,7 +195,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -195,7 +195,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
if(!(mode&K_NOECHO)) if(!(mode&K_NOECHO))
outchar(BEL); } outchar(BEL); }
break; break;
case 8: /* Ctrl-H/Backspace */ case CTRL_H: /* Ctrl-H/Backspace */
if(!i) if(!i)
break; break;
i--; i--;
...@@ -211,7 +211,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -211,7 +211,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
else if(!(mode&K_NOECHO)) else if(!(mode&K_NOECHO))
bputs("\b \b"); bputs("\b \b");
break; break;
case 9: /* Ctrl-I/TAB */ case CTRL_I: /* Ctrl-I/TAB */
if(!(i%TABSIZE)) { if(!(i%TABSIZE)) {
if(ins) { if(ins) {
if(l<maxlen) if(l<maxlen)
...@@ -238,7 +238,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -238,7 +238,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
redrwstr(str1,i,l,0); redrwstr(str1,i,l,0);
break; break;
case 12: /* Ctrl-L Center line (used to be Ctrl-V) */ case CTRL_L: /* Ctrl-L Center line (used to be Ctrl-V) */
str1[l]=0; str1[l]=0;
l=bstrlen(str1); l=bstrlen(str1);
if(!l) break; if(!l) break;
...@@ -261,7 +261,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -261,7 +261,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
CRLF; CRLF;
return(l); return(l);
case 14: /* Ctrl-N Next word */ case CTRL_N: /* Ctrl-N Next word */
if(i<l && (useron.misc&ANSI)) { if(i<l && (useron.misc&ANSI)) {
x=i; x=i;
while(str1[i]!=SP && i<l) while(str1[i]!=SP && i<l)
...@@ -270,11 +270,11 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -270,11 +270,11 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
i++; i++;
bprintf("\x1b[%dC",i-x); } bprintf("\x1b[%dC",i-x); }
break; break;
case 18: /* Ctrl-R Redraw Line */ case CTRL_R: /* Ctrl-R Redraw Line */
if(!(mode&K_NOECHO)) if(!(mode&K_NOECHO))
redrwstr(str1,i,l,0); redrwstr(str1,i,l,0);
break; break;
case 22: /* Ctrl-V Toggles Insert/Overwrite */ case CTRL_V: /* Ctrl-V Toggles Insert/Overwrite */
if(!(useron.misc&ANSI) || mode&K_NOECHO) if(!(useron.misc&ANSI) || mode&K_NOECHO)
break; break;
if(ins) { if(ins) {
...@@ -289,7 +289,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -289,7 +289,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
attr(z); attr(z);
bputs("\x1b[u"); } /* restore pos */ bputs("\x1b[u"); } /* restore pos */
break; break;
case 23: /* Ctrl-W Delete word left */ case CTRL_W: /* Ctrl-W Delete word left */
if(i<l) { if(i<l) {
x=i; /* x=original offset */ x=i; /* x=original offset */
while(i && str1[i-1]==SP) { while(i && str1[i-1]==SP) {
...@@ -319,7 +319,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -319,7 +319,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
if(!(mode&K_NOECHO)) if(!(mode&K_NOECHO))
bputs("\b \b"); } } bputs("\b \b"); } }
break; break;
case 24: /* Ctrl-X Delete entire line */ case CTRL_X: /* Ctrl-X Delete entire line */
if(mode&K_NOECHO) if(mode&K_NOECHO)
l=0; l=0;
else { else {
...@@ -331,7 +331,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode) ...@@ -331,7 +331,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode)
bputs("\b \b"); } } bputs("\b \b"); } }
i=0; i=0;
break; break;
case 25: /* Ctrl-Y Delete to end of line */ case CTRL_Y: /* Ctrl-Y Delete to end of line */
if(useron.misc&ANSI && !(mode&K_NOECHO)) { if(useron.misc&ANSI && !(mode&K_NOECHO)) {
bputs("\x1b[K"); bputs("\x1b[K");
l=i; } l=i; }
......
...@@ -58,7 +58,7 @@ char sbbs_t::putmsg(char HUGE16 *str, long mode) ...@@ -58,7 +58,7 @@ char sbbs_t::putmsg(char HUGE16 *str, long mode)
if(!(mode&P_SAVEATR)) if(!(mode&P_SAVEATR))
attr(LIGHTGRAY); attr(LIGHTGRAY);
while(str[l] && (mode&P_NOABORT || !msgabort()) && online) { while(str[l] && (mode&P_NOABORT || !msgabort()) && online) {
if(str[l]==1) { /* Ctrl-Ax sequence */ if(str[l]==CTRL_A) {
if(str[l+1]=='"' && !(sys_status&SS_NEST_PF)) { /* Quote a file */ if(str[l+1]=='"' && !(sys_status&SS_NEST_PF)) { /* Quote a file */
l+=2; l+=2;
i=0; i=0;
...@@ -161,7 +161,7 @@ char sbbs_t::putmsg(char HUGE16 *str, long mode) ...@@ -161,7 +161,7 @@ char sbbs_t::putmsg(char HUGE16 *str, long mode)
exatr=1; exatr=1;
l+=2; /* Skip |x */ l+=2; /* Skip |x */
} /* Skip second digit if it exists */ } /* Skip second digit if it exists */
else if(cfg.sys_misc&SM_WWIV && str[l]==3 && isdigit(str[l+1])) { else if(cfg.sys_misc&SM_WWIV && str[l]==CTRL_C && isdigit(str[l+1])) {
exatr=1; exatr=1;
switch(str[l+1]) { switch(str[l+1]) {
default: default:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment