Terminal-based user interface toolkit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 lines
613 B

package main
import "code.rocketnine.space/tslocum/cview"
// 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 cview.Primitive) cview.Primitive {
subFlex := cview.NewFlex()
subFlex.SetDirection(cview.FlexRow)
subFlex.AddItem(cview.NewBox(), 0, 1, false)
subFlex.AddItem(p, height, 1, true)
subFlex.AddItem(cview.NewBox(), 0, 1, false)
flex := cview.NewFlex()
flex.AddItem(cview.NewBox(), 0, 1, false)
flex.AddItem(subFlex, width, 1, true)
flex.AddItem(cview.NewBox(), 0, 1, false)
return flex
}