From bf02f5e92a9793e2b9c153feeed50d26558a0b94 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 9 Jul 2020 20:54:11 -0700 Subject: reflow --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 9a4e720..bf8baf1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -538,8 +538,14 @@ impl Bk<'_> { match event::read()? { Event::Key(e) => view.run(self, e.code), Event::Resize(cols, rows) => { - self.cols = cols; self.rows = rows as usize; + if cols != self.cols { + self.cols = cols; + let width = min(cols, self.max_width) as usize; + for c in &mut self.chapters { + c.lines = wrap(&c.text, width); + } + } } // TODO Event::Mouse(_) => (), -- cgit v1.2.3