Skip to content
Snippets Groups Projects
Commit d48528a7 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Just because we're *compiled* with graphics support doesn't mean

we support them in the current mode.

Fixes issue 175
parent 2ef6784d
No related branches found
No related tags found
1 merge request!488Overhaul LZH code
Pipeline #7487 passed
...@@ -15870,297 +15870,299 @@ size_t ...@@ -15870,297 +15870,299 @@ size_t
parse_rip(BYTE *origbuf, unsigned blen, unsigned maxlen) parse_rip(BYTE *origbuf, unsigned blen, unsigned maxlen)
{ {
#ifdef HAS_VSTAT #ifdef HAS_VSTAT
unsigned pos = 0; if (cio_api.options & CONIO_OPT_SET_PIXEL) {
size_t rip_start = maxlen + 1; unsigned pos = 0;
bool copy = false; size_t rip_start = maxlen + 1;
BYTE *buf = origbuf; bool copy = false;
BYTE *buf = origbuf;
/*
* TODO: Downloads are broken when RIP is enabled... /*
* This should certainly be fixed someday. * TODO: Downloads are broken when RIP is enabled...
*/ * This should certainly be fixed someday.
if ((rip.enabled == false) || rip_suspended) */
return blen; if ((rip.enabled == false) || rip_suspended)
return blen;
   
shadow_palette(); shadow_palette();
switch (rip.state) { switch (rip.state) {
case RIP_STATE_BOL: case RIP_STATE_BOL:
case RIP_STATE_MOL: case RIP_STATE_MOL:
break; break;
default: default:
rip_start = 0; rip_start = 0;
break; break;
} }
if (blen == 0) { if (blen == 0) {
if (rip_start == 0) { if (rip_start == 0) {
unsigned zer = 0; unsigned zer = 0;
handle_rip_line(origbuf, &zer, &pos, &rip_start, maxlen, RIP_STATE_FLUSHING); handle_rip_line(origbuf, &zer, &pos, &rip_start, maxlen, RIP_STATE_FLUSHING);
copy = true; copy = true;
blen = moredata_len; blen = moredata_len;
if (blen == 0) { if (blen == 0) {
normal_palette();
return blen;
}
buf = moredata;
moredata = NULL;
moredata_len = 0;
moredata_size = 0;
}
else {
normal_palette(); normal_palette();
return blen; return blen;
} }
buf = moredata;
moredata = NULL;
moredata_len = 0;
moredata_size = 0;
} }
else { else {
normal_palette(); if ((rip.state == RIP_STATE_CR) && (buf[0] != '\n'))
return blen;
}
}
else {
if ((rip.state == RIP_STATE_CR) && (buf[0] != '\n'))
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_BOL);
}
for (pos = 0; pos < blen; pos++) {
// TODO: \n handling could likely be moved into main switch
if ((rip.state == RIP_STATE_CR) && (buf[pos] != '\n')) {
if (pos > 0) {
pos--;
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_BOL); handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_BOL);
rip.lchars = 0;
continue;
}
} }
if (buf[pos] == '\n') {
switch (rip.state) { for (pos = 0; pos < blen; pos++) {
// Normal ending to a RIP line... // TODO: \n handling could likely be moved into main switch
case RIP_STATE_CR: if ((rip.state == RIP_STATE_CR) && (buf[pos] != '\n')) {
if (pos > 0) {
pos--;
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_BOL); handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_BOL);
rip.lchars = 0; rip.lchars = 0;
continue; continue;
}
}
if (buf[pos] == '\n') {
switch (rip.state) {
// Normal ending to a RIP line...
case RIP_STATE_CR:
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_BOL);
rip.lchars = 0;
continue;
// Continuation of line ending in CRLF
case RIP_STATE_CONT_PIPE:
case RIP_STATE_CONT_LEVEL:
case RIP_STATE_CONT_SUBLEVEL:
case RIP_STATE_CONT_CMD:
case RIP_STATE_CONT_ENDED:
rip.state -= (RIP_STATE_CONT_PIPE - RIP_STATE_PIPE);
continue;
break;
   
// Continuation of line ending in CRLF // Not a RIP line...
case RIP_STATE_CONT_PIPE: case RIP_STATE_ESC:
case RIP_STATE_CONT_LEVEL: case RIP_STATE_CSI:
case RIP_STATE_CONT_SUBLEVEL: case RIP_STATE_CSINUM:
case RIP_STATE_CONT_CMD: case RIP_STATE_BANG:
case RIP_STATE_CONT_ENDED: unrip_line(buf, &blen, &pos, &rip_start, maxlen);
rip.state -= (RIP_STATE_CONT_PIPE - RIP_STATE_PIPE); rip.state = RIP_STATE_MOL;
continue; continue;
break;
// Not a RIP line...
case RIP_STATE_ESC:
case RIP_STATE_CSI:
case RIP_STATE_CSINUM:
case RIP_STATE_BANG:
unrip_line(buf, &blen, &pos, &rip_start, maxlen);
rip.state = RIP_STATE_MOL;
continue;
   
// No change in state // No change in state
case RIP_STATE_BOL: case RIP_STATE_BOL:
case RIP_STATE_MOL: case RIP_STATE_MOL:
continue; continue;
   
// (TODO: Incorrectly?) Interpreted as a parameter byte (or whatever) // (TODO: Incorrectly?) Interpreted as a parameter byte (or whatever)
default: default:
break; break;
}
}
else if (buf[pos] == '\r') {
switch (rip.state) {
case RIP_STATE_BACKSLASH_PIPE:
case RIP_STATE_BACKSLASH_LEVEL:
case RIP_STATE_BACKSLASH_SUBLEVEL:
case RIP_STATE_BACKSLASH_CMD:
case RIP_STATE_BACKSLASH_ENDED:
break;
case RIP_STATE_ESC:
case RIP_STATE_CSI:
case RIP_STATE_CSINUM:
unrip_line(buf, &blen, &pos, &rip_start, maxlen);
rip.state = RIP_STATE_BOL;
rip.lchars = 0;
continue;
case RIP_STATE_BOL:
case RIP_STATE_MOL:
rip.state = RIP_STATE_BOL;
rip.lchars = 0;
continue;
default:
rip.state = RIP_STATE_CR;
continue;
}
} }
}
else if (buf[pos] == '\r') {
switch (rip.state) { switch (rip.state) {
case RIP_STATE_BACKSLASH_PIPE:
case RIP_STATE_BACKSLASH_LEVEL:
case RIP_STATE_BACKSLASH_SUBLEVEL:
case RIP_STATE_BACKSLASH_CMD:
case RIP_STATE_BACKSLASH_ENDED:
break;
case RIP_STATE_ESC:
case RIP_STATE_CSI:
case RIP_STATE_CSINUM:
unrip_line(buf, &blen, &pos, &rip_start, maxlen);
rip.state = RIP_STATE_BOL;
rip.lchars = 0;
continue;
case RIP_STATE_BOL: case RIP_STATE_BOL:
case RIP_STATE_MOL: case RIP_STATE_MOL:
rip.state = RIP_STATE_BOL; switch (buf[pos]) {
rip.lchars = 0; case '!':
continue; if (rip.state == RIP_STATE_MOL)
default: break;
rip.state = RIP_STATE_CR; case '\x01':
continue; case '\x02':
} if (rip.enabled) {
} rip_start = pos;
switch (rip.state) { rip.state = RIP_STATE_BANG;
case RIP_STATE_BOL: }
case RIP_STATE_MOL:
switch (buf[pos]) {
case '!':
if (rip.state == RIP_STATE_MOL)
break; break;
case '\x01': case '\x1b':
case '\x02':
if (rip.enabled) {
rip_start = pos; rip_start = pos;
rip.state = RIP_STATE_BANG; rip.state = RIP_STATE_ESC;
} break;
break; default:
case '\x1b': if (buf[pos] == '\b') {
rip_start = pos; if (rip.lchars > 0)
rip.state = RIP_STATE_ESC; rip.lchars--;
break; if (rip.lchars == 0) {
default: rip.state = RIP_STATE_BOL;
if (buf[pos] == '\b') { break;
if (rip.lchars > 0) }
rip.lchars--;
if (rip.lchars == 0) {
rip.state = RIP_STATE_BOL;
break;
} }
} else if (buf[pos] < 32) {
else if (buf[pos] < 32) { rip.lchars = -1;
rip.lchars = -1; }
} else {
else { rip.lchars++;
rip.lchars++; }
} rip.state = RIP_STATE_MOL;
rip.state = RIP_STATE_MOL; break;
break; }
}
break;
case RIP_STATE_BANG:
if (buf[pos] == '|') {
rip.state = RIP_STATE_PIPE;
break; break;
} case RIP_STATE_BANG:
unrip_line(buf, &blen, &pos, &rip_start, maxlen); if (buf[pos] == '|') {
rip.state = RIP_STATE_MOL; rip.state = RIP_STATE_PIPE;
break; break;
case RIP_STATE_PIPE: }
if ((buf[pos] >= '1') && (buf[pos] <= '9')) { unrip_line(buf, &blen, &pos, &rip_start, maxlen);
rip.state = RIP_STATE_LEVEL; rip.state = RIP_STATE_MOL;
break; break;
} case RIP_STATE_PIPE:
rip.state = RIP_STATE_CMD; if ((buf[pos] >= '1') && (buf[pos] <= '9')) {
break; rip.state = RIP_STATE_LEVEL;
case RIP_STATE_LEVEL: break;
if ((buf[pos] >= '1') && (buf[pos] <= '9')) { }
rip.state = RIP_STATE_SUBLEVEL; rip.state = RIP_STATE_CMD;
break; break;
} case RIP_STATE_LEVEL:
rip.state = RIP_STATE_CMD; if ((buf[pos] >= '1') && (buf[pos] <= '9')) {
break; rip.state = RIP_STATE_SUBLEVEL;
case RIP_STATE_SUBLEVEL: break;
rip.state = RIP_STATE_CMD; }
break; rip.state = RIP_STATE_CMD;
case RIP_STATE_CMD:
if (buf[pos] == '\\') {
rip.state = RIP_STATE_BACKSLASH_CMD;
break; break;
} case RIP_STATE_SUBLEVEL:
if (buf[pos] == '|') { rip.state = RIP_STATE_CMD;
rip.state = RIP_STATE_PIPE;
break; break;
} case RIP_STATE_CMD:
break; if (buf[pos] == '\\') {
case RIP_STATE_BACKSLASH_PIPE: rip.state = RIP_STATE_BACKSLASH_CMD;
case RIP_STATE_BACKSLASH_LEVEL: break;
case RIP_STATE_BACKSLASH_SUBLEVEL: }
case RIP_STATE_BACKSLASH_CMD: if (buf[pos] == '|') {
case RIP_STATE_BACKSLASH_ENDED: rip.state = RIP_STATE_PIPE;
if (buf[pos] == '\r') { break;
rip.state += (RIP_STATE_CONT_PIPE - RIP_STATE_BACKSLASH_PIPE); }
break; break;
} case RIP_STATE_BACKSLASH_PIPE:
rip.state -= (RIP_STATE_BACKSLASH_PIPE - RIP_STATE_PIPE); case RIP_STATE_BACKSLASH_LEVEL:
break; case RIP_STATE_BACKSLASH_SUBLEVEL:
case RIP_STATE_CR: case RIP_STATE_BACKSLASH_CMD:
// TODO: This is likely broken... case RIP_STATE_BACKSLASH_ENDED:
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL); if (buf[pos] == '\r') {
break; rip.state += (RIP_STATE_CONT_PIPE - RIP_STATE_BACKSLASH_PIPE);
case RIP_STATE_ESC: break;
if (buf[pos] == '[') { }
rip.state = RIP_STATE_CSI; rip.state -= (RIP_STATE_BACKSLASH_PIPE - RIP_STATE_PIPE);
break; break;
} case RIP_STATE_CR:
unrip_line(buf, &blen, &pos, &rip_start, maxlen); // TODO: This is likely broken...
rip.state = RIP_STATE_MOL;
break;
case RIP_STATE_CSI:
if (buf[pos] == '!') {
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL); handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL);
break; break;
} case RIP_STATE_ESC:
if ((buf[pos] >= '0') && (buf[pos] <= '9')) { if (buf[pos] == '[') {
rip.state = RIP_STATE_CSINUM; rip.state = RIP_STATE_CSI;
break; break;
} }
unrip_line(buf, &blen, &pos, &rip_start, maxlen); unrip_line(buf, &blen, &pos, &rip_start, maxlen);
rip.state = RIP_STATE_MOL; rip.state = RIP_STATE_MOL;
break;
case RIP_STATE_CSINUM:
if (buf[pos] == '!') {
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL);
break; break;
} case RIP_STATE_CSI:
if (((buf[pos] >= '0') && (buf[pos] <= '9')) || (buf[pos] == ';')) { if (buf[pos] == '!') {
rip.state = RIP_STATE_SKYPIX; handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL);
break;
}
if ((buf[pos] >= '0') && (buf[pos] <= '9')) {
rip.state = RIP_STATE_CSINUM;
break;
}
unrip_line(buf, &blen, &pos, &rip_start, maxlen);
rip.state = RIP_STATE_MOL;
break; break;
} case RIP_STATE_CSINUM:
unrip_line(buf, &blen, &pos, &rip_start, maxlen); if (buf[pos] == '!') {
rip.state = RIP_STATE_MOL; handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL);
break; break;
case RIP_STATE_SKYPIX: }
if (((buf[pos] >= '0') && (buf[pos] <= '9')) || (buf[pos] == ';')) if (((buf[pos] >= '0') && (buf[pos] <= '9')) || (buf[pos] == ';')) {
rip.state = RIP_STATE_SKYPIX;
break;
}
unrip_line(buf, &blen, &pos, &rip_start, maxlen);
rip.state = RIP_STATE_MOL;
break; break;
if (buf[pos] == '!') { case RIP_STATE_SKYPIX:
if (pendingcmp("\x1b[10;", &buf[rip_start]) == 0) { if (((buf[pos] >= '0') && (buf[pos] <= '9')) || (buf[pos] == ';'))
// This seems to be how Reign of Fire is resetting the font... break;
if (pendingcmp("\x1b[10;0!", &buf[rip_start]) != 0) { if (buf[pos] == '!') {
if (pendingcmp("\x1b[10;", &buf[rip_start]) == 0) {
// This seems to be how Reign of Fire is resetting the font...
if (pendingcmp("\x1b[10;0!", &buf[rip_start]) != 0) {
rip.state = RIP_STATE_SKYPIX_STR;
break;
}
}
if (pendingcmp("\x1b[16;", &buf[rip_start]) == 0) {
rip.state = RIP_STATE_SKYPIX_STR; rip.state = RIP_STATE_SKYPIX_STR;
break; break;
} }
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL);
break;
} }
if (pendingcmp("\x1b[16;", &buf[rip_start]) == 0) { unrip_line(buf, &blen, &pos, &rip_start, maxlen);
rip.state = RIP_STATE_SKYPIX_STR; rip.state = RIP_STATE_MOL;
break;
case RIP_STATE_SKYPIX_STR:
if (buf[pos] == '!') {
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL);
break; break;
} }
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL);
break; break;
} default:
unrip_line(buf, &blen, &pos, &rip_start, maxlen); rip.state = RIP_STATE_ENDED;
rip.state = RIP_STATE_MOL;
break;
case RIP_STATE_SKYPIX_STR:
if (buf[pos] == '!') {
handle_rip_line(buf, &blen, &pos, &rip_start, maxlen, RIP_STATE_MOL);
break; break;
} }
break;
default:
rip.state = RIP_STATE_ENDED;
break;
} }
}
   
