From 0a81372cfd3a4deda640acdecbbaf24bf78bb6a2 Mon Sep 17 00:00:00 2001 From: n4n5 Date: Sun, 24 Aug 2025 16:41:10 +0200 Subject: [PATCH] Add theme selection for code editor (#7375) Change the theme selection of the code editor Before - was showing the window theme selector After - is showing the code editor theme selector image * [x] I have followed the instructions in the PR template --------- Co-authored-by: Emil Ernerfeldt --- crates/egui_extras/src/syntax_highlighting.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/egui_extras/src/syntax_highlighting.rs b/crates/egui_extras/src/syntax_highlighting.rs index 894f2cc2..c08c6975 100644 --- a/crates/egui_extras/src/syntax_highlighting.rs +++ b/crates/egui_extras/src/syntax_highlighting.rs @@ -333,9 +333,19 @@ impl CodeTheme { } } + pub fn is_dark(&self) -> bool { + self.dark_mode + } + /// Show UI for changing the color theme. pub fn ui(&mut self, ui: &mut egui::Ui) { - egui::widgets::global_theme_preference_buttons(ui); + ui.horizontal(|ui| { + ui.selectable_value(&mut self.dark_mode, true, "🌙 Dark theme") + .on_hover_text("Use the dark mode theme"); + + ui.selectable_value(&mut self.dark_mode, false, "☀ Light theme") + .on_hover_text("Use the light mode theme"); + }); for theme in SyntectTheme::all() { if theme.is_dark() == self.dark_mode {