[GH-ISSUE #1140] [Feature request]: BoxedPrimitive interface #828

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

Originally created by @trakhimenok on GitHub (Jan 8, 2026).
Original GitHub issue: https://github.com/rivo/tview/issues/1140

Often we'd want to work with set of primitives that are boxed (e.g. have *Box)

This for example needed for managing borders state/color in general way in multi-panels layout.

I suggest we define:

// BoxedPrimitive defines a primitive with a Box
// It's implemented by Box and any type that has *Box field
type BoxedPrimitive interface {
	Primitive
	GetBox() *Box
}

And implement it once as:

// GetBox returns the box itself implementing the BoxedPrimitive interface.
func (b *Box) GetBox() *Box {
	return b
}

This allows to have code like:

var panels := []tview.BoxedPrimitive = { tview.NewTextView(), tview.NewList(), tview.NewTable()}

for _, p := range panels {
  p.GetBox().SetBorderColor(someColor)
}
Originally created by @trakhimenok on GitHub (Jan 8, 2026). Original GitHub issue: https://github.com/rivo/tview/issues/1140 Often we'd want to work with set of primitives that are boxed (e.g. have `*Box`) This for example needed for managing borders state/color in general way in multi-panels layout. I suggest we define: ```go // BoxedPrimitive defines a primitive with a Box // It's implemented by Box and any type that has *Box field type BoxedPrimitive interface { Primitive GetBox() *Box } ``` And implement it once as: ```go // GetBox returns the box itself implementing the BoxedPrimitive interface. func (b *Box) GetBox() *Box { return b } ``` This allows to have code like: ```go var panels := []tview.BoxedPrimitive = { tview.NewTextView(), tview.NewList(), tview.NewTable()} for _, p := range panels { p.GetBox().SetBorderColor(someColor) } ```
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#828
No description provided.