Skip to content

Commit

Permalink
Merge pull request #2453 from akruphi/far_about
Browse files Browse the repository at this point in the history
far:about: hide/show empty items + fix incorrect inline in FARString.hpp
  • Loading branch information
elfmz authored Oct 20, 2024
2 parents df4feaf + 2d1f4e9 commit bd0d990
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
4 changes: 2 additions & 2 deletions far2l/src/base/FARString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ class FARString
inline bool Ends(wchar_t Ch) const
{ return m_pContent->GetLength() > 0 && m_pContent->GetData()[m_pContent->GetLength() - 1] == Ch; }

inline bool Ends(const FARString &strFind) const;
inline bool Ends(const wchar_t *lpwszFind) const;
bool Ends(const FARString &strFind) const;
bool Ends(const wchar_t *lpwszFind) const;

template <typename CharT>
bool ContainsAnyOf(const CharT *needles)
Expand Down
49 changes: 43 additions & 6 deletions far2l/src/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,17 +912,19 @@ void CommandLine::RedrawWithoutComboBoxMark()

void FarAbout(PluginManager &Plugins)
{
static bool b_hide_empty = true;
int npl;
FARString fs, fs2, fs2copy;
MenuItemEx mi, mis;
mi.Flags = b_hide_empty ? LIF_HIDDEN : 0;
mis.Flags = LIF_SEPARATOR;

VMenu ListAbout(L"far:about",nullptr,0,ScrY-4);
VMenu ListAbout(b_hide_empty ? L"far:about *" : L"far:about", nullptr, 0, ScrY-4);
ListAbout.SetFlags(VMENU_SHOWAMPERSAND | VMENU_IGNORE_SINGLECLICK);
ListAbout.ClearFlags(VMENU_MOUSEREACTION);
//ListAbout.SetFlags(VMENU_WRAPMODE);
ListAbout.SetHelp(L"SpecCmd");//L"FarAbout");
ListAbout.SetBottomTitle(L"ESC or F10 to close, Ctrl-C or Ctrl-Ins - copy all, Ctrl-Alt-F - filtering");
ListAbout.SetBottomTitle(L"ESC or F10 to close, Ctrl-C or Ctrl-Ins - copy all, Ctrl-H - (un)hide empty, Ctrl-Alt-F - filtering");

fs.Format(L" FAR2L Version: %s", FAR_BUILD);
ListAbout.AddItem(fs); fs2copy = fs;
Expand Down Expand Up @@ -979,10 +981,16 @@ void FarAbout(PluginManager &Plugins)

ListAbout.AddItem(L""); fs2copy += "\n";
struct utsname un;
fs = L" uname: ";
if (uname(&un)==0) {
fs.Format(L" uname: %s %s %s %s", un.sysname, un.release, un.version, un.machine);
ListAbout.AddItem(fs); fs2copy += "\n" + fs;
fs.AppendFormat(L"%s %s %s %s", un.sysname, un.release, un.version, un.machine);
ListAbout.AddItem(fs);
}
else {
mi.strName = fs;
ListAbout.AddItem(&mi);
}
fs2copy += "\n" + fs;

static const char * const env_vars[] = {
"HOSTNAME", "USER",
Expand All @@ -993,11 +1001,16 @@ void FarAbout(PluginManager &Plugins)
"WSL_DISTRO_NAME", "WSL2_GUI_APPS_ENABLED",
"DISPLAY", "WAYLAND_DISPLAY" };
for (unsigned int i = 0; i < ARRAYSIZE(env_vars); i++) {
fs.Format(L"%23s: ", env_vars[i]);
if (apiGetEnvironmentVariable(env_vars[i], fs2)) {
fs.Format(L"%23s: %ls", env_vars[i], fs2.CPtr());
fs += fs2.CPtr();
ListAbout.AddItem(fs);
fs2copy += "\n" + fs;
}
else {
mi.strName = fs;
ListAbout.AddItem(&mi);
}
fs2copy += "\n" + fs;
}

ListAbout.AddItem(L""); fs2copy += "\n";
Expand All @@ -1006,6 +1019,8 @@ void FarAbout(PluginManager &Plugins)
fs.Format(L" Number of plugins: %d", npl);
ListAbout.AddItem(fs); fs2copy += "\n" + fs;

mi.Flags = 0;

for(int i = 0; i < npl; i++)
{
fs.Format(L"Plugin#%02d ", i+1);
Expand Down Expand Up @@ -1138,6 +1153,28 @@ void FarAbout(PluginManager &Plugins)
case KEY_CTRLNUMPAD0:
CopyToClipboard(fs2copy.CPtr());
break;
case KEY_CTRLH: {
struct MenuItemEx *mip;
if (b_hide_empty) {
b_hide_empty = false;
for (int i = 0; i < ListAbout.GetItemCount(); i++) {
mip = ListAbout.GetItemPtr(i);
mip->Flags &= ~LIF_HIDDEN;
}
ListAbout.SetTitle(L"far:about");
}
else {
b_hide_empty = true;
for (int i = 0; i < ListAbout.GetItemCount(); i++) {
mip = ListAbout.GetItemPtr(i);
if (mip->strName.Ends(L": "))
mip->Flags |= LIF_HIDDEN;
}
ListAbout.SetTitle(L"far:about *");
}
}
ListAbout.Show();
break;
default:
ListAbout.ProcessInput();
continue;
Expand Down

0 comments on commit bd0d990

Please sign in to comment.