Skip to content
Snippets Groups Projects
Commit 3c1c6556 authored by Eric Oulashin's avatar Eric Oulashin
Browse files

Bug fix: Now successfully formats filenames without extensions when listing files.

Version 2.04 - Bug fix: Now successfully formats filenames without extensions when listing files.
This addresses issue #369.
parent 6ddae40a
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!155DD File Lister bug fix: Now successfully formats filenames without extensions when listing files.
Pipeline #2857 passed
......@@ -22,11 +22,14 @@
* Things overall look good. Releasing this version. Added
* the ability to do searching via filespec, description, and
* new file search (started working on this 2022-02-08).
* 2022-02027 Eric Oulashin Version 2.03
* 2022-02-27 Eric Oulashin Version 2.03
* For terminals over 25 rows tall, the file info window will
* now be up to 45 rows tall. Also, fixed the display of the
* trailing blocks for the list header for wide terminals (over
* 80 columns).
* 2022-03-09 Eric Oulashin Version 2.04
* Bug fix: Now successfully formats filenames without extensions
* when listing files.
*/
if (typeof(require) === "function")
......@@ -80,8 +83,8 @@ if (system.version_num < 31900)
}
// Lister version information
var LISTER_VERSION = "2.03";
var LISTER_DATE = "2022-02-27";
var LISTER_VERSION = "2.04";
var LISTER_DATE = "2022-03-09";
///////////////////////////////////////////////////////////////////////////////
......@@ -2932,24 +2935,30 @@ function shortenFilename(pFilename, pMaxLen, pFillWidth)
if (typeof(pMaxLen) !== "number" || pMaxLen < 1)
return "";
var shortenedFilename = ""; // Will contain the shortened filename
// Get the filename extension. And the way we shorten the filename
// will depend on whether the filename actually has an extension or not.
var filenameExt = file_getext(pFilename);
var filenameWithoutExt = file_getname(pFilename);
var extIdx = filenameWithoutExt.indexOf(filenameExt);
if (extIdx >= 0)
filenameWithoutExt = filenameWithoutExt.substr(0, extIdx);
var maxWithoutExtLen = pMaxLen - filenameExt.length;
if (filenameWithoutExt.length > maxWithoutExtLen)
filenameWithoutExt = filenameWithoutExt.substr(0, maxWithoutExtLen);
var fillWidth = (typeof(pFillWidth) === "boolean" ? pFillWidth : false);
var adjustedFilename = "";
if (fillWidth)
adjustedFilename = format("%-" + maxWithoutExtLen + "s%s", filenameWithoutExt, filenameExt);
else
adjustedFilename = filenameWithoutExt + filenameExt;
if (typeof(filenameExt) === "string")
{
var filenameWithoutExt = file_getname(pFilename);
var extIdx = filenameWithoutExt.indexOf(filenameExt);
if (extIdx >= 0)
filenameWithoutExt = filenameWithoutExt.substr(0, extIdx);
var maxWithoutExtLen = pMaxLen - filenameExt.length;
if (filenameWithoutExt.length > maxWithoutExtLen)
filenameWithoutExt = filenameWithoutExt.substr(0, maxWithoutExtLen);
return adjustedFilename;
var fillWidth = (typeof(pFillWidth) === "boolean" ? pFillWidth : false);
if (fillWidth)
shortenedFilename = format("%-" + maxWithoutExtLen + "s%s", filenameWithoutExt, filenameExt);
else
shortenedFilename = filenameWithoutExt + filenameExt;
}
else
shortenedFilename = pFilename.substr(0, pMaxLen);
return shortenedFilename;
}
......
Digital Distortion File Lister
Version 2.03
Release date: 2022-02-27
Version 2.04
Release date: 2022-03-09
by
......
......@@ -5,6 +5,8 @@ Revision History (change log)
=============================
Version Date Description
------- ---- -----------
2.04 2022-03-09 Bug fix: Now successfully formats filenames without
extensions when listing files.
2.03 2022-02-27 For terminals over 80 rows tall, the file info window will
now be up to 45 rows tall. Also, fixed the display of the
trailing blocks for the list header for wide terminals
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment