diff --git a/src/menu.rs b/src/menu.rs index 87ba77a..c2aac97 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -67,7 +67,6 @@ impl MenuView { }}; } - let mut links = 0; for (i, line) in self.lines().iter().enumerate() { if i as u16 >= rows - 2 { return out; @@ -78,18 +77,17 @@ impl MenuView { if line.typ == Type::Info { out.push_str(" "); } else { - if links == self.link { + if line.link - 1 == self.link { out.push('*'); } else { out.push(' '); } - links += 1; out.push(' '); out.push_str("\x1b[95m"); - if links < 10 { + if line.link - 1 < 10 { out.push(' '); } - out.push_str(&links.to_string()); + out.push_str(&line.link.to_string()); out.push_str(".\x1b[0m "); } match line.typ { @@ -307,8 +305,9 @@ impl Menu { url.push_str(parts[1]); // selector } let name = parts[0][1..].to_string(); - link += 1; - let link = if typ == Type::Info { 0 } else { link }; + if typ != Type::Info { + link += 1; + } lines.push(Line { name, diff --git a/src/ui.rs b/src/ui.rs index f9dda2a..de8123d 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -50,7 +50,7 @@ impl UI { pub fn draw(&mut self) { if self.dirty { let prefix = ""; // debug - let prefix = "\x1b[2J\x1b[H"; // clear the screen + // let prefix = "\x1b[2J\x1b[H"; // clear the screen print!("{}{}", prefix, self.render()); self.dirty = false; }