Merge pull request #2407 from iced-rs/fix/text-editor-quirks
Fix some `text_editor` quirks
This commit is contained in:
commit
ce12231e22
2 changed files with 25 additions and 17 deletions
|
|
@ -456,10 +456,14 @@ impl editor::Editor for Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::Scroll { lines } => {
|
Action::Scroll { lines } => {
|
||||||
editor.action(
|
let (_, height) = editor.buffer().size();
|
||||||
font_system.raw(),
|
|
||||||
cosmic_text::Action::Scroll { lines },
|
if height < i32::MAX as f32 {
|
||||||
);
|
editor.action(
|
||||||
|
font_system.raw(),
|
||||||
|
cosmic_text::Action::Scroll { lines },
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -569,23 +569,27 @@ where
|
||||||
if state.is_focused {
|
if state.is_focused {
|
||||||
match internal.editor.cursor() {
|
match internal.editor.cursor() {
|
||||||
Cursor::Caret(position) => {
|
Cursor::Caret(position) => {
|
||||||
let position = position + translation;
|
let cursor =
|
||||||
|
Rectangle::new(
|
||||||
|
position + translation,
|
||||||
|
Size::new(
|
||||||
|
1.0,
|
||||||
|
self.line_height
|
||||||
|
.to_absolute(self.text_size.unwrap_or_else(
|
||||||
|
|| renderer.default_size(),
|
||||||
|
))
|
||||||
|
.into(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
if bounds.contains(position) {
|
if let Some(clipped_cursor) = bounds.intersection(&cursor) {
|
||||||
renderer.fill_quad(
|
renderer.fill_quad(
|
||||||
renderer::Quad {
|
renderer::Quad {
|
||||||
bounds: Rectangle {
|
bounds: Rectangle {
|
||||||
x: position.x.floor(),
|
x: clipped_cursor.x.floor(),
|
||||||
y: position.y,
|
y: clipped_cursor.y,
|
||||||
width: 1.0,
|
width: clipped_cursor.width,
|
||||||
height: self
|
height: clipped_cursor.height,
|
||||||
.line_height
|
|
||||||
.to_absolute(
|
|
||||||
self.text_size.unwrap_or_else(
|
|
||||||
|| renderer.default_size(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.into(),
|
|
||||||
},
|
},
|
||||||
..renderer::Quad::default()
|
..renderer::Quad::default()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue