Same as `refill` but prints the lines of each paragraph to the console instead of returning them and prefixes them with an optional `indent`. The width is automatically determined from the console's size.
(
console: &mut dyn Console,
paragraphs: P,
indent: &str,
)
| 107 | /// |
| 108 | /// The width is automatically determined from the console's size. |
| 109 | pub fn refill_and_print<S: AsRef<str>, P: IntoIterator<Item = S>>( |
| 110 | console: &mut dyn Console, |
| 111 | paragraphs: P, |
| 112 | indent: &str, |
| 113 | ) -> io::Result<()> { |
| 114 | // TODO(jmmv): This queries the size on every print, which is not very efficient. Should |
| 115 | // reuse this across calls, maybe by having a wrapper over Console and using it throughout. |
| 116 | let size = console.size_chars()?; |
| 117 | for line in refill_many(paragraphs, indent, usize::from(size.x)) { |
| 118 | console.print(&line)?; |
| 119 | } |
| 120 | Ok(()) |
| 121 | } |
| 122 | |
| 123 | /// Same as `refill` but prints the lines of each paragraph to a pager instead of returning |
| 124 | /// them and prefixes them with an optional `indent`. |