hide cursor when printing

pull/14/head
chris west 4 years ago
parent 9a2eb4e4b6
commit b67815b45f

@ -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,
}
}
}

@ -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) {

@ -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<String> {
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,

Loading…
Cancel
Save