* feat(textinput): do not block input on validation
This PR builds upon the excellent work in #167 and #114 and makes a
breaking change to the validation API.
Currently, validation will completely block text input if the Validate
function returns an error. This is now changed so the function no longer
blocks input if this is the case, thus handing this responsibility to
the clients.
This is helpful for cases where the user is requested to type an
existing system path, and the Validate function keeps asserting the
existence of the path. With the current implementation such a validation
is not possible.
For example:
> /
Err: nil
> /t
Err: /t: No such file or directory
> /tm
Err: /tm: No such file or directory
> /tmp
Err: nil
* fix: change name
---------
Co-authored-by: Maas Lalani <maas@lalani.dev>
* fix(textinput): out of range panic if no matched suggestions
* fix(textinput): out of bounds check
Co-authored-by: Maas Lalani <maas@lalani.dev>
---------
Co-authored-by: Maas Lalani <maas@lalani.dev>
As the number of items in `suggestions` and `m.suggestions` is known,
we can use `make` with the expected size instead of appending, which
requires more allocations as the slice grows.
* Fix pasting calculations
Available length calculation now correctly trims pasted text.
* fix(textInput): Width padding added when placeholder is used
When `placeholder` is set, padding from `Width` was not added within the `placeholderView()` function.
* Adding missing 'm.'
* Maintain Width no matter placeholder size delta
* Fixed Math
* Added Comments
* fix: lint
---------
Co-authored-by: Donovan Hubbard <37090676+donovanhubbard@users.noreply.github.com>
Co-authored-by: Maas Lalani <maas@lalani.dev>
* migrate all autocomplete-work from old branch
* added support for multiple suggestions
* fix linter issues
* refactored to only offer matching suggestions for completion
* fix: SetSuggestions + Suggestions
* make: configuration behaviour configurable
* fix for double-width runes
* refactored all suggestions to be rune-arrays
also: accepting suggestions does not overwrite the already given input, rather appends
* fix: make suggestions and OnAcceptSuggestions unexported
* refactor: refreshingMatchingSuggestions -> updateSuggestions
---------
Co-authored-by: Maas Lalani <maas@lalani.dev>
This reverts the code back to the logic from 4ce16e8 which fixed the
issue of the cursor not being moved when an initial value was set with
SetValue.
The fix regressed in 16053f4.
fixes infinite loop when deleting input that only contains whitespace
using deleteWordLeft()
fixes index out of range panic when deleting input that only contains
whitespace using deleteWordRight()
When EchoMode is not set to EchoNormal, alt+left/alt+b and
alt+right/alt+b jumps to the beginning and the end, respectively, so as
not to reveal word breaks in the masked text.