yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::cli::agent::EnhancedTUI Class Reference

Enhanced Terminal User Interface for z3ed CLI. More...

#include <enhanced_tui.h>

Collaboration diagram for yaze::cli::agent::EnhancedTUI:

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 TUIConfigGetConfig () 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_
 
Romrom_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, TUIStylestyles_
 
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
 

Detailed Description

Enhanced Terminal User Interface for z3ed CLI.

Provides a modern, feature-rich TUI with:

  • Multi-panel layout with resizable components
  • Syntax highlighting for code and JSON
  • Fuzzy search and autocomplete
  • Command palette with shortcuts
  • Rich output formatting with colors and tables
  • Mouse support (optional)
  • Customizable themes
  • Real-time command suggestions
  • History navigation and search
  • Tool output integration
  • Context-sensitive help

Definition at line 99 of file enhanced_tui.h.

Constructor & Destructor Documentation

◆ EnhancedTUI()

yaze::cli::agent::EnhancedTUI::EnhancedTUI ( const TUIConfig & config = TUIConfig{})
explicit

Definition at line 144 of file enhanced_tui.cc.

References config_, LoadTheme(), and yaze::cli::agent::TUIConfig::theme.

Here is the call graph for this function:

◆ ~EnhancedTUI()

yaze::cli::agent::EnhancedTUI::~EnhancedTUI ( )

Definition at line 148 of file enhanced_tui.cc.

References Shutdown().

Here is the call graph for this function:

Member Function Documentation

◆ Initialize()

absl::Status yaze::cli::agent::EnhancedTUI::Initialize ( )

Definition at line 152 of file enhanced_tui.cc.

References CalculateLayout(), SetupTerminal(), terminal_height_, terminal_initialized_, and terminal_width_.

Referenced by Run().

Here is the call graph for this function:

◆ Shutdown()

void yaze::cli::agent::EnhancedTUI::Shutdown ( )

Definition at line 170 of file enhanced_tui.cc.

References RestoreTerminal(), and terminal_initialized_.

Referenced by ~EnhancedTUI().

Here is the call graph for this function:

◆ SetRomContext()

void yaze::cli::agent::EnhancedTUI::SetRomContext ( Rom * rom)

Definition at line 179 of file enhanced_tui.cc.

References rom_context_.

◆ Run()

absl::Status yaze::cli::agent::EnhancedTUI::Run ( )

Definition at line 183 of file enhanced_tui.cc.

References ClearScreen(), HandleInput(), Initialize(), RefreshDisplay(), and RETURN_IF_ERROR.

Here is the call graph for this function:

◆ DisplayMessage()

void yaze::cli::agent::EnhancedTUI::DisplayMessage ( const std::string & message,
const std::string & sender = "User",
bool is_error = false )

Definition at line 197 of file enhanced_tui.cc.

References config_, FormatTimestamp(), yaze::cli::agent::TUIConfig::max_output_lines, and output_history_.

Referenced by ProcessCommand().

Here is the call graph for this function:

◆ DisplayToolOutput()

void yaze::cli::agent::EnhancedTUI::DisplayToolOutput ( const std::string & output,
const std::string & tool_name )

Definition at line 219 of file enhanced_tui.cc.

References FormatTimestamp(), and output_history_.

Referenced by yaze::cli::agent::TUICommandHandler::DisplayRichOutput().

Here is the call graph for this function:

◆ DisplaySuggestions()

void yaze::cli::agent::EnhancedTUI::DisplaySuggestions ( const std::vector< std::string > & suggestions)

Definition at line 228 of file enhanced_tui.cc.

References output_history_.

◆ UpdateStatusBar()

void yaze::cli::agent::EnhancedTUI::UpdateStatusBar ( const std::string & status)

◆ ShowHelp()

void yaze::cli::agent::EnhancedTUI::ShowHelp ( const std::string & command)

Definition at line 250 of file enhanced_tui.cc.

References command_descriptions_, commands_, and output_history_.

◆ RegisterCommand()

void yaze::cli::agent::EnhancedTUI::RegisterCommand ( const std::string & name,
std::function< absl::Status(const std::vector< std::string > &)> handler,
const std::string & description = "" )

◆ GetConfig()

const TUIConfig & yaze::cli::agent::EnhancedTUI::GetConfig ( ) const
inline

Definition at line 141 of file enhanced_tui.h.

References config_.

◆ SetConfig()

void yaze::cli::agent::EnhancedTUI::SetConfig ( const TUIConfig & config)

Definition at line 272 of file enhanced_tui.cc.

References CalculateLayout(), config_, LoadTheme(), and yaze::cli::agent::TUIConfig::theme.

Here is the call graph for this function:

◆ SetupTerminal()

void yaze::cli::agent::EnhancedTUI::SetupTerminal ( )
private

Definition at line 278 of file enhanced_tui.cc.

Referenced by Initialize().

◆ RestoreTerminal()

void yaze::cli::agent::EnhancedTUI::RestoreTerminal ( )
private

Definition at line 283 of file enhanced_tui.cc.

Referenced by Shutdown().

◆ ClearScreen()

void yaze::cli::agent::EnhancedTUI::ClearScreen ( )
private

Definition at line 288 of file enhanced_tui.cc.

Referenced by Run().

◆ RefreshDisplay()

void yaze::cli::agent::EnhancedTUI::RefreshDisplay ( )
private

◆ CalculateLayout()

◆ DrawHeader()

void yaze::cli::agent::EnhancedTUI::DrawHeader ( )
private

◆ DrawCommandPalette()

void yaze::cli::agent::EnhancedTUI::DrawCommandPalette ( )
private

Definition at line 336 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().

Here is the call graph for this function:

◆ DrawChatArea()

◆ DrawToolOutput()

void yaze::cli::agent::EnhancedTUI::DrawToolOutput ( )
private

Definition at line 392 of file enhanced_tui.cc.

Referenced by RefreshDisplay().

◆ DrawStatusBar()

void yaze::cli::agent::EnhancedTUI::DrawStatusBar ( )
private

Definition at line 397 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().

Here is the call graph for this function:

◆ DrawSidebar()

void yaze::cli::agent::EnhancedTUI::DrawSidebar ( )
private

◆ DrawHelpPanel()

void yaze::cli::agent::EnhancedTUI::DrawHelpPanel ( )
private

◆ HandleInput()

absl::Status yaze::cli::agent::EnhancedTUI::HandleInput ( )
private

Definition at line 454 of file enhanced_tui.cc.

References HandleKeyPress().

Referenced by Run().

Here is the call graph for this function:

◆ HandleKeyPress()

void yaze::cli::agent::EnhancedTUI::HandleKeyPress ( int key)
private

Definition at line 462 of file enhanced_tui.cc.

References HandleCommandPaletteKey(), HandleNormalKey(), and in_command_palette_.

Referenced by HandleInput().

Here is the call graph for this function:

◆ HandleMouseEvent()

void yaze::cli::agent::EnhancedTUI::HandleMouseEvent ( int x,
int y,
int button )
private

◆ HandleNormalKey()

void yaze::cli::agent::EnhancedTUI::HandleNormalKey ( int key)
private

Definition at line 470 of file enhanced_tui.cc.

References command_history_, config_, current_input_, yaze::cli::agent::TUIConfig::enable_autocomplete, GetCommandSuggestions(), and ProcessCommand().

Referenced by HandleKeyPress().

Here is the call graph for this function:

◆ HandleCommandPaletteKey()

void yaze::cli::agent::EnhancedTUI::HandleCommandPaletteKey ( int key)
private

Definition at line 507 of file enhanced_tui.cc.

References current_input_, in_command_palette_, palette_filter_, palette_matches_, palette_selection_, and UpdatePaletteMatches().

Referenced by HandleKeyPress().

Here is the call graph for this function:

◆ UpdatePaletteMatches()

void yaze::cli::agent::EnhancedTUI::UpdatePaletteMatches ( )
private

Definition at line 549 of file enhanced_tui.cc.

References commands_, palette_filter_, palette_matches_, and palette_selection_.

Referenced by HandleCommandPaletteKey().

◆ ProcessCommand()

absl::Status yaze::cli::agent::EnhancedTUI::ProcessCommand ( const std::string & input)
private

Definition at line 563 of file enhanced_tui.cc.

References commands_, and DisplayMessage().

Referenced by HandleNormalKey().

Here is the call graph for this function:

◆ GetCommandSuggestions()

std::vector< std::string > yaze::cli::agent::EnhancedTUI::GetCommandSuggestions ( const std::string & partial)
private

Definition at line 581 of file enhanced_tui.cc.

References commands_.

Referenced by HandleNormalKey().

◆ ExecuteCommand()

void yaze::cli::agent::EnhancedTUI::ExecuteCommand ( const std::string & command,
const std::vector< std::string > & args )
private

◆ GetStyle()

TUIStyle yaze::cli::agent::EnhancedTUI::GetStyle ( TUIComponent component) const
private

Definition at line 596 of file enhanced_tui.cc.

References styles_.

Referenced by DrawChatArea(), DrawCommandPalette(), DrawHeader(), DrawSidebar(), and DrawStatusBar().

◆ ApplyStyle()

std::string yaze::cli::agent::EnhancedTUI::ApplyStyle ( const std::string & text,
const TUIStyle & style ) const
private

◆ LoadTheme()

void yaze::cli::agent::EnhancedTUI::LoadTheme ( TUITheme theme)
private

◆ FormatTimestamp()

std::string yaze::cli::agent::EnhancedTUI::FormatTimestamp ( ) const
private

Definition at line 677 of file enhanced_tui.cc.

References config_, and yaze::cli::agent::TUIConfig::show_timestamps.

Referenced by DisplayMessage(), and DisplayToolOutput().

◆ TruncateText()

std::string yaze::cli::agent::EnhancedTUI::TruncateText ( const std::string & text,
int max_width ) const
private

Definition at line 690 of file enhanced_tui.cc.

Referenced by DrawChatArea().

◆ WrapText()

std::vector< std::string > yaze::cli::agent::EnhancedTUI::WrapText ( const std::string & text,
int width ) const
private

Definition at line 699 of file enhanced_tui.cc.

Member Data Documentation

◆ config_

TUIConfig yaze::cli::agent::EnhancedTUI::config_
private

◆ rom_context_

Rom* yaze::cli::agent::EnhancedTUI::rom_context_ = nullptr
private

Definition at line 188 of file enhanced_tui.h.

Referenced by DrawHeader(), DrawSidebar(), and SetRomContext().

◆ terminal_width_

int yaze::cli::agent::EnhancedTUI::terminal_width_ = 80
private

◆ terminal_height_

int yaze::cli::agent::EnhancedTUI::terminal_height_ = 24
private

Definition at line 192 of file enhanced_tui.h.

Referenced by CalculateLayout(), DrawStatusBar(), and Initialize().

◆ terminal_initialized_

bool yaze::cli::agent::EnhancedTUI::terminal_initialized_ = false
private

Definition at line 193 of file enhanced_tui.h.

Referenced by Initialize(), and Shutdown().

◆ layout_

struct yaze::cli::agent::EnhancedTUI::Layout yaze::cli::agent::EnhancedTUI::layout_
private

◆ current_input_

std::string yaze::cli::agent::EnhancedTUI::current_input_
private

Definition at line 206 of file enhanced_tui.h.

Referenced by DrawChatArea(), HandleCommandPaletteKey(), and HandleNormalKey().

◆ command_history_

std::vector<std::string> yaze::cli::agent::EnhancedTUI::command_history_
private

Definition at line 207 of file enhanced_tui.h.

Referenced by DrawStatusBar(), and HandleNormalKey().

◆ output_history_

std::vector<std::string> yaze::cli::agent::EnhancedTUI::output_history_
private

◆ commands_

std::map<std::string, std::function<absl::Status(const std::vector<std::string>&)> yaze::cli::agent::EnhancedTUI::commands_)
private

◆ command_descriptions_

std::map<std::string, std::string> yaze::cli::agent::EnhancedTUI::command_descriptions_
private

Definition at line 212 of file enhanced_tui.h.

Referenced by RegisterCommand(), and ShowHelp().

◆ styles_

std::map<TUIComponent, TUIStyle> yaze::cli::agent::EnhancedTUI::styles_
private

Definition at line 215 of file enhanced_tui.h.

Referenced by GetStyle(), and LoadTheme().

◆ themes_

std::map<TUITheme, std::map<TUIComponent, TUIStyle> > yaze::cli::agent::EnhancedTUI::themes_
private

Definition at line 216 of file enhanced_tui.h.

◆ cursor_x_

int yaze::cli::agent::EnhancedTUI::cursor_x_ = 0
private

Definition at line 219 of file enhanced_tui.h.

◆ cursor_y_

int yaze::cli::agent::EnhancedTUI::cursor_y_ = 0
private

Definition at line 220 of file enhanced_tui.h.

◆ in_command_palette_

bool yaze::cli::agent::EnhancedTUI::in_command_palette_ = false
private

◆ palette_filter_

std::string yaze::cli::agent::EnhancedTUI::palette_filter_
private

◆ palette_matches_

std::vector<std::string> yaze::cli::agent::EnhancedTUI::palette_matches_
private

◆ palette_selection_

int yaze::cli::agent::EnhancedTUI::palette_selection_ = 0
private

The documentation for this class was generated from the following files: