Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/application.rs')
| -rw-r--r-- | helix-term/src/application.rs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index e14bc7bb..a082a7f7 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -124,7 +124,7 @@ impl Application { let backend = TestBackend::new(120, 150); let theme_mode = backend.get_theme_mode(); - let terminal = Terminal::new(backend)?; + let mut terminal = Terminal::new(backend)?; let area = terminal.size(); let mut compositor = Compositor::new(area); let config = Arc::new(ArcSwap::from_pointee(config)); @@ -138,12 +138,7 @@ impl Application { })), handlers, ); - Self::load_configured_theme( - &mut editor, - &config.load(), - terminal.backend().supports_true_color(), - theme_mode, - ); + Self::load_configured_theme(&mut editor, &config.load(), &mut terminal, theme_mode); let keys = Box::new(Map::new(Arc::clone(&config), |config: &Config| { &config.keys @@ -395,6 +390,15 @@ impl Application { }; self.config.store(Arc::new(app_config)); } + ConfigEvent::ThemeChanged => { + let _ = self.terminal.backend_mut().set_background_color( + self.editor + .theme + .try_get_exact("ui.background") + .and_then(|style| style.bg), + ); + return; + } } // Update all the relevant members in the editor after updating @@ -422,7 +426,7 @@ impl Application { Self::load_configured_theme( &mut self.editor, &default_config, - self.terminal.backend().supports_true_color(), + &mut self.terminal, self.theme_mode, ); @@ -460,10 +464,12 @@ impl Application { fn load_configured_theme( editor: &mut Editor, config: &Config, - terminal_true_color: bool, + terminal: &mut Terminal, mode: Option<theme::Mode>, ) { - let true_color = terminal_true_color || config.editor.true_color || crate::true_color(); + let true_color = terminal.backend().supports_true_color() + || config.editor.true_color + || crate::true_color(); let theme = config .theme .as_ref() @@ -490,7 +496,13 @@ impl Application { }) }) .unwrap_or_else(|| editor.theme_loader.default_theme(true_color)); + let background_color = theme + .try_get_exact("ui.background") + .and_then(|style| style.bg); editor.set_theme(theme); + let _ = terminal + .backend_mut() + .set_background_color(background_color); } #[cfg(windows)] @@ -720,7 +732,7 @@ impl Application { Self::load_configured_theme( &mut self.editor, &self.config.load(), - self.terminal.backend().supports_true_color(), + &mut self.terminal, Some(mode.into()), ); true |