#ifndef _TUI_HELPERS_HPP_ #define _TUI_HELPERS_HPP_ #include #include #include // Free helpers shared across the TUI translation units. // Highlight the label of a focused field in interactive screens. Used so the // user can see at a glance which field will receive their next keystroke. inline ftxui::Element FocusLabel(ftxui::Element e, bool focused) { return focused ? (e | ftxui::inverted) : e; } std::string ToLower(std::string s); // ---- Context help panel (right-column on every screen) ---- struct HelpEntry { std::string key; ///< Key or chord label ("Tab", "Enter", "Ctrl-P", "s"). std::string desc; ///< Short description of what it does. }; // Renders a vertical help column: bold title, separator, then a two-column // list of (key, desc). Fixed width so the layout is consistent. ftxui::Element RenderHelpPanel(const std::string &title, const std::vector &entries); // Case-insensitive natural-order comparison: digit runs compared as integers, // letters compared after std::tolower. bool NaturalLess(const std::string &a, const std::string &b); std::string LongestCommonPrefix(const std::vector &v); // Whitespace tokeniser with `"…"` quoting (preserved-as-content). std::vector Tokenize(const std::string &s); #endif // _TUI_HELPERS_HPP_