2017-12-30 21:10:13 +00:00
|
|
|
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().
|
2020-08-18 12:03:38 +00:00
|
|
|
AddItem(nil, 0, 1, false).
|
2017-12-30 21:10:13 +00:00
|
|
|
AddItem(tview.NewFlex().
|
|
|
|
SetDirection(tview.FlexRow).
|
2020-08-18 12:03:38 +00:00
|
|
|
AddItem(nil, 0, 1, false).
|
2017-12-30 21:10:13 +00:00
|
|
|
AddItem(p, height, 1, true).
|
2020-08-18 12:03:38 +00:00
|
|
|
AddItem(nil, 0, 1, false), width, 1, true).
|
|
|
|
AddItem(nil, 0, 1, false)
|
2017-12-30 21:10:13 +00:00
|
|
|
}
|