Runs the interactive key-processing loop until the line is accepted.
(mut self)
| 403 | |
| 404 | /// Runs the interactive key-processing loop until the line is accepted. |
| 405 | async fn run(mut self) -> io::Result<String> { |
| 406 | loop { |
| 407 | let result = match self.console.read_key().await? { |
| 408 | Key::ArrowDown => self.do_up_down(1), |
| 409 | Key::ArrowLeft => self.do_move_to(self.pos.saturating_sub(1)), |
| 410 | Key::ArrowRight => self.do_move_to((self.pos + 1).min(self.line.len())), |
| 411 | Key::ArrowUp => self.do_up_down(-1), |
| 412 | Key::Backspace => self.do_backspace(), |
| 413 | Key::CarriageReturn => self.do_carriage_return(), |
| 414 | Key::Char(ch) => self.do_char(ch), |
| 415 | Key::Delete => self.do_delete(), |
| 416 | Key::End => self.do_end(), |
| 417 | Key::EofOrDelete => self.do_eof_or_delete(), |
| 418 | Key::Escape => self.do_ignore(), |
| 419 | Key::Home => self.do_home(), |
| 420 | Key::Interrupt => self.do_interrupt(), |
| 421 | Key::NewLine => self.do_newline(), |
| 422 | Key::PageDown | Key::PageUp | Key::Tab | Key::Unknown => self.do_ignore(), |
| 423 | }?; |
| 424 | |
| 425 | if let DispatchResult::Submit = result { |
| 426 | break; |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | Ok(self.finish()) |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | /// Reads a line of text interactively from the console, using the given `prompt` and pre-filling |
no test coverage detected