fastcopy

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2022 License: MIT Imports: 8 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 Handler

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

Handler handles events from the widget.

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 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
}

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 []Range

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

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

	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