Editor for Numbers
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 270
- Avg merge
- 5d 19h
- Merged PRs (30d)
- 2
Description
This is a suggestion (or perhaps someone will tell me it's already been made!).
I use cursive at work making tools which have a lot of number edits (especially f32s). Right now, the best way I handle that (ie, what is fastest to make) is just parsing a string from an EditView, but this obviously isn't very good. Is there a better solution already made, and if there is not, would you be interested in a PR for a new View which handles that?
Things I look for personally:
1. Ability to edit in whatever I want with only valid edits being submitted validly to the underlying data. Ie, I could write "aaaaa" into the box, and it won't change what I type as I type it, but silently ignore it (similar to what I do now on checking if the parse fails)
2. When I deselect the the box, we switch back to our old data if the current selection isn't valid. If the current selection *is* valid, we submit it and replace our data (and run the "on_submit" callback here, even though the user hasn't hit enter, because people rarely hit enter for inserting a number).
3. When the user hits "enter", we validate the number, and if it's valid, we run `on_submit`. If it's invalid, we revert to old data (letting them know that this is invalid).
Personally, I'd be looking for something that covers at least f32/64s (one, both, some generic that works over both) and i32. The specifics aren't suuuper important imo, since users rarely will be inserting absolutely giant numbers, so I think, at least at first, it would be fine for this to work.
Long term goals:
1. Simple math, like addition/division parsing
2. Non-decimal numbers
Does such a thing exist, and if not, would you be interested in a PR for it?
Contributor guide
Assessment
This issue has not been assessed yet.