// NewTextInput returns a new text input with given configuration options.
NewTextInput returns a new text input with given configuration options.
// NewTextInput returns a new text input with given configuration options .
func NewTextInput(cfg TextInputConfig) *TextInput {
	ti := &TextInput{
		grid:   cfg.Grid,
		stt:    cfg.Text.WithMarkups(nil),
		box:    cfg.Box,
		prompt: cfg.Prompt,
		style:  cfg.Style,
		keys:   cfg.Keys,
	}
	stdefault := gruid.Style{}
	if ti.style.Cursor == stdefault {
		ti.style.Cursor = cfg.Text.Style()
		ti.style.Cursor.Bg, ti.style.Cursor.Fg = ti.style.Cursor.Fg, ti.style.Cursor.Bg
	}
	ti.cursorMin = ti.prompt.Size().X
	ti.content = []rune(ti.stt.Text())
	ti.cursor = len(ti.content)
	if ti.keys.Quit == nil {
		ti.keys.Quit = []gruid.Key{gruid.KeyEscape, gruid.KeyTab}
	}
	ti.dirty = true
	return ti
}
func NewTextInput ( cfg TextInputConfig ) * TextInput { ti := & TextInput { grid : cfg . Grid , stt : cfg . Text . WithMarkups ( nil ) , box : cfg . Box , prompt : cfg . Prompt , style : cfg . Style , keys : cfg . Keys , } stdefault := gruid . Style { } if ti . style . Cursor == stdefault { ti . style . Cursor = cfg . Text . Style ( ) ti . style . Cursor . Bg , ti . style . Cursor . Fg = ti . style . Cursor . Fg , ti . style . Cursor . Bg } ti . cursorMin = ti . prompt . Size ( ) . X ti . content = [ ] rune ( ti . stt . Text ( ) ) ti . cursor = len ( ti . content ) if ti . keys . Quit == nil { ti . keys . Quit = [ ] gruid . Key { gruid . KeyEscape , gruid . KeyTab } } ti . dirty = true return ti }
NewTextInput returns a new text input with given configuration options.
NewTextInput returns a new text input with given configuration options .
// not true reverse with terminal driver, but good enough as a default