panel

package
v12.120.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package panel provides methods for rendering panels with text

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrorColorTag is fmtc color tag used for error messages
	ErrorColorTag = "{r}"

	// WarnColorTag is fmtc color tag used for warning messages
	WarnColorTag = "{y}"

	// InfoColorTag is fmtc color tag used for info messages
	InfoColorTag = "{c-}"
)
View Source
var Indent = 0

Indent is indent from the left side of terminal

View Source
var Width = 88

Width is panel width (≥ 40) if option WRAP is set

Functions

func Error added in v12.73.1

func Error(title, message string, options ...Option)

Error shows panel with error message

Example
Error(
	"Can't send data to remote server.",
	`{*}Lorem ipsum{!} dolor sit amet, {r*}consectetur{!} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.`,
	WRAP, BOTTOM_LINE,
)
Output:

func Info added in v12.73.1

func Info(title, message string, options ...Option)

Info shows panel with warning message

Example
Info(
	"Auto-saving is enabled - data will be saved after editing.",
	`{*}Lorem ipsum{!} dolor sit amet, {r*}consectetur{!} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.`,
	WRAP, INDENT_OUTER,
)
Output:

func Panel

func Panel(label, colorTag, title, message string, options ...Option)

Panel shows panel with given label, title, and message

Example
Panel(
	"Yolo", "{m}",
	"Excepteur sint occaecat cupidatat non proident.",
	`{*}Lorem ipsum{!} dolor sit amet, {r*}consectetur{!} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.`,
	WRAP, BOTTOM_LINE,
)
Output:

func Warn added in v12.73.1

func Warn(title, message string, options ...Option)

Warn shows panel with warning message

Example
Warn(
	"Can't find user bob on system.",
	`{*}Lorem ipsum{!} dolor sit amet, {r*}consectetur{!} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.`,
	WRAP,
)
Output:

Types

type Option

type Option uint8
const (
	// WRAP is panel rendering option for automatic text wrapping
	WRAP Option = iota + 1

	// INDENT_OUTER is panel rendering option for indent using new lines
	// before and after panel
	INDENT_OUTER

	// INDENT_INNER is panel rendering option for indent using new lines
	// before and after panel data
	INDENT_INNER

	// TOP_LINE is panel rendering option for drawing top line of panel
	TOP_LINE

	// BOTTOM_LINE is panel rendering option for drawing bottom line of panel
	BOTTOM_LINE

	// LABEL_POWERLINE is panel rendering option for using powerline symbols
	LABEL_POWERLINE
)

type Options added in v12.83.0

type Options []Option
var DefaultOptions Options

DefaultOptions is the default options used for rendering the panel if no options are passed

func (Options) Has added in v12.83.0

func (o Options) Has(option Option) bool

Has returns true if options slice contains given option

Jump to

Keyboard shortcuts

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