Repository: tarkah/tickrs (language: rust)

Issue:
Provide option to hide the toggle shortcuts
Hey hey :wave: At the moment we always show the "Toggle" shortcuts on the top right.

There is an option to not show the help, but there is no option to hide this toggle menu. For non-interactive use-cases like running on a raspberry pi with a small display attached, but no keyboard, it would be great if we could hide the toggle shortcuts.

Maybe `--hide-help` could just remove these, too?


Discussion / hints:
Great idea! I'll get this added.

Fix patch:
diff --git a/src/cli.rs b/src/cli.rs
index 5ef46f3..d796845 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -16,6 +16,9 @@ pub struct Opt {
     /// Hide help icon in top right
     pub hide_help: bool,
     #[structopt(long)]
+    /// Hide toggle block
+    pub hide_toggle: bool,
+    #[structopt(long)]
     /// Start in summary mode
     pub summary: bool,
     #[structopt(short = "i", long, default_value = "1")]
diff --git a/src/main.rs b/src/main.rs
index 94b7f3f..95fb238 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -34,6 +34,7 @@ lazy_static! {
     pub static ref OPTS: cli::Opt = cli::get_opts();
     pub static ref UPDATE_INTERVAL: u64 = OPTS.update_interval;
     pub static ref TIME_FRAME: TimeFrame = OPTS.time_frame;
+    pub static ref HIDE_TOGGLE: bool = OPTS.hide_toggle;
     pub static ref REDRAW_REQUEST: (Sender<()>, Receiver<()>) = unbounded();
     pub static ref SHOW_X_LABELS: RwLock<bool> = RwLock::new(OPTS.show_x_labels);
 }
diff --git a/src/widget/stock.rs b/src/widget/stock.rs
index a0a1602..c6a157a 100644
--- a/src/widget/stock.rs
+++ b/src/widget/stock.rs
@@ -2,7 +2,7 @@ use super::{block, OptionsState};
 use crate::common::*;
 use crate::draw::{add_padding, PaddingDirection};
 use crate::service::{self, Service};
-use crate::{SHOW_X_LABELS, TIME_FRAME};
+use crate::{HIDE_TOGGLE, SHOW_X_LABELS, TIME_FRAME};
 
 use api::model::CompanyData;
 
@@ -299,42 +299,44 @@ impl StatefulWidget for StockWidget {
                 Text::styled(format!("{:.2}", low), Style::default().fg(Color::LightCyan)),
             ];
 
-            let expand_info = [
-                Text::styled(
-                    "\n\nOptions  'o'\n",
-                    Style::default().bg(if state.show_options {
-                        Color::DarkGray
-                    } else {
-                        Color::Reset
-                    }),
-                ),
-                Text::styled("Summary  's'\n", Style::default()),
-                Text::styled(
-                    "X Labels 'x'",
-                    Style::default().bg(if show_x_labes {
-                        Color::DarkGray
-                    } else {
-                        Color::Reset
-                    }),
-                ),
-            ];
-
             Paragraph::new(company_info.iter())
                 .style(Style::default().fg(Color::White))
                 .alignment(Alignment::Left)
                 .wrap(true)
                 .render(info_chunks[0], buf);
 
-            let toggle_block = block::new(" Toggle ", None);
-            toggle_block.render(info_chunks[1], buf);
-            info_chunks[1].x += 2;
-            info_chunks[1].width -= 2;
-
-            Paragraph::new(expand_info.iter())
-                .style(Style::default().fg(Color::White))
-                .alignment(Alignment::Left)
-                .wrap(false)
-                .render(info_chunks[1], buf);
+            if !*HIDE_TOGGLE {
+                let toggle_block = block::new(" Toggle ", None);
+                toggle_block.render(info_chunks[1], buf);
+                info_chunks[1].x += 2;
+                info_chunks[1].width -= 2;
+
+                let toggle_info = [
+                    Text::styled(
+                        "\n\nOptions  'o'\n",
+                        Style::default().bg(if state.show_options {
+                            Color::DarkGray
+                        } else {
+                            Color::Reset
+                        }),
+                    ),
+                    Text::styled("Summary  's'\n", Style::default()),
+                    Text::styled(
+                        "X Labels 'x'",
+                        Style::default().bg(if show_x_labes {
+                            Color::DarkGray
+                        } else {
+                            Color::Reset
+                        }),
+                    ),
+                ];
+
+                Paragraph::new(toggle_info.iter())
+                    .style(Style::default().fg(Color::White))
+                    .alignment(Alignment::Left)
+                    .wrap(false)
+                    .render(info_chunks[1], buf);
+            }
         }
 
         // Draw graph


Test patch: