search

package
v0.3.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 49 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package search is the launcher's search: one ranked list across providers (apps, windows, files, answers, ...), frecency that learns, levels you enter and leave, and the actions of a selected row. Pure logic and effects behind small interfaces, no widgets; the panel that shows it is shell/launcher's. Everything here runs on the session's engine goroutine or a provider's own, never on the UI loop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FrecencyPath

func FrecencyPath() (string, bool)

FrecencyPath is where uses are remembered.

func SkinToneName added in v0.3.15

func SkinToneName(tone modes.SkinTone) config.LauncherSkinTone

SkinToneName is tone as the config spells it.

func SkinToneOf added in v0.3.15

func SkinToneOf(name config.LauncherSkinTone) modes.SkinTone

SkinToneOf is the config's skin tone as emoji take it.

Types

type Action

type Action struct {
	// Title names it in the panel and the footer.
	Title string
	// Icon leads its row in the actions panel.
	Icon string
	// Key runs it straight from the list, without the actions panel.
	Key ActionKey
	// Run does it.
	Run func(ctx context.Context) Outcome
}

Action is one thing to do with a row. Run happens on the engine goroutine: it may wait for the world, and the panel stays live.

type ActionKey added in v0.3.15

type ActionKey uint8

ActionKey is a key that runs a row's action from the list itself.

const (
	// ActionKeyNone is an action reached through the actions panel only.
	ActionKeyNone ActionKey = iota
	// ActionKeyDelete is Ctrl+Backspace: remove what the row stands for.
	ActionKeyDelete
)

func (ActionKey) Label added in v0.3.15

func (k ActionKey) Label() string

Label is the key as the actions panel shows it, "" for none.

type Answerer

type Answerer interface {
	Answer(query string) []Entry
}

Answerer is a provider whose rows answer the query rather than being searched through (a calculation, a web search). Answer runs on every query on the engine goroutine, so it must be quick.

type Apps

type Apps struct {
	// contains filtered or unexported fields
}

Apps offers the desktop entries, links included.

func NewApps

func NewApps(env Env, dirs []string) *Apps

NewApps searches dirs (desktopentry.ApplicationDirs).

func (*Apps) Actions

func (a *Apps) Actions(e Entry) []Action

Actions implements Provider.

func (*Apps) Load

func (a *Apps) Load(_ context.Context, publish func([]Entry))

Load implements Provider.

func (*Apps) Spec

func (*Apps) Spec() Spec

Spec implements Provider.

type Bookmarks added in v0.3.5

type Bookmarks struct {
	// contains filtered or unexported fields
}

Bookmarks offers the browsers' bookmarks.

func NewBookmarks added in v0.3.5

func NewBookmarks(env Env, index *BrowserIndex) *Bookmarks

NewBookmarks offers the bookmarks index holds.

func (*Bookmarks) Actions added in v0.3.5

func (b *Bookmarks) Actions(e Entry) []Action

Actions implements Provider.

func (*Bookmarks) Load added in v0.3.5

func (b *Bookmarks) Load(ctx context.Context, publish func([]Entry))

Load implements Provider.

func (*Bookmarks) Spec added in v0.3.5

func (b *Bookmarks) Spec() Spec

Spec implements Provider.

type BrowserIndex added in v0.3.5

type BrowserIndex struct {
	// contains filtered or unexported fields
}

BrowserIndex reads the browsers' bookmarks and history, rereading a profile only when its files changed. It lives as long as the shell, so opening the panel costs a stat per file while nobody browses.

func NewBrowserIndex added in v0.3.5

func NewBrowserIndex(home, configHome, iconDir string) *BrowserIndex

NewBrowserIndex reads the known browsers' profiles under home and configHome, keeping their favicons in iconDir.

type Calculator

type Calculator struct {
	// contains filtered or unexported fields
}

Calculator answers arithmetic, unit and currency conversions, times across zones and date arithmetic inline.

func NewCalculator added in v0.3.15

