func (i *InputField) Focus() {
	i.Gui.Cursor = true
	i.Gui.SetCurrentView(i.label.text)
}
Focus focus to input field
package component
import (
	"fmt"
	"strings"
	"github.com/jroimartin/gocui"
)
type Margin struct {
	top  int
	left int
}
type InputField struct {
	*gocui.Gui
	label *Label
	field *Field
}
type Label struct {
	text      string
	width     int
	drawFrame bool
	*Position
	*Attributes
	margin *Margin
}
type Field struct {
	text      string
	width     int
	drawFrame bool
	handlers  Handlers
	margin    *Margin
	mask      bool
	editable  bool
	ctype     ComponentType
	*Position
	*Attributes
	*Validator
}
var labelPrefix = "label"
func NewInputField(gui *gocui.Gui, labelText string, x, y, labelWidth, fieldWidth int) *InputField {
	gui.Cursor = true
	lp := &Position{
		x,
		y,
		x + labelWidth + 1,
		y + 2,
	}
	fp := &Position{
		lp.W,
		lp.Y,
		lp.W + fieldWidth,
		lp.H,
	}
	label := &Label{
		text:     labelText,
		width:    labelWidth,
		Position: lp,
		Attributes: &Attributes{
			textColor:   gocui.ColorYellow,
			textBgColor: gocui.ColorDefault,
		},
		drawFrame: false,
		margin: &Margin{
			top:  0,
			left: 0,
		},
	}
	field := &Field{
		width:    fieldWidth,
		Position: fp,
		Attributes: &Attributes{
			textColor:   gocui.ColorBlack,
			textBgColor: gocui.ColorCyan,
		},
		handlers:  make(Handlers),
		drawFrame: false,
		margin: &Margin{
			top:  0,
			left: 0,
		},
		Validator: NewValidator(gui, label.text+"validator", fp.X, fp.Y+1, fp.W, fp.H+1),
		editable:  true,
		ctype:     TypeInputField,
	}
	i := &InputField{
		Gui:   gui,
		label: label,
		field: field,
	}
	return i
}
func (i *InputField) AddFieldAttribute(textColor, textBgColor, fgColor, bgColor gocui.Attribute) *InputField {
	i.field.Attributes = &Attributes{
		textColor:      textColor,
		textBgColor:    textBgColor,
		hilightColor:   fgColor,
		hilightBgColor: bgColor,
	}
	return i
}
func (i *InputField) AddLabelAttribute(textColor, textBgColor gocui.Attribute) *InputField {
	i.label.Attributes = &Attributes{
		textColor:   textColor,
		textBgColor: textBgColor,
	}
	return i
}
func (i *InputField) AddHandler(key Key, handler Handler) *InputField {
	i.field.handlers[key] = handler
	return i
}
func (i *InputField) AddMarginTop(top int) *InputField {
	i.label.margin.top += top
	i.field.margin.top += top
	return i
}
func (i *InputField) AddMarginLeft(left int) *InputField {
	i.label.margin.left += left
	i.field.margin.left += left
	return i
}
func (i *InputField) AddValidate(errMsg string, validate func(value string) bool) *InputField {
	i.field.AddValidate(errMsg, validate)
	return i
}
func (i *InputField) SetLabelBorder() *InputField {
	i.label.drawFrame = true
	return i
}
func (i *InputField) SetFieldBorder() *InputField {
	i.field.drawFrame = true
	return i
}
func (i *InputField) SetMask() *InputField {
	i.field.mask = true
	return i
}
func (i *InputField) SetMaskKeybinding(key Key) *InputField {
	if err := i.Gui.SetKeybinding(i.label.text, key, gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error {
		v.Mask ^= '*'
		return nil
	}); err != nil {
		panic(err)
	}
	return i
}
func (i *InputField) SetText(text string) *InputField {
	i.field.text = text
	return i
}
func (i *InputField) SetCursor(b bool) *InputField {
	i.Gui.Cursor = b
	return i
}
func (i *InputField) SetEditable(b bool) *InputField {
	i.field.editable = b
	return i
}