diff --git a/form.go b/form.go index 32846a8..af46f53 100644 --- a/form.go +++ b/form.go @@ -84,11 +84,8 @@ type Form struct { // The label color. labelColor tcell.Color - // The background color of the input area. - fieldBackgroundColor tcell.Color - - // The text color of the input area. - fieldTextColor tcell.Color + // The style of the input area. + fieldStyle tcell.Style // The style of the buttons when they are not focused. buttonStyle tcell.Style @@ -115,8 +112,7 @@ func NewForm() *Form { Box: box, itemPadding: 1, labelColor: Styles.SecondaryTextColor, - fieldBackgroundColor: Styles.ContrastBackgroundColor, - fieldTextColor: Styles.PrimaryTextColor, + fieldStyle: tcell.StyleDefault.Background(Styles.ContrastBackgroundColor).Foreground(Styles.PrimaryTextColor), buttonStyle: tcell.StyleDefault.Background(Styles.ContrastBackgroundColor).Foreground(Styles.PrimaryTextColor), buttonActivatedStyle: tcell.StyleDefault.Background(Styles.PrimaryTextColor).Foreground(Styles.ContrastBackgroundColor), buttonDisabledStyle: tcell.StyleDefault.Background(Styles.ContrastBackgroundColor).Foreground(Styles.ContrastSecondaryTextColor), @@ -151,13 +147,20 @@ func (f *Form) SetLabelColor(color tcell.Color) *Form { // SetFieldBackgroundColor sets the background color of the input areas. func (f *Form) SetFieldBackgroundColor(color tcell.Color) *Form { - f.fieldBackgroundColor = color + f.fieldStyle = f.fieldStyle.Background(color) return f } // SetFieldTextColor sets the text color of the input areas. func (f *Form) SetFieldTextColor(color tcell.Color) *Form { - f.fieldTextColor = color + f.fieldStyle = f.fieldStyle.Foreground(color) + return f +} + +// SetFieldStyle sets the style of the input areas. Attributes are currently +// still ignored to maintain backwards compatibility. +func (f *Form) SetFieldStyle(style tcell.Style) *Form { + f.fieldStyle = style return f } @@ -570,12 +573,13 @@ func (f *Form) Draw(screen tcell.Screen) { if x+itemWidth >= rightLimit { itemWidth = rightLimit - x } + fieldTextColor, fieldBackgroundColor, _ := f.fieldStyle.Decompose() item.SetFormAttributes( labelWidth, f.labelColor, f.backgroundColor, - f.fieldTextColor, - f.fieldBackgroundColor, + fieldTextColor, + fieldBackgroundColor, ) // Save position.