TUI shell + ftxui via FetchContent.
- ftxui v6.1.9 fetched at configure time; vendored .a + headers dropped. - TUI: visualisation area on top, input prompt at the bottom; ↑/↓ history, Tab completion (commands + file paths), Esc cancels prompts. History is persisted (XDG on Linux, %LOCALAPPDATA% on Windows when ported). - Command registry: `new`, `load`, `search`, `clear`, `help`, `quit`/`exit`. Inline params or interactive prompts; either way the canonical inline form is what gets stored in history. - `search`: second full-screen mode with module + parts/signals menus and a live-filtered list; Tab cycles focus, Esc returns to the main shell. - Domain: `System::modules()` accessor + `SystemElementContainer::size()` to support load summary + search. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
75
src/tui/tui.hpp
Normal file
75
src/tui/tui.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef _TUI_HPP_
|
||||
#define _TUI_HPP_
|
||||
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class System;
|
||||
|
||||
class Tui {
|
||||
struct Prompt {
|
||||
std::string question;
|
||||
std::function<void(const std::string &)> on_answer;
|
||||
bool path_completion = false;
|
||||
};
|
||||
|
||||
struct CommandSpec {
|
||||
struct Param {
|
||||
std::string name;
|
||||
bool path_completion = false;
|
||||
};
|
||||
std::vector<Param> params;
|
||||
std::function<void(const std::vector<std::string> &)> action;
|
||||
};
|
||||
|
||||
std::vector<std::string> history;
|
||||
std::vector<std::string> output;
|
||||
std::string input;
|
||||
int cursor_pos;
|
||||
int history_idx;
|
||||
bool quit;
|
||||
|
||||
std::unique_ptr<System> sys;
|
||||
std::deque<Prompt> pending;
|
||||
std::map<std::string, CommandSpec> commands;
|
||||
|
||||
int screen_idx;
|
||||
std::vector<std::string> search_modules;
|
||||
std::vector<std::string> search_types;
|
||||
int search_module_idx;
|
||||
int search_type_idx;
|
||||
int search_focus_idx;
|
||||
std::string search_query;
|
||||
|
||||
public:
|
||||
Tui();
|
||||
~Tui();
|
||||
void Run();
|
||||
|
||||
private:
|
||||
void RegisterCommands();
|
||||
void Submit();
|
||||
void Dispatch(const std::string &raw);
|
||||
void Finalize(const std::string &name,
|
||||
const CommandSpec &spec,
|
||||
const std::vector<std::string> &args);
|
||||
|
||||
void HistoryUp();
|
||||
void HistoryDown();
|
||||
void CancelPending();
|
||||
void Print(const std::string &line);
|
||||
|
||||
void CompleteCommand();
|
||||
void CompletePath();
|
||||
|
||||
void LoadHistory();
|
||||
void AppendHistory(const std::string &cmd);
|
||||
|
||||
static std::vector<std::string> Tokenize(const std::string &s);
|
||||
};
|
||||
|
||||
#endif // _TUI_HPP_
|
||||
Reference in New Issue
Block a user