// We have some RIP, add to buffer... // We have some RIP, add to buffer...
normal_palette(); normal_palette();
if (rip_start <= maxlen) { if (rip_start <= maxlen) {
buffer_rip(&buf[rip_start], blen - rip_start); buffer_rip(&buf[rip_start], blen - rip_start);
if (copy) {
memcpy(origbuf, buf, rip_start);
free(buf);
}
if (rip.text_disabled)
return ansi_only(origbuf, rip_start);
return rip_start;
}
// Everything is fine...
if (copy) { if (copy) {
memcpy(origbuf, buf, rip_start); memcpy(origbuf, buf, blen);
free(buf); free(buf);
} }
if (rip.text_disabled) if (rip.text_disabled)
return ansi_only(origbuf, rip_start); return ansi_only(origbuf, blen);
return rip_start;
} }
// Everything is fine...
if (copy) {
memcpy(origbuf, buf, blen);
free(buf);
}
if (rip.text_disabled)
return ansi_only(origbuf, blen);
#endif #endif
return blen; return blen;
} }
...@@ -16169,13 +16171,15 @@ void ...@@ -16169,13 +16171,15 @@ void
suspend_rip(bool suspend) suspend_rip(bool suspend)
{ {
#ifdef HAS_VSTAT #ifdef HAS_VSTAT
if (suspend) { if (cio_api.options & CONIO_OPT_SET_PIXEL) {
if (rip.enabled) if (suspend) {
rip_suspended = true; if (rip.enabled)
} rip_suspended = true;
else { }
if (rip.enabled) else {
rip_suspended = false; if (rip.enabled)
rip_suspended = false;
}
} }
#endif #endif
} }
...@@ -16184,67 +16188,69 @@ void ...@@ -16184,67 +16188,69 @@ void
init_rip(struct bbslist *bbs) init_rip(struct bbslist *bbs)
{ {
#ifdef HAS_VSTAT #ifdef HAS_VSTAT
FREE_AND_NULL(rip.xmap);
FREE_AND_NULL(rip.ymap);
FREE_AND_NULL(rip.xunmap);
FREE_AND_NULL(rip.yunmap);
memset(&rip, 0, sizeof(rip));
rip.state = RIP_STATE_BOL;
rip.newstate = RIP_STATE_FLUSHING;
rip.enabled = (bbs->rip != RIP_VERSION_NONE) && (cio_api.options & CONIO_OPT_SET_PIXEL);
rip.version = bbs->rip;
rip.x = 0;
rip.y = 0;
rip.viewport.sx = 0;
rip.viewport.sy = 0;
rip.color = 7;
rip.font.num = 0;
rip.font.vertical = 0;
rip.font.size = 1;
rip.xor = false;
rip.fill_color = 7;
memcpy(rip.fill_pattern, "\xff\xff\xff\xff\xff\xff\xff\xff", 8);
rip.line_pattern = 0xffff;
rip.line_width = 1;
rip.x_dim = 640;
if (cio_api.options & CONIO_OPT_SET_PIXEL) { if (cio_api.options & CONIO_OPT_SET_PIXEL) {
pthread_mutex_lock(&vstatlock); FREE_AND_NULL(rip.xmap);
rip.x_max = vstat.scrnwidth; FREE_AND_NULL(rip.ymap);
rip.y_max = vstat.scrnheight; FREE_AND_NULL(rip.xunmap);
pthread_mutex_unlock(&vstatlock); FREE_AND_NULL(rip.yunmap);
if (rip.x_max > rip.x_dim) memset(&rip, 0, sizeof(rip));
rip.x_max = rip.x_dim; rip.state = RIP_STATE_BOL;
rip.y_dim = 350; rip.newstate = RIP_STATE_FLUSHING;
if (rip.y_max > rip.y_dim) rip.enabled = (bbs->rip != RIP_VERSION_NONE) && (cio_api.options & CONIO_OPT_SET_PIXEL);
rip.y_max = rip.y_dim; rip.version = bbs->rip;
} rip.x = 0;
rip.viewport.ex = rip.x_dim - 1; rip.y = 0;
rip.viewport.ey = rip.y_dim - 1; rip.viewport.sx = 0;
rip.bbs = bbs; rip.viewport.sy = 0;
if (rip.version == RIP_VERSION_1) { rip.color = 7;
rip.default_font = conio_fontdata[0].eight_by_eight; rip.font.num = 0;
rip.default_font_width = 8; rip.font.vertical = 0;
rip.default_font_height = 8; rip.font.size = 1;
} rip.xor = false;
else { rip.fill_color = 7;
pthread_mutex_lock(&vstatlock); memcpy(rip.fill_pattern, "\xff\xff\xff\xff\xff\xff\xff\xff", 8);
rip.default_font = vstat.forced_font; rip.line_pattern = 0xffff;
rip.default_font_width = vstat.charwidth; rip.line_width = 1;
rip.default_font_height = vstat.charheight; rip.x_dim = 640;
pthread_mutex_unlock(&vstatlock); if (cio_api.options & CONIO_OPT_SET_PIXEL) {
} pthread_mutex_lock(&vstatlock);
rip.x_max = vstat.scrnwidth;
rip.y_max = vstat.scrnheight;
pthread_mutex_unlock(&vstatlock);
if (rip.x_max > rip.x_dim)
rip.x_max = rip.x_dim;
rip.y_dim = 350;
if (rip.y_max > rip.y_dim)
rip.y_max = rip.y_dim;
}
rip.viewport.ex = rip.x_dim - 1;
rip.viewport.ey = rip.y_dim - 1;
rip.bbs = bbs;
if (rip.version == RIP_VERSION_1) {
rip.default_font = conio_fontdata[0].eight_by_eight;
rip.default_font_width = 8;
rip.default_font_height = 8;
}
else {
pthread_mutex_lock(&vstatlock);
rip.default_font = vstat.forced_font;
rip.default_font_width = vstat.charwidth;
rip.default_font_height = vstat.charheight;
pthread_mutex_unlock(&vstatlock);
}
   
pending_len = 0; pending_len = 0;
if (pending) if (pending)
pending[0] = 0; pending[0] = 0;
moredata_len = 0; moredata_len = 0;
if (moredata) if (moredata)
moredata[0] = 0; moredata[0] = 0;
if (bbs->rip) { if (bbs->rip) {
shadow_palette(); shadow_palette();
memcpy(&curr_ega_palette, &default_ega_palette, sizeof(curr_ega_palette)); memcpy(&curr_ega_palette, &default_ega_palette, sizeof(curr_ega_palette));
set_ega_palette(); set_ega_palette();
normal_palette(); normal_palette();
}
} }
#endif #endif
} }
...@@ -16253,7 +16259,7 @@ int ...@@ -16253,7 +16259,7 @@ int
rip_kbhit(void) rip_kbhit(void)
{ {
#ifdef HAS_VSTAT #ifdef HAS_VSTAT
if (rip.enabled) if (rip.enabled && cio_api.options & CONIO_OPT_SET_PIXEL)
if (ripbuf) if (ripbuf)
return 1; return 1;
#endif #endif
...@@ -16264,181 +16270,183 @@ int ...@@ -16264,181 +16270,183 @@ int
rip_getch(void) rip_getch(void)
{ {
#ifdef HAS_VSTAT #ifdef HAS_VSTAT
int ch; if (cio_api.options & CONIO_OPT_SET_PIXEL) {
struct mouse_event mevent; int ch;
int oldhold = hold_update; struct mouse_event mevent;
int oldhold = hold_update;
hold_update = false;
hold_update = false;
struct mouse_field *pressed;
struct mouse_field *pressed;
if (ripbuf) {
ch = ripbuf[ripbufpos++]; if (ripbuf) {
if (ripbufpos == ripbuf_pos) { ch = ripbuf[ripbufpos++];
free(ripbuf); if (ripbufpos == ripbuf_pos) {
ripbuf = NULL; free(ripbuf);
ripbuf_size = 0; ripbuf = NULL;
ripbuf_pos = 0; ripbuf_size = 0;
ripbufpos = 0; ripbuf_pos = 0;
ripbufpos = 0;
}
return ch;
} }
return ch; if ((rip.enabled == false) || rip_suspended) {
} ch = getch();
if ((rip.enabled == false) || rip_suspended) { if ((ch == 0) || (ch == 0xe0)) {
ch |= getch() << 8;
if (ch == CIO_KEY_LITERAL_E0)
ch = 0xe0;
}
return ch;
}
struct mouse_state *ms = cterm->mouse_state_change_cbdata;
gotoxy(wherex(), wherey());
ch = getch(); ch = getch();
if ((ch == 0) || (ch == 0xe0)) { if ((ch == 0) || (ch == 0xe0)) {
ch |= getch() << 8; ch |= getch() << 8;
if (ch == CIO_KEY_LITERAL_E0) if (ch == CIO_KEY_LITERAL_E0)
ch = 0xe0; ch = 0xe0;
} }
return ch;
}
struct mouse_state *ms = cterm->mouse_state_change_cbdata;
gotoxy(wherex(), wherey());
ch = getch();
if ((ch == 0) || (ch == 0xe0)) {
ch |= getch() << 8;
if (ch == CIO_KEY_LITERAL_E0)
ch = 0xe0;
}
   
shadow_palette(); shadow_palette();
if (ch == CIO_KEY_MOUSE && (!(ms->flags & MS_FLAGS_DISABLED))) { if (ch == CIO_KEY_MOUSE && (!(ms->flags & MS_FLAGS_DISABLED))) {
ch = -1; ch = -1;
getmouse(&mevent); getmouse(&mevent);
mevent.startx_res = unmap_rip_x(mevent.startx_res); mevent.startx_res = unmap_rip_x(mevent.startx_res);
mevent.starty_res = unmap_rip_y(mevent.starty_res); mevent.starty_res = unmap_rip_y(mevent.starty_res);
mevent.endx_res = unmap_rip_x(mevent.endx_res); mevent.endx_res = unmap_rip_x(mevent.endx_res);
mevent.endy_res = unmap_rip_y(mevent.endy_res); mevent.endy_res = unmap_rip_y(mevent.endy_res);
if (mevent.event == CIOLIB_BUTTON_1_PRESS) { if (mevent.event == CIOLIB_BUTTON_1_PRESS) {
for (rip_pressed = rip.mfields; rip_pressed; rip_pressed = rip_pressed->next) { for (rip_pressed = rip.mfields; rip_pressed; rip_pressed = rip_pressed->next) {
if (rip_pressed->type == MOUSE_FIELD_BUTTON) { if (rip_pressed->type == MOUSE_FIELD_BUTTON) {
if ((mevent.endx_res >= rip_pressed->data.button->box.x1) if ((mevent.endx_res >= rip_pressed->data.button->box.x1)
&& (mevent.endx_res <= rip_pressed->data.button->box.x2) && (mevent.endx_res <= rip_pressed->data.button->box.x2)
&& (mevent.endy_res >= rip_pressed->data.button->box.y1) && (mevent.endy_res >= rip_pressed->data.button->box.y1)
&& (mevent.endy_res <= rip_pressed->data.button->box.y2)) && (mevent.endy_res <= rip_pressed->data.button->box.y2))
break; break;
}
else if (rip_pressed->type == MOUSE_FIELD_HOT) {
if ((mevent.endx_res >= rip_pressed->data.hot->box.x1)
&& (mevent.endx_res <= rip_pressed->data.hot->box.x2)
&& (mevent.endy_res >= rip_pressed->data.hot->box.y1)
&& (mevent.endy_res <= rip_pressed->data.hot->box.y2))
break;
}
}
if (rip_pressed) {
if (rip_pressed->type == MOUSE_FIELD_BUTTON) {
if (rip_pressed->data.button->flags.invertable) {
// draw_button(rip_pressed->data.button, true);
invert_rect(rip_pressed->data.button->box.x1 - rip_pressed->data.button->bevel_size
,
rip_pressed->data.button->box.y1 - rip_pressed->data.button->bevel_size
,
rip_pressed->data.button->box.x2 - rip_pressed->data.button->bevel_size
,
rip_pressed->data.button->box.y2
- rip_pressed->data.button->bevel_size);
}
}
else if (rip_pressed->type == MOUSE_FIELD_HOT) {
if (rip_pressed->data.hot->invertable) {
// draw_button(rip_pressed->data.button, true);
invert_rect(rip_pressed->data.hot->box.x1,
rip_pressed->data.hot->box.y1,
rip_pressed->data.hot->box.x2,
rip_pressed->data.hot->box.y2);
} }
} else if (rip_pressed->type == MOUSE_FIELD_HOT) {
} if ((mevent.endx_res >= rip_pressed->data.hot->box.x1)
} && (mevent.endx_res <= rip_pressed->data.hot->box.x2)
else if (mevent.event == CIOLIB_BUTTON_1_RELEASE) { && (mevent.endy_res >= rip_pressed->data.hot->box.y1)
if (rip_pressed) { && (mevent.endy_res <= rip_pressed->data.hot->box.y2))
if (rip_pressed->type == MOUSE_FIELD_BUTTON) { break;
if (rip_pressed->data.button->flags.invertable) {
// draw_button(rip_pressed->data.button, false);
invert_rect(rip_pressed->data.button->box.x1 - rip_pressed->data.button->bevel_size
,
rip_pressed->data.button->box.y1 - rip_pressed->data.button->bevel_size
,
rip_pressed->data.button->box.x2 - rip_pressed->data.button->bevel_size
,
rip_pressed->data.button->box.y2
- rip_pressed->data.button->bevel_size);
} }
pressed = rip_pressed;
rip_pressed = NULL;
handle_mouse_button(pressed->data.button);
} }
else if (rip_pressed->type == MOUSE_FIELD_HOT) { if (rip_pressed) {
if (rip_pressed->data.hot->invertable) { if (rip_pressed->type == MOUSE_FIELD_BUTTON) {
// draw_button(rip_pressed->data.button, false); if (rip_pressed->data.button->flags.invertable) {
invert_rect(rip_pressed->data.hot->box.x1, // draw_button(rip_pressed->data.button, true);
rip_pressed->data.hot->box.y1, invert_rect(rip_pressed->data.button->box.x1 - rip_pressed->data.button->bevel_size
rip_pressed->data.hot->box.x2, ,
rip_pressed->data.hot->box.y2); rip_pressed->data.button->box.y1 - rip_pressed->data.button->bevel_size
,
rip_pressed->data.button->box.x2 - rip_pressed->data.button->bevel_size
,
rip_pressed->data.button->box.y2
- rip_pressed->data.button->bevel_size);
}
} }
pressed = rip_pressed; else if (rip_pressed->type == MOUSE_FIELD_HOT) {
rip_pressed = NULL; if (rip_pressed->data.hot->invertable) {
handle_command_str(pressed->data.hot->command); // draw_button(rip_pressed->data.button, true);
if (rip.mfields) { invert_rect(rip_pressed->data.hot->box.x1,
if (pressed->data.hot->resetafter) rip_pressed->data.hot->box.y1,
rv_reset("RESET", NULL); rip_pressed->data.hot->box.x2,
rip_pressed->data.hot->box.y2);
}
} }
} }
} }
else { else if (mevent.event == CIOLIB_BUTTON_1_RELEASE) {
if (rip.text_click) { if (rip_pressed) {
if ((mevent.endx >= cterm->left_margin - 1) if (rip_pressed->type == MOUSE_FIELD_BUTTON) {
&& (mevent.endx <= cterm->right_margin - 1) if (rip_pressed->data.button->flags.invertable) {
&& (mevent.endy >= cterm->top_margin - 1) // draw_button(rip_pressed->data.button, false);
&& (mevent.endy <= cterm->bottom_margin - 1)) { invert_rect(rip_pressed->data.button->box.x1 - rip_pressed->data.button->bevel_size
rip_mouse_event.x = mevent.endx; ,
rip_mouse_event.y = mevent.endy; rip_pressed->data.button->box.y1 - rip_pressed->data.button->bevel_size
rip_mouse_event.buttons = mevent.bstate | 1; ,
mousestate(&rip_mouse_event.x, rip_pressed->data.button->box.x2 - rip_pressed->data.button->bevel_size
&rip_mouse_event.y, ,
&rip_mouse_event.buttons); rip_pressed->data.button->box.y2
rip_mouse_event.type = RIP_MOUSE_EVENT_TEXT; - rip_pressed->data.button->bevel_size);
handle_command_str(rip.text_click); }
rip_mouse_event.type = RIP_MOUSE_EVENT_NONE; pressed = rip_pressed;
rip_pressed = NULL;
handle_mouse_button(pressed->data.button);
}
else if (rip_pressed->type == MOUSE_FIELD_HOT) {
if (rip_pressed->data.hot->invertable) {
// draw_button(rip_pressed->data.button, false);
invert_rect(rip_pressed->data.hot->box.x1,
rip_pressed->data.hot->box.y1,
rip_pressed->data.hot->box.x2,
rip_pressed->data.hot->box.y2);
}
pressed = rip_pressed;
rip_pressed = NULL;
handle_command_str(pressed->data.hot->command);
if (rip.mfields) {
if (pressed->data.hot->resetafter)
rv_reset("RESET", NULL);
}
} }
} }
if (rip.graphics_click) { else {
if ((mevent.endx_res >= rip.viewport.sx) && (mevent.endx_res <= rip.viewport.ex) if (rip.text_click) {
&& (mevent.endy_res >= rip.viewport.sy) if ((mevent.endx >= cterm->left_margin - 1)
&& (mevent.endy_res <= rip.viewport.ey)) { && (mevent.endx <= cterm->right_margin - 1)
rip_mouse_event.x = mevent.endx_res; && (mevent.endy >= cterm->top_margin - 1)
rip_mouse_event.y = mevent.endy_res; && (mevent.endy <= cterm->bottom_margin - 1)) {
rip_mouse_event.buttons = mevent.bstate | 1; rip_mouse_event.x = mevent.endx;
mousestate_res(&rip_mouse_event.x, rip_mouse_event.y = mevent.endy;
&rip_mouse_event.y, rip_mouse_event.buttons = mevent.bstate | 1;
&rip_mouse_event.buttons); mousestate(&rip_mouse_event.x,
rip_mouse_event.type = RIP_MOUSE_EVENT_GRAPHICS; &rip_mouse_event.y,
handle_command_str(rip.graphics_click); &rip_mouse_event.buttons);
rip_mouse_event.type = RIP_MOUSE_EVENT_NONE; rip_mouse_event.type = RIP_MOUSE_EVENT_TEXT;
handle_command_str(rip.text_click);
rip_mouse_event.type = RIP_MOUSE_EVENT_NONE;
}
}
if (rip.graphics_click) {
if ((mevent.endx_res >= rip.viewport.sx) && (mevent.endx_res <= rip.viewport.ex)
&& (mevent.endy_res >= rip.viewport.sy)
&& (mevent.endy_res <= rip.viewport.ey)) {
rip_mouse_event.x = mevent.endx_res;
rip_mouse_event.y = mevent.endy_res;
rip_mouse_event.buttons = mevent.bstate | 1;
mousestate_res(&rip_mouse_event.x,
&rip_mouse_event.y,
&rip_mouse_event.buttons);
rip_mouse_event.type = RIP_MOUSE_EVENT_GRAPHICS;
handle_command_str(rip.graphics_click);
rip_mouse_event.type = RIP_MOUSE_EVENT_NONE;
}
} }
} }
} }
} }
} else {
else { for (rip_pressed = rip.mfields; rip_pressed; rip_pressed = rip_pressed->next) {
for (rip_pressed = rip.mfields; rip_pressed; rip_pressed = rip_pressed->next) { if (rip_pressed->type == MOUSE_FIELD_BUTTON) {
if (rip_pressed->type == MOUSE_FIELD_BUTTON) { if (toupper(rip_pressed->data.button->hotkey) == toupper(ch))
if (toupper(rip_pressed->data.button->hotkey) == toupper(ch)) break;
break; }
}
if (rip_pressed) {
ch = -1;
handle_mouse_button(rip_pressed->data.button);
rip_pressed = NULL;
} }
} }
if (rip_pressed) { normal_palette();
ch = -1; hold_update = oldhold;
handle_mouse_button(rip_pressed->data.button); return ch;
rip_pressed = NULL;
}
} }
normal_palette(); #endif
hold_update = oldhold;
return ch;
#else
int ch; int ch;
   
ch = getch(); ch = getch();
...@@ -16448,5 +16456,4 @@ rip_getch(void) ...@@ -16448,5 +16456,4 @@ rip_getch(void)
ch = 0xe0; ch = 0xe0;
} }
return ch; return ch;
#endif
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment