yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
enhanced_chat_component.h
Go to the documentation of this file.
1#ifndef YAZE_CLI_TUI_ENHANCED_CHAT_COMPONENT_H
2#define YAZE_CLI_TUI_ENHANCED_CHAT_COMPONENT_H
3
4#include <ftxui/component/component.hpp>
5#include <ftxui/dom/elements.hpp>
6#include <memory>
7#include <string>
8#include <vector>
9
10#include "app/rom.h"
13
14namespace yaze {
15namespace cli {
16
17// Enhanced chat component that integrates with the unified layout
19 public:
20 explicit EnhancedChatComponent(Rom* rom_context = nullptr);
21
22 // Component interface
23 ftxui::Component GetComponent();
24 void SetRomContext(Rom* rom_context);
25
26 // Chat functionality
27 void SendMessage(const std::string& message);
28 void ClearHistory();
29 void ResetConversation();
30
31 // State management
32 bool IsFocused() const { return focused_; }
33 void SetFocused(bool focused) { focused_ = focused; }
34
35 // Configuration
36 void SetMaxHistoryLines(int lines) { max_history_lines_ = lines; }
37 int GetMaxHistoryLines() const { return max_history_lines_; }
38
39 private:
40 // Component creation
41 ftxui::Component CreateInputComponent();
42 ftxui::Component CreateHistoryComponent();
43 ftxui::Component CreateChatContainer();
44
45 // Event handling
46 bool HandleInputEvents(const ftxui::Event& event);
47 bool HandleHistoryEvents(const ftxui::Event& event);
48
49 // Message processing
50 void ProcessMessage(const std::string& message);
51 void AddMessageToHistory(const std::string& sender, const std::string& message);
53
54 // Rendering
55 ftxui::Element RenderChatMessage(const std::string& sender, const std::string& message);
56 ftxui::Element RenderInputArea();
57 ftxui::Element RenderHistoryArea();
58
59 // State
63
64 // UI State
65 std::string input_message_;
66 std::vector<std::pair<std::string, std::string>> chat_history_;
68 bool focused_ = false;
70
71 // Components
72 ftxui::Component input_component_;
73 ftxui::Component history_component_;
74 ftxui::Component chat_container_;
75
76 // Event handlers
77 std::function<bool(const ftxui::Event&)> input_event_handler_;
78 std::function<bool(const ftxui::Event&)> history_event_handler_;
79};
80
81} // namespace cli
82} // namespace yaze
83
84#endif // YAZE_CLI_TUI_ENHANCED_CHAT_COMPONENT_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:71
void SendMessage(const std::string &message)
ftxui::Element RenderChatMessage(const std::string &sender, const std::string &message)
bool HandleHistoryEvents(const ftxui::Event &event)
void ProcessMessage(const std::string &message)
void AddMessageToHistory(const std::string &sender, const std::string &message)
agent::ConversationalAgentService agent_service_
bool HandleInputEvents(const ftxui::Event &event)
std::function< bool(const ftxui::Event &)> input_event_handler_
std::vector< std::pair< std::string, std::string > > chat_history_
std::function< bool(const ftxui::Event &)> history_event_handler_
Main namespace for the application.