-
-
Notifications
You must be signed in to change notification settings - Fork 326
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
feat(text): add push methods for text and line #998
Conversation
Adds the following methods to the `Text` and `Line` structs: - Text::push_line - Text::push_span - Line::push_span This allows for adding lines and spans to a text object without having to call methods on the fields directly, which is usefult for incremental construction of text objects.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #998 +/- ##
=====================================
Coverage 89.3% 89.4%
=====================================
Files 61 61
Lines 15298 15359 +61
=====================================
+ Hits 13670 13731 +61
Misses 1628 1628 ☔ View full report in Codecov by Sentry. |
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.
Looks convenient to me
I'll wait on a second review for some feedback on this one as it's a change to the APIs which could do with some input. I think these are the most likely the right names for this, but I was wrong about the |
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.
Personally I try to create something only once I have all the parts for it together. So in this case I would have started with a Vec<Line>
which I only put into the Text as a last step. But especially with the push_span
these are more helpful in this case.
My mqttui displays JSON within my tree widget and a combination of both might be neat to have. (See payload_view.rs, json.rs and json_selector.rs). Now I'm curious about improving the output of that to look more like yours (while maintaining the tree like navigation) 🙃
Yeah, that's reasonable I guess and for making things editable it might be the better approach for the JSON editor tutorial anyway especially because the selection needs to track which spans are editable and which are not. For that I'm trying to simplify the code needed to create an editor as much as possible. The idea there being more about showing how to make an app interactive than about making it pretty (but making it pretty is an important secondary goal). I would probably use a tree widget in a real app for this sort of thing, but generally try to avoid third party things for tutorial code. |
Adds the following methods to the `Text` and `Line` structs: - Text::push_line - Text::push_span - Line::push_span This allows for adding lines and spans to a text object without having to call methods on the fields directly, which is usefult for incremental construction of text objects.
Adds the following methods to the `Text` and `Line` structs: - Text::push_line - Text::push_span - Line::push_span This allows for adding lines and spans to a text object without having to call methods on the fields directly, which is usefult for incremental construction of text objects.
Adds the following methods to the
Text
andLine
structs:This allows for adding lines and spans to a text object without having
to call methods on the fields directly, which is usefult for incremental
construction of text objects.