aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrooks J Rady <b.j.rady@gmail.com>2021-01-12 04:53:39 +0000
committerBrooks J Rady <b.j.rady@gmail.com>2021-01-12 04:53:39 +0000
commitc80c0a1fa70625c74c11fc2be4e0bde2c08e8b21 (patch)
tree530b4e935b50cf8224fbcb12be9c1dd693c07746
parentMove to published version of library (diff)
downloadsl0ppij-c80c0a1fa70625c74c11fc2be4e0bde2c08e8b21.tar.gz
sl0ppij-c80c0a1fa70625c74c11fc2be4e0bde2c08e8b21.tar.xz
sl0ppij-c80c0a1fa70625c74c11fc2be4e0bde2c08e8b21.zip
Trim and polish things a little
-rw-r--r--src/main.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index 7557b066..3774de98 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,13 +15,12 @@ impl MosaicTile for State {
}
fn draw(&mut self, _rows: usize, cols: usize) {
- let mut width = 0;
let more_msg = ", <?> More";
self.lines = vec![String::new()];
for item in get_help() {
+ let width = self.lines.last().unwrap().len();
if width + item.len() > cols - more_msg.len() {
self.lines.last_mut().unwrap().push_str(more_msg);
- width = item.len();
self.lines.push(item);
} else {
let line = self.lines.last_mut().unwrap();
@@ -29,9 +28,9 @@ impl MosaicTile for State {
line.push_str(", ");
}
line.push_str(&item);
- width += item.len() + 2;
}
}
+ self.page %= self.lines.len();
let line = format!(
"{}{}",
self.lines[self.page],
@@ -45,11 +44,8 @@ impl MosaicTile for State {
}
fn handle_global_key(&mut self, key: Key) {
- if self.lines.len() > 1 {
- if let Key::Char('?') = key {
- self.page += 1;
- self.page %= self.lines.len();
- }
+ if let Key::Char('?') = key {
+ self.page += 1;
}
}
}