autocomplete

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const AutocompleterWidth = 250

AutocompleterWidth is the minimum width of the popped up autocompleter.

View Source
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 EmojiData

type EmojiData struct {
	Name string

	// either or
	Unicode string
	Custom  emojis.Emoji
}

EmojiData is the Data structure for each emoji.

func (EmojiData) Row

func (d EmojiData) Row(ctx context.Context) *gtk.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

func NewEmojiSearcher(ctx context.Context, roomID matrix.RoomID) Searcher

NewEmojiSearcher creates a new emoji searcher.

func NewRoomMemberSearcher

func NewRoomMemberSearcher(ctx context.Context, roomID matrix.RoomID) Searcher

NewRoomMemberSearcher creates a new searcher constructor that can search up room members for the given room. It matches using '@'.

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.

Jump to

Keyboard shortcuts

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