Skip to content
Snippets Groups Projects
Commit ff1481e6 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'ddfilelister_traditional_ui_implementation' into 'master'

ddfilelister now has its own implementation of a traditional (non-lightbar) UI. Its version is now 2.12

See merge request !309
parents 64d5e8d6 9ab8ea05
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!309ddfilelister now has its own implementation of a traditional (non-lightbar) UI. Its version is now 2.12
......@@ -1007,7 +1007,7 @@ function DDLightbarMenu_Draw(pSelectedItemIndexes, pDrawBorders, pDrawScrollbar,
if (writeTheItem)
{
console.gotoxy(curPos.x, curPos.y++);
console.print("\x01n");
console.attributes = "N";
if (this.numberedMode)
printf(numberFormatStr, "");
var itemText = addAttrsToString(format(itemFormatStr, ""), this.colors.itemColor);
......@@ -1018,7 +1018,7 @@ function DDLightbarMenu_Draw(pSelectedItemIndexes, pDrawBorders, pDrawScrollbar,
}
else
{
// The user's terminal doesn't support ANSI
// ANSI mode disabled, or the user's terminal doesn't support ANSI
var numberedModeBackup = this.numberedMode;
this.numberedMode = true;
var itemLen = this.size.width;
......@@ -1027,7 +1027,7 @@ function DDLightbarMenu_Draw(pSelectedItemIndexes, pDrawBorders, pDrawScrollbar,
this.itemNumLen = numMenuItems.toString().length;
itemLen -= this.itemNumLen;
--itemLen; // Have a space for separation between the numbers and items
console.print("\x01n");
console.attributes = "N";
for (var i = 0; i < numMenuItems; ++i)
{
var showMultiSelectMark = (this.multiSelect && (typeof(pSelectedItemIndexes) == "object") && pSelectedItemIndexes.hasOwnProperty(idx));
......@@ -1513,6 +1513,8 @@ function DDLightbarMenu_GetItemText(pIdx, pItemLen, pHighlight, pSelected)
// If in numbered mode, prepend the item number to the front of the item text.
if (this.numberedMode)
{
if (this.itemNumLen == 0)
this.itemNumLen = numItems.toString().length;
var numColor = "\x01n" + this.colors.itemNumColor;
if (typeof(pHighlight) === "boolean")
numColor = (pHighlight ? this.colors.highlightedItemNumColor : this.colors.itemNumColor);
......@@ -1528,7 +1530,7 @@ function DDLightbarMenu_GetItemText(pIdx, pItemLen, pHighlight, pSelected)
function DDLightbarMenu_Erase()
{
var formatStr = "%" + this.size.width + "s"; // For use with printf()
console.print("\x01n");
console.attributes = "N";
var curPos = { x: this.pos.x, y: this.pos.y };
for (var i = 0; i < this.size.height; ++i)
{
......@@ -1665,13 +1667,13 @@ function DDLightbarMenu_GetVal(pDraw, pSelectedItemIndexes)
if (this.callOnItemNavOnStartup && typeof(this.OnItemNav) === "function")
this.OnItemNav(0, this.selectedItemIdx);
var selectedItemIndexes = { }; // For multi-select mode
if (typeof(pSelectedItemIndexes) == "object")
selectedItemIndexes = pSelectedItemIndexes;
if (this.ANSISupported())
{
// User input loop
var userChoices = null; // For multi-select mode
var selectedItemIndexes = { }; // For multi-select mode
if (typeof(pSelectedItemIndexes) == "object")
selectedItemIndexes = pSelectedItemIndexes;
var retVal = null; // For single-choice mode
// mouseInputOnly_continue specifies whether to continue to the
// next iteration if the mouse was clicked & there's no need to
......@@ -3416,26 +3418,31 @@ function getDefaultMenuItem() {
//
// Parameters:
// pStr: The string to perform the substring on
// pLen: The length of the substring
// pLen: Optional: The length of the substring. If not specified, the rest of the string will be used.
//
// Return value: A substring of the string according to the parameters
function substrWithAttrCodes(pStr, pStartIdx, pLen)
{
if (typeof(pStr) != "string")
return "";
if (typeof(pStartIdx) != "number")
if (typeof(pStr) !== "string")
return "";
if (typeof(pLen) != "number")
if (typeof(pStartIdx) !== "number")
return "";
var len = typeof(pLen) === "number" ? pLen : console.strlen(pStr)-pStartIdx;
if ((pStartIdx <= 0) && (pLen >= console.strlen(pStr)))
return pStr;
var startIdx = 0;
var screenLen = console.strlen(pStr);
if (typeof(pStartIdx) === "number" && pStartIdx >= 0 && pStartIdx < screenLen)
startIdx = pStartIdx;
var len = 0;
if (typeof(pLen) === "number" && pLen <= screenLen - startIdx)
len = pLen;
// Find the real start index. If there are Synchronet attribute
var startIdx = printedToRealIdxInStr(pStr, pStartIdx);
startIdx = printedToRealIdxInStr(pStr, startIdx);
if (startIdx < 0)
return "";
// Find the actual length of the string to get
var len = pLen;
var printableCharCount = 0;
var syncAttrCount = 0;
var syncAttrRegexWholeWord = /^\x01[krgybmcw01234567hinpq,;\.dtl<>\[\]asz]$/i;
......
; User interface style (lightbar or traditional)
interfaceStyle=lightbar
; When using the traditional interface, use the Synchronet
; stock (don't use ddfilelister at all). Valid values are
; true or false. If this is false, ddfilelister's traditional
; interface will be used if interfaceStyle is traditional.
traditionalUseSyncStock=false
; The sort order for the file list
; NATURAL: Natural sort order (same as DATE_A)
; NAME_AI: Filename ascending, case insensitive sort order
......
This diff is collapsed.
......@@ -54,4 +54,17 @@ fileAreaNumHighlight=b
; The file library/directory description for 'highlight' colors (for moving a file)
fileAreaDescHighlight=b
; The number of directories/files for 'highlight' colors (for moving a file)
fileAreaNumItemsHighlight=b
\ No newline at end of file
fileAreaNumItemsHighlight=b
; Traditional user interface for moving a file
; The color of the file area menu border (for moving a file)
fileAreaMenuBorderTrad=b
; The file area entry background color for 'normal' colors (for moving a file)
fileNormalBkgTrad=n
; The color for file lists in the traditional interface
listNumTrad=gh
; The file library/directory description for 'normal' colors (for moving a file)
fileAreaDescTrad=c
; The number of directories/files for 'normal' colors (for moving a file)
fileAreaNumItemsTrad=bh
Digital Distortion File Lister
Version 2.11
Release date: 2023-05-14
Version 2.12
Release date: 2023-08-12
by
......@@ -209,6 +209,23 @@ Main configuration file (DDMsgReader.cfg)
-----------------------------------------
Setting Description
------- -----------
interfaceStyle The user interface style to use: lightbar
or traditional. Lightbar requires ANSI
support in the user's terminal; if the
user's terminal doesn't support ANSI,
ddfilelister will fall back to a
traditional user interface.
traditionalUseSyncStock If using the traditional user interface,
whether or not to use Synchronet's stock
file lister instead of ddfilelister. Valid
values are true and false. If true,
ddfilelister won't be used at all, and
instead, Synchronet's stock file lister
will be used. If false and interfaceStyle
is traditional, ddfilelister's traditional
user interface will be used.
sortOrder String: The file sort order to use.
Valid values are:
NATURAL: Natural sort order (same as DATE_A)
......@@ -292,18 +309,35 @@ fileAreaDesc The file library/directory description for
fileAreaNumItems The number of directories/files for
'normal' colors (for moving a file)
fileAreaMenuHighlightBkg The file area entry background color for
'highlight' colors (for moving a file)
fileAreaMenuHighlightBkg The file area entry background color for
'highlight' colors (for moving a file)
fileAreaNumHighlight The file library/directory number for
'highlight' colors (for moving a file)
fileAreaNumHighlight The file library/directory number for
'highlight' colors (for moving a file)
fileAreaDescHighlight The file library/directory description for
'highlight' colors (for moving a file)
fileAreaDescHighlight The file library/directory description for
'highlight' colors (for moving a file)
fileAreaNumItemsHighlight The number of directories/files for
'highlight' colors (for moving a file)
Color settings for the traditional (non-lightbar) user interface:
fileAreaMenuBorderTrad The color of the file area menu border (for
moving a file)
fileNormalBkgTrad The file area entry background color for
'normal' colors (for moving a file)
listNumTrad The color for file lists in the traditional
interface
fileAreaDescTrad The file library/directory description for
'normal' colors (for moving a file)
fileAreaNumItemsTrad The number of directories/files for
'normal' colors (for moving a file)
5. Strings used from text.dat
=============================
......
......@@ -5,6 +5,10 @@ Revision History (change log)
=============================
Version Date Description
------- ---- -----------
2.12 2023-08-12 ddfilelister now has its own implementation of a
traditional (non-lightbar) user interface. It can still
optionally fall back on Synchronet's stock file lister
if the user's terminal doesn't support ANSI, if desired.
2.11 2023-05-14 The theme configuration file can now just contain the
attribute characters, without the control character.
Code: Refactored the function that reads the configuration
......
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