Commit Graph
34 Commits
Author SHA1 Message Date
Michael LorantandGitHub 296fcf77fa feat(textarea) Add multiline placeholder (#302)
Add the capability to show a multiline placeholder. Some refactoring was
required to improve readability and improve logic.

End of line buffer character was only shown when line numbers were
displayed which requires some verification whether this is the intended
outcome. This change resolves this issue.
2024-05-30 20:28:20 -04:00
Garrett MartinandGitHub 620ca7dfa9 fix: default textarea EndOfBufferCharacter should be ' ' (#510) 2024-05-23 17:37:59 -04:00
Ayman Bagabas 14a62710fc fix(textarea): use x/ansi to strip ansi sequences 2024-05-23 15:01:44 -04:00
Michael LorantandMaas Lalani 48dffdd97e refactor(textarea): Improve setting width
When setting the width of the textarea there were some issues
preventing this from working correctly. These problems included:

- If the maximum width needed to be used, the width of the textarea did
  not take into account the prompt and line number width.
- The viewport width did not take into account the style width.

The entire function was confusing to understand and a refactor was
warranted.

As part of this refactor, the bugs mentioned above were fixed and the
code was simplified.

To verify that the logic works as expected, unit tests were expanded to
validate that setting the width works as expected.

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-04-06 01:37:46 -04:00
Michael LorantandGitHub b9e62cbfe1 Improve textarea tests (#490) 2024-03-08 19:23:05 -05:00
Michael LorantandGitHub 6c9e52a8fd Fix end of buffer character (#491) 2024-02-29 10:29:45 -05:00
Travis HarrisonandGitHub 9fb83699e9 feat(textarea): add help to textarea key bindings (#418) 2024-02-28 11:38:47 -05:00
Maas Lalani c94f0cc151 fix(textarea): end of buffer alignment 2024-02-28 10:57:49 -05:00
Michael LorantandMaas Lalani e985ec9f15 Add tests for textarea view
Add improved unit tests for textarea view function.

The end of buffer unit test was flawed and failed to properly check
whether the end of buffer character was in the correct location. This
test has been removed as this feature is now verified as part of these
test cases.

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-02-28 10:49:34 -05:00
Christian MuehlhaeuserandMaas Lalani d98bf9db0a fix(textarea): correctly trim incoming paste 2024-01-28 12:11:46 -05:00
6fe92f94b5 perf(textarea): implement wrapping memoization
* Improve textarea performance by caching the wrap results

* Add memoization utility

* Fix failing github jobs due to requirement for 1.18

* Address linting issues

* Fix redundant docstrings

* fix: minor changes to memoization

* fix: soft-wrapped hidden line numbers

* perf: switch to `uniseg.StringWidth`

---------

Co-authored-by: Maas Lalani <maas@lalani.dev>
2024-01-22 13:30:34 -05:00
remiposoandGitHub 9266653c39 Reset blink only when CursorBlink (#378) 2023-05-13 12:56:18 -04:00
Raphael 'kena' PossandMaas Lalani afb975b469 feat(textarea): make max width/height configurable 2023-05-01 13:06:34 -04:00
Glenn GondaandChristian Rocha 3d3ed883d3 docs: fix typos and improve comment clarity 2023-02-16 17:49:32 -05:00
Raphael 'kena' PossandMaas Lalani ee382285e7 fix(textarea): fix data corruption after multi-line input
Previously, when inserting multiple lines of input at once, the underlying
Go data array was incorrectly shared in memory across multiple rows
of the textarea. This was causing input corruption, where a user trying
to modify one line would see their text added on the next line as well.

This patch fixes it.
2023-02-05 10:19:05 -08:00
Raphael 'kena' PossandMaas Lalani db06ae17d3 fix(textarea): support pastes that end with a newline character
My previous fix did not properly handle a multi-rune input that *ends*
with a newline character. In that case, the final newline was removed.

I found this using the test suite I built for textarea in bubbline at
https://github.com/knz/bubbline/tree/main/editline/internal/textarea/testdata.
2023-01-24 14:19:14 -05:00
a6a12c4a31 fix(textarea): app would crash if deleteWordRight was called at the end of line (#313)
* fix(textarea): app would crash if deleteWordRight was called at the end
of line

* fix(textarea): deleteWordRight would work incorrectly

Co-authored-by: infastin <thecookied123@gmail.com>
2023-01-23 13:10:21 -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
hhe07andGitHub b2b7040ccf fix(textarea): paste (#250) 2022-10-06 15:54:43 -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 a4ed54327f chore: move cursor bubble to internal 2022-09-14 15:45:51 -04:00
Raphael 'kena' PossandMaas Lalani 09e1f00349 textarea: support dynamic prompts
The dynamic prompt can be different on every line.
See for example:
[![asciicast](https://asciinema.org/a/iFBPBwoDZOzcoRJOgfmPk8ObH.svg)](https://asciinema.org/a/iFBPBwoDZOzcoRJOgfmPk8ObH)
2022-09-02 14:31:26 -04:00
Raphael 'kena' PossandMaas Lalani c099d31570 textarea: add some comments 2022-09-02 14:31:26 -04:00
Raphael 'kena' PossandMaas Lalani db2a8b4e16 textarea: new bindings for "go to begin" / "go to end" 2022-09-02 13:44:52 -04:00
kenaandGitHub 1c26128786 textarea: add uppercase/lowercase/capitalize word right (#210)
* Extract char navigation in separate function.

* Make wordLeft/wordRight find words on the prev/next line

... if there's no word on the current line to find any more.

* Support uppercase/lowercase/capitalize commands.

* Add transpose
2022-08-19 11:17:36 -04:00
kenaandGitHub 649f78e1fd fix(textarea): pre-allocation of value (#213)
The maximum slice size of m.value is the max number of rows,
which is the max height.
2022-08-15 10:25:20 -04:00
kenaandGitHub e72e4a190b perf(textarea): amortize heap allocs in Value (#212) 2022-08-15 10:24:54 -04:00
Maas Lalani e200bf8c81 feat: LineCount method for counting number of lines in textarea 2022-08-05 16:37:05 -04:00
Maas Lalani 47eee84147 fix: include new line characters for Length() 2022-08-05 16:37:05 -04:00
Maas Lalani 84eacf535a fix: CharLimit <= 0 should be ignored 2022-08-04 14:52:50 -04:00
Maas LalaniandGitHub 746ec595c3 fix(textarea): change placeholder color to match textinput (#192) 2022-07-07 22:34:48 -04:00
Maas Lalani 3a34fc4ff8 fix(textarea): Add deleteWordRight 2022-07-05 14:26:22 -04:00
Maas Lalani 2a2fb10f5f fix(textarea): account for base styling frame when calculating width 2022-07-05 14:26:22 -04:00
Maas Lalani 2fd583c8ef feat(textarea): Add multi-line text input 2022-06-28 12:29:24 -04:00