[feat] add live FPS to CLI status bar

This commit is contained in:
dijunkun
2026-10-31 00:36:27 +08:00
parent d687c0e2ea
commit 915cfe3a04
4 changed files with 22 additions and 3 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ inline constexpr char kKittyDelete[] =
"\033_Ga=d,d=I,i=31,q=2\033\\\033_Ga=d,d=I,i=32,q=2\033\\";
bool KittyReply(const std::string &response);
struct StatusBar {
std::string progress, compact_progress, error, view, network;
std::string progress, compact_progress, error, view, network, fps;
bool control = false, command_mode = false;
};
// Three padded ASCII rows. Shortcuts are compacted as whole groups to fit.
+7 -2
View File
@@ -59,11 +59,16 @@ std::vector<std::string> StatusLines(const StatusBar &bar, int columns) {
const auto progress =
bar.error.empty() ? bar.progress : "Error: " + bar.error;
auto left = mode + " | " + progress;
auto right = bar.view + (bar.network.empty() ? "" : " | " + bar.network);
auto metrics = bar.fps;
if (!bar.network.empty())
metrics += (metrics.empty() ? "" : " | ") + bar.network;
auto right = bar.view + (metrics.empty() ? "" : " | " + metrics);
if (left.size() + right.size() + 2 > inner)
right = bar.network;
right = metrics;
if (left.size() + right.size() + 2 > inner && bar.error.empty())
left = mode + " | " + bar.compact_progress;
if (left.size() + right.size() + 2 > inner)
right = bar.fps;
if (left.size() + right.size() + 2 > inner)
right.clear();
std::string status = Clip(left, inner);