[GH-ISSUE #933] Change List border to single line #684

Open
opened 2026-03-04 01:07:01 +03:00 by kerem · 4 comments
Owner

Originally created by @abitrolly on GitHub (Jan 5, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/933

After calling list.SetBorder(true) (see the code below) the default width of https://pkg.go.dev/github.com/rivo/tview#List is double line.

image

I want to change that to single line, but can't find the API. There are two functions that may do this, but it is not clear what parameters they get and what is the effect.

If changing the style is possible, an example would be appreciated.

package main

import (
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	list := tview.NewList().
		AddItem("List item 1", "Some explanatory text", 'a', nil).
		AddItem("List item 2", "Some explanatory text", 'b', nil).
		AddItem("List item 3", "Some explanatory text", 'c', nil).
		AddItem("List item 4", "Some explanatory text", 'd', nil).
		AddItem("Quit", "Press to exit", 'q', func() {
			app.Stop()
		})
	list.SetBorder(true) // <-- this adds double borders
	if err := app.SetRoot(list, true).SetFocus(list).Run(); err != nil {
		panic(err)
	}
}
Originally created by @abitrolly on GitHub (Jan 5, 2024). Original GitHub issue: https://github.com/rivo/tview/issues/933 After calling `list.SetBorder(true)` (see the code below) the default width of https://pkg.go.dev/github.com/rivo/tview#List is double line. ![image](https://github.com/rivo/tview/assets/8781107/1360a57e-a43c-467b-bab1-c1ef114f95ad) I want to change that to single line, but can't find the API. There are two functions that may do this, but it is not clear what parameters they get and what is the effect. * https://pkg.go.dev/github.com/rivo/tview#Box.SetBorderAttributes * https://pkg.go.dev/github.com/rivo/tview#Box.SetBorderStyle If changing the style is possible, an example would be appreciated. ```go package main import ( "github.com/rivo/tview" ) func main() { app := tview.NewApplication() list := tview.NewList(). AddItem("List item 1", "Some explanatory text", 'a', nil). AddItem("List item 2", "Some explanatory text", 'b', nil). AddItem("List item 3", "Some explanatory text", 'c', nil). AddItem("List item 4", "Some explanatory text", 'd', nil). AddItem("Quit", "Press to exit", 'q', func() { app.Stop() }) list.SetBorder(true) // <-- this adds double borders if err := app.SetRoot(list, true).SetFocus(list).Run(); err != nil { panic(err) } } ```
Author
Owner

@abitrolly commented on GitHub (Jan 6, 2024):

Thanks for the confirmation that tview currently doesn't allow to set border drawing chars for separate components. )

Nice to see that it is already implemented in the fork. I think tview could adopt the BorderStyle structure.

https://github.com/digitallyserviced/tview/blob/digitally/borders.go#L5

I guess it is even possible to preserve existing properties of tcell.Style that is passed to current version of tview Box.SetBorderStyle(), so that API is backwards compatible.

<!-- gh-comment-id:1879597283 --> @abitrolly commented on GitHub (Jan 6, 2024): Thanks for the confirmation that `tview` currently doesn't allow to set border drawing chars for separate components. ) Nice to see that it is already implemented in the fork. I think `tview` could adopt the `BorderStyle` structure. https://github.com/digitallyserviced/tview/blob/digitally/borders.go#L5 I guess it is even possible to preserve existing properties of `tcell.Style` that is passed to current version of `tview` `Box.SetBorderStyle()`, so that API is backwards compatible.
Author
Owner

@abitrolly commented on GitHub (Jan 6, 2024):

Found #747 with the request to dynamically set border rules.

<!-- gh-comment-id:1879597872 --> @abitrolly commented on GitHub (Jan 6, 2024): Found #747 with the request to dynamically set border rules.
Author
Owner

@abitrolly commented on GitHub (Jan 8, 2024):

@digitallyserviced the biggest challenge in maintaining (public) libraries is to design interfaces in future compatible manner. Do not break things, and ensure that future extensibility is possible. I see that at least your Box.SetBorderStyle implementation breaks API, so that's one reason to avoid the change.

As for your other changes, they don't seem to be related to single or double line problem.

<!-- gh-comment-id:1880625975 --> @abitrolly commented on GitHub (Jan 8, 2024): @digitallyserviced the biggest challenge in maintaining (public) libraries is to design interfaces in future compatible manner. Do not break things, and ensure that future extensibility is possible. I see that at least your `Box.SetBorderStyle` implementation breaks API, so that's one reason to avoid the change. As for your other changes, they don't seem to be related to single or double line problem.
Author
Owner

@carpii commented on GitHub (Jan 17, 2024):

@digitallyserviced - You regularly promote your fork, and indeed you seem to have made a lot of improvements to it.

But the problem is, it's a big bunch of undocumented changes.
No serious developer is going to switch from an official repo to a random fork where none of the changes have been documented.

<!-- gh-comment-id:1894723351 --> @carpii commented on GitHub (Jan 17, 2024): @digitallyserviced - You regularly promote your fork, and indeed you seem to have made a lot of improvements to it. But the problem is, it's a big bunch of undocumented changes. No serious developer is going to switch from an official repo to a random fork where none of the changes have been documented.
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#684
No description provided.