-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
TextEditor
widget (or multi-line text input)
#2123
Conversation
TextEditor
widget or multi-line text inputTextEditor
widget (or multi-line text input)
widget/src/text_editor.rs
Outdated
} | ||
} | ||
mouse::ScrollDelta::Pixels { y, .. } => { | ||
-y.signum() as i32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scrolling behavior with touchpad is weird. If you scroll slowly it actually scrolls more lines more quickly than if you scroll a lot.
Because the editor scrolls by whole lines, I think you will need to keep some state like "fraction of a line already scrolled" to add it to the scroll distance on the next event. Or something like that.
"TextEditor is cumbersome to use. I only need a multiline input, not a text editor. Is there a simpler solution?" |
This PR introduces a multi-line text input widget called
TextEditor
.A
TextEditor
can be created with someContent
and produces anAction
when the user interacts with it. ThisAction
can be performed on theContent
duringupdate
to apply any cursor movements, clicks, and edits.A
TextEditor
uses the newtext::Highlighter
API to potentially highlight text. A new subcrateiced_highlighter
contains a new basic syntax highlighter implementation on top ofsyntect
.A new
editor
example has been implemented which leverages theTextEditor
to build a simple text editor program with syntax highlighting. The latest video-tutorial in theiced-rs
YouTube channel walks through the creation of the example: https://www.youtube.com/watch?v=gcBJ7cPSALo