...
 
Commits (2)
......@@ -2,7 +2,7 @@
/* Synchronet External Program Software Development Kit */
/* $Id: xsdk.c,v 1.41 2016/08/13 18:57:00 rswindell Exp $ */
/* $Id: xsdk.c,v 1.41 2020/09/20 18:57:00 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
......@@ -581,6 +581,7 @@ int keyhit()
char inkey(long mode)
{
static in_ctrl_p;
static ansi_len;
uchar ch=0,hour,min,sec;
long tleft;
int i=0;
......@@ -621,19 +622,19 @@ char inkey(long mode)
i=stdin_getch();
switch(i) {
case 0x47: /* Home - Same as Ctrl-B */
return(2); /* ctrl-b beginning of line */
return TERM_KEY_HOME; /* ctrl-b beginning of line */
case 0x4b: /* Left Arrow - same as ctrl-] */
return(0x1d);
return TERM_KEY_LEFT;
case 0x4d: /* Right Arrow - same as ctrl-f */
return(6);
return TERM_KEY_RIGHT;
case 0x48: /* Up arrow - same as ctrl-^ */
return(0x1e);
return TERM_KEY_UP;
case 0x50: /* Down arrow - same as CR */
return(CR);
return TERM_KEY_DOWN;
case 0x4f: /* End - same as Ctrl-E */
return(5); /* ctrl-e - end of line */
return TERM_KEY_END;
case 0x52: /* Insert */
return(0x1f); /* ctrl-minus - insert mode */
return TERM_KEY_INSERT; /* ctrl-minus - insert mode */
case 0x53: /* Delete */
return(0x7f); /* ctrl-bkspc - del cur char */
}
......@@ -641,6 +642,44 @@ char inkey(long mode)
ch=i;
}
if(ch == ESC) {
ansi_len = !ansi_len;
}
else if(ansi_len == 1) {
if(ch == '[')
ansi_len++;
else
ansi_len = 0;
}
else if(ansi_len == 2) {
ansi_len =0 ;
switch(ch) {
case 'A':
return TERM_KEY_UP;
case 'B':
return TERM_KEY_DOWN;
case 'C':
return TERM_KEY_RIGHT;
case 'D':
return TERM_KEY_LEFT;
case 'H':
return TERM_KEY_HOME;
case 'V':
return TERM_KEY_PAGEUP;
case 'U':
return TERM_KEY_PAGEDN;
case 'F':
case 'K':
return TERM_KEY_END;
case '@':
return TERM_KEY_INSERT;
default:
return 0;
}
}
if(ansi_len)
return 0;
if(ch==0x10 || ch==0x1e) { /* Ctrl-P or Ctrl-^ */
if(in_ctrl_p || !ctrl_dir[0]) /* keep from being recursive */
return(0);
......@@ -974,7 +1013,7 @@ int getstr(char *strout, size_t maxlen, long mode)
}
outchar(str1[i++]=1);
break;
case 2: /* Ctrl-B Beginning of Line */
case TERM_KEY_HOME: /* Ctrl-B Beginning of Line */
if(user_misc&ANSI && i) {
bprintf("\x1b[%dD",i);
i=0;
......@@ -1005,7 +1044,7 @@ int getstr(char *strout, size_t maxlen, long mode)
l-=x-i; /* l=new length */
}
break;
case 5: /* Ctrl-E End of line */
case TERM_KEY_END: /* Ctrl-E End of line */
if(user_misc&ANSI && i<l) {
bprintf("\x1b[%dC",l-i); /* move cursor right one */
i=l;
......@@ -1687,7 +1726,7 @@ int nopen(const char *str, int access)
bprintf("\r\nNOPEN COLLISION - File: %s Count: %d\r\n"
,str,count);
if(file==-1 && errno==EACCES)
bputs("\7\r\nNOPEN: ACCESS DENIED\r\n\7");
bprintf("\7\r\nNOPEN: ACCESS DENIED: %s\r\n\7", str);
return(file);
}
......
......@@ -2,13 +2,13 @@
/* Synchronet XSDK constants, macros, and type definitions */
/* $Id: xsdkdefs.h,v 1.10 2009/01/01 12:45:59 deuce Exp $ */
/* $Id: xsdkdefs.h,v 1.11 2020/09/20 12:45:59 deuce Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
......@@ -290,6 +290,19 @@ enum { /* Node Action */
#define KEY_BUFSIZE 256
#endif
/* Special terminal key mappings */
#define TERM_KEY_HOME CTRL_B
#define TERM_KEY_END CTRL_E
#define TERM_KEY_UP CTRL_CARET
#define TERM_KEY_DOWN CTRL_J
#define TERM_KEY_LEFT CTRL_CLOSE_BRACKET
#define TERM_KEY_RIGHT CTRL_F
#define TERM_KEY_INSERT CTRL_V
#define TERM_KEY_DELETE DEL
#define TERM_KEY_ABORT CTRL_C
#define TERM_KEY_PAGEUP CTRL_P
#define TERM_KEY_PAGEDN CTRL_N
#define CRLF { outchar(CR); outchar(LF); }
#define SYSOP (user_level>=sysop_level) /* Is current user sysop t/f macro */
......
......@@ -370,6 +370,7 @@ void movement(int sx,int sy,int sz,int sgx,int sgy)
break;
case '4': /* Move West */
case 'A':
case TERM_KEY_LEFT:
check=inway(x,y,z,gx-1,gy);
if(weapon_ready) { tpic=LEFT;
if(check)
......@@ -404,6 +405,7 @@ void movement(int sx,int sy,int sz,int sgx,int sgy)
break;
case '6': /* Move East */
case 'D':
case TERM_KEY_RIGHT:
check=inway(x,y,z,gx+1,gy);
if(weapon_ready) { tpic=RIGHT;
if(check)
......@@ -438,6 +440,7 @@ void movement(int sx,int sy,int sz,int sgx,int sgy)
break;
case '2': /* Move South */
case 'X':
case TERM_KEY_DOWN:
check=inway(x,y,z,gx,gy+1);
if(weapon_ready) { tpic=DOWN;
if(check)
......@@ -474,6 +477,7 @@ void movement(int sx,int sy,int sz,int sgx,int sgy)
break;
case '8': /* Move North */
case 'W':
case TERM_KEY_UP:
check=inway(x,y,z,gx,gy-1);
if(weapon_ready) { tpic=UP;
if(check)
......@@ -512,6 +516,7 @@ void movement(int sx,int sy,int sz,int sgx,int sgy)
break;
case '7': /* Move NorthWest */
case 'Q':
case TERM_KEY_HOME:
check=inway(x,y,z,gx-1,gy-1);
if(weapon_ready) { tpic=UP;
if(check)
......@@ -534,6 +539,7 @@ void movement(int sx,int sy,int sz,int sgx,int sgy)
break;
case '9': /* Move NorthEast */
case 'E':
case TERM_KEY_PAGEUP:
check=inway(x,y,z,gx+1,gy-1);
if(weapon_ready) { tpic=UP;
if(check)
......@@ -556,6 +562,7 @@ void movement(int sx,int sy,int sz,int sgx,int sgy)
break;
case '1': /* Move SouthWest */
case 'Z':
case TERM_KEY_END:
check=inway(x,y,z,gx-1,gy+1);
if(weapon_ready) { tpic=DOWN;
if(check)
......@@ -578,6 +585,7 @@ void movement(int sx,int sy,int sz,int sgx,int sgy)
break;
case '3': /* Move SouthEast */
case 'C':
case TERM_KEY_PAGEDN:
check=inway(x,y,z,gx+1,gy+1);
if(weapon_ready) { tpic=DOWN;
if(check)
......