From 1861707d2d7e4c31decb8ca3c8571f843ce6d8fc Mon Sep 17 00:00:00 2001 From: Ben Kirwin Date: Sun, 6 Nov 2022 18:06:41 -0500 Subject: [PATCH] Disable find by default --- src/config.rs | 2 ++ src/main.rs | 83 ++++++++++++++++++++++++++------------------------- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4a11c34..9f2d308 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize}; pub struct Config { pub cell_height: i32, pub extra_chars: Vec, + pub experimental: bool, } impl Config { @@ -32,6 +33,7 @@ impl Default for Config { Config { cell_height: 40, extra_chars: vec![], + experimental: false, } } } diff --git a/src/main.rs b/src/main.rs index 5f847e5..a14f0a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -387,49 +387,50 @@ impl Widget for Editor { Button::new(&text_tab.title, Msg::SwitchTab { tab: Tab::Meta }, true) .render_split(&mut header, Side::Left, 0.5); - Spaced( - 40, - &[ - Button::new( - "find", - Msg::SwitchTab { - tab: Tab::Search { - id, - contents: IndexedString::index( - text_tab.text.buffer.content_string(), - ), - results: vec![], - }, - }, - true, - ), - Button::new( - "undo", - Msg::Tab { + let mut buttons = vec![]; + if self.config.experimental { + buttons.push(Button::new( + "find", + Msg::SwitchTab { + tab: Tab::Search { id, - msg: TabMsg::Undo, + contents: IndexedString::index( + text_tab.text.buffer.content_string(), + ), + results: vec![], }, - !text_tab.text.undos.is_empty(), - ), - Button::new( - "redo", - Msg::Tab { - id, - msg: TabMsg::Redo, - }, - !text_tab.text.redos.is_empty(), - ), - Button::new( - "save", - Msg::Tab { - id, - msg: TabMsg::Save, - }, - text_tab.path.is_some() && text_tab.dirty, - ), - ], - ) - .render_placed(header, 1.0, 0.5); + }, + true, + )) + } + buttons.extend([ + Button::new( + "undo", + Msg::Tab { + id, + msg: TabMsg::Undo, + }, + !text_tab.text.undos.is_empty(), + ), + Button::new( + "redo", + Msg::Tab { + id, + msg: TabMsg::Redo, + }, + !text_tab.text.redos.is_empty(), + ), + Button::new( + "save", + Msg::Tab { + id, + msg: TabMsg::Save, + }, + text_tab.path.is_some() && text_tab.dirty, + ), + ]); + + Spaced(40, &buttons).render_placed(header, 1.0, 0.5); } TabType::Shell(s) => { Button::new(&s.title, Msg::SwitchTab { tab: Tab::Meta }, true)