Replies: 1 comment 2 replies
-
How about this? let theme = egui_extras::syntax_highlighting::CodeTheme::from_memory(ui.ctx());
let mut layouter = |ui: &egui::Ui, string: &str, wrap_width: f32| {
let layout_job = egui_extras::syntax_highlighting::highlight(ui.ctx(), &theme, string, "".into());
ui.fonts(|f| f.layout_job(layout_job))
};
egui::ScrollArea::both()
.auto_shrink(false)
.show(ui, |ui| {
ui.add_enabled(true, egui::TextEdit::multiline(&mut self.text)
.code_editor()
.layouter(&mut layouter)
.desired_rows(10)
.desired_width(f32::INFINITY)
.frame(false)
);
}); By the way, "".into() is a code syntax specification and is defined like this in the egui source code. match language.to_lowercase().as_str() {
"c" | "h" | "hpp" | "cpp" | "c++" => Some(Self::cpp()),
"py" | "python" => Some(Self::python()),
"rs" | "rust" => Some(Self::rust()),
"toml" => Some(Self::toml()),
_ => {
None // unsupported language
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Trying to make a multiline textedit that does not wrap lines but scrolls horizontally.
I have
(You can see me guessing at the tweaks I need)
If a type a line that goes off the visible area it wraps rather than forcing a horizontal scroll bar. (Vertical works fine)
Beta Was this translation helpful? Give feedback.
All reactions