fastcopy

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fastcopy implements the core fastcopy functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotationStyle added in v0.13.0

type AnnotationStyle struct {
	// Matched text that is still a candidate for selection.
	Match tcell.Style

	// Matched text that is no longer a candidate for selection.
	Skipped tcell.Style

	// Label that the user must type to select the hint.
	Label tcell.Style

	// Part of a multi-character label that the user has already typed.
	LabelTyped tcell.Style
}

AnnotationStyle is the style of annotations for hints and matched text.

type Handler

type Handler interface {
	// HandleSelection reports the hint label and the corresponding matched
	// text.
	HandleSelection(Selection)
}

Handler handles events from the widget.

type Match added in v0.8.0

type Match struct {
	// Matcher is the name of the matcher that found this match.
	Matcher string

	// Range identifies the matched area.
	Range Range
}

Match is a single entry matched by fastcopy.

func (Match) String added in v0.8.0

func (m Match) String() string

type Range

type Range struct{ Start, End int }

Range specifies a range of offsets in a text, referring to the [start:end) subslice of the text.

func (Range) Len

func (r Range) Len() int

Len reports the length of this range.

func (Range) String

func (r Range) String() string

type Selection added in v0.8.0

type Selection struct {
	// Text is the matched text.
	Text string

	// Matchers is a list of names of matchers that matched this text.
	// Invariant: this list contains at least one item.
	Matchers []string

	// Shift reports whether shift was pressed when this value was
	// selected.
	Shift bool
}

Selection is a choice made by the user in the fastcopy UI.

type Style

type Style struct {
	Normal       tcell.Style // normal text
	Match        tcell.Style // matched text
	SkippedMatch tcell.Style // matched text that is not selected

	HintLabel      tcell.Style // labels for hints
	HintLabelInput tcell.Style // typed portion of hints

	// Multi-select mode:
	SelectedMatch tcell.Style // one of the selected matches
	DeselectLabel tcell.Style // label for deselection
}

Style configures the display style of the widget.

type Widget

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

Widget is the main fastcopy widget. It displays some fixed text with zero or more hints and unique prefix-free labels next to each hint to select that label.

func (*Widget) Draw

func (w *Widget) Draw(view views.View)

Draw draws the widget onto the provided view.

func (*Widget) HandleEvent

func (w *Widget) HandleEvent(ev tcell.Event) (handled bool)

HandleEvent handles input for the widget. This only responds to text input, and delegates everything else to the caller.

func (*Widget) Input

func (w *Widget) Input() string

Input reports the text input into the label so far to partially select a label.

type WidgetConfig

type WidgetConfig struct {
	// Text to display on the widget.
	Text string

	// Matched offsets in text.
	Matches []Match

	// Alphabet we'll use to generate labels.
	HintAlphabet []rune

	// Handler handles events from the widget. This includes hint
	// selection.
	Handler Handler

	// Style configures the look of the widget.
	Style Style
	// contains filtered or unexported fields
}

WidgetConfig configures the fastcopy widget.

func (*WidgetConfig) Build

func (cfg *WidgetConfig) Build() *Widget

Build builds a new Fastcopy widget using the provided configuration.

Jump to

Keyboard shortcuts

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