mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
fix: CodeTheme functions - ui and add builder (#7684)
Following this MR https://github.com/emilk/egui/pull/7375 Without Syntect, the urrent theme selector is `global_theme_preference_buttons`. It should be the dark_theme variable of the local CodeTheme - same as syntect Tested with ```sh cargo run # and cargo run --features syntect ``` * [x] I have followed the instructions in the PR template thanks for this amazing library!
This commit is contained in:
@@ -90,15 +90,25 @@ impl crate::View for CodeEditor {
|
||||
};
|
||||
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
ui.add(
|
||||
egui::TextEdit::multiline(code)
|
||||
.font(egui::TextStyle::Monospace) // for cursor height
|
||||
.code_editor()
|
||||
.desired_rows(10)
|
||||
.lock_focus(true)
|
||||
.desired_width(f32::INFINITY)
|
||||
.layouter(&mut layouter),
|
||||
);
|
||||
let editor = egui::TextEdit::multiline(code)
|
||||
.font(egui::TextStyle::Monospace) // for cursor height
|
||||
.code_editor()
|
||||
.desired_rows(10)
|
||||
.lock_focus(true)
|
||||
.desired_width(f32::INFINITY)
|
||||
.layouter(&mut layouter);
|
||||
let editor = if cfg!(feature = "syntect") {
|
||||
editor
|
||||
} else {
|
||||
use egui::Color32;
|
||||
let background_color = if theme.is_dark() {
|
||||
Color32::BLACK
|
||||
} else {
|
||||
Color32::WHITE
|
||||
};
|
||||
editor.background_color(background_color)
|
||||
};
|
||||
ui.add(editor);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user