Rename SetBorderPadding and GetBorderPadding as SetPadding and GetPadding

This commit is contained in:
Trevor Slocum 2020-10-26 10:41:47 -07:00
parent 7a5e47b598
commit 36671ba7d3
8 changed files with 28 additions and 13 deletions

View file

@ -19,6 +19,7 @@ v1.5.1 (WIP)
- Optimize TextView (writing is 90% faster, drawing is 50% faster)
- Remove return values from methods which return their primitive (breaks chaining)
- Remove Application.ForceDraw (Application.Draw may be called anywhere)
- Rename SetBorderPadding and GetBorderPadding as SetPadding and GetPadding
- Rename Pages as Panels
- Support bracketed paste mode via tcell

24
box.go
View file

@ -19,7 +19,7 @@ type Box struct {
// Whether or not the box is visible.
visible bool
// Border padding.
// Padding.
paddingTop, paddingBottom, paddingLeft, paddingRight int
// The border color when the box has focus.
@ -94,15 +94,15 @@ func NewBox() *Box {
return b
}
// GetBorderPadding returns the size of the borders around the box content.
func (b *Box) GetBorderPadding() (top, bottom, left, right int) {
// GetPadding returns the size of the padding around the box content.
func (b *Box) GetPadding() (top, bottom, left, right int) {
b.l.RLock()
defer b.l.RUnlock()
return b.paddingTop, b.paddingBottom, b.paddingLeft, b.paddingRight
}
// SetBorderPadding sets the size of the borders around the box content.
func (b *Box) SetBorderPadding(top, bottom, left, right int) {
// SetPadding sets the size of the padding around the box content.
func (b *Box) SetPadding(top, bottom, left, right int) {
b.l.Lock()
defer b.l.Unlock()
@ -578,3 +578,17 @@ func (b *Box) GetFocusable() Focusable {
return b.focus
}
// GetBorderPadding returns the size of the padding around the box content. It
// is provided for backwards compatibility. Application developers should use
// GetPadding instead.
func (b *Box) GetBorderPadding() (top, bottom, left, right int) {
return b.GetPadding()
}
// SetBorderPadding sets the size of the padding around the box content. It
// is provided for backwards compatibility. Application developers should use
// SetPadding instead.
func (b *Box) SetBorderPadding(top, bottom, left, right int) {
b.SetPadding(top, bottom, left, right)
}

View file

@ -34,7 +34,7 @@ func (c *ContextMenu) initializeList() {
c.list.SetWrapAround(true)
c.list.ShowFocus(false)
c.list.SetBorder(true)
c.list.SetBorderPadding(
c.list.SetPadding(
Styles.ContextMenuPaddingTop,
Styles.ContextMenuPaddingBottom,
Styles.ContextMenuPaddingLeft,

View file

@ -16,7 +16,7 @@ func Code(p cview.Primitive, width, height int, code string) cview.Primitive {
codeView := cview.NewTextView()
codeView.SetWrap(false)
codeView.SetDynamicColors(true)
codeView.SetBorderPadding(1, 1, 2, 0)
codeView.SetPadding(1, 1, 2, 0)
fmt.Fprint(codeView, code)
f := cview.NewFlex()

View file

@ -281,7 +281,7 @@ func Table(nextSlide func()) (title string, content cview.Primitive) {
code := cview.NewTextView()
code.SetWrap(false)
code.SetDynamicColors(true)
code.SetBorderPadding(1, 1, 2, 0)
code.SetPadding(1, 1, 2, 0)
list := cview.NewList()
@ -343,7 +343,7 @@ func Table(nextSlide func()) (title string, content cview.Primitive) {
}
list.ShowSecondaryText(false)
list.SetBorderPadding(1, 1, 2, 2)
list.SetPadding(1, 1, 2, 2)
var demoTableText = []struct {
text string

View file

@ -155,7 +155,7 @@ func TreeView(nextSlide func()) (title string, content cview.Primitive) {
treeCode.SetWrap(false)
treeCode.SetDynamicColors(true)
treeCode.SetText(strings.Replace(treeAllCode, "$$$", treeBasicCode, -1))
treeCode.SetBorderPadding(1, 1, 2, 0)
treeCode.SetPadding(1, 1, 2, 0)
flex := cview.NewFlex()
flex.AddItem(tree, 0, 1, true)

View file

@ -145,7 +145,7 @@ type Form struct {
// NewForm returns a new form.
func NewForm() *Form {
box := NewBox()
box.SetBorderPadding(1, 1, 1, 1)
box.SetPadding(1, 1, 1, 1)
f := &Form{
Box: box,

View file

@ -46,7 +46,7 @@ func NewModal() *Modal {
m.form.SetButtonBackgroundColor(Styles.PrimitiveBackgroundColor)
m.form.SetButtonTextColor(Styles.PrimaryTextColor)
m.form.SetBackgroundColor(Styles.ContrastBackgroundColor)
m.form.SetBorderPadding(0, 0, 0, 0)
m.form.SetPadding(0, 0, 0, 0)
m.form.SetCancelFunc(func() {
if m.done != nil {
m.done(-1, "")
@ -57,7 +57,7 @@ func NewModal() *Modal {
m.frame.SetBorder(true)
m.frame.SetBorders(0, 0, 1, 0, 0, 0)
m.frame.SetBackgroundColor(Styles.ContrastBackgroundColor)
m.frame.SetBorderPadding(1, 1, 1, 1)
m.frame.SetPadding(1, 1, 1, 1)
m.focus = m
return m