Textarea #59

Open
opened 1 year ago by flowchartsman · 2 comments

A longstanding issue with tview has been its lack of a "textarea-style" multiline form input. While the difficulties implementing it seem valid enough, it's been two years and there's no good solution that does not require a heavy lift like femto or gemacs or languishing PRs, and even hacking around it by shelling out to vim is a non-starter because of deadlock issues, which, incidentally, plagues cview as well

It would be wonderful to have literally any method of allowing the user to specify multiple lines in some kind of structured way, but right now it just can't be done, save for perhaps prompting them with a modal and an inputfield to load a text file, but forcing them to have two windows open just to get work done feels like a bridge too far.

A [longstanding issue](https://github.com/rivo/tview/issues/64) with tview has been its lack of a "textarea-style" multiline form input. While the difficulties implementing it seem valid enough, it's been two years and there's no good solution that does not require a heavy lift like [femto](https://github.com/pgavlin/femto) or [gemacs](https://github.com/glycerine/gemacs) or [languishing PRs](https://github.com/rivo/tview/pull/447), and even hacking around it by shelling out to vim is a non-starter because of [deadlock issues](https://github.com/rivo/tview/issues/244), which, incidentally, [plagues cview as well](https://code.rocketnine.space/tslocum/cview/issues/58) It would be wonderful to have literally any method of allowing the user to specify multiple lines in some kind of structured way, but right now it just can't be done, save for perhaps prompting them with a modal and an inputfield to load a text file, but forcing them to have two windows open just to get work done feels like a bridge too far.
tslocum added the
enhancement
label 1 year ago
Owner

rivo has a valid point about there being inherent bugs in how the text is iterated as runes rather than graphemes in this PR. If that were fixed I would be glad to merge the PR. It might be easier to add multi-line support directly to InputField. I will spend some time looking to each.

rivo has a valid point about there being inherent bugs in how the text is iterated as runes rather than graphemes in this PR. If that were fixed I would be glad to merge the PR. It might be easier to add multi-line support directly to InputField. I will spend some time looking to each.
Poster

LOL, I was just posting here to say that I took a crack at the conversion, and even hacking to see if it would work involved nastiness like:

func (f *TextArea) deleteRune() (newLine, newPos int) {
	// get position cursor in buffer
	line, pos := f.cursorByScreen()
	if pos == 0 && line == 0 {
		return
	}
	index := f.view.index[line]
	runes := []rune(string(f.view.buffer[index.Line]))
	if 0 < pos && pos < len(f.view.buffer[index.Line])+1 {

Which would make iterating on improvements afterwards relatively nightmarish. Your suspicion of extending InputField is starting to sound correct.

LOL, I was just posting here to say that I took a crack at the conversion, and even hacking to see if it would work involved nastiness like: ```go func (f *TextArea) deleteRune() (newLine, newPos int) { // get position cursor in buffer line, pos := f.cursorByScreen() if pos == 0 && line == 0 { return } index := f.view.index[line] runes := []rune(string(f.view.buffer[index.Line])) if 0 < pos && pos < len(f.view.buffer[index.Line])+1 { ``` Which would make iterating on improvements afterwards relatively nightmarish. Your suspicion of extending InputField is starting to sound correct.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.