| 94 | } |
| 95 | |
| 96 | std::string read_escape_sequence() { |
| 97 | std::string seq; |
| 98 | seq.push_back('\x1b'); |
| 99 | |
| 100 | auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(40); |
| 101 | while (std::chrono::steady_clock::now() < deadline) { |
| 102 | if (!stdin_has_pending_input(0)) { |
| 103 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); |
| 104 | continue; |
| 105 | } |
| 106 | |
| 107 | unsigned char next = 0; |
| 108 | if (!read_single_byte(next)) { |
| 109 | break; |
| 110 | } |
| 111 | |
| 112 | seq.push_back(static_cast<char>(next)); |
| 113 | if ((next >= 'A' && next <= 'Z') || (next >= 'a' && next <= 'z') || next == '~') { |
| 114 | break; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | return seq; |
| 119 | } |
| 120 | |
| 121 | void redraw_input_line(const std::string& prompt, const std::string& line) { |
| 122 | std::cout << "\r" << prompt << line << "\x1b[K" << std::flush; |
no test coverage detected