// Draw implements gruid.Model.Draw for TextInput.
Draw implements gruid.Model.Draw for TextInput.
// Draw implements gruid . Model . Draw for TextInput .
func (ti *TextInput) Draw() gruid.Grid {
	if !ti.dirty {
		return ti.drawn
	}
	cgrid := ti.grid
	if ti.box != nil {
		ti.box.Draw(ti.grid)
		rg := ti.grid.Range()
		cgrid = ti.grid.Slice(rg.Shift(1, 1, -1, -1))
	}
	cgrid.Fill(gruid.Cell{Rune: ' ', Style: ti.stt.Style()})
	ti.prompt.Draw(cgrid)
	crg := cgrid.Range()
	start := ti.start()
	ti.stt.WithText(string(ti.content[start:])).Draw(cgrid.Slice(crg.Shift(ti.cursorMin, 0, 0, 0)))
	ti.stt.With(string(ti.cursorRune()), ti.style.Cursor).Draw(cgrid.Slice(crg.Shift(ti.cursorMin+ti.cursor-start, 0, 0, 0)))
	ti.dirty = false
	ti.drawn = ti.grid
	return ti.drawn
}
func ( ti * TextInput ) Draw ( ) gruid . Grid { if ! ti . dirty { return ti . drawn } cgrid := ti . grid if ti . box != nil { ti . box . Draw ( ti . grid ) rg := ti . grid . Range ( ) cgrid = ti . grid . Slice ( rg . Shift ( 1 , 1 , - 1 , - 1 ) ) } cgrid . Fill ( gruid . Cell { Rune : ' ' , Style : ti . stt . Style ( ) } ) ti . prompt . Draw ( cgrid ) crg := cgrid . Range ( ) start := ti . start ( ) ti . stt . WithText ( string ( ti . content [ start : ] ) ) . Draw ( cgrid . Slice ( crg . Shift ( ti . cursorMin , 0 , 0 , 0 ) ) ) ti . stt . With ( string ( ti . cursorRune ( ) ) , ti . style . Cursor ) . Draw ( cgrid . Slice ( crg . Shift ( ti . cursorMin + ti . cursor - start , 0 , 0 , 0 ) ) ) ti . dirty = false ti . drawn = ti . grid return ti . drawn }
Draw implements gruid.Model.Draw for TextInput.
Draw implements gruid . Model . Draw for TextInput .