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

Introduce Editor Trait for Flexible Text Widget Integration and Feature Flag for CodeEditor #15

Merged
merged 4 commits into from
Jul 13, 2024

Conversation

GodGotzi
Copy link
Contributor

Description

This pull request introduces an abstraction layer via the Editor trait to enable users to incorporate additional text widgets with syntax highlighting. It also implements a feature flag for the existing CodeEditor.

Changes Made

  • Added Editor trait with methods append and syntax to generalize functionality for text widgets.
  • Modified highlight and associated functions in highlighting.rs to accept generic Editor trait bounds instead of directly referencing CodeEditor.
  • Implemented Editor for CodeEditor, defining append and syntax methods accordingly.

Motivation and Context

The addition of the Editor trait allows for flexibility in integrating various text widgets with syntax highlighting capabilities, enhancing the extensibility and usability of the codebase. The feature flag ensures compatibility with existing code while paving the way for future enhancements.

Notes for Reviewers

Please review the changes to highlighting.rs and lib.rs for adherence to the new Editor trait usage and feature flag implementation. Ensure compatibility with existing features and provide feedback on the design and implementation decisions.

@GodGotzi
Copy link
Contributor Author

GodGotzi commented Jul 12, 2024

I tried to create an efficient reader widget for egui which only renders a specific region of a string slice so I tried to build a low cost reader on top of your crate which doesn't work out of the box. Your Syntax Highlighting comes in handy. So I introduced a trait which represents any editor.

example is working
tests fail on rustdoc codeblocks btw

@GodGotzi
Copy link
Contributor Author

GodGotzi commented Jul 12, 2024

Example

image
This is your editor but a lot faster for readonly which renders 3MB of text very very fast in about 30µs. That was only possible because of the Abstraction

https://github.com/GodGotzi/fiberslice-5d/blob/main/src/ui/widgets/reader.rs

@p4ymak p4ymak merged commit d4c2ffd into p4ymak:main Jul 13, 2024
1 check passed
@p4ymak
Copy link
Owner

p4ymak commented Jul 13, 2024

@GodGotzi Looks good! Thank you!

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