/ game / src / io.rs
io.rs
 1  #[inline]
 2  pub(crate) fn display_text<S : AsRef<str>>(text: S) {
 3      let text = text.as_ref();
 4      let (columns, _) = crossterm::terminal::size().ok().unwrap_or((80, 25));
 5      let columns: usize = columns.into();
 6      let text = textwrap::wrap(text, columns);
 7  
 8      text.into_iter().for_each(|line| {
 9          println!("{}", line);
10      });
11  }
12  
13  macro_rules! display {
14      ($text:expr) => {
15          crate::io::display_text($text)
16      };
17  
18      ($fmt:expr, $text:expr) => {
19          crate::io::display_text(format!($fmt, $text))
20      };
21  }
22  
23  pub(crate) use display;