From 1dc7ca9489c548e0dc8f0969aec38b2c5a5b5ed7 Mon Sep 17 00:00:00 2001 From: Lakshay Gupta <183514000+Lakshayg136@users.noreply.github.com> Date: Mon, 13 Jul 2026 10:15:14 +0530 Subject: [PATCH] Resolve issues #33, #42, #43 and fix macOS compilation --- src/file_manager.h | 49 +++++++++++++++++++++++++++++++++++++++++++--- src/main.cpp | 4 ++++ src/utils.cpp | 2 +- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/file_manager.h b/src/file_manager.h index 3c94415..62f137e 100644 --- a/src/file_manager.h +++ b/src/file_manager.h @@ -37,7 +37,9 @@ #include #include #include +#ifndef __APPLE__ #include +#endif #include #include @@ -1586,6 +1588,7 @@ class FileManager { // --- Auto-Update (Inotify) Functions --- void initInotify() { +#ifndef __APPLE__ inotifyFd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC); if (inotifyFd < 0) { inotifyFd = inotify_init(); @@ -1594,9 +1597,11 @@ class FileManager { stopInotify = false; inotifyThread = std::thread(&FileManager::inotifyWorker, this); } +#endif } void inotifyWorker() { +#ifndef __APPLE__ struct pollfd pfd; pfd.fd = inotifyFd; pfd.events = POLLIN; @@ -1650,9 +1655,11 @@ class FileManager { } } } +#endif } void updateInotifyWatches() { +#ifndef __APPLE__ if (inotifyFd < 0) return; std::lock_guard lock(inotifyMutex); @@ -1709,6 +1716,7 @@ class FileManager { } } catch (...) {} } +#endif } // --- Async Size Worker Function --- @@ -4294,6 +4302,15 @@ class FileManager { int maxLines = getmaxy(win) - 2; if (paneFiles.empty()) { + if (!paneIsSearching) { + int my = getmaxy(win); + int mx = getmaxx(win); + std::string emptyMsg = "󰉖 This directory is empty"; + size_t len = utf8_length(emptyMsg); + wattron(win, COLOR_PAIR(7) | A_BOLD); + mvwprintw(win, my / 2, (mx - (int)len) / 2, "%s", emptyMsg.c_str()); + wattroff(win, COLOR_PAIR(7) | A_BOLD); + } wnoutrefresh(win); return; } @@ -5777,11 +5794,13 @@ class FileManager { wattron(winPreview, COLOR_PAIR(1) | A_BOLD); mvwprintw(winPreview, contentStart, 2, "󰉖 Content:"); wattroff(winPreview, COLOR_PAIR(1) | A_BOLD); + int line = contentStart + 1; try { - int line = contentStart + 1; + bool hasVisibleContent = false; for (const auto& entry : fs::directory_iterator(file.path)) { if (!showHidden && entry.path().filename().string().front() == '.') continue; + hasVisibleContent = true; if (line >= height - 3) break; std::string subName = entry.path().filename().string(); @@ -5825,7 +5844,15 @@ class FileManager { mvwprintw(winPreview, line++, 4, "%s %s", s.icon, subName.c_str()); wattroff(winPreview, COLOR_PAIR(s.pair)); } + if (!hasVisibleContent) { + wattron(winPreview, COLOR_PAIR(7) | A_BOLD); + mvwprintw(winPreview, line, 4, "󰉖 This directory is empty"); + wattroff(winPreview, COLOR_PAIR(7) | A_BOLD); + } } catch (...) { + wattron(winPreview, COLOR_PAIR(7) | A_BOLD); + mvwprintw(winPreview, line, 4, "󰉖 This directory is empty"); + wattroff(winPreview, COLOR_PAIR(7) | A_BOLD); } wnoutrefresh(winPreview); } else if (isPdf || isDoc || isXls || isPpt) { @@ -6193,16 +6220,32 @@ class FileManager { attroff(COLOR_PAIR(9) | A_BOLD); } + // Compute directory statistics + size_t numFolders = 0; + size_t numFiles = 0; + for (const auto& f : currentFiles) { + if (f.is_directory) { + numFolders++; + } else { + numFiles++; + } + } + std::string statsStr = " 📁 " + std::to_string(numFolders) + " folders | 📄 " + std::to_string(numFiles) + " files"; + attron(A_DIM); std::string pathStr = isTrashMode ? "trash://" : currentPath.string(); - int maxPathW = width - 35; - if (maxPathW < 10) maxPathW = 10; + int maxPathW = width - 35 - (int)utf8_length(statsStr); + if (maxPathW < 15) maxPathW = 15; if ((int)pathStr.length() > maxPathW) { pathStr = utf8_safe_truncate_left(pathStr, maxPathW - 3); } printw(" %s", pathStr.c_str()); attroff(A_DIM); + attron(COLOR_PAIR(6)); + printw("%s", statsStr.c_str()); + attroff(COLOR_PAIR(6)); + if (!isTrashMode) { try { fs::space_info si = fs::space(currentPath); diff --git a/src/main.cpp b/src/main.cpp index e6eca2f..267cfd0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,11 +10,15 @@ int main(int argc, char* argv[]) { if (arg == "-v" || arg == "--version") { std::cout << "Fyzenor version " << VERSION << std::endl; return 0; + } else if (arg == "-a" || arg == "--about") { + std::cout << "Fyzenor - The Blazing Fast, Modern C++ Terminal File Manager Version: " << VERSION << std::endl; + return 0; } else if (arg == "-h" || arg == "--help") { std::cout << "Fyzenor - The Blazing Fast, Modern C++ Terminal File Manager" << std::endl; std::cout << "Usage: fyzenor [options]" << std::endl; std::cout << "Options:" << std::endl; std::cout << " -v, --version Show version information" << std::endl; + std::cout << " -a, --about Show about information" << std::endl; std::cout << " -h, --help Show this help message" << std::endl; return 0; } diff --git a/src/utils.cpp b/src/utils.cpp index b6e2d77..c0e5043 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -91,7 +91,7 @@ std::string getCacheDir() { std::string getCachePath(const fs::path& p, int w, int h) { try { - auto mtime = fs::last_write_time(p).time_since_epoch().count(); + auto mtime = static_cast(fs::last_write_time(p).time_since_epoch().count()); std::string to_hash = p.string() + std::to_string(mtime) + std::to_string(w) + std::to_string(h);