Notify Highlighter of topmost line change

This commit is contained in:
Héctor Ramón Jiménez 2023-09-17 19:27:51 +02:00
parent 23d00445ff
commit 2897986f2d
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 61 additions and 31 deletions

View file

@ -1,10 +1,12 @@
use crate::core::text::editor::{self, Action, Cursor, Direction, Motion};
use crate::core::text::editor::{
self, Action, Cursor, Direction, Edit, Motion,
};
use crate::core::text::highlighter::{self, Highlighter};
use crate::core::text::LineHeight;
use crate::core::{Font, Pixels, Point, Rectangle, Size};
use crate::text;
use cosmic_text::Edit;
use cosmic_text::Edit as _;
use std::fmt;
use std::sync::{self, Arc};
@ -370,22 +372,42 @@ impl editor::Editor for Editor {
}
// Editing events
Action::Insert(c) => {
editor
.action(font_system.raw(), cosmic_text::Action::Insert(c));
}
Action::Paste(text) => {
editor.insert_string(&text, None);
}
Action::Enter => {
editor.action(font_system.raw(), cosmic_text::Action::Enter);
}
Action::Backspace => {
editor
.action(font_system.raw(), cosmic_text::Action::Backspace);
}
Action::Delete => {
editor.action(font_system.raw(), cosmic_text::Action::Delete);
Action::Edit(edit) => {
match edit {
Edit::Insert(c) => {
editor.action(
font_system.raw(),
cosmic_text::Action::Insert(c),
);
}
Edit::Paste(text) => {
editor.insert_string(&text, None);
}
Edit::Enter => {
editor.action(
font_system.raw(),
cosmic_text::Action::Enter,
);
}
Edit::Backspace => {
editor.action(
font_system.raw(),
cosmic_text::Action::Backspace,
);
}
Edit::Delete => {
editor.action(
font_system.raw(),
cosmic_text::Action::Delete,
);
}
}
let cursor = editor.cursor();
let selection = editor.select_opt().unwrap_or(cursor);
internal.topmost_line_changed =
Some(cursor.min(selection).line);
}
// Mouse events