Input
(&mut self, prompt: &str)
| 460 | |
| 461 | // Input |
| 462 | pub fn input(&mut self, prompt: &str) -> Option<String> |
| 463 | { |
| 464 | print!("{}", prompt); |
| 465 | self.offset = offset_from_prompt(prompt); |
| 466 | self.cur = self.offset; |
| 467 | self.ln = Vec::with_capacity(80); |
| 468 | let mut parser = Parser::new(); |
| 469 | |
| 470 | while let Some(c) = crate::io::stdin().readchar() |
| 471 | { |
| 472 | match c |
| 473 | { |
| 474 | // End of text |
| 475 | '\x03' => |
| 476 | { |
| 477 | println!(); |
| 478 | return Some(String::new()); |
| 479 | } |
| 480 | |
| 481 | // End of transmission |
| 482 | '\x04' => |
| 483 | { |
| 484 | println!(); |
| 485 | return None; |
| 486 | }, |
| 487 | |
| 488 | // New line |
| 489 | '\n' => |
| 490 | { |
| 491 | self.compupdate(); |
| 492 | self.histupdate(); |
| 493 | println!(); |
| 494 | return Some(self.ln.iter().collect()); |
| 495 | }, |
| 496 | |
| 497 | c => |
| 498 | { |
| 499 | for b in c.to_string().as_bytes() |
| 500 | { |
| 501 | parser.advance(self, *b); |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | None |
| 508 | } |
| 509 | |
| 510 | |
| 511 | // New |
no test coverage detected