Writes `text` to the console, followed by a newline or CRLF pair depending on the needs of the console to advance a line. The input `text` is not supposed to contain any control characters, such as CR or LF.
(&mut self, text: &str)
| 81 | /// |
| 82 | /// The input `text` is not supposed to contain any control characters, such as CR or LF. |
| 83 | pub(crate) async fn print(&mut self, text: &str) -> io::Result<()> { |
| 84 | self.console.print(text)?; |
| 85 | if self.console.is_interactive() { |
| 86 | if let Some(yielder) = self.yielder.as_ref() { |
| 87 | let mut yielder = yielder.borrow_mut(); |
| 88 | yielder.yield_now().await; |
| 89 | } |
| 90 | |
| 91 | self.cur_columns += text.len(); |
| 92 | self.cur_lines += (self.cur_columns / usize::from(self.size.x)) + 1; |
| 93 | |
| 94 | if self.cur_lines >= usize::from(self.size.y) - 1 { |
| 95 | self.console.print(self.more_message)?; |
| 96 | if matches!(self.console.read_key().await?, Key::Escape | Key::Interrupt) { |
| 97 | return Err(io::Error::new(io::ErrorKind::Interrupted, "Interrupted")); |
| 98 | } |
| 99 | |
| 100 | self.cur_lines = 0; |
| 101 | } |
| 102 | |
| 103 | self.cur_columns = 0; |
| 104 | } |
| 105 | Ok(()) |
| 106 | } |
| 107 | |
| 108 | /// Writes the text into the console at the position of the cursor. |
| 109 | /// |