search

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STORY_BORG_FILE = "/tmp/search-story.borg"
)

Variables

View Source
var Empty stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	paths, err := createBorgFiles(5)
	if err != nil {
		return nil, err
	}

	return New(
		ctx,
		bind.NewBindScope(nil),
		bind.NewBindScope(nil),
		bind.NewBindScope(nil),
		WithRequest(Request{
			Query:   "asdasdasd",
			Files:   paths,
			Workers: 3,
		}),
	), nil
}
View Source
var Load stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	paths, err := createBorgFiles(5)
	if err != nil {
		return nil, err
	}

	return New(
		ctx,
		bind.NewBindScope(nil),
		bind.NewBindScope(nil),
		bind.NewBindScope(nil),
		WithRequest(Request{
			Query:   "bar",
			Files:   paths,
			Workers: 3,
		}),
	), nil
}
View Source
var Many stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	borg, err := createBorgFiles(5)
	if err != nil {
		return nil, err
	}

	var paths []string
	for i := 0; i < 100; i++ {
		paths = append(paths, borg...)
	}

	return New(
		ctx,
		bind.NewBindScope(nil),
		bind.NewBindScope(nil),
		bind.NewBindScope(nil),
		WithRequest(Request{
			Query:   "bar",
			Files:   paths,
			Workers: 3,
		}),
	), nil
}

Functions

func New

func New(
	ctx context.Context,
	searchBinds, timeBinds, copyBinds *bind.BindScope,
	options ...Option,
) *taro.Program

Types

type ActionEvent

type ActionEvent struct {
	Type ActionType
}

type ActionType

type ActionType int
const (
	ActionCancel ActionType = iota
	ActionNext
	ActionPrev
	ActionFirst
	ActionLast
	ActionInput
)

type Option

type Option func(*Search)

func WithRequest

func WithRequest(req Request) Option

type Request

type Request struct {
	Query string
	Files []string
	// The number of goroutines to use
	Workers int
}
type Search struct {
	util.Lifetime
	// contains filtered or unexported fields
}

func (*Search) Execute

func (s *Search) Execute(request Request) (taro.Model, tea.Cmd)

func (*Search) Init

func (s *Search) Init() tea.Cmd

func (*Search) Update

func (s *Search) Update(msg tea.Msg) (taro.Model, tea.Cmd)

func (*Search) View

func (s *Search) View(state *tty.State)

Jump to

Keyboard shortcuts

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