In order for custom window titles to also benefit from the usual dynamic changes (like current panel dir, filename in viewer/editor etc.), I've added (in my local repo) a case-insensitive "%Title" placeholder to the "-title:..." command-line option, to represent the native FAR title string.
Just ~10 lines in 1 file; the diff page from my fork (%GitHub%/lunakid/FarManager/commit/f259ebfe16d79db471b29a1d4733bb2d8335b475.patch):
Code: Select all
From f259ebfe16d79db471b29a1d4733bb2d8335b475 Mon Sep 17 00:00:00 2001
From: Sz
Date: Sun, 30 Jun 2019 23:06:43 +0200
Subject: [PATCH] Allow reusing the original title in customized ones as "-title:Example %Title"
---
far/constitle.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/far/constitle.cpp b/far/constitle.cpp
index 9ead50e60..96104d80f 100644
--- a/far/constitle.cpp
+++ b/far/constitle.cpp
@@ -104,6 +104,16 @@ static string& FarTitle()
return strFarTitle;
}
+string CookTitle(string_view NewTitle)
+{
+ if (UserTitle().empty())
+ return NewTitle + GetFarTitleAddons();
+
+ string CustomizedTitle = UserTitle();
+ replace_icase(CustomizedTitle, L"%Title"sv, NewTitle);
+ return CustomizedTitle;
+}
+
void ConsoleTitle::SetUserTitle(string_view const Title)
{
UserTitle() = Title;
@@ -116,7 +126,7 @@ void ConsoleTitle::SetFarTitle(string_view const Title, bool Flush)
SCOPED_ACTION(std::lock_guard)(TitleCS);
FarTitle() = Title;
- Global->ScrBuf->SetTitle(UserTitle().empty()? FarTitle() + GetFarTitleAddons() : UserTitle());
+ Global->ScrBuf->SetTitle(CookTitle(Title));
if (Flush)
{
Global->ScrBuf->Flush(flush_type::title);
If someone with the right "muscle memory" could copy-paste the change (and/or adjust as needed), that seems like the easiest way to me.
But any guidance is appreciated. Cheers!
Sz.