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

TextEditor widget (or multi-line text input) #2123

Merged
merged 70 commits into from
Oct 27, 2023
Merged

TextEditor widget (or multi-line text input) #2123

merged 70 commits into from
Oct 27, 2023

Conversation

hecrj
Copy link
Member

@hecrj hecrj commented Oct 27, 2023

This PR introduces a multi-line text input widget called TextEditor.

A TextEditor can be created with some Content and produces an Action when the user interacts with it. This Action can be performed on the Content during update to apply any cursor movements, clicks, and edits.

A TextEditor uses the new text::Highlighter API to potentially highlight text. A new subcrate iced_highlighter contains a new basic syntax highlighter implementation on top of syntect.

A new editor example has been implemented which leverages the TextEditor to build a simple text editor program with syntax highlighting. The latest video-tutorial in the iced-rs YouTube channel walks through the creation of the example: https://www.youtube.com/watch?v=gcBJ7cPSALo

@hecrj hecrj added this to the 0.12 milestone Oct 27, 2023
@hecrj hecrj changed the title TextEditor widget or multi-line text input TextEditor widget (or multi-line text input) Oct 27, 2023
}
}
mouse::ScrollDelta::Pixels { y, .. } => {
-y.signum() as i32
Copy link
Contributor

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.

@hecrj hecrj merged commit d731996 into master Oct 27, 2023
24 checks passed
@hecrj hecrj deleted the text-editor branch October 27, 2023 15:36
@hecrj hecrj mentioned this pull request Nov 1, 2023
@cnwzhu
Copy link

cnwzhu commented Apr 25, 2024

"TextEditor is cumbersome to use. I only need a multiline input, not a text editor. Is there a simpler solution?"

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

Successfully merging this pull request may close these issues.

3 participants