func NewCalculator(rates *answer.Rates, currency answer.CurrencyParser, zones *answer.Zones, now func() time.Time) *Calculator

NewCalculator answers currencies over rates (nil answers none), reading "kr" and symbols with currency, placing times through zones, on now's calendar.

func (*Calculator) Actions

func (*Calculator) Actions(e Entry) []Action

Actions implements Provider.

func (*Calculator) Answer

func (c *Calculator) Answer(query string) []Entry

Answer implements Answerer.

func (*Calculator) Load

func (c *Calculator) Load(ctx context.Context, publish func([]Entry))

Load implements Provider: it reads or fetches the currency rates when due, and has the list answered again once they changed. Answer never waits for them.

func (*Calculator) Spec

func (*Calculator) Spec() Spec

Spec implements Provider.

type Cancel

type Cancel struct{}

Cancel ends the session with nothing done (Esc at the root).

type Characters added in v0.3.15

type Characters struct {
	// contains filtered or unexported fields
}

Characters finds any character Unicode names. Its forty thousand names are never published as rows: it searches charnames' compact table itself and builds rows only for what shows.

func NewCharacters added in v0.3.15

func NewCharacters(table func() (*charnames.Table, error)) *Characters

NewCharacters searches table's names (charnames.Shared), read on the first search.

func (*Characters) Actions added in v0.3.15

func (*Characters) Actions(e Entry) []Action

Actions implements Provider.

func (*Characters) Load added in v0.3.15

func (*Characters) Load(context.Context, func([]Entry))

Load implements Provider: the table is read on the first search, not when the panel opens.

func (*Characters) Search added in v0.3.15

func (c *Characters) Search(q *launcher.FuzzyQuery, query string, limit int) []Found

Search implements Searcher.

func (*Characters) Spec added in v0.3.15

func (c *Characters) Spec() Spec

Spec implements Provider.

type Clipboard

type Clipboard struct {
	// contains filtered or unexported fields
}

Clipboard offers the clipboard history. Accepting a row puts it back under the mime it arrived with.

func NewClipboard

func NewClipboard(history modes.ClipboardHistory, previews bool) *Clipboard

NewClipboard builds the root's section of history; nil (a compositor without data-control) offers nothing.

func (*Clipboard) Actions

func (c *Clipboard) Actions(e Entry) []Action

Actions implements Provider.

func (*Clipboard) Load

func (c *Clipboard) Load(_ context.Context, publish func([]Entry))

Load implements Provider.

func (*Clipboard) Spec

func (c *Clipboard) Spec() Spec

Spec implements Provider.

type Close

type Close struct{}

Close ends the session: the action did its work.

type CloseThen added in v0.3.5

type CloseThen struct{ Run func() }

CloseThen ends the session and runs Run on the UI loop once the panel has left the screen.

type Control added in v0.3.5

type Control struct {
	// ID stays the same across states: "Turn On" and "Turn Off" are one
	// control, so what is learned of it is kept.
	ID                        string
	Title, Subtitle, Keywords string
	Icon                      string
	Effect                    ControlEffect
}

Control is one thing the panel can switch or start in a service of the shell.

type ControlEffect added in v0.3.5

type ControlEffect interface {
	// contains filtered or unexported methods
}

ControlEffect is what choosing a control does.

type Controls added in v0.3.5

type Controls struct {
	// contains filtered or unexported fields
}

Controls offers rows of the shell's own services. Load reads their state each time the panel opens, as it decides what the rows say.

func NewControls added in v0.3.5

func NewControls(load func(ctx context.Context) []Control) *Controls

NewControls offers what load returns.

func (*Controls) Actions added in v0.3.5

func (*Controls) Actions(e Entry) []Action

Actions implements Provider.

func (*Controls) Load added in v0.3.5

func (c *Controls) Load(ctx context.Context, publish func([]Entry))

Load implements Provider.

func (*Controls) Spec added in v0.3.5

