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

Rewrite status bar code

This will prevent the cursor from showing up when redrawing the
status bar, and implements feature request 79.
parent ef511bd9
Branches
Tags
No related merge requests found
Pipeline #7822 passed
...@@ -277,10 +277,10 @@ struct vmem_cell { ...@@ -277,10 +277,10 @@ struct vmem_cell {
uint8_t legacy_attr; uint8_t legacy_attr;
uint8_t ch; uint8_t ch;
uint8_t font; uint8_t font;
uint32_t fg; /* RGB 00RRGGBB High bit indicates palette colour uint32_t fg; /* RGB 80RRGGBB High bit clear indicates palette colour
* bit 26 indicates it is dirty and must be redrawn * bit 26 indicates it is dirty and must be redrawn
*/ */
uint32_t bg; /* RGB 00RRGGBB High bit indicates palette colour uint32_t bg; /* RGB 80RRGGBB High bit clear indicates palette colour
* bit 24 indicates double-height * bit 24 indicates double-height
* bit 25 indicates Prestel * bit 25 indicates Prestel
* bit 26 indicates pixel graphics present * bit 26 indicates pixel graphics present
......
...@@ -9,6 +9,7 @@ Fix X11 mode scaling and fullscreen with minimal X servers ...@@ -9,6 +9,7 @@ Fix X11 mode scaling and fullscreen with minimal X servers
Massively improve output performance Massively improve output performance
Add option to configure audio output Add option to configure audio output
Lower audio output volume by 12dB Lower audio output volume by 12dB
Reimplement status bar code
Version 1.4a Version 1.4a
------------ ------------
......
...@@ -319,175 +319,136 @@ cleanup: ...@@ -319,175 +319,136 @@ cleanup:
return; return;
} }
static struct vmem_cell *status_bar;
size_t status_bar_sz;
bool force_status_update = false;
void void
update_status(struct bbslist *bbs, int speed, int ooii_mode, bool ata_inv) update_status(struct bbslist *bbs, int speed, int ooii_mode, bool ata_inv)
{ {
char nbuf[LIST_NAME_MAX + 10 + 11 + 7 + 10 + 6 + 1]; /* size_t i;
int avail = 30;
int timeon;
int rc;
char nbuf[31]; /*
* Room for "Name (Logging) (115300) (DrWy) (OOTerm2) (INV)" and terminator * Room for "Name (Logging) (115300) (DrWy) (OOTerm2) (INV)" and terminator
* SAFE and Logging should me be possible. * SAFE and Logging should be possible.
*/ */
int oldscroll; char sbuf[10];
int olddmc = hold_update; char tobuf[9];
struct text_info txtinfo; char fullbuf[81];
int64_t now; int64_t now = xp_fast_timer64();
struct mouse_state *ms = cterm->mouse_state_change_cbdata;
static int64_t lastupd = 0; static int64_t lastupd = 0;
static int oldspeed = 0; static int oldspeed = 0;
static int lastmouse = 0; static uint32_t oldbits = UINT32_MAX;
int newmouse; uint32_t newbits;
int timeon;
char sep;
int oldfont_norm;
int oldfont_bright;
struct mouse_state *ms = cterm->mouse_state_change_cbdata;
if (term.nostatus) if (term.nostatus)
return; return;
now = xp_fast_timer64(); if (status_bar == NULL || status_bar_sz != term.width) {
newmouse = ((ms->mode == MM_OFF) ? 1 : 0) | (ms->flags & MS_FLAGS_DISABLED); free(status_bar);
if (rip_did_reinit) { status_bar_sz = term.width;
rip_did_reinit = false; status_bar = calloc(status_bar_sz, sizeof(status_bar[0]));
} if (status_bar == NULL) {
else { status_bar_sz = 0;
if ((now == lastupd) && (speed == oldspeed) && (newmouse == lastmouse)) {
return; return;
} }
for (i = 0; i < status_bar_sz; i++) {
status_bar[i].fg = 0x80ffff54;
status_bar[i].bg = 0x800000a8;
status_bar[i].ch = ' ';
status_bar[i].font = 0;
status_bar[i].legacy_attr = 0x4b;
} }
oldfont_norm = getfont(1);
oldfont_bright = getfont(2);
setfont(0, false, 1);
setfont(0, false, 2);
switch (getfont(1)) {
case 0:
case 17:
case 18:
case 19:
case 25:
case 26:
case 27:
case 28:
case 29:
case 31:
sep = 0xb3;
break;
default:
sep = '|';
} }
lastupd = now;
lastmouse = newmouse;
oldspeed = speed;
timeon = now - bbs->fast_connected;
if (timeon > 360000)
timeon = 360000;
else if (timeon < 0)
timeon = 0;
gettextinfo(&txtinfo);
oldscroll = _wscroll;
hold_update = true;
textattr(YELLOW | (BLUE << 4));
/* Move to status line thinger */ if (term.width < 80)
window(term.x - 1, term.y + term.height - 1, term.x + term.width - 2, term.y + term.height - 1); lastupd = now;
gotoxy(1, 1); if (ata_inv)
_wscroll = 0; newbits = 1;
strcpy(nbuf, bbs->name); else
newbits = 0;
if (safe_mode) if (safe_mode)
strcat(nbuf, " (SAFE)"); newbits |= 0x02;
if (cterm->log) if (cterm->log)
strcat(nbuf, " (Logging)"); newbits |= 0x04;
if (speed)
sprintf(strchr(nbuf, 0), " (%d)", speed);
if (cterm->doorway_mode) if (cterm->doorway_mode)
strcat(nbuf, " (DrWy)"); newbits |= 0x08;
switch (ooii_mode) { if (ooii_mode >= 1 && ooii_mode <= 3)
case 1: newbits |= (ooii_mode << 4);
strcat(nbuf, " (OOTerm)"); if (force_status_update) {
break; newbits |= 0x40;
case 2: force_status_update = false;
strcat(nbuf, " (OOTerm1)"); }
break; if (rip_did_reinit)
case 3: rip_did_reinit = false;
strcat(nbuf, " (OOTerm2)"); else {
break; if ((now == lastupd) && (speed == oldspeed) && (oldbits == newbits))
return;
} }
if (ata_inv) lastupd = now;
strcat(nbuf, " (INV)"); oldspeed = speed;
ciolib_setcolour(11, 4); oldbits = newbits;
switch(cio_api.mode) { switch(cio_api.mode) {
case CIOLIB_MODE_CURSES: case CIOLIB_MODE_CURSES:
case CIOLIB_MODE_CURSES_IBM: case CIOLIB_MODE_CURSES_IBM:
case CIOLIB_MODE_ANSI: case CIOLIB_MODE_ANSI:
if (term.width < 80) { if (term.width >= 80)
cprintf(" %-30.30s %c %-6.6s ", avail = 29;
nbuf, }
sep,
conn_types[bbs->conn_type]); if (speed)
} snprintf(sbuf, sizeof(sbuf), " (%d)", speed);
else if (timeon > 359999) { else
cprintf(" %-29.29s %c %-6.6s %c Connected: Too Long %c CTRL-S for menu ", sbuf[0] = 0;
nbuf, rc = snprintf(nbuf, avail + 1, "%s%s%s%s%s%s%s", bbs->name, safe_mode ? " (SAFE)" : ""
sep, , cterm->log ? " (Logging)" : "", sbuf, cterm->doorway_mode ? " (DrWy)" : ""
conn_types[bbs->conn_type], , ooii_mode == 1 ? " (OOTerm)" : ooii_mode == 2 ? " (OOTerm1)" : ooii_mode == 3 ? " (OOTerm2)" : ""
sep, , ata_inv ? " (INV)" : "");
sep); if (rc > avail) {
nbuf[avail - 1] = '.';
nbuf[avail - 2] = '.';
nbuf[avail - 3] = '.';
}
if (term.width >= 80) {
timeon = now - bbs->fast_connected;
if (timeon > 360000)
timeon = 360000;
else if (timeon < 0)
timeon = 0;
if (timeon > 359999)
strlcpy(tobuf, "Too Long", sizeof(tobuf));
else
snprintf(tobuf, sizeof(tobuf), "%02d:%02d:%02d", timeon / 3600, (timeon / 60) % 60
, timeon % 60);
snprintf(fullbuf, sizeof(fullbuf), " %-*.*s %c %-6.6s %c Connected: %s %c %s", avail, avail, nbuf, 0xb3
, conn_types[bbs->conn_type], 0xb3, tobuf, 0xb3
, avail == 29 ? "CTRL-S for menu" : ALT_KEY_NAME3CH "-Z for menu ");
} }
else { else {
cprintf(" %-29.29s %c %-6.6s %c Connected: %02d:%02d:%02d %c CTRL-S for menu ", snprintf(fullbuf, sizeof(fullbuf), " %-*.*s %c %-6.6s ", avail, avail, nbuf, 0xb3
nbuf, , conn_types[bbs->conn_type]);
sep,
conn_types[bbs->conn_type],
sep,
timeon / 3600,
(timeon / 60) % 60,
timeon % 60,
sep);
} }
break; if (ms->mode == 0) {
default: status_bar[30].ch = ' ';
if (term.width < 80) { }
cprintf(" %-30.30s %c %-6.6s %*s", for (i = 1; fullbuf[i]; i++) {
nbuf, status_bar[i].ch = fullbuf[i];
sep,
conn_types[bbs->conn_type],
term.width - 40, "");
}
else if (timeon > 359999) {
cprintf(" %-30.30s %c %-6.6s %c Connected: Too Long %c "ALT_KEY_NAME3CH "-Z for menu ",
nbuf,
sep,
conn_types[bbs->conn_type],
sep,
sep);
} }
else {
cprintf(
" %-30.30s %c %-6.6s %c Connected: %02d:%02d:%02d %c "ALT_KEY_NAME3CH "-Z for menu ",
nbuf,
sep,
conn_types[bbs->conn_type],
sep,
timeon / 3600,
(timeon / 60) % 60,
timeon % 60,
sep);
}
break; /* 1+29 +3 +6 +3 +11 +3+3+2 +3 +6 +4 +5 */
}
if (wherex() - term.y + 1 >= term.width)
clreol();
if (ms->mode != 0) { if (ms->mode != 0) {
gotoxy(31, 1); // TODO: Clear before M?
ciolib_setcolour((ms->flags & MS_FLAGS_DISABLED) ? 8 : 11, 4); //status_bar[29].ch = ' ';
putch('M'); status_bar[30].ch = 'M';
} if (ms->flags & MS_FLAGS_DISABLED)
_wscroll = oldscroll; status_bar[30].fg = 0x80545454;
setfont(oldfont_norm, 0, 1); else
setfont(oldfont_bright, 0, 2); status_bar[30].fg = 0x80ffff54;
textattr(txtinfo.attribute); }
window(txtinfo.winleft, txtinfo.wintop, txtinfo.winright, txtinfo.winbottom); vmem_puttext(term.x - 1, term.y + term.height - 1, term.x + term.width - 2, term.y + term.height - 1
gotoxy(txtinfo.curx, txtinfo.cury); , status_bar);
hold_update = olddmc;
} }
#if defined(_WIN32) && defined(_DEBUG) && defined(DUMP) #if defined(_WIN32) && defined(_DEBUG) && defined(DUMP)
...@@ -4218,6 +4179,7 @@ doterm(struct bbslist *bbs) ...@@ -4218,6 +4179,7 @@ doterm(struct bbslist *bbs)
if (bbs->rip) if (bbs->rip)
ms.mode = MM_RIP; ms.mode = MM_RIP;
setup_mouse_events(&ms); setup_mouse_events(&ms);
force_status_update = true;
for (; !quitting;) { for (; !quitting;) {
hold_update = true; hold_update = true;
sleep = true; sleep = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment