utils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package overlay provides functionality for compositing text-based UI elements with positioning support. I copied this package from https://github.com/rmhubbert/bubbletea-overlay

Index

Constants

This section is empty.

Variables

View Source
var BlueColor = strconv.Itoa(4 + 0)
View Source
var BoldStyle = lipgloss.NewStyle().Bold(true)
View Source
var BoxStyle = lipgloss.NewStyle().Border(lipgloss.RoundedBorder())
View Source
var Formatter = colorjson.Formatter{
	Indent:      2,
	KeyColor:    color.New(color.FgBlue),
	StringColor: color.New(color.FgGreen),
	NumberColor: color.New(color.FgCyan),
	BoolColor:   color.New(color.FgYellow),
}
View Source
var GrayColor = strconv.Itoa(8 + 0)
View Source
var GreenColor = strconv.Itoa(2 + 0)
View Source
var Line = lipgloss.NewStyle().Border(lipgloss.NormalBorder()).BorderRight(true).BorderLeft(false).BorderTop(false).BorderBottom(false)
View Source
var OrangeColor = strconv.Itoa(3 + 0)
View Source
var PurpleColor = strconv.Itoa(5 + 0)
View Source
var RedColor = strconv.Itoa(1 + 0)
View Source
var WhiteColor = strconv.Itoa(7 + 0)

Functions

func Clamp

func Clamp(v, lower, upper int) int

Clamp calculates the lowest possible number between the given boundaries.

func Composite

func Composite(fg, bg string, xPos, yPos Position, xOff, yOff int) string

Composite merges and flattens the background and foreground views into a single view. This implementation is based off of the one used by Superfile - https://github.com/yorukot/superfile/blob/main/src/pkg/string_function/overplace.go

func Lines

func Lines(s string) []string

Lines normalises any non standard new lines within a string, and then splits and returns a slice of strings split on the new lines.

func Offsets

func Offsets(fg, bg string, xPos, yPos Position, xOff, yOff int) (int, int)

Offsets calculates the actual vertical and horizontal offsets used to position the foreground relative to the background.

func PrintHorizontalBorder

func PrintHorizontalBorder(height, totalLineCount int, scrollPercent float64) (leftBorder, rightBorder string)

func PrintVerticalBorder

func PrintVerticalBorder(width int) (topBorder, bottomBorder string)

func RenderSeparator

func RenderSeparator() string

func ThumbHeightFromProgress

func ThumbHeightFromProgress(height, TotalLine int) int

func Whitespace

func Whitespace(length int) string

Whitespace returns a string of whitespace characters of the requested length.

Types

type Position

type Position int

Position defines the positioning type for overlay elements.

const (
	Left Position = iota
	Center
	Right
	Top
	Bottom
)

Jump to

Keyboard shortcuts

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