func (*Controls) Spec() Spec

Spec implements Provider.

type Copy

type Copy struct{ Text string }

Copy puts Text on the clipboard and ends the session.

type Deps

type Deps struct {
	Env Env
	// Clipboard is the history; nil without data-control.
	Clipboard modes.ClipboardHistory
	// Vault builds a vault level; nil without a vault.
	Vault func() launcher.Mode
	// SettingsPages asks lys-settings for its pages.
	SettingsPages func(context.Context) ([]settingspage.Page, error)
	// Windows is the compositor's; nil where none is known.
	Windows modes.WindowBackend
	// Browser reads the browsers' bookmarks and history; nil offers neither.
	Browser *BrowserIndex
	// Toggles, Media and Capture read the rows of the shell's services; a
	// nil one offers none.
	Toggles, Media, Capture func(ctx context.Context) []Control
	// SkinTone is what person and hand emoji show in; SetSkinTone keeps a tone
	// picked from an emoji's actions as the new default (nil keeps none).
	SkinTone    modes.SkinTone
	SetSkinTone func(modes.SkinTone)
	// Rates are the currency reference rates, kept across sessions; nil
	// answers no currencies.
	Rates *answer.Rates
	// Sources keeps the stable sources' rows between sessions; nil loads
	// every source in every session.
	Sources *Sources
}

Deps are the shell services a search session draws on.

type Emoji

type Emoji struct {
	// contains filtered or unexported fields
}

Emoji offers the emoji table.

func NewEmoji

func NewEmoji(load func() []modes.Emoji, tone modes.SkinTone, setTone func(modes.SkinTone)) *Emoji

NewEmoji offers load's emoji (modes.AvailableEmoji) in skin tone tone. Typing a tone picked from an emoji's actions hands it to setTone, which keeps it as the new default. Load decompresses a table, so it runs only on the provider's goroutine.

func (*Emoji) Actions

func (e *Emoji) Actions(entry Entry) []Action

Actions implements Provider: type and copy in the current tone, then, for an emoji that takes one, each of the five tones.

func (*Emoji) Load

func (e *Emoji) Load(_ context.Context, publish func([]Entry))

Load implements Provider.

func (*Emoji) Spec

func (e *Emoji) Spec() Spec

Spec implements Provider.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is one session's search, on its own goroutine: providers load beside it and publish into it, queries are answered in order, and a query already overtaken by a newer one is skipped, so typing fast costs one answer rather than one per key. Answering a query reuses its memory: only what a provider's answer or the query's own text needs is allocated.

func Start

func Start(root *Level, openFrecency func() (*Frecency, error), sink Sink, deliver func(func())) *Engine

Start runs the engine over root. openFrecency runs on its goroutine, as it reads the disk; nil learns nothing. deliver hops onto the UI loop.

func (*Engine) Activate

func (e *Engine) Activate(id string, action int)

Activate runs action number action of the row with this id.

func (*Engine) Back

func (e *Engine) Back()

Back leaves the current level; at the root it finishes with Cancel.

func (*Engine) Done

func (e *Engine) Done() <-chan struct{}

Done closes once the engine and its providers have all returned.

func (*Engine) Recycle

func (e *Engine) Recycle(rows []Row)

Recycle hands a frame's rows back once nothing reads them.

func (*Engine) SetQuery

func (e *Engine) SetQuery(text string, seq uint64)

SetQuery answers text; seq numbers the edit, so a frame can say which edits it has seen.

func (*Engine) ShowActions

func (e *Engine) ShowActions(id string)

ShowActions enters the actions panel of the row with this id.

func (*Engine) Stop

func (e *Engine) Stop()

Stop ends the engine and every provider it started. It does not wait: the UI loop calls it, and an action in flight may still be finishing.

func (*Engine) Submit

func (e *Engine) Submit(text string)

Submit is Enter with no row: the level's Submit gets the text.

type Entry

