[GH-ISSUE #64] Feature request: textarea #43

Closed
opened 2026-03-04 01:01:22 +03:00 by kerem · 30 comments
Owner

Originally created by @uthng on GitHub (Mar 5, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/64

Hi,

I have just found your package. It is very interessting and I am trying to write an application with it.
I would like to know if there is any plan to create a texarea in the near future ?

Thanks.
NT

Originally created by @uthng on GitHub (Mar 5, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/64 Hi, I have just found your package. It is very interessting and I am trying to write an application with it. I would like to know if there is any plan to create a **texarea** in the near future ? Thanks. NT
kerem 2026-03-04 01:01:22 +03:00
Author
Owner

@rivo commented on GitHub (Mar 5, 2018):

Hi, glad you like it. I don't have concrete plans for a text area yet. I have been thinking about extending the TextView class to make it editable. However, adding that would get me very close to implementing a full text editor:

  • Adding/removing characters
  • Navigating the text (not trivial with automatic line breaks etc.)
  • Selecting areas, cutting/pasting (optional at first maybe)
  • Deal with TextView's color/region tags somehow
  • Rewriting the Form class so editable TextView objects can also be included (e.g. this could break the horizontal layout)

So it's not a minor thing to add. I could add an "on roadmap" label to this issue if this is something you definitely need. This would mean I will eventually add it. But it could then still be some time before that happens and I don't know how urgent your need is here. (See #23 for an example of an "on roadmap" feature.)

Do you have a specific use case where an InputField is not enough?

<!-- gh-comment-id:370372080 --> @rivo commented on GitHub (Mar 5, 2018): Hi, glad you like it. I don't have concrete plans for a text area yet. I have been thinking about extending the `TextView` class to make it editable. However, adding that would get me very close to implementing a full text editor: - Adding/removing characters - Navigating the text (not trivial with automatic line breaks etc.) - Selecting areas, cutting/pasting (optional at first maybe) - Deal with `TextView`'s color/region tags somehow - Rewriting the `Form` class so editable `TextView` objects can also be included (e.g. this could break the horizontal layout) So it's not a minor thing to add. I could add an "on roadmap" label to this issue if this is something you definitely need. This would mean I will eventually add it. But it could then still be some time before that happens and I don't know how urgent your need is here. (See #23 for an example of an "on roadmap" feature.) Do you have a specific use case where an `InputField` is not enough?
Author
Owner

@uthng commented on GitHub (Mar 5, 2018):

I have intention to use tview to write several console applications. And in some of them, I need to modify a value under JSON format for example. I understand that it is not easy to but I think it is necessary when we edit some complexe data such as json, html etc. I have been thinking about making TextView to be editable. But I have not really entered in the code yet.

<!-- gh-comment-id:370413616 --> @uthng commented on GitHub (Mar 5, 2018): I have intention to use tview to write several console applications. And in some of them, I need to modify a value under JSON format for example. I understand that it is not easy to but I think it is necessary when we edit some complexe data such as json, html etc. I have been thinking about making TextView to be editable. But I have not really entered in the code yet.
Author
Owner

@rivo commented on GitHub (Mar 5, 2018):

For your own project, you could probably come up with something simple by using TextView, intercepting key events with SetInputCapture(), and using regions and highlights to simulate a cursor.

TextView is already very complex. You can try to extend it but with so many things to consider -- and given that I have to maintain it in the long term -- I'm not sure I will merge any pull requests in that direction.

So I'm adding the "on roadmap" label. This means I will implement this but I don't know yet when. I will have to dedicate quite some time to it.

<!-- gh-comment-id:370424717 --> @rivo commented on GitHub (Mar 5, 2018): For your own project, you could probably come up with something simple by using `TextView`, intercepting key events with [`SetInputCapture()`](https://godoc.org/github.com/rivo/tview#Box.SetInputCapture), and using [regions and highlights](https://godoc.org/github.com/rivo/tview#TextView) to simulate a cursor. `TextView` is already very complex. You can try to extend it but with so many things to consider -- and given that I have to maintain it in the long term -- I'm not sure I will merge any pull requests in that direction. So I'm adding the "on roadmap" label. This means I will implement this but I don't know yet when. I will have to dedicate quite some time to it.
Author
Owner

@uthng commented on GitHub (Mar 5, 2018):

Yes, I think that I can manage in my projects so dont worry about when you
will implement it. Anyway, thanks to add "on roadmap" for this request
because it will be really nice to have it as a base element.


Thanh NGUYEN

On 5 March 2018 at 14:50, rivo notifications@github.com wrote:

For your own project, you could probably come up with something simple by
using TextView, intercepting key events with SetInputCapture()
https://godoc.org/github.com/rivo/tview#Box.SetInputCapture, and using regions
and highlights https://godoc.org/github.com/rivo/tview#TextView to
simulate a cursor.

TextView is already very complex. You can try to extend it but with so
many things to consider -- and given that I have to maintain it in the long
term -- I'm not sure I will merge any pull requests in that direction.

So I'm adding the "on roadmap" label. This means I will implement this but
I don't know yet when. I will have to dedicate quite some time to it.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/rivo/tview/issues/64#issuecomment-370424717, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AWQwr4LCdrEFSWgjQoG8QlUnxGCcvJoFks5tbUKfgaJpZM4Sb2jx
.

<!-- gh-comment-id:370556517 --> @uthng commented on GitHub (Mar 5, 2018): Yes, I think that I can manage in my projects so dont worry about when you will implement it. Anyway, thanks to add "on roadmap" for this request because it will be really nice to have it as a base element. ------------- Thanh NGUYEN On 5 March 2018 at 14:50, rivo <notifications@github.com> wrote: > For your own project, you could probably come up with something simple by > using TextView, intercepting key events with SetInputCapture() > <https://godoc.org/github.com/rivo/tview#Box.SetInputCapture>, and using regions > and highlights <https://godoc.org/github.com/rivo/tview#TextView> to > simulate a cursor. > > TextView is already very complex. You can try to extend it but with so > many things to consider -- and given that I have to maintain it in the long > term -- I'm not sure I will merge any pull requests in that direction. > > So I'm adding the "on roadmap" label. This means I will implement this but > I don't know yet when. I will have to dedicate quite some time to it. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/rivo/tview/issues/64#issuecomment-370424717>, or mute > the thread > <https://github.com/notifications/unsubscribe-auth/AWQwr4LCdrEFSWgjQoG8QlUnxGCcvJoFks5tbUKfgaJpZM4Sb2jx> > . >
Author
Owner

@glycerine commented on GitHub (Mar 10, 2018):

@uthng Just fyi, there is also a full blown editor atop of tcell, https://github.com/zyedidia/micro, which is MIT licensed and of course is quite tuned to editing text. With mouse support, copy-paste clipboard, macros, plugin system, highlighting, etc.

<!-- gh-comment-id:372030556 --> @glycerine commented on GitHub (Mar 10, 2018): @uthng Just fyi, there is also a full blown editor atop of tcell, https://github.com/zyedidia/micro, which is MIT licensed and of course is quite tuned to editing text. With mouse support, copy-paste clipboard, macros, plugin system, highlighting, etc.
Author
Owner

@glycerine commented on GitHub (Mar 11, 2018):

a full blown editor atop of tcell, https://github.com/zyedidia/micro

In addition to micro/if you prefer emacs keybindings, I have ported godit to Garrett's tcell, calling the result gemacs: https://github.com/glycerine/gemacs. It is an emacs written in pure Go. As it uses tcell, it should (at least, theoretically) be tview compatible.

<!-- gh-comment-id:372093229 --> @glycerine commented on GitHub (Mar 11, 2018): > a full blown editor atop of tcell, https://github.com/zyedidia/micro In addition to micro/if you prefer emacs keybindings, I have ported `godit` to Garrett's `tcell`, calling the result `gemacs`: https://github.com/glycerine/gemacs. It is an emacs written in pure Go. As it uses tcell, it should (at least, theoretically) be tview compatible.
Author
Owner

@ernierasta commented on GitHub (Jan 10, 2019):

Hi everyone, are there any news about textarea? I would like to use tview on my current project, but I need to be able to edit few lines of text. We already have controls working in inputbox, so maybe we are closer to have multiline inputbox?
I really want to avoid using gocui. ;-)

<!-- gh-comment-id:453081238 --> @ernierasta commented on GitHub (Jan 10, 2019): Hi everyone, are there any news about textarea? I would like to use tview on my current project, but I need to be able to edit few lines of text. We already have controls working in inputbox, so maybe we are closer to have multiline inputbox? I really want to avoid using gocui. ;-)
Author
Owner

@rivo commented on GitHub (Jan 24, 2019):

Apologies for taking so long but this is really a more complicated issue for which I currently don't seem to have the time. I will definitely add it but cannot give you a time frame for this.

Out of interest, in your application, would you need support for region and colour tags while editing? Or are you looking for a simple text-only editor here?

<!-- gh-comment-id:457174235 --> @rivo commented on GitHub (Jan 24, 2019): Apologies for taking so long but this is really a more complicated issue for which I currently don't seem to have the time. I will definitely add it but cannot give you a time frame for this. Out of interest, in your application, would you need support for region and colour tags while editing? Or are you looking for a simple text-only editor here?
Author
Owner

@ernierasta commented on GitHub (Jan 24, 2019):

@rivo no need for apology, it is open source, we all are working on it when we have time or/and we want!

I personally think, that simple text-only editor would be needed most of times. And in my app this is also the case, regions and color tags would not be used.

<!-- gh-comment-id:457340611 --> @ernierasta commented on GitHub (Jan 24, 2019): @rivo no need for apology, it is open source, we all are working on it when we have time or/and we want! I personally think, that simple text-only editor would be needed most of times. And in my app this is also the case, regions and color tags would not be used.
Author
Owner

@Bios-Marcel commented on GitHub (Feb 23, 2019):

I made something using regions and highlights, maybe this is useful to someone. The code is quite error prone and unperformant and it still has some bugs, but overall it works! I would not recommend something like this for editing big chunks of text. I might replace it with an actual tview component at some point though. And if I do, I'll create a PR.

record

The code can be found here: https://github.com/Bios-Marcel/cordless/blob/master/internal/ui/editor.go

<!-- gh-comment-id:466706656 --> @Bios-Marcel commented on GitHub (Feb 23, 2019): I made something using regions and highlights, maybe this is useful to someone. The code is quite error prone and unperformant and it still has some bugs, but overall it works! I would not recommend something like this for editing big chunks of text. I might replace it with an actual tview component at some point though. And if I do, I'll create a PR. ![record](https://user-images.githubusercontent.com/19377618/53292590-dbaa4e80-37c4-11e9-99dc-ecc5924336eb.gif) The code can be found here: https://github.com/Bios-Marcel/cordless/blob/master/internal/ui/editor.go
Author
Owner

@glycerine commented on GitHub (Feb 24, 2019):

@ernierasta https://github.com/glycerine/gemacs doesn't ship with rivo/tview, but that matters little. It uses tcell too and it would take a few trivial lines of code to use it as your textarea editor.

<!-- gh-comment-id:466716138 --> @glycerine commented on GitHub (Feb 24, 2019): @ernierasta https://github.com/glycerine/gemacs doesn't ship with rivo/tview, but that matters little. It uses tcell too and it would take a few trivial lines of code to use it as your textarea editor.
Author
Owner

@matheusd commented on GitHub (Mar 14, 2019):

@glycerine any chance you have a demo on hand with embedding either editor as a tview form field?

<!-- gh-comment-id:473051083 --> @matheusd commented on GitHub (Mar 14, 2019): @glycerine any chance you have a demo on hand with embedding either editor as a tview form field?
Author
Owner

@glycerine commented on GitHub (Mar 14, 2019):

@matheusd not off hand.

<!-- gh-comment-id:473054706 --> @glycerine commented on GitHub (Mar 14, 2019): @matheusd not off hand.
Author
Owner

@ernierasta commented on GitHub (Mar 15, 2019):

@glycerine @Bios-Marcel thank you both for valuable input! I will probably use one of given options. And I am joining to @matheusd question, example would be very welcome.

Thank you guys again!

<!-- gh-comment-id:473174207 --> @ernierasta commented on GitHub (Mar 15, 2019): @glycerine @Bios-Marcel thank you both for valuable input! I will probably use one of given options. And I am joining to @matheusd question, example would be very welcome. Thank you guys again!
Author
Owner

@matheusd commented on GitHub (Mar 15, 2019):

I tested @Bios-Marcel Editor impl, and while it does have issues, it seems reasonable for a first try.

The only thing I felt missing from it was being able to move up/down lines.

<!-- gh-comment-id:473252162 --> @matheusd commented on GitHub (Mar 15, 2019): I tested @Bios-Marcel `Editor` impl, and while it does have issues, it seems reasonable for a first try. The only thing I felt missing from it was being able to move up/down lines.
Author
Owner

@lhanson commented on GitHub (Sep 21, 2019):

Rather than implement editor functionality in tview, would it make more sense to simply punt to using $EDITOR? That way whatever workflow/bindings the user is already accustomed to works seamlessly.

<!-- gh-comment-id:533812985 --> @lhanson commented on GitHub (Sep 21, 2019): Rather than implement editor functionality in tview, would it make more sense to simply punt to using $EDITOR? That way whatever workflow/bindings the user is already accustomed to works seamlessly.
Author
Owner

@ernierasta commented on GitHub (Sep 21, 2019):

@lhanson that is not what this ticket is about. You can probably do what You describe right now. We are talking about textarea here. It is similar to box You put Your comment in, it has multiple lines and at least some basic editing capabilities. You need to have it forms in app, not as separate thing. But thank You for stopping by. :-)

<!-- gh-comment-id:533820302 --> @ernierasta commented on GitHub (Sep 21, 2019): @lhanson that is not what this ticket is about. You can probably do what You describe right now. We are talking about textarea here. It is similar to box You put Your comment in, it has multiple lines and at least some basic editing capabilities. You need to have it forms in app, not as separate thing. But thank You for stopping by. :-)
Author
Owner

@pgavlin commented on GitHub (Oct 28, 2019):

I've just posted femto, a tview-compatible editor component derived from the micro editor. The API is a work-in-progress, but I think the basics should work.

<!-- gh-comment-id:546757966 --> @pgavlin commented on GitHub (Oct 28, 2019): I've just posted [femto](https://github.com/pgavlin/femto), a `tview`-compatible editor component derived from [the micro editor](https://github.com/pgavlin/femto/blob/master/github.com/zyedidia/micro). The API is a work-in-progress, but I think the basics should work.
Author
Owner

@ernierasta commented on GitHub (Oct 28, 2019):

Great work @pgavlin! Thank you for letting us know!

<!-- gh-comment-id:546829498 --> @ernierasta commented on GitHub (Oct 28, 2019): Great work @pgavlin! Thank you for letting us know!
Author
Owner

@Bios-Marcel commented on GitHub (Oct 28, 2019):

Thanks for letting us know, I'll keep and eye on it and might use it :D

<!-- gh-comment-id:546838468 --> @Bios-Marcel commented on GitHub (Oct 28, 2019): Thanks for letting us know, I'll keep and eye on it and might use it :D
Author
Owner

@millerlogic commented on GitHub (Feb 6, 2020):

I've just posted femto

Hey @pgavlin thanks for that! I've used femto with ssh paste.run
I'll probably be forking and making some pull requests.

<!-- gh-comment-id:582709879 --> @millerlogic commented on GitHub (Feb 6, 2020): > I've just posted [femto](https://github.com/pgavlin/femto) Hey @pgavlin thanks for that! I've used femto with ```ssh paste.run``` I'll probably be forking and making some pull requests.
Author
Owner

@7onetella commented on GitHub (Feb 27, 2020):

@rivo thank you for creating a wonderful library for tui. I am using your library with my project here.

https://github.com/7onetella/minidoc

for one liner I use TextInput, for multiple lines, I exec to VIM, and back.

I am happy with using VIM for multiline edit but not everyone is comfortable with VIM.

it would be nice to have textarea for sure but I understand that you have a normal busy life like the rest of us. thank you anyway.

<!-- gh-comment-id:592132079 --> @7onetella commented on GitHub (Feb 27, 2020): @rivo thank you for creating a wonderful library for tui. I am using your library with my project here. https://github.com/7onetella/minidoc for one liner I use TextInput, for multiple lines, I exec to VIM, and back. I am happy with using VIM for multiline edit but not everyone is comfortable with VIM. it would be nice to have textarea for sure but I understand that you have a normal busy life like the rest of us. thank you anyway.
Author
Owner

@Konstantin8105 commented on GitHub (May 14, 2020):

Add minimal PR #447 with multi-line text editor or TextArea

<!-- gh-comment-id:628892506 --> @Konstantin8105 commented on GitHub (May 14, 2020): Add minimal PR #447 with multi-line text editor or `TextArea`
Author
Owner

@flowchartsman commented on GitHub (Apr 22, 2021):

Is anyone aware of another widget (in any repo) that implements this functionality, even in a very basic way? I fully understand the difficulties in doing an implementation "the right way", and I excitedly await a more official "textarea" from @rivo, but I have found myself 99% of the way through an application and blocked by the the need for a simple, multiline input, and I cannot make it work. Femto is too heavy, #447 requires forking (i.e. I can't isolate it as an internal import because it depends too heavily on internal changes and dependencies), and shelling out to $editor is completely broken, at least for me. I don't need much, and can hack quite easily around anything more than "a box that I can shuffle text around in", but I also don't want to dive into a rabbit hole making a new widget when I have been able to get so far without diving into internals at all. I am at the point where I am considering vendoring the entire library with a diff of #447 overlaid on top of it just to get this one piece of functionality, so I am asking here as a last resort.

<!-- gh-comment-id:825224503 --> @flowchartsman commented on GitHub (Apr 22, 2021): Is anyone aware of another widget (in any repo) that implements this functionality, even in a very basic way? I fully understand the difficulties in doing an implementation "the right way", and I excitedly await a more official "textarea" from @rivo, but I have found myself 99% of the way through an application and blocked by the the need for a simple, multiline input, and I cannot make it work. Femto is too heavy, #447 requires forking (i.e. I can't isolate it as an internal import because it depends too heavily on internal changes and dependencies), and shelling out to `$editor` is [completely broken](https://github.com/rivo/tview/issues/244), at least for me. I don't need much, and can hack quite easily around anything more than "a box that I can shuffle text around in", but I also don't want to dive into a rabbit hole making a new widget when I have been able to get so far without diving into internals at all. I am at the point where I am considering vendoring the entire library with a diff of #447 overlaid on top of it just to get this one piece of functionality, so I am asking here as a last resort.
Author
Owner

@glycerine commented on GitHub (Apr 22, 2021):

@flowchartsman see my comment above. https://github.com/glycerine/gemacs

<!-- gh-comment-id:825227152 --> @glycerine commented on GitHub (Apr 22, 2021): @flowchartsman see my comment above. https://github.com/glycerine/gemacs
Author
Owner

@flowchartsman commented on GitHub (Apr 22, 2021):

@glycerine, I did (by the way, love your libraries), but, like you mentioned above in 2018, there's no quick example of embedding it as a widget and when I looked at the repo I was a little daunted by the complexity, and you appear to vendor tcell as well, so I honestly didn't consider it an option and looked elsewhere. Perhaps I should take another look, though some more guidance would be helpful.

<!-- gh-comment-id:825231043 --> @flowchartsman commented on GitHub (Apr 22, 2021): @glycerine, I did (by the way, love your libraries), but, like you mentioned above in 2018, there's no quick example of embedding it as a widget and when I looked at the repo I was a little daunted by the complexity, and you appear to vendor tcell as well, so I honestly didn't consider it an option and looked elsewhere. Perhaps I should take another look, though some more guidance would be helpful.
Author
Owner

@glycerine commented on GitHub (Apr 22, 2021):

Sorry, its been too long. You'll have to dive in, I'm afraid. The rabbit hole is likely very shallow though with gemacs an micro examples.

<!-- gh-comment-id:825270812 --> @glycerine commented on GitHub (Apr 22, 2021): Sorry, its been too long. You'll have to dive in, I'm afraid. The rabbit hole is likely very shallow though with gemacs an micro examples.
Author
Owner

@rivo commented on GitHub (May 4, 2021):

Please check out #594

<!-- gh-comment-id:831863554 --> @rivo commented on GitHub (May 4, 2021): Please check out #594
Author
Owner

@golangdojo99 commented on GitHub (Sep 27, 2022):

This issue should be closed now that the TextArea widget has been implemented.

<!-- gh-comment-id:1259228949 --> @golangdojo99 commented on GitHub (Sep 27, 2022): This issue should be closed now that the `TextArea` widget has been implemented.
Author
Owner

@rivo commented on GitHub (Dec 11, 2022):

See #594

<!-- gh-comment-id:1345594440 --> @rivo commented on GitHub (Dec 11, 2022): See #594
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#43
No description provided.