1
0
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:
n4n5
2026-01-05 09:54:18 -07:00
committed by GitHub
parent 0566fb17a5
commit f26d7d8072
2 changed files with 50 additions and 23 deletions

View File

@@ -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);
});
}
}