diff --git a/src/sbbs3/asc2ans.c b/src/sbbs3/asc2ans.c index 44e45b0c6aed6ef0d28050ce2ef51a04f76614d2..820ffb5f8fb7f1e6f51c5fe1fa2502f558ad7d99 100644 --- a/src/sbbs3/asc2ans.c +++ b/src/sbbs3/asc2ans.c @@ -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 '-': diff --git a/src/sbbs3/atcodes.cpp b/src/sbbs3/atcodes.cpp index 6a34f71f1af0ec8d197cef06d43ce89747b17c76..8ad8bb682cbf9bd0dc902f94dbd71b2751b51b21 100644 --- a/src/sbbs3/atcodes.cpp +++ b/src/sbbs3/atcodes.cpp @@ -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); diff --git a/src/sbbs3/con_out.cpp b/src/sbbs3/con_out.cpp index 66822a694370a01f665e063c8a27c31342955da6..dfcd625972e457236387fce28c5fd9c559505580 100644 --- a/src/sbbs3/con_out.cpp +++ b/src/sbbs3/con_out.cpp @@ -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 */ diff --git a/src/sbbs3/getkey.cpp b/src/sbbs3/getkey.cpp index 356ab38944ac30b8d80400408e7542b96f19e2f5..6c4c1204c00e03286f014144df2eccadc43f5aad 100644 --- a/src/sbbs3/getkey.cpp +++ b/src/sbbs3/getkey.cpp @@ -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++; diff --git a/src/sbbs3/inkey.cpp b/src/sbbs3/inkey.cpp index 690f107a756c234912324b686a3ecdca3ed78f36..16cd53cde36c0f755aa0c7853cee377a8e11c513 100644 --- a/src/sbbs3/inkey.cpp +++ b/src/sbbs3/inkey.cpp @@ -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); } diff --git a/src/sbbs3/js_console.cpp b/src/sbbs3/js_console.cpp index f1d03f92b36828d5b7f85c3e1dd5d869fc359520..cf8eb5fbd1b5122489edd78b326273a6d27cf5c1 100644 --- a/src/sbbs3/js_console.cpp +++ b/src/sbbs3/js_console.cpp @@ -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 }, diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index f3f15e4d6004e1cb348341f8a7a01158531750dd..d9b9f38140624eb8bcd6c5964be45ee43b64784f 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -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; diff --git a/src/sbbs3/putmsg.cpp b/src/sbbs3/putmsg.cpp index 3fa8eb716bf7ebd3d4c379d1832972a22c05c719..237da583146bcd30cb54b879b86219261d7cb35b 100644 --- a/src/sbbs3/putmsg.cpp +++ b/src/sbbs3/putmsg.cpp @@ -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)); } diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 3ef8913432618c7f1c8382ec45ffa9a00459d47a..a368520b3bf857743ebde6e09eb95c8704516c0a 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -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); diff --git a/src/sbbs3/sbbsdefs.h b/src/sbbs3/sbbsdefs.h index 0832a487362811dcabf5976a71f2344645dd803a..6fc511ad9f5703dc1c86ac500f6b3bed559560bc 100644 --- a/src/sbbs3/sbbsdefs.h +++ b/src/sbbs3/sbbsdefs.h @@ -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 */