Skip to content

Commit 6ff0082

Browse files
authored
V0.2.14 (#22)
* egui 0.32 * version up
1 parent 1566784 commit 6ff0082

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "egui_code_editor"
33
authors = ["Roman Chumak <p4ymak@yandex.ru>"]
4-
version = "0.2.13"
4+
version = "0.2.14"
55
edition = "2021"
66
license = "MIT"
77
repository = "https://github.com/p4ymak/egui_code_editor"
@@ -11,7 +11,7 @@ categories = ["gui", "text-editors"]
1111
keywords = ["egui", "GUI", "editor", "syntax", "highlighting"]
1212

1313
[dependencies]
14-
egui = { version = "0.31", optional = true }
14+
egui = { version = "0.32", optional = true }
1515
serde = { version = "1", optional = true}
1616

1717
[lib]
@@ -33,5 +33,5 @@ name = "tui"
3333
test = true
3434

3535
[dev-dependencies]
36-
eframe = "0.31"
36+
eframe = "0.32"
3737
colorful = "0.3"

src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ impl CodeEditor {
263263

264264
#[cfg(feature = "egui")]
265265
fn numlines_show(&self, ui: &mut egui::Ui, text: &str) {
266+
use egui::TextBuffer;
267+
266268
let total = if text.ends_with('\n') || text.is_empty() {
267269
text.lines().count() + 1
268270
} else {
@@ -295,9 +297,9 @@ impl CodeEditor {
295297
* 0.5
296298
* !(total + self.numlines_shift <= 0 && self.numlines_only_natural) as u8 as f32;
297299

298-
let mut layouter = |ui: &egui::Ui, string: &str, _wrap_width: f32| {
300+
let mut layouter = |ui: &egui::Ui, text_buffer: &dyn TextBuffer, _wrap_width: f32| {
299301
let layout_job = egui::text::LayoutJob::single_section(
300-
string.to_string(),
302+
text_buffer.as_str().to_string(),
301303
egui::TextFormat::simple(
302304
egui::FontId::monospace(self.fontsize),
303305
self.theme.type_color(TokenType::Comment(true)),
@@ -321,6 +323,8 @@ impl CodeEditor {
321323
#[cfg(feature = "egui")]
322324
/// Show Code Editor
323325
pub fn show(&mut self, ui: &mut egui::Ui, text: &mut dyn egui::TextBuffer) -> TextEditOutput {
326+
use egui::TextBuffer;
327+
324328
let mut text_edit_output: Option<TextEditOutput> = None;
325329
let mut code_editor = |ui: &mut egui::Ui| {
326330
ui.horizontal_top(|h| {
@@ -331,10 +335,11 @@ impl CodeEditor {
331335
egui::ScrollArea::horizontal()
332336
.id_salt(format!("{}_inner_scroll", self.id))
333337
.show(h, |ui| {
334-
let mut layouter = |ui: &egui::Ui, string: &str, _wrap_width: f32| {
335-
let layout_job = highlight(ui.ctx(), self, string);
336-
ui.fonts(|f| f.layout_job(layout_job))
337-
};
338+
let mut layouter =
339+
|ui: &egui::Ui, text_buffer: &dyn TextBuffer, _wrap_width: f32| {
340+
let layout_job = highlight(ui.ctx(), self, text_buffer.as_str());
341+
ui.fonts(|f| f.layout_job(layout_job))
342+
};
338343
let output = egui::TextEdit::multiline(text)
339344
.id_source(&self.id)
340345
.lock_focus(true)

0 commit comments

Comments
 (0)