Commit 085af70c authored by echicken's avatar echicken 🐔

Merge branch 'master' of gitlab.synchro.net:sbbs/sbbs

parents a418c2dc 2bc1d73f
Pipeline #328 passed with stage
in 18 minutes and 18 seconds
......@@ -566,57 +566,46 @@ const char* sbbs_t::term_charset(long term)
/****************************************************************************/
int sbbs_t::outchar(char ch)
{
/*
* outchar_esc values:
* 0: No sequence
* 1: ESC
* 2: CSI
* 3: Final byte
* 4: APS, DCS, PM, or OSC
* 5: SOS
* 6: ESC inside of SOS
*/
if(console&CON_ECHO_OFF)
return 0;
if(ch==ESC && outchar_esc < 4)
outchar_esc=1;
else if(outchar_esc==1) {
if(ch=='[')
outchar_esc++;
else if(ch=='_' || ch=='P' || ch == '^' || ch == ']')
outchar_esc=4;
if(ch == ESC && outchar_esc < ansiState_string)
outchar_esc = ansiState_esc;
else if(outchar_esc == ansiState_esc) {
if(ch == '[')
outchar_esc = ansiState_csi;
else if(ch == '_' || ch == 'P' || ch == '^' || ch == ']')
outchar_esc = ansiState_string;
else if(ch=='X')
outchar_esc=5;
else if(ch >= 0x40 && ch <= 0x5f)
outchar_esc=3;
outchar_esc = ansiState_sos;
else if(ch >= '@' && ch <= '_')
outchar_esc = ansiState_final;
else
outchar_esc=0;
outchar_esc = ansiState_none;
}
else if(outchar_esc==2) {
if(ch>='@' && ch<='~')
outchar_esc++;
else if(outchar_esc == ansiState_csi) {
if(ch >= '@' && ch <= '~')
outchar_esc = ansiState_final;
}
else if(outchar_esc==4) { // APS, DCS, PM, or OSC
else if(outchar_esc == ansiState_string) { // APS, DCS, PM, or OSC
if (ch == ESC)
outchar_esc = 1;
if (!((ch >= 0x08 && ch <= 0x0d) || (ch >= 0x20 && ch <= 0x7e)))
outchar_esc = 0;
outchar_esc = ansiState_esc;
if (!((ch >= '\b' && ch <= '\r') || (ch >= ' ' && ch <= '~')))
outchar_esc = ansiState_none;
}
else if(outchar_esc==5) { // SOS
else if(outchar_esc == ansiState_sos) { // SOS
if (ch == ESC)
outchar_esc++;
outchar_esc = ansiState_sos_esc;
}
else if(outchar_esc==6) { // ESC inside SOS
else if(outchar_esc == ansiState_sos_esc) { // ESC inside SOS
if (ch == '\\')
outchar_esc = 1;
outchar_esc = ansiState_esc;
else if (ch == 'X')
outchar_esc = 0;
outchar_esc = ansiState_none;
else
outchar_esc = 5;
outchar_esc = ansiState_sos;
}
else
outchar_esc=0;
outchar_esc = ansiState_none;
long term = term_supports();
char utf8[UTF8_MAX_LEN + 1] = "";
if(!(term&PETSCII)) {
......@@ -642,7 +631,7 @@ int sbbs_t::outchar(char ch)
if(!(console&CON_R_ECHO))
return 0;
if((console&CON_R_ECHOX) && (uchar)ch>=' ' && !outchar_esc) {
if((console&CON_R_ECHOX) && (uchar)ch>=' ' && outchar_esc == ansiState_none) {
ch=text[YNQP][3];
if(text[YNQP][2]==0 || ch==0) ch='X';
}
......@@ -677,7 +666,7 @@ int sbbs_t::outchar(char ch)
outcom(ch);
}
}
if(!outchar_esc) {
if(outchar_esc == ansiState_none) {
/* Track cursor position locally */
switch(ch) {
case '\a': // 7
......@@ -718,8 +707,8 @@ int sbbs_t::outchar(char ch)
break;
}
}
if(outchar_esc==3)
outchar_esc=0;
if(outchar_esc == ansiState_final)
outchar_esc = ansiState_none;
if(lncntr==rows-1 && ((useron.misc&(UPAUSE^(console&CON_PAUSEOFF))) || sys_status&SS_PAUSEON)
&& !(sys_status&(SS_PAUSEOFF|SS_ABORT))) {
......
......@@ -3369,7 +3369,7 @@ sbbs_t::sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const
pause_hotspot = NULL;
console = 0;
online = 0;
outchar_esc = 0;
outchar_esc = ansiState_none;
nodemsg_inside = 0; /* allows single nest */
hotkey_inside = 0; /* allows single nest */
event_time = 0;
......
......@@ -389,8 +389,8 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
size=msgtoqwk(&msg, qwk, mode|QM_REPLYTO, &smb, /* confnum: */0, hdrs);
smb_unlockmsghdr(&smb,&msg);
smb_freemsgmem(&msg);
msgndx++;
if(ndx && size) {
msgndx++;
f=ltomsbin(msgndx); /* Record number */
ch=0; /* Sub number, not used */
if(personal) {
......@@ -529,8 +529,8 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
size=msgtoqwk(&msg, qwk, mode, &smb, conf, hdrs, voting);
smb_unlockmsghdr(&smb,&msg);
msgndx++;
if(ndx && size) {
msgndx++;
f=ltomsbin(msgndx); /* Record number */
ch=0; /* Sub number, not used */
if(personal
......
......@@ -193,10 +193,6 @@ char sbbs_t::putmsgfrag(const char* buf, long* mode, long org_cols, JSObject* ob
l+=2;
}
}
else if((str[l]=='`' || str[l]=='') && str[l+1]=='[') {
outchar(ESC); /* Convert `[ and [ to ESC[ */
l++;
}
else if(!((*mode)&P_NOXATTRS)
&& (cfg.sys_misc&SM_PCBOARD) && str[l]=='@' && str[l+1]=='X'
&& isxdigit((unsigned char)str[l+2]) && isxdigit((unsigned char)str[l+3])) {
......@@ -348,12 +344,12 @@ char sbbs_t::putmsgfrag(const char* buf, long* mode, long org_cols, JSObject* ob
}
/* ansi escape sequence */
if(outchar_esc) {
if(outchar_esc >= ansiState_csi) {
if(str[l]=='A' || str[l]=='B' || str[l]=='H' || str[l]=='J'
|| str[l]=='f' || str[l]=='u') /* ANSI anim */
lncntr=0; /* so defeat pause */
if(str[l]=='"') {
l++; /* don't pass on keyboard reassignment */
if(str[l]=='"' || str[l]=='c') {
l++; /* don't pass on keyboard reassignment or Device Attributes (DA) requests */
continue;
}
}
......
......@@ -348,7 +348,15 @@ public:
scfg_t cfg;
int outchar_esc; // track ANSI escape seq output
enum ansiState {
ansiState_none // No sequence
,ansiState_esc // Escape
,ansiState_csi // CSI
,ansiState_final // Final byte
,ansiState_string // APS, DCS, PM, or OSC
,ansiState_sos // SOS
,ansiState_sos_esc // ESC inside SOS
} outchar_esc; // track ANSI escape seq output
int rioctl(ushort action); // remote i/o control
bool rio_abortable;
......
......@@ -526,8 +526,8 @@ void listmsgs(ulong start, ulong count)
,beep,i,smb.last_error);
break;
}
printf("%4"PRIu32" %-25.25s %-25.25s %s\n"
,msg.hdr.number,msg.from,msg.to,msg.subj);
printf("%4lu/#%-4"PRIu32" %-25.25s %-25.25s %s\n"
,start + l, msg.hdr.number,msg.from,msg.to,msg.subj);
smb_freemsgmem(&msg);
l++;
}
......@@ -1381,10 +1381,11 @@ int setmsgattr(smb_t* smb, ulong number, uint16_t attr)
/****************************************************************************/
/* Read messages in message base */
/****************************************************************************/
void readmsgs(ulong start)
void readmsgs(ulong start, ulong count)
{
char *inbuf;
int i,done=0,domsg=1;
ulong rd = 0;
smbmsg_t msg;
if(start)
......@@ -1426,6 +1427,8 @@ void readmsgs(ulong start)
printf("\n\n");
if((inbuf=smb_getmsgtxt(&smb,&msg, msgtxtmode))!=NULL) {
char* p;
REPLACE_CHARS(inbuf, ESC, '.', p);
printf("%s",remove_ctrl_a(inbuf, inbuf));
free(inbuf);
}
......@@ -1436,9 +1439,16 @@ void readmsgs(ulong start)
,beep,i,smb.last_error);
break;
}
smb_freemsgmem(&msg);
smb_freemsgmem(&msg);
rd++;
}
domsg=1;
if(count) {
if(rd >= count)
break;
msg.offset++;
continue;
}
printf("\nReading %s (?=Menu): ",smb.file);
switch(toupper(getch())) {
case '?':
......@@ -1816,7 +1826,7 @@ int main(int argc, char **argv)
fprintf(errfp, "\nError %d (%s) unlocking %s\n", i, smb.last_error, smb.file);
break;
case 'r':
readmsgs(getmsgnum(cmd+1));
readmsgs(getmsgnum(cmd+1), count);
y=strlen(cmd)-1;
break;
case 'R':
......
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