utils

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IDLength max ID length to display.
	IDLength = 12
	// RefreshInterval application refresh interval.
	RefreshInterval = 1000 * time.Millisecond

	ContainerIDLabel  = "CONTAINER ID:"
	PruneCommandLabel = "prune"
)

Variables

View Source
var (
	CommandMenuKey = uiKeyInfo{
		Key:      tcell.Key(256),
		KeyRune:  rune('m'),
		KeyLabel: "m",
		KeyDesc:  "display command menu",
	}
	SortMenuKey = uiKeyInfo{
		Key:      tcell.Key(256),
		KeyRune:  rune('s'),
		KeyLabel: "s",
		KeyDesc:  "display sort menu",
	}
	NextScreenKey = uiKeyInfo{
		Key:      tcell.Key(256),
		KeyRune:  rune('l'),
		KeyLabel: "l",
		KeyDesc:  "switch to next screen",
	}
	PreviousScreenKey = uiKeyInfo{
		Key:      tcell.Key(256),
		KeyRune:  rune('h'),
		KeyLabel: "h",
		KeyDesc:  "switch to previous screen",
	}
	MoveUpKey = uiKeyInfo{
		Key:      tcell.KeyUp,
		KeyRune:  rune('k'),
		KeyLabel: "k",
		KeyDesc:  "move up",
	}
	MoveDownKey = uiKeyInfo{
		Key:      tcell.KeyDown,
		KeyRune:  rune('j'),
		KeyLabel: "j",
		KeyDesc:  "move down",
	}
	CloseDialogKey = uiKeyInfo{
		Key:      tcell.KeyEsc,
		KeyLabel: "Esc",
		KeyDesc:  "close the active dialog",
	}
	SwitchFocusKey = uiKeyInfo{
		Key:      tcell.KeyTab,
		KeyLabel: "Tab",
		KeyDesc:  "switch between widgets",
	}
	DeleteKey = uiKeyInfo{
		Key:      tcell.KeyDelete,
		KeyLabel: "Delete",
		KeyDesc:  "delete the selected item",
	}
	ArrowUpKey = uiKeyInfo{
		Key:      tcell.KeyUp,
		KeyLabel: "Arrow Up",
		KeyDesc:  "move up",
	}
	ArrowDownKey = uiKeyInfo{
		Key:      tcell.KeyDown,
		KeyLabel: "Arrow Down",
		KeyDesc:  "move down",
	}
	ArrowLeftKey = uiKeyInfo{
		Key:      tcell.KeyLeft,
		KeyLabel: "Arrow Left",
		KeyDesc:  "previous screen",
	}
	ArrowRightKey = uiKeyInfo{
		Key:      tcell.KeyRight,
		KeyLabel: "Arrow Right",
		KeyDesc:  "next screen",
	}
	ScrollUpKey = uiKeyInfo{
		Key:      tcell.KeyPgUp,
		KeyLabel: "Page Up",
		KeyDesc:  "scroll up",
	}
	ScrollDownKey = uiKeyInfo{
		Key:      tcell.KeyPgDn,
		KeyLabel: "Page Down",
		KeyDesc:  "scroll down",
	}
	AppExitKey = uiKeyInfo{
		Key:      tcell.KeyCtrlC,
		KeyLabel: "Ctrl+c",
		KeyDesc:  "exit application",
	}
	HelpScreenKey = uiKeyInfo{
		Key:      tcell.KeyF1,
		KeyLabel: "F1",
		KeyDesc:  "display help screen",
	}
	SystemScreenKey = uiKeyInfo{
		Key:      tcell.KeyF2,
		KeyLabel: "F2",
		KeyDesc:  "display system screen",
	}
	PodsScreenKey = uiKeyInfo{
		Key:      tcell.KeyF3,
		KeyLabel: "F3",
		KeyDesc:  "display pods screen",
	}
	ContainersScreenKey = uiKeyInfo{
		Key:      tcell.KeyF4,
		KeyLabel: "F4",
		KeyDesc:  "display containers screen",
	}
	VolumesScreenKey = uiKeyInfo{
		Key:      tcell.KeyF5,
		KeyLabel: "F5",
		KeyDesc:  "display volumes screen",
	}
	ImagesScreenKey = uiKeyInfo{
		Key:      tcell.KeyF6,
		KeyLabel: "F6",
		KeyDesc:  "display images screen",
	}
	NetworksScreenKey = uiKeyInfo{
		Key:      tcell.KeyF7,
		KeyLabel: "F7",
		KeyDesc:  "display networks screen",
	}
	SecretsScreenKey = uiKeyInfo{
		Key:      tcell.KeyF8,
		KeyLabel: "F8",
		KeyDesc:  "display secrets screen",
	}
)
View Source
var (
	ErrURLMissingScheme = errors.New("url missing scheme")
	ErrInvalidFilename  = errors.New("invalid filename (should not contain ':')")
)

UIKeysBindings user interface key bindings.

Functions

func AlignStringListWidth

func AlignStringListWidth(list []string) ([]string, int)

AlignStringListWidth returns max string len in the list.

func EmptyBoxSpace added in v0.2.0

func EmptyBoxSpace(bgColor tcell.Color) *tview.Box

EmptyBoxSpace returns simple Box without border with bgColor as background.

func GetIDWithLimit added in v0.7.0

func GetIDWithLimit(id string) string

GetIDWithLimit return ID string with limited string characters.

func LabelWidthLeftPadding added in v1.8.0

func LabelWidthLeftPadding(input string, padding int) string

LabelWidthLeftPadding adds left space padding.

func ParseKeyEventKey added in v0.2.0

func ParseKeyEventKey(event *tcell.EventKey) *tcell.EventKey

ParseKeyEventKey parsed and changes key events key and rune base on keyname.

func ProgressUsageString added in v0.2.0

func ProgressUsageString(percentage float64) string

ProgressUsageString return progressbar string (bars + usage percentage).

func ResolveHomeDir added in v0.3.1

func ResolveHomeDir(path string) (string, error)

ResolveHomeDir converts a path referencing the home directory via "~" to an absolute path.

func StringToEventKey added in v0.5.0

func StringToEventKey(input string) []*tcell.EventKey

StringToEventKey returns list of key events equvalant to the input string.

func StringToInputLabel added in v1.8.0

func StringToInputLabel(input string, maxWidth int) string

StringToInputLabel create string with max width required for input fields.

func UserHomeDir added in v0.4.0

func UserHomeDir() (string, error)

UserHomeDir returns user's home directory.

func ValidURL added in v0.3.1

func ValidURL(urlStr string) error

ValidURL checks a string urlStr is a url or not.

func ValidateFileName added in v0.3.1

func ValidateFileName(filename string) error

ValidateFileName returns an error if filename contains ":" as it is currently not supported.

Types

type UIDialog added in v0.13.0

type UIDialog interface {
	tview.Primitive
	IsDisplay() bool
	Hide()
}

Jump to

Keyboard shortcuts

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