prompt

package module
v0.0.0-...-ea2a2fb Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 11 Imported by: 1

README

license CI godoc goreport codecov Lines of Code insights

Bubbleprompt

Bubbleprompt is a bubbletea widget for building interactive terminal prompts. While the implementation is different, most of the ideas in this library are taken from the excellent go-prompt library. Credit for most of the ideas presented here belongs to the go-prompt authors. This library is still WIP and not yet ready for use.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blur

func Blur() tea.Cmd

func Focus

func Focus() tea.Cmd

func MsgFilter

func MsgFilter(_ tea.Model, msg tea.Msg) tea.Msg

func SetRenderer

func SetRenderer(r renderer.Renderer, retainHistory bool) tea.Cmd

Types

type ExecutorFinishedMsg

type ExecutorFinishedMsg tea.Model

type InputHandler

type InputHandler[T any] interface {
	Init() tea.Cmd
	Update(msg tea.Msg) (InputHandler[T], tea.Cmd)
	Execute(input string, prompt *Model[T]) (tea.Model, error)
	Complete(prompt Model[T]) ([]suggestion.Suggestion[T], error)
}

type Model

type Model[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](
	inputHandler InputHandler[T],
	textInput input.Input[T],
	opts ...Option[T],
) Model[T]

func (Model[T]) Init

func (m Model[T]) Init() tea.Cmd

func (Model[T]) Renderer

func (m Model[T]) Renderer() renderer.Renderer

func (*Model[T]) SuggestionManager

func (m *Model[T]) SuggestionManager() suggestion.Manager[T]

func (Model[T]) SuggestionOffset

func (m Model[T]) SuggestionOffset() int

func (Model[T]) TextInput

func (m Model[T]) TextInput() input.Input[T]

func (Model[T]) Update

func (m Model[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model[T]) View

func (m Model[T]) View() string

type Option

type Option[T any] func(model *Model[T])

func WithFocusOnStart

func WithFocusOnStart[T any](focusOnStart bool) Option[T]

func WithFormatters

func WithFormatters[T any](formatters suggestion.Formatters) Option[T]

func WithRenderer

func WithRenderer[T any](r renderer.Renderer) Option[T]

func WithSuggestionManager

func WithSuggestionManager[T any](manager suggestion.Manager[T]) Option[T]

func WithUnmanagedRenderer

func WithUnmanagedRenderer[T any](opts ...renderer.Option) Option[T]

func WithViewportRenderer

func WithViewportRenderer[T any](opts ...renderer.Option) Option[T]

Directories

Path Synopsis
commandinput
Package commandinput provides an implementation of the [input.Input] interface.
Package commandinput provides an implementation of the [input.Input] interface.
simpleinput
Package simpleinput provides an implementation of the [input.Input] interface.
Package simpleinput provides an implementation of the [input.Input] interface.

Jump to

Keyboard shortcuts

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