Newer
Older
case '?': /* Conditional blank-line */
if(column > 0)
case '[': /* Carriage return */
break;
case ']': /* Line feed */
break;
case 'A': /* Ctrl-A */
case 'Z': /* Ctrl-Z */
outchar(CTRL_Z);
break;
case 'H': /* High intensity */
atr|=HIGH;
attr(atr);
break;
case 'I':
if((term_supports()&(ICE_COLOR|PETSCII)) != ICE_COLOR)
attr(atr|BLINK);
break;
case 'E': /* Bright Background */
if(term_supports()&(ICE_COLOR|PETSCII))
attr(atr|BG_BRIGHT);
case 'F': /* Blink, only if alt Blink Font is loaded */
if(((atr&HIGH) && (console&CON_HBLINK_FONT)) || (!(atr&HIGH) && (console&CON_BLINK_FONT)))
attr(atr|BLINK);
else if(x == 'F' && !(atr&HIGH)) /* otherwise, set HIGH attribute (only if capital 'F') */
attr(atr|HIGH);
break;
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
case 'N': /* Normal */
attr(LIGHTGRAY);
break;
case 'R':
atr=(atr&0xf8)|RED;
attr(atr);
break;
case 'G':
atr=(atr&0xf8)|GREEN;
attr(atr);
break;
case 'B':
atr=(atr&0xf8)|BLUE;
attr(atr);
break;
case 'W': /* White */
atr=(atr&0xf8)|LIGHTGRAY;
attr(atr);
break;
case 'C':
atr=(atr&0xf8)|CYAN;
attr(atr);
break;
case 'M':
atr=(atr&0xf8)|MAGENTA;
attr(atr);
break;
case 'Y': /* Yellow */
atr=(atr&0xf8)|BROWN;
attr(atr);
break;
case 'K': /* Black */
atr=(atr&0xf8)|BLACK;
attr(atr);
break;
case '0': /* Black Background */
attr(atr);
break;
case '1': /* Red Background */
break;
case '2': /* Green Background */
break;
case '3': /* Yellow Background */
break;
case '4': /* Blue Background */
break;
case '5': /* Magenta Background */
break;
case '6': /* Cyan Background */
break;
case '7': /* White Background */
break;
}
/****************************************************************************/
/* Sends terminal control codes to change remote terminal colors/attributes */
/****************************************************************************/
int sbbs_t::attr(int atr)
int newatr = atr;
long term = term_supports();
if(term&PETSCII) {
if(atr&(0x70|BG_BRIGHT)) { // background color (reverse video for PETSCII)
if(atr&BG_BRIGHT)
atr |= HIGH;
else
atr &= ~HIGH;
atr = (atr&(BLINK|HIGH)) | ((atr&0x70)>>4);
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
outcom(PETSCII_REVERSE_ON);
} else
outcom(PETSCII_REVERSE_OFF);
if(atr&BLINK)
outcom(PETSCII_FLASH_ON);
else
outcom(PETSCII_FLASH_OFF);
switch(atr&0x0f) {
case BLACK:
outcom(PETSCII_BLACK);
break;
case WHITE:
outcom(PETSCII_WHITE);
break;
case DARKGRAY:
outcom(PETSCII_DARKGRAY);
break;
case LIGHTGRAY:
outcom(PETSCII_LIGHTGRAY);
break;
case BLUE:
outcom(PETSCII_BLUE);
break;
case LIGHTBLUE:
outcom(PETSCII_LIGHTBLUE);
break;
case CYAN:
outcom(PETSCII_MEDIUMGRAY);
break;
case LIGHTCYAN:
outcom(PETSCII_CYAN);
break;
case YELLOW:
outcom(PETSCII_YELLOW);
break;
case BROWN:
outcom(PETSCII_BROWN);
break;
case RED:
outcom(PETSCII_RED);
break;
case LIGHTRED:
outcom(PETSCII_LIGHTRED);
break;
case GREEN:
outcom(PETSCII_GREEN);
break;
case LIGHTGREEN:
outcom(PETSCII_LIGHTGREEN);
break;
case MAGENTA:
outcom(PETSCII_ORANGE);
break;
case LIGHTMAGENTA:
outcom(PETSCII_PURPLE);
break;
}
}
else if(term&ANSI)
rputs(ansi(newatr,curatr,str));
curatr=newatr;
return 0;
}
/****************************************************************************/
/* Checks to see if user has hit Pause or Abort. Returns 1 if user aborted. */
/* If the user hit Pause, waits for a key to be hit. */
/* Emulates remote XON/XOFF flow control on local console */
/* Preserves SS_ABORT flag state, if already set. */
/* Called from various listing procedures that wish to check for abort */
/****************************************************************************/
bool sbbs_t::msgabort()
{

rswindell
committed
static ulong counter;
if(sys_status&SS_SYSPAGE && !(++counter%100))
sbbs_beep(sbbs_random(800),1);

rswindell
committed
checkline();
if(sys_status&SS_ABORT)
return(true);
if(!online)
return(true);
return(false);
}
int sbbs_t::backfill(const char* instr, float pct, int full_attr, int empty_attr)
char* str = strip_ctrl(instr, NULL);
if(!term_supports(ANSI))
bputs(str);
else {
for(int i=0; i<len; i++) {
if(((float)(i+1) / len)*100.0 <= pct)
atr = full_attr;
else
atr = empty_attr;
if(curatr != atr) attr(atr);
outchar(str[i]);
}
attr(save_atr);
free(str);
void sbbs_t::progress(const char* text, int count, int total, int interval)
{
char str[128];
if(cfg.node_num == 0)
return; // Don't output this for events
if((count%interval) != 0)
return;
if(text == NULL) text = "";
float pct = ((float)count/total)*100.0F;
SAFEPRINTF2(str, "[ %-8s %4.1f%% ]", text, pct);
cursor_left(backfill(str, pct, cfg.color[clr_progress_full], cfg.color[clr_progress_empty]));
}
struct savedline {
char buf[LINE_BUFSIZE+1]; /* Line buffer (i.e. ANSI-encoded) */
uint beg_attr; /* Starting attribute of each line */
uint end_attr; /* Ending attribute of each line */
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
long column; /* Current column number */
};
bool sbbs_t::saveline(void)
{
struct savedline line;
line.beg_attr = latr;
line.end_attr = curatr;
line.column = column;
snprintf(line.buf, sizeof(line.buf), "%.*s", lbuflen, lbuf);
TERMINATE(line.buf);
lbuflen=0;
return listPushNodeData(&savedlines, &line, sizeof(line)) != NULL;
}
bool sbbs_t::restoreline(void)
{
struct savedline* line = (struct savedline*)listPopNode(&savedlines);
if(line == NULL)
return false;
lbuflen=0;
attr(line->beg_attr);
rputs(line->buf);
curatr = line->end_attr;
column = line->column;
free(line);
return true;
}