\brief Create a new line and move cursor to it
| 1168 | |
| 1169 | /// \brief Create a new line and move cursor to it |
| 1170 | void CLIWide::create_new_line_and_jump(InputState& state) { |
| 1171 | // Create a new empty line after the current line |
| 1172 | state.lines.insert(state.lines.begin() + state.current_line_index + 1, ""); |
| 1173 | state.is_wrapped_line.insert(state.is_wrapped_line.begin() + state.current_line_index + 1, true); // Mark as wrapped |
| 1174 | state.current_line_index++; |
| 1175 | state.cursor_pos = 0; |
| 1176 | state.prompt_len = 4; // "... " for continuation lines |
| 1177 | |
| 1178 | // Safety check: ensure vectors stay in sync |
| 1179 | if (state.lines.size() != state.is_wrapped_line.size()) { |
| 1180 | size_t min_size = (state.lines.size() < state.is_wrapped_line.size()) ? state.lines.size() : state.is_wrapped_line.size(); |
| 1181 | state.lines.resize(min_size); |
| 1182 | state.is_wrapped_line.resize(min_size); |
| 1183 | } |
| 1184 | |
| 1185 | // Print the new line |
| 1186 | std::cout << std::endl << "... "; |
| 1187 | std::cout.flush(); |
| 1188 | |
| 1189 | // Position cursor at the beginning of the new line |
| 1190 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 1191 | if (GetConsoleScreenBufferInfo(hConsoleOutput, &csbi)) { |
| 1192 | COORD pos = {static_cast<SHORT>(state.prompt_len), csbi.dwCursorPosition.Y}; |
| 1193 | SetConsoleCursorPosition(hConsoleOutput, pos); |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | /// \brief Handle backspace with line wrapping support |
| 1198 | void CLIWide::handle_backspace_with_wrapping(InputState& state) { |