From 8dc86ed411f1fb0efc4cd74d982844552415c2c2 Mon Sep 17 00:00:00 2001
From: Eric Oulashin <eric.oulashin@gmail.com>
Date: Sun, 17 Sep 2023 14:59:33 -0700
Subject: [PATCH] DD File Lister: Blank out the "# Files Listed" string if used
 as a loadable module (optional, defaults to true)

---
 xtrn/ddfilelister/ddfilelister.cfg     |  5 +++++
 xtrn/ddfilelister/ddfilelister.js      | 22 ++++++++++++++++++++--
 xtrn/ddfilelister/readme.txt           | 10 +++++++++-
 xtrn/ddfilelister/revision_history.txt |  8 ++++++--
 4 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/xtrn/ddfilelister/ddfilelister.cfg b/xtrn/ddfilelister/ddfilelister.cfg
index ebf0f7a51b..0afe62224c 100644
--- a/xtrn/ddfilelister/ddfilelister.cfg
+++ b/xtrn/ddfilelister/ddfilelister.cfg
@@ -20,5 +20,10 @@ sortOrder=NATURAL
 ; Whether or not to pause after viewing a file
 pauseAfterViewingFile=true
 
+; When used as a loadable module, whether or not to blank out
+; the "# Files Listed" string (from text.dat) so that Synchronet
+; won't display it after the lister exits
+blankNFilesListedStrIfLoadableModule=true
+
 ; The name of the color theme configuration file
 themeFilename=defaultTheme.cfg
diff --git a/xtrn/ddfilelister/ddfilelister.js b/xtrn/ddfilelister/ddfilelister.js
index 55376359a4..5c0b614724 100644
--- a/xtrn/ddfilelister/ddfilelister.js
+++ b/xtrn/ddfilelister/ddfilelister.js
@@ -89,6 +89,10 @@
  *                              Fix for "Empty directory" message after quitting (the lister must
  *                              exit with the number of files listed).  Also, updates for filename
  *                              searching, and help screen now should always pause.
+ * 2023-09-17 Eric Oulashin     New configuration option: blankNFilesListedStrIfLoadableModule,
+ *                              If true (default), then when started as a loadable module, replace the
+ *                              "# Files Listed" text with an empty string so that it won't be displayed
+ *                              after exit
 */
 
 "use strict";
@@ -108,7 +112,7 @@ if (system.version_num < 31900)
 		console.crlf();
 		console.pause();
 	}
-	exit();
+	exit(0);
 }
 
 
@@ -123,7 +127,7 @@ require("attr_conv.js", "convertAttrsToSyncPerSysCfg");
 
 // Lister version information
 var LISTER_VERSION = "2.15";
-var LISTER_DATE = "2023-09-16";
+var LISTER_DATE = "2023-09-17";
 
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -271,6 +275,11 @@ var gSearchVerbose = false;
 // When called as a lodable module, one of the options is to scan all dirs
 var gScanAllDirs = false;
 
+// Setting from the configuration file: When used as a loadable module, whether
+// or not to blank out the "# Files Listed" string (from text.dat) so that
+// Synchronet won't display it after the lister exits
+var gBlankNFilesListedStrIfLoadableModule = true;
+
 // Read the configuration file and set the settings
 readConfigFile();
 
@@ -3795,6 +3804,11 @@ function readConfigFile()
 				if (typeof(settingsObj[prop]) === "boolean")
 					gPauseAfterViewingFile = settingsObj[prop];
 			}
+			else if (propUpper == "BLANKNFILESLISTEDSTRIFLOADABLEMODULE")
+			{
+				if (typeof(settingsObj[prop]) === "boolean")
+					gBlankNFilesListedStrIfLoadableModule = settingsObj[prop];
+			}
 			else if (propUpper == "THEMEFILENAME")
 			{
 				if (typeof(settingsObj[prop]) === "string")
@@ -4032,6 +4046,10 @@ function parseArgs(argv)
 		// There must be either 2 or 3 arguments
 		if (argv.length < 2)
 			return false;
+		// If gBlankNFilesListedStrIfLoadableModule is true, replace the "# Files Listed" text with an
+		// empty string so that it won't be displayed after exit
+		if (gBlankNFilesListedStrIfLoadableModule)
+			bbs.replace_text(NFilesListed, "");
 		// The 2nd argument is the mode/behavior bits in either case
 		var FLBehavior = parseInt(argv[1]);
 		if (isNaN(FLBehavior))
diff --git a/xtrn/ddfilelister/readme.txt b/xtrn/ddfilelister/readme.txt
index 24a3545206..08ec719641 100644
--- a/xtrn/ddfilelister/readme.txt
+++ b/xtrn/ddfilelister/readme.txt
@@ -1,6 +1,6 @@
                         Digital Distortion File Lister
                                  Version 2.15
-                           Release date: 2023-09-16
+                           Release date: 2023-09-17
 
                                      by
 
@@ -238,6 +238,11 @@ sortOrder                             String: The file sort order to use.
 
 pauseAfterViewingFile                 Whether or not to pause after viewing a
                                       file
+									  
+blankNFilesListedStrIfLoadableModule  When used as a loadable module, whether or
+                                      not to blank out the "# Files Listed"
+                                      string (from text.dat) so that Synchronet
+                                      won't display it after the lister exits
 
 themeFilename                         The name of the configuration file to
                                       use for colors & string settings
@@ -346,3 +351,6 @@ Synchronet's ctrl directory):
 - DirLibOrAll (622)
 - FileSpecStarDotStar (199)
 - SearchStringPrompt (76)
+- NFilesListed (168): This string will be blanked if the file lister is used as
+  a loadable module and the blankNFilesListedStrIfLoadableModule configuration
+  setting is true
\ No newline at end of file
diff --git a/xtrn/ddfilelister/revision_history.txt b/xtrn/ddfilelister/revision_history.txt
index 0083271eae..075c312742 100644
--- a/xtrn/ddfilelister/revision_history.txt
+++ b/xtrn/ddfilelister/revision_history.txt
@@ -5,12 +5,16 @@ Revision History (change log)
 =============================
 Version  Date         Description
 -------  ----         -----------
-2.15     2023-09-16   Fix for "Empty directory" message after quitting (the
+2.15     2023-09-17   Fix for "Empty directory" message after quitting (the
                       lister must exit with the number of files listed).  Also,
                       updates for filename searching. Also, note ddfilelister is
                       best NOT to be used for the Scan Dirs loadable module
                       option (only for List Files), and the help screen should
-                      now always pause at the end.
+                      now always pause at the end. Also, New configuration
+                      option: blankNFilesListedStrIfLoadableModule, If true
+                      (default), then when started as a loadable module, replace
+                      the "# Files Listed" text with an empty string so that it
+                      won't be displayed after exit.
 2.14     2023-09-02   Fix for the lightbar interface: When erasing the file info
                       window, the file date is not shown on a duplicate line if
                       the file date is already showing in the description area
-- 
GitLab