1package ui23import (4 tea "charm.land/bubbletea/v2"56 "src.rest/cat/012/internal/sheet"7 "src.rest/cat/012/internal/ui/formula"8 "src.rest/cat/012/internal/ui/suggest"9)1011// Formula suggestions and signatures are package suggest; here is what12// they ask of the model.1314// typeKey applies a line-editing key to the entry. Typing or deleting15// shows suggestions; moving the caret hides them, as in Sheets.16func (m *Model) typeKey(k tea.KeyPressMsg) {17 before := m.line.Text()18 m.line.Key(k)19 m.entry.assist = suggest.List{Active: m.line.Text() != before}20}2122// inFunction reports whether the caret is inside a known function's23// parentheses.24func (m *Model) inFunction() bool {25 _, ok := sheet.LookupFunc(formula.ScanCaret(m.storedFormula(m.line.Buf), m.line.Pos).Fn)26 return ok27}2829// inTable reports whether the caret is inside a structured reference's30// brackets, Sales[Am.31func (m *Model) inTable() bool {32 _, ok := suggest.InTable(m.storedFormula(m.line.Buf), m.line.Pos)33 return ok34}3536// The suggestions' host.3738// Typing reports whether an entry is being typed in the cell (ENTER or39// EDIT) with nothing open over it.40func (h host) Typing() bool {41 return (h.m.mode == modeEnter || h.m.mode == modeEdit) && h.m.overlay == nil42}4344func (h host) EntrySheet() *sheet.Sheet { return h.m.entrySheet() }45func (h host) Stored(buf []rune) []rune { return h.m.storedFormula(buf) }46func (h host) TextX() int { return formulaBarTextX() }