diff --git a/src/config.rs b/src/config.rs index 6036c7e..879b475 100644 --- a/src/config.rs +++ b/src/config.rs @@ -39,6 +39,7 @@ pub struct Config { pub tor: bool, pub wide: bool, pub emoji: bool, + pub cursor: bool, } impl Default for Config { @@ -49,6 +50,7 @@ impl Default for Config { tor: false, wide: false, emoji: false, + cursor: true, } } } diff --git a/src/main.rs b/src/main.rs index 96aad1e..0bb8a79 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,6 +86,11 @@ fn run() -> i32 { return 0; } + if mode == Mode::Print { + cfg.cursor = false; + cfg.wide = true; + } + let start = cfg.start.clone(); let mut ui = UI::new(cfg); if let Err(e) = ui.open(&start, &start) { diff --git a/src/menu.rs b/src/menu.rs index 8071465..9ec4d80 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -13,6 +13,7 @@ pub struct Menu { pub longest: usize, // size of the longest line pub raw: String, // raw response pub input: String, // user's inputted value + pub cursor: bool, // show the cursor? usually true pub link: usize, // selected link pub scroll: usize, // scrolling offset pub searching: bool, // search mode? @@ -154,6 +155,7 @@ impl Menu { fn render_lines(&mut self, cfg: &Config) -> String { self.wide = cfg.wide; + self.cursor = cfg.cursor; let mut out = String::new(); let iter = self.lines.iter().skip(self.scroll).take(self.rows() - 1); let indent = self.indent(); @@ -165,7 +167,7 @@ impl Menu { if line.typ == Type::Info { out.push_str(" "); } else { - if line.link == self.link { + if line.link == self.link && self.cursor { out.push_str("\x1b[97;1m*\x1b[0m") } else { out.push(' '); @@ -238,7 +240,7 @@ impl Menu { /// Print this string to draw the cursor on screen. /// Returns None if no is link selected. fn draw_cursor(&self) -> Option { - if self.links.is_empty() { + if self.links.is_empty() || !self.cursor { return None; } let (x, y) = self.screen_coords(self.link)?; @@ -806,6 +808,7 @@ impl Menu { input: String::new(), link: 0, scroll: 0, + cursor: true, searching: false, size: (0, 0), tls: false,