|
|
@ -81,6 +81,9 @@ type model struct { |
|
|
|
datasheetsLoaded bool // Whether or not the datasheets are loaded or not
|
|
|
|
datasheetViewport viewport.Model // Viewport for the PDF content
|
|
|
|
datasheetViewportStyle lipgloss.Style // Style to show while showing datasheet viewport
|
|
|
|
|
|
|
|
indexSpinner spinner.Model // Spinner to show that content indexes are being loaded
|
|
|
|
querySpinner spinner.Model // Spinner to show that content is being queried
|
|
|
|
} |
|
|
|
|
|
|
|
// datasheetFromName retrieves a datasheet via a name.
|
|
|
@ -209,6 +212,18 @@ func (m model) Init() tea.Cmd { |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
// filterDatasheetContents filters datasheet by content from user input.
|
|
|
|
func filterDatasheetContents(m model) []string { |
|
|
|
// TODO: implement indexing work beforehand
|
|
|
|
// wait for datasheetsLoaded to go true
|
|
|
|
// then iterate m.datasheets and index them
|
|
|
|
//
|
|
|
|
// for this function, catch 3 chars or more in the textinput
|
|
|
|
// start the query, fire the spinner and block any other queries
|
|
|
|
// coming in. return the list hits that come back from the query
|
|
|
|
return []string{} |
|
|
|
} |
|
|
|
|
|
|
|
// filterDatasheetNames filters datasheet names based on user input.
|
|
|
|
func filterDatasheetNames(m model) []string { |
|
|
|
search := m.input.Value() |
|
|
@ -246,7 +261,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
|
|
|
cmds = append(cmds, cmd) |
|
|
|
|
|
|
|
if m.input.Focused() && m.datasheetsLoaded { |
|
|
|
m.filteredDatasheets = filterDatasheetNames(m) |
|
|
|
if m.filterMode == filenameFilterMode { |
|
|
|
m.filteredDatasheets = filterDatasheetNames(m) |
|
|
|
} else { |
|
|
|
m.filteredDatasheets = filterDatasheetContents(m) |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: implement cursor for scrolling up/down filtered
|
|
|
|
// results so we can view the PDF contents as desired
|
|
|
|