diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-18 02:52:35 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-18 02:53:31 +0300 |
| commit | 36b4001f4526b60f1c9b67a4a34596e5ad2bcca1 (patch) | |
| tree | 520ab28a0a3f3f798e6e655fc83529e8617720e9 /src/pane/osc.rs | |
| parent | aca35ea76f3df15ec68fd07959d939f5e7a78a6c (diff) | |
feat: sync theme with host appearance
refs #675
Diffstat (limited to 'src/pane/osc.rs')
| -rw-r--r-- | src/pane/osc.rs | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/pane/osc.rs b/src/pane/osc.rs index e7b97a79..83cb47ae 100644 --- a/src/pane/osc.rs +++ b/src/pane/osc.rs @@ -885,22 +885,44 @@ pub(super) fn write_host_terminal_theme( terminal: &mut crate::ghostty::Terminal, theme: crate::terminal_theme::TerminalTheme, ) { - if let Some(color) = theme.foreground { - let sequence = crate::terminal_theme::osc_set_default_color_sequence( + write_host_terminal_theme_selective(terminal, theme, true, true); +} + +pub(super) fn write_host_terminal_theme_selective( + terminal: &mut crate::ghostty::Terminal, + theme: crate::terminal_theme::TerminalTheme, + foreground: bool, + background: bool, +) { + if foreground { + write_host_default_color( + terminal, crate::terminal_theme::DefaultColorKind::Foreground, - color, + theme.foreground, ); - terminal.write(sequence.as_bytes()); } - if let Some(color) = theme.background { - let sequence = crate::terminal_theme::osc_set_default_color_sequence( + if background { + write_host_default_color( + terminal, crate::terminal_theme::DefaultColorKind::Background, - color, + theme.background, ); - terminal.write(sequence.as_bytes()); } } +fn write_host_default_color( + terminal: &mut crate::ghostty::Terminal, + kind: crate::terminal_theme::DefaultColorKind, + color: Option<crate::terminal_theme::RgbColor>, +) { + let sequence = if let Some(color) = color { + crate::terminal_theme::osc_set_default_color_sequence(kind, color) + } else { + crate::terminal_theme::osc_reset_default_color_sequence(kind).to_string() + }; + terminal.write(sequence.as_bytes()); +} + pub(super) fn restore_host_terminal_theme_if_needed( core: &mut GhosttyPaneCore, pane_id: PaneId, |
