userinput

package
v0.0.0-...-9f8393d Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveHTML

func RemoveHTML(s string) string

RemoveHTML in case a user input interface does not support HTML. This is used internally by an interface implementation.

Types

type Choice

type Choice struct {
	Text     string // the text the user can input.
	Shortcut rune   // leave zero for no shortcut.
	Default  bool   // set to true if it's the default option.
}

Choice is a user input choice for use with Input.GetInput

type Interface

type Interface interface {
	GetInput(ctx context.Context, output string, choice ...Choice) (string, error)
}

Interface gets user input. GetInput's output string is what is presented to the user. The returned string is the user input. The output string can contain basic HTML tags and entities, which may be used or stripped. Waits until either the user inputs or the ctx is done.

type NotifyInput

type NotifyInput struct {
	Summary   string
	AppIcon   string
	Category  string
	SoundName string
	// contains filtered or unexported fields
}

NotifyInput gets user input via dbus notifications.

func (*NotifyInput) GetInput

func (input *NotifyInput) GetInput(ctx context.Context, output string, choices ...Choice) (string, error)

GetInput implements Input.

func (*NotifyInput) Supported

func (input *NotifyInput) Supported() error

Supported returns nil on success if supported.

type TermInput

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

TermInput reads input from the terminal.

func (*TermInput) GetInput

func (input *TermInput) GetInput(ctx context.Context, output string, choices ...Choice) (string, error)

GetInput implements Input; Run must be called first. Instance thread safe when properly using Run. What the user inputs is not validated, it simply returns the first thing the user enters.

func (*TermInput) Run

func (input *TermInput) Run(ctx context.Context)

Run reads terminal input. Doesn't return until the ctx is done, however it has to wait until a line is read from stdin or EOF. Not thread safe: must be called and return before any GetInput calls.

Jump to

Keyboard shortcuts

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