type Entry struct {
	// ID identifies the row across queries, so the selection can follow
	// it. Unique within its provider.
	ID string
	// Learn is the frecency key; "" never learns. Rows that are the same
	// thing to the user share one (every window of an application).
	Learn string
	// Title is the row's main text, matched and highlighted.
	Title string
	// Subtitle is the dim text beside it, matched.
	Subtitle string
	// Keywords are matched and never shown.
	Keywords string
	// Icon leads the row; Glyph leads it instead when set (an emoji).
	Icon  launcher.Icon
	Glyph string
	// Completion is what Tab puts in the search field ("" opens the
	// actions panel instead).
	Completion string
	// Hint is the dim text at the row's end, as an action's key.
	Hint string
	// Rank is added to the row's score: a recent file over one merely
	// indexed.
	Rank int
	// Preview is the row's side pane.
	Preview launcher.Preview
	// Data is the provider's own, for Actions.
	Data any
}

Entry is one row a provider offers.

type Env

type Env struct {
	// Spawn runs an argv detached; nothing waits for it.
	Spawn func(argv []string)
	// SpawnShell runs a shell line detached.
	SpawnShell func(line string)
	// Terminal is the terminal emulator command ("" autodetects).
	Terminal string
}

Env is how providers reach out of the process: a seam, so a test's launches and opens land in a list instead of on the desktop.

func RealEnv

func RealEnv(terminal string) Env

RealEnv spawns for real.

type Files

type Files struct {
	// contains filtered or unexported fields
}

Files searches recent files and an index of the home directory, and answers a typed path with its directory's contents.

func NewFiles

func NewFiles(env Env, cfg FilesConfig) *Files

NewFiles builds the provider.

func (*Files) Actions

func (f *Files) Actions(e Entry) []Action

Actions implements Provider.

func (*Files) Answer

func (f *Files) Answer(query string) []Entry

Answer implements Answerer: a query that is a path lists its directory filtered by the name being typed. It is one directory read, on the engine goroutine.

func (*Files) Load

func (f *Files) Load(ctx context.Context, publish func([]Entry))

Load implements Provider: what it can have at once first, the walk behind it if the index has gone stale.

func (*Files) Spec

func (*Files) Spec() Spec

Spec implements Provider.

type FilesConfig

type FilesConfig struct {
	// Roots are walked; a walk stays on each root's filesystem.
	Roots []string
	// Exclude are directory names to skip, on top of skippedDirs.
	Exclude []string
	// CachePath is the index's file.
	CachePath string
	// RecentPath is the desktop's recently-used.xbel.
	RecentPath string
	// Home abbreviates paths and resolves a leading ~.
	Home string
	// Previews asks for the side pane.
	Previews bool
	// Now is the clock (the index's age).
	Now func() time.Time
}

FilesConfig bounds what Files reads.

type Found added in v0.3.15

type Found struct {
	Entry Entry
	Score int32
	Title []rune
}

Found is a row a Searcher built, its score, and its title as the matcher reads it, for highlights.

type Frame

type Frame struct {
	// Depth is how many levels sit under this one; 0 is the root.
	Depth int
	// Title, Placeholder, Message, Mask and SubmitTitle are the level's.
	Title, Placeholder, Message string
	Mask                        bool
	SubmitTitle                 string
	// CanSubmit is Enter accepting the typed text with no row selected.
	CanSubmit bool
	// Query is the text these rows answer.
	Query string
	// QuerySeq is the last edit of the field the engine had seen. A panel
	// that has sent a later one keeps its text: what was typed since must
	// not be overwritten by a frame that predates it.
	QuerySeq uint64
	// SetField asks the panel to put Field in the search field: a level
	// was entered or left, or an action set the query.
	SetField bool
	Field    string
	// Late marks rows that arrived while the query stood still: the
	// selection stays on the row it is on.
	Late bool
	// Rows are the list. They stay the receiver's until it hands them
	// back with Engine.Recycle.
	Rows []Row
}

Frame is everything the panel shows for one state of the search.

