console

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrimitiveInfoModal  = "info_modal"
	PrimitiveRetryModal = "retry_modal"
	PrimitiveErrorModal = "error_modal"
	PrimitiveList       = "list"
	PrimitiveTailView   = "tail_view"
	PrimitiveFilter     = "filter"
	PrimitiveSearch     = "search"
	PrimitiveRate       = "rate"

	PageConnectionAttempt = "page_" + PrimitiveInfoModal
	PageConnectionRetry   = "page_" + PrimitiveRetryModal
	PageSelectComponent   = "page_" + PrimitiveList
	PageTailError         = "page_" + PrimitiveErrorModal
	PageTailView          = "page_" + PrimitiveTailView
	PageFilter            = "page_" + PrimitiveFilter
	PageSearch            = "page_" + PrimitiveSearch
	PageRate              = "page_" + PrimitiveRate

	DefaultViewOptionsPrettyJSON         = true
	DefaultViewOptionsEnableColors       = true
	DefaultViewOptionsDisplayLineNumbers = true
	DefaultViewOptionsDisplayTimestamp   = true
)

Variables

View Source
var (
	ColorMap = map[Element]Color{
		TextPrimary: {
			Name:       "white",
			Hex256:     "#FFFFFF",
			Tcell256:   tcell.ColorWhite,
			Hex24Bit:   "#FFFFFF",
			Tcell24Bit: tcell.ColorWhite,
		},
		TextSecondary: {
			Name:       "light purple",
			Hex256:     fmt.Sprintf("#%X", tcell.Color141.Hex()),
			Tcell256:   tcell.Color141,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(157, 135, 215)),
			Tcell24Bit: tcell.NewRGBColor(157, 135, 215),
		},
		TextAccent1: {
			Name:       "yellow",
			Hex256:     fmt.Sprintf("#%X", tcell.Color221.Hex()),
			Tcell256:   tcell.Color221,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(255, 204, 85).Hex()),
			Tcell24Bit: tcell.NewRGBColor(255, 204, 85),
		},
		TextAccent2: {
			Name:       "cyan",
			Hex256:     fmt.Sprintf("#%X", tcell.Color44.Hex()),
			Tcell256:   tcell.Color44,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(33, 196, 199).Hex()),
			Tcell24Bit: tcell.NewRGBColor(33, 196, 199),
		},
		TextAccent3: {
			Name:       "red",
			Hex256:     fmt.Sprintf("#%X", tcell.Color203.Hex()),
			Tcell256:   tcell.Color203,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(255, 114, 93).Hex()),
			Tcell24Bit: tcell.NewRGBColor(255, 114, 93),
		},
		ActiveButtonBg: {
			Name:       "red",
			Hex256:     fmt.Sprintf("%X", tcell.Color203.Hex()),
			Tcell256:   tcell.Color203,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(255, 114, 93).Hex()),
			Tcell24Bit: tcell.NewRGBColor(255, 114, 93),
		},
		ActiveButtonFg: {
			Name:       "white",
			Hex256:     fmt.Sprintf("%X", tcell.ColorWhite.Hex()),
			Tcell256:   tcell.ColorWhite,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(255, 255, 255).Hex()),
			Tcell24Bit: tcell.ColorWhite,
		},
		InactiveButtonBg: {
			Name:       "dark off-white",
			Hex256:     fmt.Sprintf("#%X", tcell.Color188.Hex()),
			Tcell256:   tcell.Color188,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(217, 217, 217).Hex()),
			Tcell24Bit: tcell.NewRGBColor(217, 217, 217),
		},
		InactiveButtonFg: {
			Name:       "dark grey",
			Hex256:     fmt.Sprintf("#%X", tcell.Color239.Hex()),
			Tcell256:   tcell.Color239,
			Hex24Bit:   fmt.Sprintf("%X", tcell.Color239.Hex()),
			Tcell24Bit: tcell.ColorWhite,
		},
		MenuActiveBg: {
			Name:       "light gray",
			Hex256:     fmt.Sprintf("#%X", tcell.Color188.Hex()),
			Tcell256:   tcell.Color188,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(217, 217, 217).Hex()),
			Tcell24Bit: tcell.NewRGBColor(217, 217, 217),
		},
		MenuInactiveFg: {
			Name:       "",
			Hex256:     fmt.Sprintf("#%X", tcell.Color141.Hex()),
			Tcell256:   tcell.Color141,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(157, 135, 215).Hex()),
			Tcell24Bit: tcell.NewRGBColor(157, 135, 215),
		},
		InputFieldFg: {
			Name:       "very dark gray",
			Hex256:     fmt.Sprintf("#%X", tcell.Color234.Hex()),
			Tcell256:   tcell.Color234,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.Color234.Hex()),
			Tcell24Bit: tcell.Color234,
		},
		InputFieldBg: {
			Name:       "light off-white",
			Hex256:     fmt.Sprintf("#%X", tcell.Color254.Hex()),
			Tcell256:   tcell.Color254,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.Color254.Hex()),
			Tcell24Bit: tcell.Color254,
		},
		WindowBg: {
			Name:       "dark purple",
			Hex256:     fmt.Sprintf("#%X", tcell.Color56.Hex()),
			Tcell256:   tcell.Color56,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(36, 29, 55).Hex()),
			Tcell24Bit: tcell.NewRGBColor(36, 29, 55),
		},
		CLIBg: {
			Name:       "almost black",
			Hex256:     fmt.Sprintf("#%X", tcell.Color236.Hex()),
			Tcell256:   tcell.Color236,
			Hex24Bit:   fmt.Sprintf("#%X", tcell.NewRGBColor(40, 40, 40).Hex()),
			Tcell24Bit: tcell.NewRGBColor(40, 40, 40),
		},
	}

	DefaultColor = Color{
		Name:       "default white",
		Hex256:     fmt.Sprintf("%X", tcell.ColorWhite.Hex()),
		Tcell256:   tcell.ColorWhite,
		Hex24Bit:   fmt.Sprintf("%X", tcell.ColorWhite.Hex()),
		Tcell24Bit: tcell.ColorWhite,
	}

	TerminalColorMode ColorMode // Set during init()
)
View Source
var (
	MenuString = `[white]Q[-] ["Q"][#9D87D7]Quit[-][""]  ` +
		`[white]S[-] ["S"][#9D87D7]Select Component[-][""]  ` +
		`[white]R[-] ["R"][#9D87D7::s]Set Sample Rate[-:-:-][""]  ` +
		`[white]F[-] ["F"][#9D87D7]Filter[-][""]  ` +
		`[white]P[-] ["P"][#9D87D7]Pause[-][""]  ` +
		`[white]O[-] ["O"][#9D87D7]View Options[-][""] ` +
		`[white]/[-] ["Search"][#9D87D7]Search[-][""]`
)

