diff --git a/README.md b/README.md index 046e00e..15c8e81 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ font_size = 16.0 | Option | Default | Description | |--------|---------|-------------| | `auto_hide_toolbar` | `false` | If `true`, the menu bar at the top will be hidden. Move your mouse to the top of the window to reveal it. | +| `hide_tab_bar` | 'true' | If `false`, a separate tab bar will be drawn below the toolbar. | | `show_line_numbers` | `false` | If `true`, line numbers will be displayed on the side specified by `line_side`. | | `line_side` | `false` | If `false`, line numbers are on the left. If `true`, they are on the right. | | `word_wrap` | `false` | If `true`, lines will wrap when they reach the edge of the window. | diff --git a/src/app/config.rs b/src/app/config.rs index 8fa2eab..7f14af5 100644 --- a/src/app/config.rs +++ b/src/app/config.rs @@ -7,8 +7,8 @@ use super::theme::Theme; pub struct Config { #[serde(default = "default_auto_hide_toolbar")] pub auto_hide_toolbar: bool, - #[serde(default = "default_auto_hide_tab_bar")] - pub auto_hide_tab_bar: bool, + #[serde(default = "default_hide_tab_bar")] + pub hide_tab_bar: bool, #[serde(default = "default_show_line_numbers")] pub show_line_numbers: bool, #[serde(default = "default_word_wrap")] @@ -24,19 +24,33 @@ pub struct Config { // pub vim_mode: bool, } -fn default_auto_hide_toolbar() -> bool { false } -fn default_auto_hide_tab_bar() -> bool { true } -fn default_show_line_numbers() -> bool { false } -fn default_word_wrap() -> bool { true } -fn default_line_side() -> bool { false } -fn default_font_family() -> String { "Proportional".to_string() } -fn default_font_size() -> f32 { 14.0 } +fn default_auto_hide_toolbar() -> bool { + false +} +fn default_hide_tab_bar() -> bool { + true +} +fn default_show_line_numbers() -> bool { + false +} +fn default_word_wrap() -> bool { + true +} +fn default_line_side() -> bool { + false +} +fn default_font_family() -> String { + "Proportional".to_string() +} +fn default_font_size() -> f32 { + 14.0 +} impl Default for Config { fn default() -> Self { Self { auto_hide_toolbar: false, - auto_hide_tab_bar: true, + hide_tab_bar: true, show_line_numbers: false, word_wrap: true, theme: Theme::default(), @@ -53,7 +67,9 @@ impl Config { let config_dir = if let Some(config_dir) = dirs::config_dir() { config_dir.join(format!("{}", env!("CARGO_PKG_NAME"))) } else if let Some(home_dir) = dirs::home_dir() { - home_dir.join(".config").join(format!("{}", env!("CARGO_PKG_NAME"))) + home_dir + .join(".config") + .join(format!("{}", env!("CARGO_PKG_NAME"))) } else { return None; }; @@ -92,7 +108,7 @@ impl Config { let default_config = Self::default(); config.merge_with_default(default_config); config - }, + } Err(e) => { eprintln!( "Failed to read config file {}: {}", @@ -108,7 +124,7 @@ impl Config { if self.font_family.is_empty() { self.font_family = default.font_family; } - + if self.font_size <= 0.0 { self.font_size = default.font_size; } diff --git a/src/app/state/app_impl.rs b/src/app/state/app_impl.rs index bb39ec5..c0021e6 100644 --- a/src/app/state/app_impl.rs +++ b/src/app/state/app_impl.rs @@ -24,7 +24,7 @@ impl eframe::App for TextEditor { menu_bar(self, ctx); - if !self.auto_hide_tab_bar { + if !self.hide_tab_bar { tab_bar(self, ctx); } diff --git a/src/app/state/config.rs b/src/app/state/config.rs index 644dd09..815ff13 100644 --- a/src/app/state/config.rs +++ b/src/app/state/config.rs @@ -19,7 +19,7 @@ impl TextEditor { show_line_numbers: config.show_line_numbers, word_wrap: config.word_wrap, auto_hide_toolbar: config.auto_hide_toolbar, - auto_hide_tab_bar: config.auto_hide_tab_bar, + hide_tab_bar: config.hide_tab_bar, theme: config.theme, line_side: config.line_side, font_family: config.font_family, @@ -80,7 +80,7 @@ impl TextEditor { Config { auto_hide_toolbar: self.auto_hide_toolbar, show_line_numbers: self.show_line_numbers, - auto_hide_tab_bar: self.auto_hide_tab_bar, + hide_tab_bar: self.hide_tab_bar, word_wrap: self.word_wrap, theme: self.theme, line_side: self.line_side, diff --git a/src/app/state/default.rs b/src/app/state/default.rs index 54afebc..4370523 100644 --- a/src/app/state/default.rs +++ b/src/app/state/default.rs @@ -19,7 +19,7 @@ impl Default for TextEditor { show_line_numbers: false, word_wrap: true, auto_hide_toolbar: false, - auto_hide_tab_bar: true, + hide_tab_bar: true, theme: Theme::default(), line_side: false, font_family: "Proportional".to_string(), diff --git a/src/app/state/editor.rs b/src/app/state/editor.rs index 0211e2d..a0511aa 100644 --- a/src/app/state/editor.rs +++ b/src/app/state/editor.rs @@ -44,7 +44,7 @@ pub struct TextEditor { pub(crate) show_line_numbers: bool, pub(crate) word_wrap: bool, pub(crate) auto_hide_toolbar: bool, - pub(crate) auto_hide_tab_bar: bool, + pub(crate) hide_tab_bar: bool, pub(crate) theme: Theme, pub(crate) line_side: bool, pub(crate) font_family: String, diff --git a/src/ui/menu_bar.rs b/src/ui/menu_bar.rs index 2ffcd80..ea61237 100644 --- a/src/ui/menu_bar.rs +++ b/src/ui/menu_bar.rs @@ -182,10 +182,7 @@ pub(crate) fn menu_bar(app: &mut TextEditor, ctx: &egui::Context) { app.save_config(); ui.close_menu(); } - if ui - .checkbox(&mut app.auto_hide_tab_bar, "Hide Tab Bar") - .clicked() - { + if ui.checkbox(&mut app.hide_tab_bar, "Hide Tab Bar").clicked() { app.save_config(); ui.close_menu(); } @@ -270,7 +267,7 @@ pub(crate) fn menu_bar(app: &mut TextEditor, ctx: &egui::Context) { } }); - if app.auto_hide_tab_bar { + if app.hide_tab_bar { let tab_title = if let Some(tab) = app.get_active_tab() { tab.title.clone() } else {