Commit Graph
89 Commits
Author SHA1 Message Date
Ayman Bagabas 1b341485f2 fix(textinput): return a pointer to StyleState 2024-10-23 16:52:57 -04:00
Christian Rocha 432972ae77 feat(textinput): add styles for focused and blurred states 2024-10-23 16:43:23 -04:00
Christian Rocha 30d7e7bd31 chore(textinput): use a getter and setter for width 2024-10-23 16:43:23 -04:00
Christian Rocha 17533b1286 chore(textinput): use getter and setter for width 2024-10-23 16:43:23 -04:00
Christian Rocha aa1fe05f2e chore(textinput): DefaultKeyMap is now a func that returns a KeyMap 2024-10-23 16:43:22 -04:00
Ayman Bagabas 287c9c4ffd chore: merge branch 'master' into v2-exp 2024-10-21 14:16:22 -04:00
David Luevano AlvaradoandChristian Rocha 4382fdf1c6 feat(textinput): expose matched suggestions and index 2024-09-19 14:16:51 -04:00
Ayman Bagabas 09242fdf67 refactor!: remove deprecated references
This removes all the `NewModel` functions from all the bubbles and any
deprecated fields and types.
2024-09-19 13:44:03 -04:00
Ayman Bagabas a2602f8509 feat!: v2: move to v2 module 2024-09-18 14:12:55 -04:00
Ayman Bagabas 0fdf5f5be5 feat: use bubbletea/v2 2024-09-18 14:09:58 -04:00
Ayman Bagabas a93bfef532 feat!: use bubbletea@v2-exp 2024-09-09 14:12:52 -04:00
Ayman BagabasandGitHub 11a9fccd58 chore: fix lint issues (#534) 2024-05-31 16:48:29 -04:00
9030d22eec feat(textinput): do not block input on validation (#185)
* 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>
2024-03-13 21:22:49 -04:00
Maas LalaniandGitHub 8a6f531287 feat: add ctrl+right and ctrl+left to perform WordBackward and WordForward actions (#387) 2024-03-04 11:00:05 -05:00
79cc9621d5 fix(textinput): out of range panic if no matched suggestions (#473)
* 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>
2024-02-02 16:02:24 -05:00
Maas Lalani 6399027ab7 perf(textinput): use uniseg.StringWidth 2024-01-22 15:37:12 -05:00
naglisandMaas Lalani ec883029c8 refactor(textinput): reduce allocations
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.
2024-01-08 12:07:49 -05:00
f36aa3c4b5 fix(textinput): Placeholder No Longer Changes Width + Paste Calculation (#451)
* 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>
2023-12-23 16:02:26 -05:00
Maas LalaniandGitHub fc50558f4b Revert "fix: truncate textinput placeholder (#442)" (#450)
This reverts commit 9a0ff2ba4d.
2023-12-23 13:57:42 -05:00
9a0ff2ba4d fix: truncate textinput placeholder (#442)
Co-authored-by: Sean Banko <seanbanko@Seans-MacBook-Air.local>
2023-12-21 23:14:53 -05:00
lc-1010andChristian Rocha f53b3d9f61 fix: Unicode character encoding error 2023-09-28 10:29:30 -04:00
eda891258c Support suggestions and autocompletion in textinput (#407)
* 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>
2023-08-21 11:26:02 -04:00
remiposoandGitHub 9266653c39 Reset blink only when CursorBlink (#378) 2023-05-13 12:56:18 -04:00
Maas Lalani dc58240609 chore(lint): help msg unused param 2023-05-01 12:56:08 -04:00
Maas Lalani ab1f7134e4 fix: deprecate CursorStyle in favour of Cursor.Style 2023-04-08 14:19:53 -04:00
Glenn GondaandMaas Lalani 78a82d1616 fix(textinput): KeyMap typo 2023-03-07 22:01:46 -05:00
Savannah OstrowskiandChristian Rocha e4e3137a64 Remove unused BackgroundStyle in text input 2023-03-01 19:52:54 -05:00
Glenn GondaandChristian Rocha 3d3ed883d3 docs: fix typos and improve comment clarity 2023-02-16 17:49:32 -05:00
Raphael 'kena' PossandMaas Lalani 53724e6a72 feat: bracketed paste in textarea + textinput
This also fixes a longstanding bug where newlines, tabs
or other control characters in the clipboard would cause
the input to be corrupted on paste.
2023-01-09 16:30:24 -05:00
Christian Rocha 30c01cabdc chore: apply appropriate GoDoc syntax to deprecated items 2022-11-17 10:41:13 -05:00
Raphael 'kena' PossandMaas Lalani 9a48dca003 feat: support key bindings in textinput like textarea 2022-10-07 11:27:19 -04:00
Maas Lalani d3aed22a41 Revert "chore: move cursor bubble to internal"
This reverts commit a4ed54327f.
2022-10-06 15:33:16 -04:00
Maas Lalani d177512114 fix: set value moves cursor only when empty and at starting position 2022-10-06 11:42:29 -04:00
Tom PayneandGitHub 72d87e4513 chore: Miscellaneous minor fixes (#243)
* chore: remove internal use of deprecated NewModel

* chore: miscellaneous comment fixes
2022-09-15 10:51:42 -04:00
Maas Lalani a4ed54327f chore: move cursor bubble to internal 2022-09-14 15:45:51 -04:00
Maas LalaniandGitHub a99b55cda1 Delegate Cursor Logic to cursor bubble (#181)
* refactor: remove cursor logic from textinput
* chore: Add Deprecated Fields to avoid breaking changes
* fix: Ctrl+A and typing moves to end bug
2022-09-14 10:44:10 -04:00
Maas Lalani 8f65160828 fix: add ctrl+h to backspace text 2022-07-31 13:20:02 -04:00
Gabriel NagyandMaas Lalani 588393fbf8 fix(textinput): set cursor on initial value
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.
2022-07-05 09:16:19 -04:00
IllusionMan1212andMaas Lalani e57fd292cc feat: added Validate function for textinput 2022-06-10 12:17:24 -04:00
Christian Rocha a1e1b461b6 fix(textinput): support KeySpace in both present and future Bubble Tea versions
Closes #144
2022-05-29 08:25:34 -07:00
Austin ScheyandChristian Rocha e349920524 Add Blink method to textinput to return blink state 2022-03-01 07:35:21 -05:00
Christian Rocha 746834a7ce Add safety check in textinput's clamp 2022-01-20 13:23:58 -05:00
Christian Rocha fd306528f9 Rename var in deleteWordRight in textinput for additional clarity 2022-01-20 13:23:58 -05:00
Christian Rocha a4dc540f3d Re-add panic guard in deleteWordLeft in textinput, just in case 2022-01-20 13:23:58 -05:00
IllusionMan1212andChristian Rocha 151d1026dd fix(textinput): use old cursor pos and simplify logic 2022-01-19 18:31:55 -05:00
Christian Rocha 764fd321f6 Cleanup an old var 2022-01-19 12:31:50 -05:00
Christian Rocha 091c915462 Fix various godoc comments 2022-01-19 12:31:50 -05:00
IllusionMan1212andChristian Rocha c426cb580b fix textinput infinite loop and panic
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()
2022-01-11 12:27:57 -05:00
Christian Rocha b35f96cd2d Deprecate NewModel() constructors; use New() instead 2022-01-11 11:26:13 -05:00
Christian Rocha d06aa4aa48 Ensure that textinputs can only receive their own blink messages 2021-06-02 10:49:43 -04:00