MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / CLIWide

Class CLIWide

src/runner/cli_wide.hpp:18–99  ·  view source on GitHub ↗

\brief CLIWide class for interactive input handling

Source from the content-addressed store, hash-verified

16
17/// \brief CLIWide class for interactive input handling
18class CLIWide {
19 public:
20 CLIWide();
21 ~CLIWide();
22
23 /// \brief Get interactive input with arrow key support
24 std::string get_interactive_input();
25
26 /// \brief Add command to history
27 void add_to_history(const std::string& command);
28
29 private:
30 // Command history for arrow key navigation
31 std::deque<std::string> command_history;
32 int history_index = -1;
33 static constexpr size_t max_history_size = 100;
34
35#ifdef _WIN32
36 // Console handles
37 HANDLE hConsoleInput;
38 HANDLE hConsoleOutput;
39 DWORD originalInputMode;
40 DWORD originalOutputMode;
41
42 /// \brief Input state structure
43 struct InputState {
44 std::vector<std::string> lines;
45 std::vector<bool> is_wrapped_line; // Track which lines were created by wrapping
46 int current_line_index = 0;
47 size_t cursor_pos = 0;
48 int history_nav_index = -1;
49 bool paste_mode = false;
50 int prompt_len = 4;
51
52 // UTF-8 input accumulation
53 std::string utf8_buffer;
54 int expected_utf8_bytes = 0;
55 };
56
57 /// \brief Key handling methods
58 enum class KeyAction {
59 CONTINUE,
60 NEW_LINE,
61 BREAK_INNER_LOOP,
62 BREAK_OUTER_LOOP,
63 RETURN_INPUT
64 };
65
66 KeyAction handle_extended_key(const KEY_EVENT_RECORD& keyEvent, InputState& state);
67 KeyAction handle_regular_key(const KEY_EVENT_RECORD& keyEvent, InputState& state);
68 KeyAction handle_arrow_keys(const KEY_EVENT_RECORD& keyEvent, InputState& state);
69 KeyAction handle_navigation_keys(const KEY_EVENT_RECORD& keyEvent, InputState& state);
70 void handle_history_navigation(bool up, InputState& state);
71 void handle_multiline_navigation(bool up, InputState& state);
72 bool should_continue_input(const InputState& state);
73 void print_prompt_and_line(const InputState& state);
74 void redraw_line_from_cursor(const InputState& state);
75

Callers 1

cli_wide_posix.cppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected