Skip to content

[Feature request]: BoxedPrimitive interface #1140

@trakhimenok

Description

@trakhimenok

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions