Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit b468feda authored by rswindell's avatar rswindell
Browse files

2 more uses of the "HOT" @-code:

- "HOT" by itself will set the hot-spot attribute to the *current* attribute
  (just colorize the @-code in your editor the same as you do your cmd keys
  no need to memorize color-code mnemonics)
- "HOT:OFF" will turn off the hot-spot attribute through the end of the text or   util re-enabled
- Use a more greedy/liberal hot-spot matching algoirthm so that hot spots can overlap and the "best" one will be chosen. No way to opt-out of this algorithm (e.g. to use a conservative matching algo) currently.
- Earlier parse of @~ codes to keep text prestine
parent f393a83f
......@@ -104,6 +104,21 @@ int sbbs_t::show_atcode(const char *instr, JSObject* obj)
(*tp)=0;
sp=(str+1);
if(*sp == '~' && *(sp + 1)) { // Mouse hot-spot
sp++;
tp = strchr(sp + 1, '~');
if(tp == NULL)
tp = sp;
else {
*tp = 0;
tp++;
}
c_unescape_str(tp);
add_hotspot(tp, column, column + strlen(sp) - 1, row);
bputs(sp);
return len;
}
disp_len=len;
if((p = strchr(sp, '|')) != NULL) {
if(strchr(p, 'T') != NULL)
......@@ -239,22 +254,16 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode, bool
str[0]=0;
if(*sp == '~' && *(sp + 1)) {
sp++;
tp = strchr(sp + 1, '~');
if(tp == NULL)
tp = sp;
else {
*tp = 0;
tp++;
}
c_unescape_str(tp);
add_hotspot(tp, column, column + strlen(sp) - 1, row);
return sp;
if(strcmp(sp, "HOT") == 0) { // Auto-mouse hot-spot attribute
hot_attr = curatr;
return nulstr;
}
if(strncmp(sp, "HOT:", 4) == 0) { // Auto-mouse hot-spot attribute
hot_attr = attrstr(sp + 4);
sp += 4;
if(stricmp(sp, "off") == 0)
hot_attr = 0;
else
hot_attr = attrstr(sp);
return nulstr;
}
......
......@@ -345,12 +345,28 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
return handle_ctrlkey(TERM_KEY_ABORT, mode);
if(button != 0x20) // Left-click
continue;
for(list_node_t* node = mouse_hotspots.first; node != NULL; node = node->next) {
list_node_t* node;
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 && x <= spot->maxx)
break;
}
if(node == NULL && liberal_hotspots) {
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)
break;
}
}
if(node == NULL && liberal_hotspots) {
for(node = mouse_hotspots.first; node != NULL; node = node->next) {
struct mouse_hotspot* spot = (struct mouse_hotspot*)node->data;
if(spot->y == y)
break;
}
}
if(node != NULL) {
struct mouse_hotspot* spot = (struct mouse_hotspot*)node->data;
if(spot->y != y)
continue;
if(x < spot->minx || x > spot->maxx)
continue;
#ifdef _DEBUG
{
char dbg[128];
......@@ -458,20 +474,23 @@ void sbbs_t::set_mouse(long flags)
}
}
void sbbs_t::add_hotspot(struct mouse_hotspot* spot)
struct mouse_hotspot* sbbs_t::add_hotspot(struct mouse_hotspot* spot)
{
if(spot->y < 0)
spot->y = row;
if(spot->minx < 0)
spot->minx = 0;
spot->minx = column;
if(spot->maxx < 0)
spot->maxx = cols - 1;
#ifdef _DEBUG
lprintf(LOG_DEBUG, "Adding mouse hot spot %ld-%ld x %ld = '%s'"
,spot->minx, spot->maxx, spot->y, spot->cmd);
#endif
listInsertNodeData(&mouse_hotspots, spot, sizeof(*spot));
list_node_t* node = listInsertNodeData(&mouse_hotspots, spot, sizeof(*spot));
if(node == NULL)
return NULL;
set_mouse(MOUSE_MODE_X10);
return (struct mouse_hotspot*)node->data;
}
void sbbs_t::clear_hotspots(void)
......@@ -504,32 +523,32 @@ void sbbs_t::scroll_hotspots(long count)
clear_hotspots();
}
void sbbs_t::add_hotspot(char cmd, long minx, long maxx, long y)
struct mouse_hotspot* sbbs_t::add_hotspot(char cmd, long minx, long maxx, long y)
{
struct mouse_hotspot spot = {0};
spot.cmd[0] = cmd;
spot.minx = minx;
spot.maxx = maxx;
spot.y = y;
add_hotspot(&spot);
return add_hotspot(&spot);
}
void sbbs_t::add_hotspot(ulong num, long minx, long maxx, long y)
struct mouse_hotspot* sbbs_t::add_hotspot(ulong num, 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;
add_hotspot(&spot);
return add_hotspot(&spot);
}
void sbbs_t::add_hotspot(const char* cmd, long minx, long maxx, long y)
struct mouse_hotspot* sbbs_t::add_hotspot(const char* cmd, long minx, long maxx, long y)
{
struct mouse_hotspot spot = {0};
SAFECOPY(spot.cmd, cmd);
spot.minx = minx;
spot.maxx = maxx;
spot.y = y;
add_hotspot(&spot);
return add_hotspot(&spot);
}
......@@ -3362,6 +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;
console = 0;
online = 0;
outchar_esc = 0;
......
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