type Frecency

type Frecency struct {
	// contains filtered or unexported fields
}

Frecency learns what gets picked: every use adds one to a count that halves every two weeks, kept overall and for the query it was found by, so "f" comes to mean Firefox for someone who keeps choosing it. The file lives in the state directory and is replaced atomically. The shell keeps one for its lifetime, so a session closing and the next opening may use it at once.

func OpenFrecency

func OpenFrecency(path string, now func() time.Time) (*Frecency, error)

OpenFrecency reads path. A missing file is an empty store; a corrupt one is an error, and a store that starts empty and replaces it on the next use (the launcher still has to open).

func (*Frecency) Boost

func (f *Frecency) Boost(key string) int

Boost is the score key's history adds, overall.

func (*Frecency) Forget

func (f *Frecency) Forget(key string) error

Forget drops key and saves.

func (*Frecency) QueryBoostsInto

func (f *Frecency) QueryBoostsInto(into map[string]int, query string) bool

QueryBoostsInto fills into, empty, with each key picked for query (or a query it starts with) and the score that adds, so typing what you typed last time finds what you chose last time. It reports whether it found any.

func (*Frecency) Record

func (f *Frecency) Record(key, query string) error

Record counts one use of key, found by query, and saves.

type Immediate

type Immediate interface{ Immediate() }

Immediate marks a provider whose rows are already in memory: its Load runs as the level opens, so the level's first frame has them and the panel does not change height a moment later.

type Level

type Level struct {
	// Title is the breadcrumb beside the field; "" at the root.
	Title string
	// Placeholder is the empty field's text.
	Placeholder string
	// Message is shown above the rows.
	Message string
	// Mask shows the field as dots: the input is a secret.
	Mask bool
	// Providers are searched.
	Providers []Provider
	// Submit is Enter with no row selected: the typed text is the
	// answer (a script's argument, a master password). Nil: nothing.
	Submit func(ctx context.Context, text string) Outcome
	// SubmitTitle names Submit in the footer.
	SubmitTitle string
	// Query is what the field starts with.
	Query string
}

Level is one screen of the panel: the search field and what it searches. Esc goes back through levels, then closes.

func CharactersLevel added in v0.3.15

func CharactersLevel(table func() (*charnames.Table, error)) *Level

CharactersLevel searches every named character, as the Unicode Characters row and `-show unicode` open it.

func EmojiLevel added in v0.3.15

func EmojiLevel(load func() []modes.Emoji, tone modes.SkinTone, setTone func(modes.SkinTone)) *Level

EmojiLevel lists every emoji, as the Emoji Picker row opens it.

func ModeLevel

func ModeLevel(mode launcher.Mode, title string) *Level

ModeLevel hosts a rofi mode as a level, so what already works as a mode (the vault, with its unlock prompt and field picker) keeps one implementation. Its reloads swap the level; its masked prompts mask the field.

func NewRoot

func NewRoot(cfg config.LauncherSearchConfig, power config.PowerConfig, d Deps, home string) *Level

NewRoot builds the root level from the configuration: one provider per enabled source, nothing loaded yet.

type Links struct {
	// contains filtered or unexported fields
}

Links offers the configured quick links and snippets. A link whose URL takes {query} completes to its keyword: "gh rust" answers with the filled URL.

func NewLinks(env Env, links []config.LauncherQuicklink, snippets []config.LauncherSnippet, previews bool) *Links

NewLinks offers links and snippets.

func (*Links) Actions

func (l *Links) Actions(e Entry) []Action

Actions implements Provider.

func (*Links) Answer

func (l *Links) Answer(query string) []Entry

Answer implements Answerer: "<keyword> <text>" fills that link.

func (*Links) Load

func (l *Links) Load(_ context.Context, publish func([]Entry))

Load implements Provider.

func (*Links) Spec

func (*Links) Spec() Spec

Spec implements Provider.

type Outcome

type Outcome interface {
	// contains filtered or unexported methods
}

Outcome is what the panel does after an action ran.

type PickerLevels added in v0.3.5

type PickerLevels struct {
	Emoji, Characters, Vault, Bookmarks, Visited, Processes func() *Level
}

PickerLevels are the levels of the pickers with nothing to configure; a nil one leaves its row out.

type Pickers

type Pickers struct {
	// contains filtered or unexported fields
}

Pickers are root rows that open a whole list of their own: the full clipboard history, every emoji, the vault, every bookmark, the most visited pages, the running processes.

func NewPickers

func NewPickers(history modes.ClipboardHistory, levels PickerLevels, previews bool) *Pickers

NewPickers builds the rows for what is available. A nil history leaves its row out, as does a nil level.

func (*Pickers) Actions

func (*Pickers) Actions(e Entry) []Action

Actions implements Provider.

func (*Pickers) Load

func (p *Pickers) Load(_ context.Context, publish func([]Entry))

Load implements Provider.

func (*Pickers) Spec

func (*Pickers) Spec() Spec

Spec implements Provider.

type Processes added in v0.3.5

type Processes struct {
	// contains filtered or unexported fields
}

Processes lists the user's running processes to end one. It is only ever a picker's level: a search for an app should not offer to kill it.

func (*Processes) Actions added in v0.3.5

func (p *Processes) Actions(e Entry) []Action

Actions implements Provider.

func (*Processes) Load added in v0.3.5

func (p *Processes) Load(ctx context.Context, publish func([]Entry))

Load implements Provider.

func (*Processes) Spec added in v0.3.5

func (*Processes) Spec() Spec

Spec implements Provider.

type Provider

type Provider interface {
	Spec() Spec
	Load(ctx context.Context, publish func([]Entry))
	Actions(e Entry) []Action
}

Provider offers rows. Load runs once per level on its own goroutine: it reads the disk or a socket and calls publish with the rows it has, as often as it learns more, each call replacing the last; it returns when done or ctx ends. Actions lists a row's actions, the first the default; it must not wait for anything, as the panel calls it when the selection moves.

type Push

type Push struct{ Level *Level }

Push enters a level; Esc comes back.

type Reload

type Reload struct{}

Reload loads the current level's providers again.

type Replace

type Replace struct{ Level *Level }

Replace swaps the current level for another.

type Row

type Row struct {
	// Header is a heading's text; "" for an entry.
	Header string
	// Entry is the row; nil for a heading. It is never written after its
	// provider published it.
	Entry *Entry
	// contains filtered or unexported fields
}

Row is one line of the list: a section heading (Header set) or an entry. It points at its entry rather than copying it, and a row of the list is 64 bytes, so a frame costs little whatever an entry holds.

func (Row) Actions

func (r Row) Actions() []Action

Actions lists the row's actions, the default first.

func (Row) AppendHighlights

func (r Row) AppendHighlights(dst []int, q *launcher.FuzzyQuery) []int

AppendHighlights appends the positions in the title, counted in grapheme clusters, of the characters q matched. It is computed when asked, so only rows on screen pay for it, on the reader's own q and buffer.

type RunNow added in v0.3.5

type RunNow func(ctx context.Context) error

RunNow runs while the panel stays open, so a failure can be said in its footer. It closes on success.

type RunOnceClosed added in v0.3.5

type RunOnceClosed func()

RunOnceClosed runs on the UI loop after the panel has left the screen and given the keyboard back: what looks at the screen must not find the panel on it. It must not wait.

type Script

type Script struct {
	Path, Title, Subtitle, Keywords, Icon string
	Output                                ScriptOutput
	Args                                  []ScriptArg
}

Script is one script command, as its header says.

func ParseScript

func ParseScript(path string, head io.Reader) (Script, bool, error)

ParseScript reads a script's directives from its leading comment lines. A file with no @lys.title is not a command; a directive it cannot read is an error naming the line, so a typo does not silently run the script differently.

type ScriptArg

type ScriptArg struct {
	Name     string
	Optional bool
}

ScriptArg is one argument a script asks for.

type ScriptOutput

type ScriptOutput uint8

ScriptOutput says what happens to a script's run.

const (
	// ScriptSilent runs it detached; nobody reads its output.
	ScriptSilent ScriptOutput = iota
	// ScriptTerminal runs it in a terminal.
	ScriptTerminal
	// ScriptCopy waits for it and copies its stdout.
	ScriptCopy
)

The script output modes.

type Scripts

type Scripts struct {
	// contains filtered or unexported fields
}

Scripts offers the executables of a directory as commands. The format is in docs/guide/launcher.md.

func NewScripts

func NewScripts(env Env, dir string) *Scripts

NewScripts reads dir.

func (*Scripts) Actions

func (s *Scripts) Actions(e Entry) []Action

Actions implements Provider.

func (*Scripts) Load

func (s *Scripts) Load(_ context.Context, publish func([]Entry))

Load implements Provider.

func (*Scripts) Spec

func (*Scripts) Spec() Spec

Spec implements Provider.

type Searcher added in v0.3.15

type Searcher interface {
	Search(q *launcher.FuzzyQuery, query string, limit int) []Found
}

Searcher is a provider with too many rows to publish (every character Unicode names): it matches the query against a compact table of its own, on the engine goroutine, and returns at most limit rows with their scores, best first, building only those. An empty query lists its first rows.

type Section

type Section uint8

Section is the heading a row sits under.

const (
	SectionAnswer Section = iota
	// SectionRecent is what an empty query shows: what gets used.
	SectionRecent
	SectionApps
	SectionWindows
	SectionCommands
	SectionLinks
	SectionBrowser
	SectionSettings
	SectionFiles
	SectionClipboard
	SectionEmoji
	SectionCharacters
	SectionVault
	SectionWeb
	// SectionNone is a flat list: an actions panel or a picker.
	SectionNone
)

The sections. Their order breaks ties between sections of equal rank.

func (Section) Title

func (s Section) Title() string

Title is the section's heading, "" for a flat list.

type SetQuery

type SetQuery struct{ Text string }

SetQuery replaces the search field's text.

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

Settings offers lys-settings' pages.

func NewSettings

func NewSettings(env Env, pages func(context.Context) ([]settingspage.Page, error)) *Settings

NewSettings offers pages.

func (*Settings) Actions

func (s *Settings) Actions(e Entry) []Action

Actions implements Provider.

func (*Settings) Load

func (s *Settings) Load(ctx context.Context, publish func([]Entry))

Load implements Provider.

func (*Settings) Spec

func (*Settings) Spec() Spec

Spec implements Provider.

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Shell answers a query led by ">": run the rest as a command.

func NewShell

func NewShell(env Env) *Shell

NewShell builds it.

func (*Shell) Actions

func (s *Shell) Actions(e Entry) []Action

Actions implements Provider.

func (*Shell) Answer

func (*Shell) Answer(query string) []Entry

Answer implements Answerer.

func (*Shell) Load

func (*Shell) Load(context.Context, func([]Entry))

Load implements Provider.

func (*Shell) Spec

func (*Shell) Spec() Spec

Spec implements Provider.

type Sink

type Sink interface {
	// Results is a new list.
	Results(Frame)
	// Finish ends the session: Close, Cancel or Copy.
	Finish(Outcome)
	// Notice says something in the footer without changing the list.
	Notice(message string)
}

Sink receives the engine's results; both run through deliver, on the UI loop.

type Sources added in v0.3.13

type Sources struct {
	// contains filtered or unexported fields
}

Sources keeps what the panel searches and rarely changes for the shell's lifetime: the rows of the apps, scripts, settings, files and emoji, and the frecency store. A session shows the rows kept from the last one in its first frame and loads a source again only once a watch saw its files change, so opening the panel reads nothing from the disk.

func NewSources added in v0.3.13

