feat: Improve Blink Cursor (#34)

* add cursor color to theme

* adjust
This commit is contained in:
reya
2025-05-13 13:26:02 +07:00
committed by GitHub
parent 4e24061817
commit 4f066b7c00
3 changed files with 14 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ use super::TextInput;
const RIGHT_MARGIN: Pixels = px(5.);
const BOTTOM_MARGIN: Pixels = px(20.);
const CURSOR_THICKNESS: Pixels = px(2.);
pub(super) struct TextElement {
input: Entity<TextInput>,
@@ -140,7 +141,7 @@ impl TextElement {
if input.show_cursor(window, cx) {
// cursor blink
let cursor_height =
window.text_style().font_size.to_pixels(window.rem_size()) + px(2.);
window.text_style().font_size.to_pixels(window.rem_size()) + px(4.);
cursor = Some(fill(
Bounds::new(
@@ -148,9 +149,9 @@ impl TextElement {
bounds.left() + cursor_pos.x,
bounds.top() + cursor_pos.y + ((line_height - cursor_height) / 2.),
),
size(px(1.), cursor_height),
size(CURSOR_THICKNESS, cursor_height),
),
cx.theme().element_active,
cx.theme().cursor,
))
};
}