[PR #1141] feat: new BoxedPrimitive interface implemented by *Box #1138

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

📋 Pull Request Information

Original PR: https://github.com/rivo/tview/pull/1141
Author: @trakhimenok
Created: 1/8/2026
Status: 🔄 Open

Base: masterHead: boxed-interface


📝 Commits (1)

  • 4893286 feat: new BoxedPrimitive interface implemented by *Box

📊 Changes

3 files changed (+102 additions, -0 deletions)

View changed files

📝 box.go (+5 -0)
box_test.go (+89 -0)
boxed_primitive.go (+8 -0)

📄 Description

Resolve #1140

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

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

This PR introduces:

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

That is implemented by:

// 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

for _, p := range panels {
  p.GetBox().SetBorderColor(someColor)
}

I've added test but if needed I can remove them.

Let me know if I need to make any adjustments - I'm open to feedback.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rivo/tview/pull/1141 **Author:** [@trakhimenok](https://github.com/trakhimenok) **Created:** 1/8/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `boxed-interface` --- ### 📝 Commits (1) - [`4893286`](https://github.com/rivo/tview/commit/4893286e2696c3eb537cd2a26dcebeb4a96a20cf) feat: new BoxedPrimitive interface implemented by *Box ### 📊 Changes **3 files changed** (+102 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `box.go` (+5 -0) ➕ `box_test.go` (+89 -0) ➕ `boxed_primitive.go` (+8 -0) </details> ### 📄 Description Resolve #1140 Often we'd want to work with set of primitives that are boxed (e.g. have `*Box` field) This for example needed for managing borders state/color in general way in multi-panels layout. This PR introduces: ```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 } ``` That is implemented by: ```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 for _, p := range panels { p.GetBox().SetBorderColor(someColor) } ``` I've added test but if needed I can remove them. Let me know if I need to make any adjustments - I'm open to feedback. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1138
No description provided.