-
-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Adding TextViews or other Primitives into List #228
Comments
I have looked into Regions. There isn't a method to change Region texts afaik. |
I understand you want to have a way to edit the content of a As for your suggestion, I'm not sure how having a If this is not what you're looking for, I'm afraid I'll need more information. Maybe you can construct a screenshot or something that illustrates what you're looking for. |
A list strips newlines off of subtitles for me, so it's not viable. Thanks for your help though. |
Again, it seems I have trouble understanding your requirement. I'll leave this issue open for a while so you can post more information that may help me come up with a solution for you. |
Regarding just the ListView part of my "requirement": package main
import (
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication()
list := tview.NewList().
AddItem("List item 1", "New line \ndoesn't work", ' ', nil).
AddItem("List item 2", "Another\nexample\nwith\n4 lines", ' ', nil).
AddItem("Quit", "Press to exit", 'q', func() {
app.Stop()
})
if err := app.SetRoot(list, true).Run(); err != nil {
panic(err)
}
} I figured if we could have a TextView box for the ListView elements instead of individual strings, that would allow for more things such as colors, formatting and new lines (which is what the issue is in the example). |
Apologies for the late reply. Colors are allowed in lists: package main
import (
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication()
list := tview.NewList().
AddItem("List item 1", "[red]Colors[green] are allowed", 0, nil).
AddItem("Quit", "Press to exit", 'q', func() {
app.Stop()
})
if err := app.SetRoot(list, true).Run(); err != nil {
panic(err)
}
} I think the main issue is allowing multi-line list items. I'm not sure I will add this to a package main
import (
"fmt"
"strconv"
"strings"
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication()
textView := tview.NewTextView().
SetRegions(true)
items := []string{
"This is the first list item",
"This is the second list item",
"This is a list\nitem split into three\ndifferent lines",
"This is a list item\nsplit into two lines",
}
currentItem := 2
// Generate text view string.
formattedItems := make([]string, len(items))
for index, item := range items {
formattedItems[index] = fmt.Sprintf(`["%d"]%s[""]`, index, item)
}
// Set text view content.
textView.SetText(strings.Join(formattedItems, "\n")).
Highlight(strconv.Itoa(currentItem))
if err := app.SetRoot(textView, true).Run(); err != nil {
panic(err)
}
} But your first comment in this thread mentioned "editing" list items. So I'm not quite sure if this would cover everything you want to do. |
Thanks for replying. While developing my app, I have found out I could simply store the messages in an array and override the TextView when there's an edit. I thought the performance would be crap like in any GUI app I've ever worked with, but it turns out it worked really well. |
That's great. Thanks for the feedback. |
Hello. I'm programming an application that requires changing live text data on the screen. Right now, I have one large TextView box that's formatted. However, I can't edit an existing text without seeking over the entire View.
It would be nice if there's a way to add small TextViews as List entries and set a unique identifier for them, so it's easier to iterate and replace the entry alone instead of the entire box.
The text was updated successfully, but these errors were encountered: