diff --git a/Cargo.toml b/Cargo.toml index 7be76a9..672f28c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "egui_code_editor" authors = ["Roman Chumak "] -version = "0.2.21" +version = "0.2.22" edition = "2024" license = "MIT" repository = "https://github.com/p4ymak/egui_code_editor" @@ -11,7 +11,7 @@ categories = ["gui", "text-editors"] keywords = ["egui", "GUI", "editor", "syntax", "highlighting"] [dependencies] -egui = { version = "0.33", optional = true } +egui = { version = "0.34", optional = true } serde = { version = "1", optional = true} [lib] @@ -33,5 +33,5 @@ name = "tui" test = true [dev-dependencies] -eframe = "0.33" +eframe = "0.34" colorful = "0.3" diff --git a/examples/demo.rs b/examples/demo.rs index 6610282..542289b 100644 --- a/examples/demo.rs +++ b/examples/demo.rs @@ -166,8 +166,8 @@ impl CodeEditorDemo { } } impl eframe::App for CodeEditorDemo { - fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { - egui::SidePanel::left("theme_picker").show(ctx, |ui| { + fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) { + egui::Panel::left("theme_picker").show_inside(ui, |ui| { ui.heading("Theme"); egui::ScrollArea::both().show(ui, |ui| { for theme in THEMES.iter() { @@ -176,16 +176,16 @@ impl eframe::App for CodeEditorDemo { .clicked() { if theme.is_dark() { - ctx.set_visuals(egui::Visuals::dark()); + ui.set_visuals(egui::Visuals::dark()); } else { - ctx.set_visuals(egui::Visuals::light()); + ui.set_visuals(egui::Visuals::light()); } }; } }); }); - egui::SidePanel::right("syntax_picker").show(ctx, |ui| { + egui::Panel::right("syntax_picker").show_inside(ui, |ui| { ui.horizontal(|h| { h.heading("Syntax"); h.checkbox(&mut self.example, "Example"); @@ -207,7 +207,7 @@ impl eframe::App for CodeEditorDemo { }); }); - egui::CentralPanel::default().show(ctx, |ui| { + egui::CentralPanel::default().show_inside(ui, |ui| { ui.horizontal(|h| { h.label("Numbering Shift"); h.add(egui::DragValue::new(&mut self.shift)); diff --git a/src/completer/mod.rs b/src/completer/mod.rs index 306648c..99f66b6 100644 --- a/src/completer/mod.rs +++ b/src/completer/mod.rs @@ -1,12 +1,11 @@ mod trie; -use std::collections::BTreeSet; - use crate::{ColorTheme, Syntax, Token, TokenType, format_token}; use egui::{ Event, Frame, Modifiers, Sense, Stroke, TextBuffer, text_edit::TextEditOutput, text_selection::text_cursor_state::ccursor_previous_word, }; +use std::collections::BTreeSet; use trie::Trie; impl From<&Syntax> for Trie { @@ -194,7 +193,7 @@ impl Completer { cursor_rect, editor_output.response.layer_id, ) - .frame(Frame::popup(&ctx.style()).fill(theme.bg())) + .frame(Frame::popup(&ctx.global_style()).fill(theme.bg())) .sense(Sense::empty()) .show(|ui| { ui.response().sense = Sense::empty(); diff --git a/src/highlighting.rs b/src/highlighting.rs index e5535e8..c910e30 100644 --- a/src/highlighting.rs +++ b/src/highlighting.rs @@ -247,5 +247,10 @@ pub type HighlightCache = egui::util::cache::FrameCache; #[cfg(feature = "egui")] pub fn highlight(ctx: &egui::Context, cache: &T, text: &str) -> LayoutJob { - ctx.memory_mut(|mem| mem.caches.cache::().get((cache, text))) + ctx.memory_mut(|mem| { + mem.caches + .cache::() + .get((cache, text)) + .to_owned() + }) } diff --git a/src/lib.rs b/src/lib.rs index 2aaa792..aa5aeea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -316,7 +316,7 @@ impl CodeEditor { .id_source(format!("{}_numlines", self.id)) .font(egui::TextStyle::Monospace) .interactive(false) - .frame(false) + .frame(egui::Frame::NONE) .desired_rows(self.rows) .desired_width(width) .layouter(&mut layouter), @@ -361,7 +361,7 @@ impl CodeEditor { .id_source(&self.id) .lock_focus(true) .desired_rows(self.rows) - .frame(true) + .frame(egui::Frame::NONE) .desired_width(self.desired_width) .layouter(&mut layouter) .show(ui);