git: 459f1a3acfe0 - main - misc/far2l: try to further improve information panel display

From: Alexey Dokuchaev <danfe_at_FreeBSD.org>
Date: Fri, 28 Nov 2025 12:40:48 UTC
The branch main has been updated by danfe:

URL: https://cgit.FreeBSD.org/ports/commit/?id=459f1a3acfe03c50580a71757bd42fb3389d3182

commit 459f1a3acfe03c50580a71757bd42fb3389d3182
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2025-11-28 12:39:32 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2025-11-28 12:39:32 +0000

    misc/far2l: try to further improve information panel display
    
    - Follow existing logic for volume name and do not show empty
      disk serial number
    - Obtain volume name by invoking fstyp(8) utility as it seems
      we currently do not have a library function for that
    - In the InfoList::PrintInfo() method, call CellsCount()
      instead of GetLength() to handle strings with double-width,
      e.g. CJK characters correctly
---
 misc/far2l/files/patch-far2l_src_farwinapi.cpp     | 23 ++++++++++++++++++++--
 .../files/patch-far2l_src_panels_infolist.cpp      | 23 +++++++++++++++++++++-
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/misc/far2l/files/patch-far2l_src_farwinapi.cpp b/misc/far2l/files/patch-far2l_src_farwinapi.cpp
index c5bc3cafab73..760615a0c3b2 100644
--- a/misc/far2l/files/patch-far2l_src_farwinapi.cpp
+++ b/misc/far2l/files/patch-far2l_src_farwinapi.cpp
@@ -19,7 +19,7 @@
  {
  	struct statvfs svfs {};
  	const std::string &path = Wide2MB(lpwszRootPathName);
-@@ -483,8 +484,6 @@ BOOL apiGetVolumeInformation(const wchar_t *lpwszRootP
+@@ -483,13 +484,9 @@ BOOL apiGetVolumeInformation(const wchar_t *lpwszRootP
  
  	if (lpMaximumComponentLength)
  		*lpMaximumComponentLength = svfs.f_namemax;
@@ -28,7 +28,17 @@
  	if (lpFileSystemFlags)
  		*lpFileSystemFlags = (DWORD)svfs.f_flag;
  
-@@ -507,8 +506,22 @@ BOOL apiGetVolumeInformation(const wchar_t *lpwszRootP
+-	if (pVolumeName) {
+-		pVolumeName->Clear();
+ #if 0
+ #if defined(FS_IOC_GETFSLABEL) && defined(FSLABEL_MAX)
+ 		int fd = open(path.c_str(), O_RDONLY);
+@@ -502,13 +499,35 @@ BOOL apiGetVolumeInformation(const wchar_t *lpwszRootP
+ 		}
+ #endif
+ #endif
+-	}
+ 
  	if (pFileSystemName) {
  		*pFileSystemName = MountInfo().GetFileSystem(path);
  	}
@@ -49,6 +59,15 @@
 +				*pDiskIdent = ident;
 +			close(fd);
 +		}
++	}
++	if (pVolumeName) {
++		std::string reply{}, cmd{"fstyp -l " + devname};
++		if (POpen(reply, cmd.c_str())) {
++			const auto pos = reply.find(' ') + 1;
++			if (pos > 0) {
++				*pVolumeName = reply.substr(pos, reply.size() - pos - 1);
++			} //else pVolumeName->Clear();
++		} //else pVolumeName->Clear();
  	}
  
  	return TRUE;
diff --git a/misc/far2l/files/patch-far2l_src_panels_infolist.cpp b/misc/far2l/files/patch-far2l_src_panels_infolist.cpp
index f3b70d2fc3bc..43e0f9ea1f52 100644
--- a/misc/far2l/files/patch-far2l_src_panels_infolist.cpp
+++ b/misc/far2l/files/patch-far2l_src_panels_infolist.cpp
@@ -36,7 +36,19 @@
  		} else						// Error!
  			strTitle = strCurDir;	// strDriveRoot;
  
-@@ -444,7 +441,7 @@ void InfoList::DisplayObject()
+@@ -259,9 +256,11 @@ void InfoList::DisplayObject()
+ 				PrintInfo(strVolumeName);
+ 			}
+ 
++		if (!strDiskNumber.IsEmpty()) {
+ 			GotoXY(X1 + 2, CurY++);
+ 			PrintText(Msg::InfoDiskNumber);
+ 			PrintInfo(strDiskNumber);
++		}
+ 
+ 			// new fields
+ 			GotoXY(X1 + 2, CurY++);
+@@ -444,7 +443,7 @@ void InfoList::DisplayObject()
  			PrintInfo(strOutStr);
  		}
  
@@ -45,3 +57,12 @@
  		struct sysinfo si = {};
  		if (sysinfo(&si) == 0) {
  			DWORD dwMemoryLoad = 100 - ToPercent64(si.freeram + si.freeswap, si.totalram + si.totalswap);
+@@ -683,7 +682,7 @@ void InfoList::PrintInfo(const wchar_t *str)
+ 
+ 	FARString strStr = str;
+ 	TruncStr(strStr, MaxLength);
+-	int Length = (int)strStr.GetLength();
++	int Length = (int)strStr.CellsCount();
+ 	int NewX = X2 - Length - 1;
+ 
+ 	if (NewX > X1 && NewX > WhereX()) {