Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cursor blinking in text editor #152

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tannal
Copy link

@tannal tannal commented Oct 31, 2024

Implemented some kind of timer using ControlFlow::WaitUntil.
I believe the timer thing can be handled in a more general way, but I haven't figured it out yet.
blink.webm

Comment on lines +147 to +148
_ => {}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to handle WaitCancelled.

@@ -42,6 +42,10 @@ impl Editor {
self.editor.text()
}

pub fn cursor_blink(&mut self) {
self.cursor_blink = !self.cursor_blink;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to handle this with a periodic function, instead of a toggle, but I won't block on this.

@@ -300,10 +304,10 @@ impl Editor {
scene.fill(Fill::NonZero, transform, Color::STEEL_BLUE, None, &rect);
}
if let Some(cursor) = self.editor.selection_strong_geometry(1.5) {
scene.fill(Fill::NonZero, transform, Color::WHITE, None, &cursor);
scene.fill(Fill::NonZero, transform, if self.cursor_blink {Color::TRANSPARENT} else {Color::WHITE}, None, &cursor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're painting the whole scene regardless, might as well just add the condition around both of these if let Somes.

@xorgy
Copy link
Member

xorgy commented Nov 7, 2024

And overall, remember to run cargo fmt on your code before committing it. It will fail CI if it is not formatted the way the machine wants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants