Skip to content
Snippets Groups Projects
Commit 3bf32372 authored by rswindell's avatar rswindell
Browse files

Created new putmsg() mode flag: P_WORDWRAP and use it in show_msg() to wrap

long lines in messages for the user's terminal. May be used for viewing other
files with long lines (e.g. G-text files) in the future.
parent c50f40dd
Branches
Tags
No related merge requests found
......@@ -188,7 +188,7 @@ void sbbs_t::show_msg(smbmsg_t* msg, long mode)
if((text=smb_getmsgtxt(&smb,msg,GETMSGTXT_ALL))!=NULL) {
truncsp_lines(text);
putmsg(text, mode);
putmsg(text, mode|P_WORDWRAP);
smb_freemsgtxt(text);
}
}
......
......@@ -47,9 +47,10 @@
/* the attributes prior to diplaying the message are always restored. */
/* Ignores Ctrl-Z's */
/****************************************************************************/
char sbbs_t::putmsg(const char *str, long mode)
char sbbs_t::putmsg(const char *buf, long mode)
{
char tmpatr,tmp2[256],tmp3[128];
char* str=buf;
uchar exatr=0;
int orgcon=console,i;
ulong l=0,sys_status_sav=sys_status;
......@@ -63,6 +64,14 @@ char sbbs_t::putmsg(const char *str, long mode)
sys_status|=SS_PAUSEOFF;
if(mode&P_HTML)
putcom("\x02\x02");
if(mode&P_WORDWRAP) {
char *wrapped;
if((wrappped=::wordwrap(buf, cols-4, cols-1, /* handle_quotes */TRUE)) == NULL)
errormsg(WHERE,ERR_ALLOC,"wordwrap buffer",0);
else
str=wrapped;
}
while(str[l] && (mode&P_NOABORT || !msgabort()) && online) {
if(str[l]==CTRL_A && str[l+1]!=0) {
if(str[l+1]=='"' && !(sys_status&SS_NEST_PF)) { /* Quote a file */
......@@ -280,6 +289,9 @@ char sbbs_t::putmsg(const char *str, long mode)
pause();
}
if(str!=buf) /* malloc'd copy of buffer */
free(str);
/* Restore original settings of Forced Pause On/Off */
sys_status&=~(SS_PAUSEOFF|SS_PAUSEON);
sys_status|=(sys_status_sav&(SS_PAUSEOFF|SS_PAUSEON));
......
......@@ -698,6 +698,7 @@ typedef enum { /* Values for xtrn_t.event */
#define P_NOPAUSE (1<<4) /* Disable screen pause */
#define P_HTML (1<<5) /* Message is HTML */
#define P_NOCRLF (1<<6) /* Don't prepend a CRLF in printfile() */
#define P_WORDWRAP (1<<7) /* Word-wrap long lines for user's terminal */
/* Bits in 'mode' for listfiles */
#define FL_ULTIME (1<<0) /* List files by upload time */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment