From cfeb22f9ba4a61576a725032c0c61b68cf02c2d1 Mon Sep 17 00:00:00 2001
From: Eric Oulashin <eric.oulashin@gmail.com>
Date: Wed, 13 Apr 2022 18:38:38 -0700
Subject: [PATCH] Dates shown in file desriptions when extended descriptions
 are enabled. When extended file descriptions are enabled, the file date is
 now shown with the file description on the last line.

---
 xtrn/ddfilelister/ddfilelister.js      | 41 +++++++++++++++++++-------
 xtrn/ddfilelister/readme.txt           |  4 +--
 xtrn/ddfilelister/revision_history.txt |  2 ++
 3 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/xtrn/ddfilelister/ddfilelister.js b/xtrn/ddfilelister/ddfilelister.js
index edf9dc69ed..600f61fd3b 100644
--- a/xtrn/ddfilelister/ddfilelister.js
+++ b/xtrn/ddfilelister/ddfilelister.js
@@ -43,6 +43,10 @@
  *                              Fix for "fileDesc is not defined" error when displaying
  *                              the file description on the main screen.  Also made a
  *                              small refactor to the main screen refresh function.
+ * 2022-04-13 Eric Oulashin     Version 2.06
+ *                              When extended file descriptions are enabled, the file
+ *                              date is now shown with the file description on the last
+ *                              line.
 */
 
 if (typeof(require) === "function")
@@ -98,8 +102,8 @@ if (system.version_num < 31900)
 }
 
 // Lister version information
-var LISTER_VERSION = "2.05a";
-var LISTER_DATE = "2022-03-13";
+var LISTER_VERSION = "2.06";
+var LISTER_DATE = "2022-04-13";
 
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -2128,9 +2132,14 @@ function createFileListMenu(pQuitKeys)
 		return Object.keys(this.selectedItemIndexes).length;
 	};
 
-	// OnItemNav function for when the user navigates to a new item
-	fileListMenu.OnItemNav = function(pOldItemIdx, pNewItemIdx) {
-		displayFileExtDescOnMainScreen(pNewItemIdx);
+	// If extended file descriptions are enabled, set the OnItemNav function for
+	// when the user navigates to a new item, to display the file description
+	// next to the file menu.
+	if (extendedDescEnabled())
+	{
+		fileListMenu.OnItemNav = function(pOldItemIdx, pNewItemIdx) {
+			displayFileExtDescOnMainScreen(pNewItemIdx);
+		};
 	}
 
 	return fileListMenu;
@@ -3656,22 +3665,34 @@ function displayFileExtDescOnMainScreen(pFileIdx, pStartScreenRow, pEndScreenRow
 	{
 		if (screenRowForPrinting > screenRowNum++)
 			continue;
-		console.gotoxy(startX, screenRowForPrinting++);
 		// Note: substrWithAttrCodes() is defined in dd_lightbar_menu.js
 		// Normally it would be handy to use printf() to print the text line:
 		//printf(formatStr, substrWithAttrCodes(fileDescArray[i], 0, maxDescLen));
 		// However, printf() doesn't account for attribute codes and thus may not
 		// fill the rest of the width.  So, we do that manually.
 		var descLine = substrWithAttrCodes(fileDescArray[i], 0, maxDescLen);
-		console.print(descLine);
-		var remainingLen = maxDescLen - console.strlen(descLine);
-		if (remainingLen > 0)
-			printf("%" + remainingLen + "s", "");
+		var lineTextLength = console.strlen(descLine);
+		if (lineTextLength > 0)
+		{
+			console.gotoxy(startX, screenRowForPrinting++);
+			console.print(descLine);
+			var remainingLen = maxDescLen - lineTextLength;
+			if (remainingLen > 0)
+				printf("%" + remainingLen + "s", "");
+		}
 		// Stop printing the description lines when we reach the last line on
 		// the screen where we want to print.
 		if (screenRowForPrinting > lastScreenRow)
 			break;
 	}
+	// If there is room, shoe the file date on the next line
+	if (screenRowForPrinting <= lastScreenRow && fileMetadata.hasOwnProperty("time"))
+	{
+		console.print("\1n");
+		console.gotoxy(startX, screenRowForPrinting++);
+		var dateStr = "Date: " + strftime("%Y-%m-%d", fileMetadata.time);
+		printf("%-" + maxDescLen + "s", dateStr.substr(0, maxDescLen));
+	}
 	// Clear the rest of the lines to the bottom of the list area
 	console.print("\1n");
 	while (screenRowForPrinting <= lastScreenRow)
diff --git a/xtrn/ddfilelister/readme.txt b/xtrn/ddfilelister/readme.txt
index 1842252b21..94eebff6b4 100644
--- a/xtrn/ddfilelister/readme.txt
+++ b/xtrn/ddfilelister/readme.txt
@@ -1,6 +1,6 @@
                         Digital Distortion File Lister
-                                 Version 2.05a
-                           Release date: 2022-03-13
+                                 Version 2.06
+                           Release date: 2022-04-13
 
                                      by
 
diff --git a/xtrn/ddfilelister/revision_history.txt b/xtrn/ddfilelister/revision_history.txt
index 99fc0c0b7e..2625683679 100644
--- a/xtrn/ddfilelister/revision_history.txt
+++ b/xtrn/ddfilelister/revision_history.txt
@@ -5,6 +5,8 @@ Revision History (change log)
 =============================
 Version  Date         Description
 -------  ----         -----------
+2.06     2022-04-13   When extended file descriptions are enabled, the file date
+                      is now shown with the file description on the last line.
 2.05a    2022-03-13   Fix for "fileDesc is not defined" error when displaying
                       the file description on the main screen.
 2.05     2022-03-12   Now makes use of the user's extended file description
-- 
GitLab