mirror of
https://github.com/rivo/tview.git
synced 2024-11-07 03:20:39 +00:00
17 lines
534 B
Go
17 lines
534 B
Go
package main
|
|
|
|
import "github.com/rivo/tview"
|
|
|
|
// Center returns a new primitive which shows the provided primitive in its
|
|
// center, given the provided primitive's size.
|
|
func Center(width, height int, p tview.Primitive) tview.Primitive {
|
|
return tview.NewFlex().
|
|
AddItem(tview.NewBox(), 0, 1, false).
|
|
AddItem(tview.NewFlex().
|
|
SetDirection(tview.FlexRow).
|
|
AddItem(tview.NewBox(), 0, 1, false).
|
|
AddItem(p, height, 1, true).
|
|
AddItem(tview.NewBox(), 0, 1, false), width, 1, true).
|
|
AddItem(tview.NewBox(), 0, 1, false)
|
|
}
|