Commit 6f16fafe authored by rswindell's avatar rswindell

Both hungry/liberal hot-spots and strict hot-spots can be defined now, at the...

Both hungry/liberal hot-spots and strict hot-spots can be defined now, at the same time. For Nelgin.
Use ^A` to define a single-char strict hot-spot using Ctrl-A codes. Unfortunately, this usurps the "home" Ctrl-A code which nothing seems to use but has now been changed to ^A'.
Use ` instead of ~ in mnemonics to define strict single-char hot-spots (also displays the cmd key in [] instead () on non ANSI/PETSCII terms).
Use @` instead of @~ codes to define strict hot-keys.
Use HOT:STRICT @-code to declare a strict hot-key color.
Use HOT:HUNGRY @-code to toggle back to hungry color-defined hot-keys (the default).
New optional boolean argument to JS console.add_hotkey(), hungry = true by default.
parent 90ea89d8
......@@ -142,8 +142,8 @@ int main(int argc, char **argv)
ANSI;
fprintf(out,"2J"); /* clear screen */
/* fall-through */
case '`':
ANSI;
case '\'':
ANSI;
fprintf(out,"H"); /* home cursor */
break;
case '-':
......
......@@ -104,7 +104,7 @@ int sbbs_t::show_atcode(const char *instr, JSObject* obj)
(*tp)=0;
sp=(str+1);
if(*sp == '~' && *(sp + 1)) { // Mouse hot-spot
if(*sp == '~' && *(sp + 1)) { // Mouse hot-spot (hungry)
sp++;
tp = strchr(sp + 1, '~');
if(tp == NULL)
......@@ -114,7 +114,22 @@ int sbbs_t::show_atcode(const char *instr, JSObject* obj)
tp++;
}
c_unescape_str(tp);
add_hotspot(tp, column, column + strlen(sp) - 1, row);
add_hotspot(tp, /* hungry: */true, column, column + strlen(sp) - 1, row);
bputs(sp);
return len;
}
if(*sp == '`' && *(sp + 1)) { // Mouse hot-spot (strict)
sp++;
tp = strchr(sp + 1, '`');
if(tp == NULL)
tp = sp;
else {
*tp = 0;
tp++;
}
c_unescape_str(tp);
add_hotspot(tp, /* hungry: */false, column, column + strlen(sp) - 1, row);
bputs(sp);
return len;
}
......@@ -260,7 +275,15 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode, bool
}
if(strncmp(sp, "HOT:", 4) == 0) { // Auto-mouse hot-spot attribute
sp += 4;
if(stricmp(sp, "off") == 0)
if(stricmp(sp, "hungry") == 0) {
hungry_hotspots = true;
hot_attr = curatr;
}
else if(stricmp(sp, "strict") == 0) {
hungry_hotspots = false;
hot_attr = curatr;
}
else if(stricmp(sp, "off") == 0)
hot_attr = 0;
else
hot_attr = attrstr(sp);
......
......@@ -92,9 +92,14 @@ int sbbs_t::bputs(const char *str, long mode)
l++;
if(str[l] == 'Z') /* EOF (uppercase 'Z' only) */
break;
if(str[l] == '~' && str[l + 1] != '\0') {
if(str[l] == '~' && str[l + 1] != '\0') { // Mouse hot-spot (hungry)
l++;
add_hotspot(str[l]);
add_hotspot(str[l], /* hungry */true);
continue;
}
if(str[l] == '`' && str[l + 1] != '\0') { // Mouse hot-spot (strict)
l++;
add_hotspot(str[l], /* hungry */false);
continue;
}
ctrl_a(str[l++]);
......@@ -1127,7 +1132,8 @@ void sbbs_t::ctrl_a(char x)
case 'L': /* CLS (form feed) */
CLS;
break;
case '`': /* Home cursor */
case '\'': /* Home cursor */
case '`': // usurped by strict hot-spot
cursor_home();
break;
case '>': /* CLREOL */
......
......@@ -329,7 +329,7 @@ void sbbs_t::mnemonics(const char *str)
l++;
if(!ctrl_a_codes)
attr(cfg.color[clr_mnehigh]);
add_hotspot(str[l], column, column);
add_hotspot(str[l], /* hungry: */true, column, column);
outchar(str[l]);
l++;
if(!(term&(ANSI|PETSCII)))
......@@ -337,6 +337,20 @@ void sbbs_t::mnemonics(const char *str)
if(!ctrl_a_codes)
attr(cfg.color[clr_mnelow]);
}
else if(str[l]=='`' && str[l+1]!=0) {
if(!(term&(ANSI|PETSCII)))
outchar('[');
l++;
if(!ctrl_a_codes)
attr(cfg.color[clr_mnehigh]);
add_hotspot(str[l], /* hungry: */false, column, column);
outchar(str[l]);
l++;
if(!(term&(ANSI|PETSCII)))
outchar(']');
if(!ctrl_a_codes)
attr(cfg.color[clr_mnelow]);
}
else {
if(str[l]==CTRL_A && str[l+1]!=0) {
l++;
......
......@@ -351,17 +351,17 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
if(spot->y == y && x >= spot->minx && x <= spot->maxx)
break;
}
if(node == NULL && liberal_hotspots) {
if(node == NULL) {
for(node = mouse_hotspots.first; node != NULL; node = node->next) {
struct mouse_hotspot* spot = (struct mouse_hotspot*)node->data;
if(spot->y == y && x >= spot->minx)
if(spot->hungry && spot->y == y && x >= spot->minx)
break;
}
}
if(node == NULL && liberal_hotspots) {
if(node == NULL) {
for(node = mouse_hotspots.first; node != NULL; node = node->next) {
struct mouse_hotspot* spot = (struct mouse_hotspot*)node->data;
if(spot->y == y)
if(spot->hungry && spot->y == y)
break;
}
}
......@@ -523,32 +523,35 @@ void sbbs_t::scroll_hotspots(long count)
clear_hotspots();
}
struct mouse_hotspot* sbbs_t::add_hotspot(char cmd, long minx, long maxx, long y)
struct mouse_hotspot* sbbs_t::add_hotspot(char cmd, bool hungry, long minx, long maxx, long y)
{
struct mouse_hotspot spot = {0};
spot.cmd[0] = cmd;
spot.minx = minx;
spot.maxx = maxx;
spot.y = y;
spot.hungry = hungry;
return add_hotspot(&spot);
}
struct mouse_hotspot* sbbs_t::add_hotspot(ulong num, long minx, long maxx, long y)
struct mouse_hotspot* sbbs_t::add_hotspot(ulong num, bool hungry, long minx, long maxx, long y)
{
struct mouse_hotspot spot = {0};
SAFEPRINTF(spot.cmd, "%lu\r", num);
spot.minx = minx;
spot.maxx = maxx;
spot.y = y;
spot.hungry = hungry;
return add_hotspot(&spot);
}
struct mouse_hotspot* sbbs_t::add_hotspot(const char* cmd, long minx, long maxx, long y)
struct mouse_hotspot* sbbs_t::add_hotspot(const char* cmd, bool hungry, long minx, long maxx, long y)
{
struct mouse_hotspot spot = {0};
SAFECOPY(spot.cmd, cmd);
spot.minx = minx;
spot.maxx = maxx;
spot.y = y;
spot.hungry = hungry;
return add_hotspot(&spot);
}
......@@ -579,10 +579,15 @@ js_add_hotspot(JSContext *cx, uintN argc, jsval *arglist)
JSString* js_str = JS_ValueToString(cx, argv[0]);
if(js_str == NULL)
return JS_FALSE;
bool hungry = true;
int32 min_x = -1;
int32 max_x = -1;
int32 y = -1;
uintN argn = 1;
if(argc > argn && JSVAL_IS_BOOLEAN(argv[argn])) {
hungry = JSVAL_TO_BOOLEAN(argv[argn]);
argn++;
}
if(argc > argn) {
if(!JS_ValueToInt32(cx,argv[argn], &min_x))
return JS_FALSE;
......@@ -2305,7 +2310,7 @@ static jsSyncMethodSpec js_console_functions[] = {
,JSDOCSTR("sends an unprocessed byte value to the remote terminal")
,31700
},
{"add_hotspot", js_add_hotspot, 1, JSTYPE_VOID, JSDOCSTR("cmd [,min_x] [,max_x] [,y]")
{"add_hotspot", js_add_hotspot, 1, JSTYPE_VOID, JSDOCSTR("cmd [,bool hungry=<tt>true</tt>] [,min_x] [,max_x] [,y]")
,JSDOCSTR("adds a mouse hot-spot (a clickable screen area that generates keyboard input)")
,31800
},
......
......@@ -3362,7 +3362,7 @@ sbbs_t::sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const
rio_abortable=false;
mouse_mode = MOUSE_MODE_OFF;
liberal_hotspots = true;
hungry_hotspots = true;
console = 0;
online = 0;
outchar_esc = 0;
......
......@@ -64,6 +64,7 @@ char sbbs_t::putmsg(const char *buf, long mode, long org_cols, JSObject* obj)
struct mouse_hotspot hot_spot = {0};
hot_attr = 0;
hungry_hotspots = true;
attr_sp=0; /* clear any saved attributes */
tmpatr=curatr; /* was lclatr(-1) */
if(!(mode&P_SAVEATR))
......@@ -148,7 +149,11 @@ char sbbs_t::putmsg(const char *buf, long mode, long org_cols, JSObject* obj)
else if(str[l+1] == 'Z') /* Ctrl-AZ==EOF (uppercase 'Z' only) */
break;
else if(str[l + 1] == '~' && str[l + 2] != '\0') {
add_hotspot(str[l + 2]);
add_hotspot(str[l + 2], /* hungry: */true);
l += 2;
}
else if(str[l + 1] == '`' && str[l + 2] != '\0') {
add_hotspot(str[l + 2], /* hungry: */false);
l += 2;
}
else {
......@@ -389,6 +394,7 @@ char sbbs_t::putmsg(const char *buf, long mode, long org_cols, JSObject* obj)
hot_spot.maxx = column;
hot_spot.cmd[strlen(hot_spot.cmd)] = str[l];
} else if(hot_spot.cmd[0]) {
hot_spot.hungry = hungry_hotspots;
add_hotspot(&hot_spot);
memset(&hot_spot, 0, sizeof(hot_spot));
}
......
......@@ -305,6 +305,15 @@ extern int thread_suid_broken; /* NPTL is no longer broken */
/* Synchronet Node Instance class definition */
#if defined(__cplusplus) && defined(JAVASCRIPT)
struct mouse_hotspot { // Mouse hot-spot
char cmd[128];
long y;
long minx;
long maxx;
bool hungry;
};
class sbbs_t
{
......@@ -567,6 +576,13 @@ public:
bool ansi_save(void);
bool ansi_restore(void);
void ansi_getlines(void);
enum ansi_mouse_mode {
ANSI_MOUSE_X10 = 9,
ANSI_MOUSE_NORM = 1000,
ANSI_MOUSE_BTN = 1002,
ANSI_MOUSE_ANY = 1003,
ANSI_MOUSE_EXT = 1006
};
int ansi_mouse(enum ansi_mouse_mode, bool enable);
/* Command Shell Methods */
......@@ -802,14 +818,23 @@ public:
/* inkey.cpp */
char inkey(long mode, unsigned long timeout=0);
char handle_ctrlkey(char ch, long mode=0);
// Terminal mouse reporting mode (mouse_mode)
#define MOUSE_MODE_OFF 0 // No terminal mouse reporting enabled/expected
#define MOUSE_MODE_X10 (1<<0) // X10 compatible mouse reporting enabled
#define MOUSE_MODE_NORM (1<<1) // Normal tracking mode mouse reporting
#define MOUSE_MODE_BTN (1<<2) // Button-event tracking mode mouse reporting
#define MOUSE_MODE_ANY (1<<3) // Any-event tracking mode mouse reporting
#define MOUSE_MODE_EXT (1<<4) // SGR-encoded extended coordinate mouse reporting
long mouse_mode; // Mouse reporting mode flags
uint hot_attr; // Auto-Mouse hot-spot attribute (when non-zero)
bool liberal_hotspots;
bool hungry_hotspots;
link_list_t mouse_hotspots; // Mouse hot-spots
struct mouse_hotspot* add_hotspot(struct mouse_hotspot*);
struct mouse_hotspot* add_hotspot(char cmd, long minx = -1, long maxx = -1, long y = -1);
struct mouse_hotspot* add_hotspot(ulong num, long minx = -1, long maxx = -1, long y = -1);
struct mouse_hotspot* add_hotspot(const char* cmd, long minx = -1, long maxx = -1, long y = -1);
struct mouse_hotspot* add_hotspot(char cmd, bool hungry = true, long minx = -1, long maxx = -1, long y = -1);
struct mouse_hotspot* add_hotspot(ulong num, bool hungry = true, long minx = -1, long maxx = -1, long y = -1);
struct mouse_hotspot* add_hotspot(const char* cmd, bool hungry = true, long minx = -1, long maxx = -1, long y = -1);
void clear_hotspots(void);
void scroll_hotspots(long count);
void set_mouse(long mode);
......
......@@ -494,22 +494,6 @@ typedef enum { /* Values for xtrn_t.event */
#define CON_HBLINK_FONT (1<<21) /* Alt high-blink attribute font activated */
#define CON_CR_CLREOL (1<<31) // outchar('\r') clears to end-of-line first
// Terminal mouse reporting mode (mouse_mode)
#define MOUSE_MODE_X10 (1<<0) // X10 compatible mouse reporting enabled
#define MOUSE_MODE_NORM (1<<1) // Normal tracking mode mouse reporting
#define MOUSE_MODE_BTN (1<<2) // Button-event tracking mode mouse reporting
#define MOUSE_MODE_ANY (1<<3) // Any-event tracking mode mouse reporting
#define MOUSE_MODE_EXT (1<<4) // SGR-encoded extended coordinate mouse reporting
#define MOUSE_MODE_OFF 0
enum ansi_mouse_mode {
ANSI_MOUSE_X10 = 9,
ANSI_MOUSE_NORM = 1000,
ANSI_MOUSE_BTN = 1002,
ANSI_MOUSE_ANY = 1003,
ANSI_MOUSE_EXT = 1006
};
/* Number of milliseconds */
#define DELAY_AUTOHG 1500 /* Delay for auto-hangup (xfer) */
......@@ -1122,11 +1106,4 @@ typedef struct { /* Sub-board scan information */
uint32_t sav_last; /* Saved Last read message number */
} subscan_t;
struct mouse_hotspot { // Mouse hot-spot
char cmd[128];
long y;
long minx;
long maxx;
};
#endif /* Don't add anything after this #endif statement */
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