Documentation ¶
Index ¶
- Constants
- type Autocompleter
- func (a *Autocompleter) Autocomplete()
- func (a *Autocompleter) Clear() bool
- func (a *Autocompleter) IsVisible() bool
- func (a *Autocompleter) MoveDown() bool
- func (a *Autocompleter) MoveUp() bool
- func (a *Autocompleter) Select() bool
- func (a *Autocompleter) SetTimeout(d time.Duration)
- func (a *Autocompleter) Use(searchers ...Searcher)
- type Data
- type EmojiData
- type RoomMemberData
- type Searcher
- type SelectedData
- type SelectedFunc
Constants ¶
const AutocompleterWidth = 250
AutocompleterWidth is the minimum width of the popped up autocompleter.
const MaxResults = 8
MaxResults is the maximum number of search results.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Autocompleter ¶
type Autocompleter struct {
// contains filtered or unexported fields
}
Autocompleter is the autocompleter instance.
func New ¶
func New(ctx context.Context, text *gtk.TextView, f SelectedFunc) *Autocompleter
New creates a new instance of autocompleter.
func (*Autocompleter) Autocomplete ¶
func (a *Autocompleter) Autocomplete()
Autocomplete updates the Autocompleter popover to show what the internal input buffer has.
func (*Autocompleter) Clear ¶
func (a *Autocompleter) Clear() bool
Clear clears the Autocompleter and hides it.
func (*Autocompleter) IsVisible ¶
func (a *Autocompleter) IsVisible() bool
IsVisible returns true if the popover is currently visible.
func (*Autocompleter) MoveDown ¶
func (a *Autocompleter) MoveDown() bool
func (*Autocompleter) MoveUp ¶
func (a *Autocompleter) MoveUp() bool
func (*Autocompleter) Select ¶
func (a *Autocompleter) Select() bool
Select selects the current Autocompleter entry.
func (*Autocompleter) SetTimeout ¶
func (a *Autocompleter) SetTimeout(d time.Duration)
SetTimeout sets the timeout for each autocompletion.
func (*Autocompleter) Use ¶
func (a *Autocompleter) Use(searchers ...Searcher)
Use registers the given searcher instance into the autocompleter.
type Data ¶
type Data interface { // Row constructs a new ListBoxRow for display inside the list. Row(context.Context) *gtk.ListBoxRow }
Data represents a data structure capable of being displayed inside a list by constructing a new ListBoxRow.
type RoomMemberData ¶
type RoomMemberData indexer.IndexedRoomMember
RoomMemberData is the data for each room member. It implements Data.
func (RoomMemberData) Row ¶
func (d RoomMemberData) Row(ctx context.Context) *gtk.ListBoxRow
Row implements Data.
type Searcher ¶
type Searcher interface { // Rune is the triggering rune for this searcher. Rune() rune // Search searches the given string and returns a list of data. The returned // list of Data only needs to be valid until the next call of Search. Search(ctx context.Context, str string) []Data }
Searcher is the interface for anything that can handle searching up a particular entity, such as a room member.
func NewEmojiSearcher ¶
NewEmojiSearcher creates a new emoji searcher.
type SelectedData ¶
type SelectedData struct { // Bounds contains the iterators that sit around the word used for // searching. The iterators are guaranteed to be valid until the callback // returns. Bounds [2]*gtk.TextIter // Data is the selected entry's data. Data Data }
SelectedData wraps around a Data to provide additional metadata that could be useful for the user.
type SelectedFunc ¶
type SelectedFunc func(SelectedData) bool
SelectedFunc is the callback type that is called when the user has selected an entry inside the autocompleter. If the callback returns true, then the autocompleter closes itself; otherwise, it does nothing.