| 155 | } |
| 156 | |
| 157 | std::string CLIWide::get_interactive_input() { |
| 158 | #ifdef FASTFLOWLM_USE_READLINE |
| 159 | std::vector<std::string> lines; |
| 160 | bool paste_mode = false; |
| 161 | |
| 162 | while (true) { |
| 163 | const char* prompt = lines.empty() ? ">>> " : "... "; |
| 164 | char* line = readline(prompt); |
| 165 | if (!line) { |
| 166 | if (lines.empty()) { |
| 167 | return "/bye"; |
| 168 | } |
| 169 | std::cout << std::endl; |
| 170 | break; |
| 171 | } |
| 172 | |
| 173 | std::string input(line); |
| 174 | free(line); |
| 175 | |
| 176 | if (lines.empty() && !input.empty() && input[0] == '/') { |
| 177 | add_to_history(input); |
| 178 | return input; |
| 179 | } |
| 180 | |
| 181 | bool has_continuation = !input.empty() && input.back() == '\\'; |
| 182 | if (has_continuation) { |
| 183 | input.pop_back(); |
| 184 | } |
| 185 | |
| 186 | lines.push_back(input); |
| 187 | |
| 188 | if (has_continuation) { |
| 189 | continue; |
| 190 | } |
| 191 | |
| 192 | if (paste_mode) { |
| 193 | if (wait_for_pending_input(5, 15)) { |
| 194 | continue; |
| 195 | } |
| 196 | paste_mode = false; |
| 197 | trim_trailing_empty_lines(lines); |
| 198 | break; |
| 199 | } |
| 200 | |
| 201 | if (wait_for_pending_input(1, 30)) { |
| 202 | paste_mode = true; |
| 203 | continue; |
| 204 | } |
| 205 | |
| 206 | if (lines.size() == 1 && lines[0].empty()) { |
| 207 | return std::string(); |
| 208 | } |
| 209 | |
| 210 | trim_trailing_empty_lines(lines); |
| 211 | break; |
| 212 | } |
| 213 | |
| 214 | std::string merged = join_lines(lines); |
nothing calls this directly
no test coverage detected