idtui

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Block               = "█"
	CaretDownEmpty      = "▽"
	CaretDownFilled     = "▼"
	CaretLeftFilled     = "◀" // "<"
	CaretRightEmpty     = "▷" // ">"
	CaretRightFilled    = "▶" // ">"
	CornerBottomLeft    = "╰"
	CornerBottomRight   = "╯"
	CornerTopLeft       = "╭"
	CornerTopRight      = "╮"
	CrossBar            = "┼"
	DotEmpty            = "○"
	DotFilled           = "●"
	HorizBar            = "─"
	HorizBottomBar      = "┬"
	HorizHalfLeftBar    = "╴"
	HorizHalfRightBar   = "╶"
	HorizTopBar         = "┴"
	HorizTopBoldBar     = "┻"
	InactiveGroupSymbol = VertBar
	TaskSymbol          = VertRightBoldBar
	VertBar             = "│"
	VertBoldBar         = "┃"
	VertDottedBar       = "┊" // ┊┆┇┋╎
	VertLeftBar         = "┤"
	VertLeftBoldBar     = "┫"
	VertRightBar        = "├"
	VertRightBoldBar    = "┣"
	IconSkipped         = "∅"
	IconSuccess         = "✔"
	IconFailure         = "✘"
)

Variables

Functions

func ColorProfile added in v0.11.1

func ColorProfile() termenv.Profile

ColorProfile returns Ascii if, and only if, NO_COLOR or similar is set. Otherwise it returns termenv.ANSI, allowing colors to be used.

Note that color profiles beyond simple ANSI are not used by Progrock. 16 colors is all you need. Anything else disrespects the user's color scheme preferences.

func FromCmdContext added in v0.13.0

func FromCmdContext(ctx context.Context) (*cmdContext, bool)

func NewOutput added in v0.11.1

func NewOutput(w io.Writer, opts ...termenv.OutputOption) *termenv.Output

NewOutput returns a termenv.Output that will always use color, regardless of whether w is a TTY, unless NO_COLOR is explicitly set.

Progrock is opinionated here. Termenv disables colors by default if stdout is not a TTY or if the CI env var is set. We don't want that, because folks deserve colorful output in CI too.

To disable colors, set NO_COLOR (https://no-color.org/).

func WithPrintTraceLink(ctx context.Context, printTraceLink bool) context.Context

WithPrintTraceLink is used for enabling printing the trace link for the selected commands.

Types

type Dump added in v0.12.0

type Dump struct {
	Newline string
	Prefix  string
}

func (*Dump) DumpID added in v0.12.0

func (d *Dump) DumpID(out *termenv.Output, id *call.ID) error

type Frontend

type Frontend interface {
	// Run starts a frontend, and runs the target function.
	Run(ctx context.Context, opts dagui.FrontendOpts, f func(context.Context) error) error

	// SetPrimary tells the frontend which span should be treated like the focal
	// point of the command. Its output will be displayed at the end, and its
	// children will be promoted to the "top-level" of the TUI.
	SetPrimary(spanID trace.SpanID)
	Background(cmd tea.ExecCommand) error
	// RevealAllSpans tells the frontend to show all spans, not just the spans
	// beneath the primary span.
	SetRevealAllSpans(bool)

	// Can consume otel spans and logs.
	SpanExporter() sdktrace.SpanExporter
	LogExporter() sdklog.Exporter

	// ConnectedToEngine is called when the CLI connects to an engine.
	ConnectedToEngine(ctx context.Context, name string, version string, clientID string)
	// SetCloudURL is called after the CLI checks auth and sets the cloud URL.
	SetCloudURL(ctx context.Context, url string, msg string, logged bool)
}

func New

func New() Frontend

func NewPlain added in v0.11.5

func NewPlain() Frontend

type FrontendSpanExporter added in v0.11.7

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

func (FrontendSpanExporter) Background added in v0.11.7

func (fe FrontendSpanExporter) Background(cmd tea.ExecCommand) error

func (FrontendSpanExporter) Close added in v0.11.7

func (fe FrontendSpanExporter) Close() error

func (FrontendSpanExporter) ConnectedToEngine added in v0.11.7

func (fe FrontendSpanExporter) ConnectedToEngine(ctx context.Context, name string, version string, clientID string)

func (FrontendSpanExporter) ExportSpans added in v0.11.7

func (fe FrontendSpanExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

func (FrontendSpanExporter) ForceFlush added in v0.11.7

func (fe FrontendSpanExporter) ForceFlush(context.Context) error

func (FrontendSpanExporter) Init added in v0.11.7

func (fe FrontendSpanExporter) Init() tea.Cmd

func (FrontendSpanExporter) LogExporter added in v0.11.7

func (fe FrontendSpanExporter) LogExporter() sdklog.Exporter

func (FrontendSpanExporter) Render added in v0.11.7

func (fe FrontendSpanExporter) Render(out *termenv.Output) error

func (FrontendSpanExporter) Run added in v0.11.7

func (fe FrontendSpanExporter) Run(ctx context.Context, opts dagui.FrontendOpts, run func(context.Context) error) error

Run starts the TUI, calls the run function, stops the TUI, and finally prints the primary output to the appropriate stdout/stderr streams.

func (FrontendSpanExporter) SetCloudURL added in v0.12.0

func (fe FrontendSpanExporter) SetCloudURL(ctx context.Context, url string, msg string, logged bool)

func (FrontendSpanExporter) SetPrimary added in v0.11.7

func (fe FrontendSpanExporter) SetPrimary(spanID trace.SpanID)

func (FrontendSpanExporter) SetRevealAllSpans added in v0.12.5

func (fe FrontendSpanExporter) SetRevealAllSpans(val bool)

func (FrontendSpanExporter) Shutdown added in v0.11.7

func (fe FrontendSpanExporter) Shutdown(ctx context.Context) error

func (FrontendSpanExporter) SpanExporter added in v0.11.7

func (fe FrontendSpanExporter) SpanExporter() sdktrace.SpanExporter

func (FrontendSpanExporter) Update added in v0.11.7

func (fe FrontendSpanExporter) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (FrontendSpanExporter) View added in v0.11.7

func (fe FrontendSpanExporter) View() string

type Vterm added in v0.9.9

type Vterm struct {
	Offset int
	Height int
	Width  int

	Prefix string
	// contains filtered or unexported fields
}

func NewVterm added in v0.9.9

func NewVterm() *Vterm

func (*Vterm) Init added in v0.9.9

func (term *Vterm) Init() tea.Cmd

func (*Vterm) LastLine added in v0.9.9

func (term *Vterm) LastLine() string

LastLine returns the last line of visible text, with ANSI formatting, but without any trailing whitespace.

func (*Vterm) Print added in v0.9.9

func (term *Vterm) Print(w io.Writer) error

Print prints the full log output without any formatting.

func (*Vterm) Render added in v0.9.9

func (term *Vterm) Render(w io.Writer, offset, height int)

Bytes returns the output for the given region of the terminal, with ANSI formatting.

func (*Vterm) ScrollPercent added in v0.9.9

func (term *Vterm) ScrollPercent() float64

func (*Vterm) SetHeight added in v0.9.9

func (term *Vterm) SetHeight(height int)

func (*Vterm) SetPrefix added in v0.9.9

func (term *Vterm) SetPrefix(prefix string)

func (*Vterm) SetWidth added in v0.9.9

func (term *Vterm) SetWidth(width int)

func (*Vterm) Term added in v0.9.9

func (term *Vterm) Term() *midterm.Terminal

func (*Vterm) Update added in v0.9.9

func (term *Vterm) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Vterm) UsedHeight added in v0.9.9

func (term *Vterm) UsedHeight() int

func (*Vterm) View added in v0.9.9

func (term *Vterm) View() string

View returns the output for the current region of the terminal, with ANSI formatting.

func (*Vterm) Write added in v0.9.9

func (term *Vterm) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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