From ee00b5f8dbd2ddcfc13a5497e266b4aaa1e812ae Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Fri, 12 Apr 2019 00:10:39 +0000 Subject: [PATCH] Define and use a new external message editor option: SAVECOLUMNS (default: off) - when enabled, the current terminal width (columns) will be saved in the msg header. When using the internal msg editor or raw intput mode, the columns are always saved in the message editor. fseditor.js should have this option enabled. --- src/sbbs3/bulkmail.cpp | 4 +--- src/sbbs3/email.cpp | 4 +--- src/sbbs3/fido.cpp | 4 +--- src/sbbs3/netmail.cpp | 8 ++------ src/sbbs3/postmsg.cpp | 4 +--- src/sbbs3/sbbs.h | 1 + src/sbbs3/sbbsdefs.h | 1 + src/sbbs3/writemsg.cpp | 14 ++++++++++++++ 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/sbbs3/bulkmail.cpp b/src/sbbs3/bulkmail.cpp index 073e208d67..cc4e3ac3c7 100644 --- a/src/sbbs3/bulkmail.cpp +++ b/src/sbbs3/bulkmail.cpp @@ -111,9 +111,7 @@ bool sbbs_t::bulkmail(uchar *ar) msg.hdr.when_written.time=time32(NULL); msg.hdr.when_written.zone=sys_timezone(&cfg); - if(editor!=NULL) - smb_hfield_str(&msg,SMB_EDITOR,editor); - smb_hfield_bin(&msg, SMB_COLUMNS, cols); + editor_info_to_msg(&msg, editor); memset(&smb,0,sizeof(smb)); smb.subnum=INVALID_SUB; /* mail database */ diff --git a/src/sbbs3/email.cpp b/src/sbbs3/email.cpp index 667f8082ce..3826b82763 100644 --- a/src/sbbs3/email.cpp +++ b/src/sbbs3/email.cpp @@ -317,9 +317,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode, add_msg_ids(&cfg, &smb, &msg, remsg); - if(editor!=NULL) - smb_hfield_str(&msg,SMB_EDITOR,editor); - smb_hfield_bin(&msg, SMB_COLUMNS, cols); + editor_info_to_msg(&msg, editor); smb_dfield(&msg,TEXT_BODY,length); diff --git a/src/sbbs3/fido.cpp b/src/sbbs3/fido.cpp index 30515b8b3f..126c722bcc 100644 --- a/src/sbbs3/fido.cpp +++ b/src/sbbs3/fido.cpp @@ -350,9 +350,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode, smb_t* resm smb_hfield_str(&msg,SUBJECT, subj); - if(editor!=NULL) - smb_hfield_str(&msg,SMB_EDITOR,editor); - smb_hfield_bin(&msg, SMB_COLUMNS, cols); + editor_info_to_msg(&msg, editor); if(cfg.netmail_misc&NMAIL_DIRECT) msg.hdr.netattr |= MSG_DIRECT; diff --git a/src/sbbs3/netmail.cpp b/src/sbbs3/netmail.cpp index 47c4aaa622..2437040850 100644 --- a/src/sbbs3/netmail.cpp +++ b/src/sbbs3/netmail.cpp @@ -279,9 +279,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode, smb_t* resm add_msg_ids(&cfg, &smb, &msg, remsg); - if(editor!=NULL) - smb_hfield_str(&msg,SMB_EDITOR,editor); - smb_hfield_bin(&msg, SMB_COLUMNS, cols); + editor_info_to_msg(&msg, editor); smb_dfield(&msg,TEXT_BODY,length); @@ -493,9 +491,7 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode, smb_t* resm add_msg_ids(&cfg, &smb, &msg, /* remsg: */NULL); - if(editor!=NULL) - smb_hfield_str(&msg,SMB_EDITOR,editor); - smb_hfield_bin(&msg, SMB_COLUMNS, cols); + editor_info_to_msg(&msg, editor); smb_dfield(&msg,TEXT_BODY,length); diff --git a/src/sbbs3/postmsg.cpp b/src/sbbs3/postmsg.cpp index 7006b3d09c..ff5d26790e 100644 --- a/src/sbbs3/postmsg.cpp +++ b/src/sbbs3/postmsg.cpp @@ -290,9 +290,7 @@ bool sbbs_t::postmsg(uint subnum, long wm_mode, smb_t* resmb, smbmsg_t* remsg) add_msg_ids(&cfg, &smb, &msg, remsg); - if(editor!=NULL) - smb_hfield_str(&msg,SMB_EDITOR,editor); - smb_hfield_bin(&msg, SMB_COLUMNS, cols); + editor_info_to_msg(&msg, editor); if((cfg.sub[subnum]->misc&SUB_MSGTAGS) && (tags[0] || text[TagMessageQ][0] == 0 || !noyes(text[TagMessageQ]))) { diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index c443fb4083..4245a362ac 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -668,6 +668,7 @@ public: bool movemsg(smbmsg_t* msg, uint subnum); int process_edited_text(char* buf, FILE* stream, long mode, unsigned* lines, unsigned maxlines); int process_edited_file(const char* src, const char* dest, long mode, unsigned* lines, unsigned maxlines); + void editor_info_to_msg(smbmsg_t*, const char* editor); /* postmsg.cpp */ bool postmsg(uint subnum, long wm_mode = WM_NONE, smb_t* resmb = NULL, smbmsg_t* remsg = NULL); diff --git a/src/sbbs3/sbbsdefs.h b/src/sbbs3/sbbsdefs.h index 1ddf306e90..23c67d6b3e 100644 --- a/src/sbbs3/sbbsdefs.h +++ b/src/sbbs3/sbbsdefs.h @@ -410,6 +410,7 @@ typedef enum { /* Values for xtrn_t.event */ #define XTRN_PAUSE (1<<19) /* Force a screen pause on exit */ #define XTRN_NOECHO (1<<20) /* Don't echo stdin to stdout */ #define QUOTEWRAP (1<<21) /* Word-wrap quoted message text */ +#define SAVECOLUMNS (1<<22) /* Save/share current terminal width */ #define XTRN_CONIO (1<<31) /* Intercept Windows Console I/O (Drwy) */ /* Bits in cfg.xtrn_misc */ diff --git a/src/sbbs3/writemsg.cpp b/src/sbbs3/writemsg.cpp index ffd060a4ee..fc2df30e8c 100644 --- a/src/sbbs3/writemsg.cpp +++ b/src/sbbs3/writemsg.cpp @@ -657,6 +657,20 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, long mode, return(true); } +void sbbs_t::editor_info_to_msg(smbmsg_t* msg, const char* editor) +{ + if(editor != NULL) + smb_hfield_str(msg, SMB_EDITOR, editor); + + ushort useron_xedit = useron.xedit; + + if(useron_xedit > 0 && !chk_ar(cfg.xedit[useron_xedit - 1]->ar, &useron, &client)) + useron_xedit = 0; + + if(editor == NULL || useron_xedit == 0 || (cfg.xedit[useron_xedit - 1]->misc&SAVECOLUMNS)) + smb_hfield_bin(msg, SMB_COLUMNS, cols); +} + /****************************************************************************/ /****************************************************************************/ /* Modify 'str' to for quoted format. Remove ^A codes, etc. */ -- GitLab