Functions

func Center

func Center(p tview.Primitive, width, height int) tview.Primitive

func Hex

func Hex(e Element) string

func Tcell

func Tcell(e Element) tcell.Color

Types

type Color

type Color struct {
	Name string

	Hex256   string
	Tcell256 tcell.Color

	Hex24Bit   string
	Tcell24Bit tcell.Color
}

type ColorMode

type ColorMode int
const (
	ModeUnsupported ColorMode = iota
	Mode256
	Mode24Bit
)

type Console

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

func New

func New(opts *Options) (*Console, error)

func (*Console) DisplayErrorModal

func (c *Console) DisplayErrorModal(msg string)

func (*Console) DisplayFilter

func (c *Console) DisplayFilter(defaultValue string, answerCh chan<- string)

func (*Console) DisplayInfoModal

func (c *Console) DisplayInfoModal(msg string, quitAnimationCh chan struct{}, answerCh chan error)

DisplayInfoModal will display an animated modal with the given message. InputCh is used by caller to indicate that the modal can be closed (in this case, it will cause the method to stop the animation goroutine). OutputCh is used by method to inform caller that the user has exited the modal.

func (*Console) DisplayRate

func (c *Console) DisplayRate(defaultValue int, answerCh chan<- int)

func (*Console) DisplayRetryModal

func (c *Console) DisplayRetryModal(msg, pageName string, answerCh chan bool)

DisplayRetryModal will display a modal with a given message + retry/quit buttons.

func (*Console) DisplaySearch

func (c *Console) DisplaySearch(defaultValue string, answerCh chan<- string)

func (*Console) DisplaySelectList

func (c *Console) DisplaySelectList(title string, audiences []*protos.Audience, answerCh chan<- *types.TailComponent)

DisplaySelectList will display a list of items and return the select item on the output channel

func (*Console) DisplayTail

func (c *Console) DisplayTail(pageTail *tview.TextView, tailComponent *types.TailComponent, actionCh chan<- *types.Action) *tview.TextView

DisplayTail will display tail + write any actions we receive from the user to the action channel; the action channel is read by the tail() method. Accepts an _optional_ pageTail to facilitate re-use of the tail view. This is needed so that when filter/pause is applied, the tail view retains the data captured within it.

func (*Console) DisplayViewOptions

func (c *Console) DisplayViewOptions(defaultViewOptions *types.ViewOptions, answerCh chan<- *types.ViewOptions)

func (*Console) GetInputCapture

func (c *Console) GetInputCapture() func(event *tcell.EventKey) *tcell.EventKey

func (*Console) Redraw

func (c *Console) Redraw(f func())

func (*Console) SetInputCapture

func (c *Console) SetInputCapture(f func(event *tcell.EventKey) *tcell.EventKey)

func (*Console) SetMenuEntryOff

func (c *Console) SetMenuEntryOff(item string)

func (*Console) SetMenuEntryOn

func (c *Console) SetMenuEntryOn(item string)

func (*Console) Start

func (c *Console) Start()

func (*Console) Stop

func (c *Console) Stop()

func (*Console) ToggleAllMenuHighlights

func (c *Console) ToggleAllMenuHighlights()

func (*Console) ToggleMenuHighlight

func (c *Console) ToggleMenuHighlight(regions ...string)

type Element

type Element int
const (
	TextPrimary Element = iota
	TextSecondary
	TextAccent1
	TextAccent2
	TextAccent3
	ActiveButtonBg
	ActiveButtonFg
	InactiveButtonBg
	InactiveButtonFg
	MenuActiveBg
	MenuInactiveFg
	InputFieldFg
	InputFieldBg
	WindowBg
	CLIBg
)

type Options

type Options struct {
	Config *config.Config
	Logger *log.Logger
}

Jump to

Keyboard shortcuts

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