func NewSources(watch WatchFunc, now func() time.Time) *Sources

NewSources keeps rows refreshed through watch; nil watches nothing, so every session loads its sources again behind the rows it starts with.

func (*Sources) Frecency added in v0.3.13

func (s *Sources) Frecency(open func() (*Frecency, error)) func() (*Frecency, error)

Frecency opens the store once with open and hands every later session the same one.

type Spec

type Spec struct {
	Section Section
	// MinQuery is the query length, in characters, below which its rows
	// stay out: a one-letter query should not list every emoji.
	MinQuery int
	// Weight is added to its rows' score: a good app beats an equally
	// good match in a file name.
	Weight int
}

Spec says how a provider's rows take part in a list.

type Stay

type Stay struct{ Message string }

Stay leaves everything as it is, Message shown when not empty (a failure said in the footer rather than swallowed).

type System

type System struct {
	// contains filtered or unexported fields
}

System offers the session commands, through the commands the power menu runs. Those that end what you are doing ask first: a fuzzy search and an Enter should not be enough to reboot.

func NewSystem

func NewSystem(env Env, power config.PowerConfig) *System

NewSystem builds it over the power configuration.

func (*System) Actions

func (s *System) Actions(e Entry) []Action

Actions implements Provider.

func (*System) Load

func (s *System) Load(_ context.Context, publish func([]Entry))

Load implements Provider.

func (*System) Spec

func (*System) Spec() Spec

Spec implements Provider.

type Type added in v0.3.3

type Type struct{ Text string }

Type ends the session and enters Text in the window it leaves focused.

type VisitedPages added in v0.3.5

type VisitedPages struct {
	// contains filtered or unexported fields
}

VisitedPages offers the browsers' most visited pages.

func NewVisitedPages added in v0.3.5

func NewVisitedPages(env Env, index *BrowserIndex, hideBookmarked bool) *VisitedPages

NewVisitedPages offers the visited pages index holds; hideBookmarked leaves out those the bookmarks list too.

func (*VisitedPages) Actions added in v0.3.5

func (v *VisitedPages) Actions(e Entry) []Action

Actions implements Provider.

func (*VisitedPages) Load added in v0.3.5

func (v *VisitedPages) Load(ctx context.Context, publish func([]Entry))

Load implements Provider.

func (*VisitedPages) Spec added in v0.3.5

func (v *VisitedPages) Spec() Spec

Spec implements Provider.

type WatchFunc added in v0.3.13

type WatchFunc func(paths []string, recursive bool, fn func()) (stop func(), err error)

WatchFunc calls fn when anything under paths changes (app.WatchFiles).

type Web

type Web struct {
	// contains filtered or unexported fields
}

Web is the fallback at the bottom of every list: search the web for what was typed. The template's {query} takes the escaped text.

func NewWeb

func NewWeb(env Env, name, template string) *Web

NewWeb searches with name's template.

func (*Web) Actions

func (w *Web) Actions(e Entry) []Action

Actions implements Provider.

func (*Web) Answer

func (w *Web) Answer(query string) []Entry

Answer implements Answerer.

func (*Web) Load

func (*Web) Load(context.Context, func([]Entry))

Load implements Provider.

func (*Web) Spec

func (*Web) Spec() Spec

Spec implements Provider.

type Windows

type Windows struct {
	// contains filtered or unexported fields
}

Windows offers the open windows to jump to, on whichever compositor the shell runs on. The focused window stays out: nothing to jump to.

func NewWindows

func NewWindows(backend modes.WindowBackend) *Windows

NewWindows uses backend; nil (no compositor it knows) offers nothing.

func (*Windows) Actions

func (w *Windows) Actions(e Entry) []Action

Actions implements Provider.

func (*Windows) Load

func (w *Windows) Load(ctx context.Context, publish func([]Entry))

Load implements Provider.

func (*Windows) Spec

func (*Windows) Spec() Spec

Spec implements Provider.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL