Commit 4941fc94 authored by rswindell's avatar rswindell
Browse files

Store the terminal width (in columns) of the text editor used to create the

message text (when relevant and available) - this helps when re-wrapping the
message text (e.g. for quoting) and not always guessing "80 columns".
parent be7d06bc
......@@ -113,6 +113,7 @@ bool sbbs_t::bulkmail(uchar *ar)
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_hfield_bin(&msg, SMB_COLUMNS, cols);
memset(&smb,0,sizeof(smb));
smb.subnum=INVALID_SUB; /* mail database */
......
......@@ -322,6 +322,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_hfield_bin(&msg, SMB_COLUMNS, cols);
smb_dfield(&msg,TEXT_BODY,length);
......
......@@ -331,6 +331,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_hfield_bin(&msg, SMB_COLUMNS, cols);
if(cfg.netmail_misc&NMAIL_DIRECT)
msg.hdr.netattr |= MSG_DIRECT;
......
......@@ -204,6 +204,8 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, uint subnum
/* Synchronet */
if((p=(char*)smb_get_hfield(msg,hfield_type=SMB_EDITOR,NULL))!=NULL)
fprintf(hdrs,"%s: %s\n", smb_hfieldtype(hfield_type), p);
if((p=(char*)smb_get_hfield(msg,hfield_type=SMB_COLUMNS,NULL))!=NULL)
fprintf(hdrs,"%s: %u\n", smb_hfieldtype(hfield_type), *(uint8_t*)p);
if((p=(char*)smb_get_hfield(msg,hfield_type=SMB_TAGS,NULL))!=NULL)
fprintf(hdrs,"%s: %s\n", smb_hfieldtype(hfield_type), p);
......
......@@ -264,6 +264,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_hfield_bin(&msg, SMB_COLUMNS, cols);
smb_dfield(&msg,TEXT_BODY,length);
......@@ -470,6 +471,7 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode)
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_hfield_bin(&msg, SMB_COLUMNS, cols);
smb_dfield(&msg,TEXT_BODY,length);
......
......@@ -348,6 +348,7 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_hfield_bin(&msg, SMB_COLUMNS, cols);
if((cfg.sub[subnum]->misc&SUB_MSGTAGS)
&& (tags[0] || text[TagMessageQ][0] == 0 || !noyes(text[TagMessageQ]))) {
......
......@@ -138,6 +138,10 @@ static void qwk_parse_header_list(ulong confnum, smbmsg_t* msg, str_list_t* head
/* Synchronet */
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SMB_EDITOR),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SMB_COLUMNS),value))!=NULL) {
uint8_t columns = atoi(p);
smb_hfield_bin(msg,hfield_type,columns);
}
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SMB_TAGS),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
......
......@@ -120,9 +120,12 @@ void sbbs_t::msghdr(smbmsg_t* msg)
/* variable fields */
for(i=0;i<msg->total_hfields;i++) {
char *p;
char* p = str;
bprintf("%-16.16s ",smb_hfieldtype(msg->hfield[i].type));
switch(msg->hfield[i].type) {
case SMB_COLUMNS:
sprintf(str, "%u", *(uint8_t*)msg->hfield_dat[i]);
break;
case SENDERNETTYPE:
case RECIPIENTNETTYPE:
case REPLYTONETTYPE:
......
......@@ -80,6 +80,10 @@ void sbbs_t::quotemsg(smbmsg_t* msg, int tails)
char* wrapped=NULL;
FILE* fp;
ushort useron_xedit = useron.xedit;
uint8_t org_cols = TERM_COLS_DEFAULT;
if(msg->columns != 0)
org_cols = msg->columns;
if(useron_xedit && !chk_ar(cfg.xedit[useron_xedit-1]->ar, &useron, &client))
useron_xedit = 0;
......@@ -94,8 +98,8 @@ void sbbs_t::quotemsg(smbmsg_t* msg, int tails)
if((buf=smb_getmsgtxt(&smb,msg,tails)) != NULL) {
strip_invalid_attr(buf);
if(useron_xedit && (cfg.xedit[useron_xedit-1]->misc&QUOTEWRAP))
wrapped=::wordwrap(buf, cols-4, cols-1, /* handle_quotes: */TRUE);
if(!useron_xedit || (useron_xedit && (cfg.xedit[useron_xedit-1]->misc&QUOTEWRAP)))
wrapped=::wordwrap(buf, cols-4, org_cols - 1, /* handle_quotes: */TRUE);
if(wrapped!=NULL) {
fputs(wrapped,fp);
free(wrapped);
......
......@@ -235,6 +235,7 @@
#define SMB_EDITOR 0x68
#define SMB_TAGS 0x69 /* List of tags (ala hash-tags) related to this message */
#define SMB_TAG_DELIMITER " "
#define SMB_COLUMNS 0x6a /* original text editor width in fixed-width columns */
#define FILEATTACH 0x70
#define DESTFILE 0x71
......@@ -646,6 +647,7 @@ typedef struct { /* Message */
uint32_t upvotes; /* Vote tally for this message */
uint32_t downvotes; /* Vote tally for this message */
uint32_t total_votes; /* Total votes for this message or poll */
uint8_t columns; /* 0 means unknown or N/A */
} smbmsg_t;
......
......@@ -857,6 +857,9 @@ static void set_convenience_ptr(smbmsg_t* msg, uint16_t hfield_type, void* hfiel
case SMB_TAGS:
msg->tags=(char*)hfield_dat;
break;
case SMB_COLUMNS:
msg->columns=*(uint8_t*)hfield_dat;
break;
case SMB_EXPIRATION:
msg->expiration=*(uint32_t*)hfield_dat;
break;
......
......@@ -80,6 +80,7 @@ char* SMBCALL smb_hfieldtype(uint16_t type)
case SMB_COST: return("Cost");
case SMB_EDITOR: return("Editor");
case SMB_TAGS: return("Tags");
case SMB_COLUMNS: return("Columns");
case FORWARDED: return("Forwarded");
/* All X-FTN-* are RFC-compliant */
......
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