Enhanced Terminal User Interface for z3ed CLI. More...
#include <enhanced_tui.h>
Classes | |
struct | Layout |
Public Member Functions | |
EnhancedTUI (const TUIConfig &config=TUIConfig{}) | |
~EnhancedTUI () | |
absl::Status | Initialize () |
void | Shutdown () |
void | SetRomContext (Rom *rom) |
absl::Status | Run () |
void | DisplayMessage (const std::string &message, const std::string &sender="User", bool is_error=false) |
void | DisplayToolOutput (const std::string &output, const std::string &tool_name) |
void | DisplaySuggestions (const std::vector< std::string > &suggestions) |
void | UpdateStatusBar (const std::string &status) |
void | ShowHelp (const std::string &command) |
void | RegisterCommand (const std::string &name, std::function< absl::Status(const std::vector< std::string > &)> handler, const std::string &description="") |
const TUIConfig & | GetConfig () const |
void | SetConfig (const TUIConfig &config) |
Private Member Functions | |
void | SetupTerminal () |
void | RestoreTerminal () |
void | ClearScreen () |
void | RefreshDisplay () |
void | CalculateLayout () |
void | DrawHeader () |
void | DrawCommandPalette () |
void | DrawChatArea () |
void | DrawToolOutput () |
void | DrawStatusBar () |
void | DrawSidebar () |
void | DrawHelpPanel () |
absl::Status | HandleInput () |
void | HandleKeyPress (int key) |
void | HandleMouseEvent (int x, int y, int button) |
void | HandleNormalKey (int key) |
void | HandleCommandPaletteKey (int key) |
void | UpdatePaletteMatches () |
absl::Status | ProcessCommand (const std::string &input) |
std::vector< std::string > | GetCommandSuggestions (const std::string &partial) |
void | ExecuteCommand (const std::string &command, const std::vector< std::string > &args) |
TUIStyle | GetStyle (TUIComponent component) const |
std::string | ApplyStyle (const std::string &text, const TUIStyle &style) const |
void | LoadTheme (TUITheme theme) |
std::string | FormatTimestamp () const |
std::string | TruncateText (const std::string &text, int max_width) const |
std::vector< std::string > | WrapText (const std::string &text, int width) const |
Private Attributes | |
TUIConfig | config_ |
Rom * | rom_context_ = nullptr |
int | terminal_width_ = 80 |
int | terminal_height_ = 24 |
bool | terminal_initialized_ = false |
struct yaze::cli::agent::EnhancedTUI::Layout | layout_ |
std::string | current_input_ |
std::vector< std::string > | command_history_ |
std::vector< std::string > | output_history_ |
std::map< std::string, std::function< absl::Status(const std::vector< std::string > &)> > | commands_ |
std::map< std::string, std::string > | command_descriptions_ |
std::map< TUIComponent, TUIStyle > | styles_ |
std::map< TUITheme, std::map< TUIComponent, TUIStyle > > | themes_ |
int | cursor_x_ = 0 |
int | cursor_y_ = 0 |
bool | in_command_palette_ = false |
std::string | palette_filter_ |
std::vector< std::string > | palette_matches_ |
int | palette_selection_ = 0 |
Enhanced Terminal User Interface for z3ed CLI.
Provides a modern, feature-rich TUI with:
Definition at line 99 of file enhanced_tui.h.
Definition at line 137 of file enhanced_tui.cc.
References config_, LoadTheme(), and yaze::cli::agent::TUIConfig::theme.
yaze::cli::agent::EnhancedTUI::~EnhancedTUI | ( | ) |
Definition at line 141 of file enhanced_tui.cc.
References Shutdown().
absl::Status yaze::cli::agent::EnhancedTUI::Initialize | ( | ) |
Definition at line 145 of file enhanced_tui.cc.
References CalculateLayout(), SetupTerminal(), terminal_height_, terminal_initialized_, and terminal_width_.
Referenced by Run().
void yaze::cli::agent::EnhancedTUI::Shutdown | ( | ) |
Definition at line 163 of file enhanced_tui.cc.
References RestoreTerminal(), and terminal_initialized_.
Referenced by ~EnhancedTUI().
void yaze::cli::agent::EnhancedTUI::SetRomContext | ( | Rom * | rom | ) |
Definition at line 172 of file enhanced_tui.cc.
References rom_context_.
absl::Status yaze::cli::agent::EnhancedTUI::Run | ( | ) |
Definition at line 176 of file enhanced_tui.cc.
References ClearScreen(), HandleInput(), Initialize(), RefreshDisplay(), and RETURN_IF_ERROR.
void yaze::cli::agent::EnhancedTUI::DisplayMessage | ( | const std::string & | message, |
const std::string & | sender = "User" , |
||
bool | is_error = false |
||
) |
Definition at line 190 of file enhanced_tui.cc.
References config_, FormatTimestamp(), yaze::cli::agent::TUIConfig::max_output_lines, and output_history_.
Referenced by ProcessCommand().
void yaze::cli::agent::EnhancedTUI::DisplayToolOutput | ( | const std::string & | output, |
const std::string & | tool_name | ||
) |
Definition at line 218 of file enhanced_tui.cc.
References FormatTimestamp(), and output_history_.
Referenced by yaze::cli::agent::TUICommandHandler::DisplayRichOutput().
void yaze::cli::agent::EnhancedTUI::DisplaySuggestions | ( | const std::vector< std::string > & | suggestions | ) |
Definition at line 231 of file enhanced_tui.cc.
References output_history_.
void yaze::cli::agent::EnhancedTUI::UpdateStatusBar | ( | const std::string & | status | ) |
Definition at line 249 of file enhanced_tui.cc.
Referenced by yaze::cli::agent::TUICommandHandler::DisplayProgress().
void yaze::cli::agent::EnhancedTUI::ShowHelp | ( | const std::string & | command | ) |
Definition at line 254 of file enhanced_tui.cc.
References command_descriptions_, commands_, and output_history_.
void yaze::cli::agent::EnhancedTUI::RegisterCommand | ( | const std::string & | name, |
std::function< absl::Status(const std::vector< std::string > &)> | handler, | ||
const std::string & | description = "" |
||
) |
Definition at line 271 of file enhanced_tui.cc.
References command_descriptions_, and commands_.
|
inline |
Definition at line 140 of file enhanced_tui.h.
References config_.
void yaze::cli::agent::EnhancedTUI::SetConfig | ( | const TUIConfig & | config | ) |
Definition at line 278 of file enhanced_tui.cc.
References CalculateLayout(), config_, LoadTheme(), and yaze::cli::agent::TUIConfig::theme.
|
private |
Definition at line 284 of file enhanced_tui.cc.
Referenced by Initialize().
|
private |
Definition at line 289 of file enhanced_tui.cc.
Referenced by Shutdown().
|
private |
Definition at line 294 of file enhanced_tui.cc.
Referenced by Run().
|
private |
Definition at line 299 of file enhanced_tui.cc.
References DrawChatArea(), DrawCommandPalette(), DrawHeader(), DrawSidebar(), DrawStatusBar(), and DrawToolOutput().
Referenced by Run().
|
private |
Definition at line 312 of file enhanced_tui.cc.
References yaze::cli::agent::EnhancedTUI::Layout::chat_height, yaze::cli::agent::EnhancedTUI::Layout::header_height, yaze::cli::agent::EnhancedTUI::Layout::help_width, layout_, yaze::cli::agent::EnhancedTUI::Layout::sidebar_width, yaze::cli::agent::EnhancedTUI::Layout::status_height, terminal_height_, terminal_width_, and yaze::cli::agent::EnhancedTUI::Layout::tool_height.
Referenced by Initialize(), and SetConfig().
|
private |
Definition at line 321 of file enhanced_tui.cc.
References ApplyStyle(), config_, GetStyle(), yaze::cli::agent::kHeader, rom_context_, terminal_width_, yaze::cli::agent::TUIConfig::theme, and yaze::cli::agent::TUIThemeToString().
Referenced by RefreshDisplay().
|
private |
Definition at line 343 of file enhanced_tui.cc.
References ApplyStyle(), GetStyle(), in_command_palette_, yaze::cli::agent::kCommandPalette, palette_filter_, palette_matches_, and palette_selection_.
Referenced by RefreshDisplay().
|
private |
Definition at line 365 of file enhanced_tui.cc.
References ApplyStyle(), yaze::cli::agent::EnhancedTUI::Layout::chat_height, config_, current_input_, GetStyle(), yaze::cli::agent::EnhancedTUI::Layout::header_height, yaze::cli::agent::kChatArea, layout_, output_history_, yaze::cli::agent::TUIConfig::prompt_style, yaze::cli::agent::EnhancedTUI::Layout::sidebar_width, terminal_width_, and TruncateText().
Referenced by RefreshDisplay().
|
private |
Definition at line 393 of file enhanced_tui.cc.
Referenced by RefreshDisplay().
|
private |
Definition at line 398 of file enhanced_tui.cc.
References ApplyStyle(), command_history_, commands_, GetStyle(), in_command_palette_, yaze::cli::agent::kStatusBar, terminal_height_, and terminal_width_.
Referenced by RefreshDisplay().
|
private |
Definition at line 418 of file enhanced_tui.cc.
References ApplyStyle(), GetStyle(), yaze::cli::agent::EnhancedTUI::Layout::header_height, yaze::cli::agent::kSidebar, layout_, rom_context_, yaze::cli::agent::EnhancedTUI::Layout::sidebar_width, yaze::Rom::size(), and terminal_width_.
Referenced by RefreshDisplay().
|
private |
|
private |
Definition at line 447 of file enhanced_tui.cc.
References HandleKeyPress().
Referenced by Run().
|
private |
Definition at line 455 of file enhanced_tui.cc.
References HandleCommandPaletteKey(), HandleNormalKey(), and in_command_palette_.
Referenced by HandleInput().
|
private |
|
private |
Definition at line 463 of file enhanced_tui.cc.
References command_history_, config_, current_input_, yaze::cli::agent::TUIConfig::enable_autocomplete, GetCommandSuggestions(), and ProcessCommand().
Referenced by HandleKeyPress().
|
private |
Definition at line 500 of file enhanced_tui.cc.
References current_input_, in_command_palette_, palette_filter_, palette_matches_, palette_selection_, and UpdatePaletteMatches().
Referenced by HandleKeyPress().
|
private |
Definition at line 541 of file enhanced_tui.cc.
References commands_, palette_filter_, palette_matches_, and palette_selection_.
Referenced by HandleCommandPaletteKey().
|
private |
Definition at line 554 of file enhanced_tui.cc.
References commands_, and DisplayMessage().
Referenced by HandleNormalKey().
|
private |
Definition at line 571 of file enhanced_tui.cc.
References commands_.
Referenced by HandleNormalKey().
|
private |
|
private |
Definition at line 584 of file enhanced_tui.cc.
References styles_.
Referenced by DrawChatArea(), DrawCommandPalette(), DrawHeader(), DrawSidebar(), DrawStatusBar(), and ExecuteCommand().
|
private |
Definition at line 594 of file enhanced_tui.cc.
References yaze::cli::agent::TUIStyle::background_color, yaze::cli::agent::TUIStyle::bold, yaze::cli::agent::TUIStyle::foreground_color, yaze::cli::agent::TUIStyle::italic, and yaze::cli::agent::TUIStyle::underline.
Referenced by DrawChatArea(), DrawCommandPalette(), DrawHeader(), DrawSidebar(), and DrawStatusBar().
|
private |
Definition at line 623 of file enhanced_tui.cc.
References yaze::cli::agent::kChatArea, yaze::cli::agent::kDark, yaze::cli::agent::kDefault, yaze::cli::agent::kHeader, yaze::cli::agent::kSidebar, yaze::cli::agent::kStatusBar, yaze::cli::agent::kZelda, LoadTheme(), and styles_.
Referenced by EnhancedTUI(), LoadTheme(), and SetConfig().
|
private |
Definition at line 652 of file enhanced_tui.cc.
References config_, and yaze::cli::agent::TUIConfig::show_timestamps.
Referenced by DisplayMessage(), and DisplayToolOutput().
|
private |
Definition at line 665 of file enhanced_tui.cc.
Referenced by DrawChatArea().
|
private |
Definition at line 673 of file enhanced_tui.cc.
|
private |
Definition at line 185 of file enhanced_tui.h.
Referenced by DisplayMessage(), DrawChatArea(), DrawHeader(), EnhancedTUI(), FormatTimestamp(), GetConfig(), HandleNormalKey(), and SetConfig().
|
private |
Definition at line 186 of file enhanced_tui.h.
Referenced by DrawHeader(), DrawSidebar(), and SetRomContext().
|
private |
Definition at line 189 of file enhanced_tui.h.
Referenced by CalculateLayout(), DrawChatArea(), DrawHeader(), DrawSidebar(), DrawStatusBar(), and Initialize().
|
private |
Definition at line 190 of file enhanced_tui.h.
Referenced by CalculateLayout(), DrawStatusBar(), and Initialize().
|
private |
Definition at line 191 of file enhanced_tui.h.
Referenced by Initialize(), and Shutdown().
|
private |
Referenced by CalculateLayout(), DrawChatArea(), and DrawSidebar().
|
private |
Definition at line 204 of file enhanced_tui.h.
Referenced by DrawChatArea(), HandleCommandPaletteKey(), and HandleNormalKey().
|
private |
Definition at line 205 of file enhanced_tui.h.
Referenced by DrawStatusBar(), and HandleNormalKey().
|
private |
Definition at line 206 of file enhanced_tui.h.
Referenced by DisplayMessage(), DisplaySuggestions(), DisplayToolOutput(), DrawChatArea(), and ShowHelp().
|
private |
Definition at line 207 of file enhanced_tui.h.
Referenced by DrawStatusBar(), GetCommandSuggestions(), ProcessCommand(), RegisterCommand(), ShowHelp(), and UpdatePaletteMatches().
|
private |
Definition at line 208 of file enhanced_tui.h.
Referenced by RegisterCommand(), and ShowHelp().
|
private |
Definition at line 211 of file enhanced_tui.h.
Referenced by GetStyle(), and LoadTheme().
|
private |
Definition at line 212 of file enhanced_tui.h.
|
private |
Definition at line 215 of file enhanced_tui.h.
|
private |
Definition at line 216 of file enhanced_tui.h.
|
private |
Definition at line 217 of file enhanced_tui.h.
Referenced by DrawCommandPalette(), DrawStatusBar(), HandleCommandPaletteKey(), and HandleKeyPress().
|
private |
Definition at line 218 of file enhanced_tui.h.
Referenced by DrawCommandPalette(), HandleCommandPaletteKey(), and UpdatePaletteMatches().
|
private |
Definition at line 219 of file enhanced_tui.h.
Referenced by DrawCommandPalette(), HandleCommandPaletteKey(), and UpdatePaletteMatches().
|
private |
Definition at line 220 of file enhanced_tui.h.
Referenced by DrawCommandPalette(), HandleCommandPaletteKey(), and UpdatePaletteMatches().