build: split core/ from frontends/; prepare for multiple GUI/TUI targets
Reorganise the tree into business vs frontend as separate directories:
src/core/{domain,imports,app} (was system/, imports/, app/)
src/frontends/tui/ (was tui/ + main.cpp)
tests/tui/ (the FTXUI-coupled helper test)
All cross-dir #include paths rewritten; same-dir includes untouched.
CMake: essim_core is the frontend-agnostic business library — links libzip,
pugixml and bsdl, NO GUI toolkit. Each frontend is a self-contained
src/frontends/<name>/ (own CMakeLists, toolkit, main.cpp) that links
essim_core, selected with -DESSIM_FRONTEND=<name> (default tui; 'none' = core +
tests only, no toolkit fetched). FTXUI moved into the tui frontend. Tests are
split: essim_tests links essim_core (no FTXUI), essim_tui_tests links essim_tui.
Verified: default tui build green (ctest 2/2); ESSIM_FRONTEND=none builds the
core + tests with FTXUI never fetched and no `essim` binary.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
39
src/frontends/tui/tui_helpers.hpp
Normal file
39
src/frontends/tui/tui_helpers.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef _TUI_HELPERS_HPP_
|
||||
#define _TUI_HELPERS_HPP_
|
||||
|
||||
#include <ftxui/dom/elements.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// 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<HelpEntry> &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<std::string> &v);
|
||||
|
||||
// Whitespace tokeniser with `"…"` quoting (preserved-as-content).
|
||||
std::vector<std::string> Tokenize(const std::string &s);
|
||||
|
||||
#endif // _TUI_HELPERS_HPP_
|
||||
Reference in New Issue
Block a user