stdgomods

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TERM_INITED bool = false // Only want to do init once

	XPos, YPos int // X and Y position of the cursor as reported by 'UpdateCursorLocation'
)
View Source
var (
	DEBUG bool // Enable PDebug output

	StatusFunctions []statusFunction // List of functions that should be called by `UpdateStatus`

)
View Source
var (
	Start time.Time // When we want to start our timer
	End   time.Time // Track if we togged debug output or not in ToggleDebugIfNeeded()
)

Ideally this would be a map or array so we could have multiple timers. TODO: Do that thing mentioned in the previous line

Functions

func AddStatusFunction

func AddStatusFunction(f statusFunction)

func B2S

func B2S(s string) []byte

func Blue

func Blue(msg string) string

func Bold

func Bold(msg string) string

func CDown

func CDown()

func CLeft

func CLeft()

func CRight

func CRight()

func CUp

func CUp()

func Check

func Check(err error, msg string)

func Cleanup

func Cleanup()

Things we want to make sure we run on exit. Ideally, whoever calls us will put a `defer stdgomods.Cleanup()` very early in their `main()` function.

func ClearEntireLine

func ClearEntireLine()

func ClearFromHereDown

func ClearFromHereDown()

func ClearFromHereUp

func ClearFromHereUp()

func ClearScreen

func ClearScreen()

func ClearToBeginningOfLine

func ClearToBeginningOfLine()

func ClearToEndOfLine

func ClearToEndOfLine()

func Colorize

func Colorize(frmt string, color aec.ANSI, vars ...interface{}) string

// Colorization functions

func Cyan

func Cyan(msg string) string

func FmtPDebug

func FmtPDebug(frmt string, vars ...interface{})

func GetBoolEnvVar

func GetBoolEnvVar(envName string, defaultValue bool) bool

Sometimes we want to use boolean ENV variables.

func GetCurrentCursorLocation

func GetCurrentCursorLocation() (int, int)

func GetEnvVar

func GetEnvVar(envName string, defaultValue string) string

If an ENV variable is set, return that value. Otherwise, return the default

func GetNumericEnvVar

func GetNumericEnvVar(envName string, defaultValue int) int

Sometimes we want to use numeric ENV variables.

func InitOutputTools

func InitOutputTools()

func InitTerm

func InitTerm()

func IntPct

func IntPct(progress, total int64) int64

func MoveCursorDown

func MoveCursorDown(times int)

func MoveCursorLeft

func MoveCursorLeft(times int)

func MoveCursorRight

func MoveCursorRight(times int)

func MoveCursorTo

func MoveCursorTo(x, y int)

func MoveCursorUp

func MoveCursorUp(times int)

func NewDurationTimer

func NewDurationTimer() *durationTimer

func Orange

func Orange(msg string) string

func PBlue

func PBlue(frmt string, vars ...interface{})

func PColorize

func PColorize(frmt string, color aec.ANSI, vars ...interface{})

func PCyan

func PCyan(frmt string, vars ...interface{})

func PDebug

func PDebug(msg ...string)

Print debug info. Uses logger with one-time config options set in InitOutputTools() It will only print if the global DEBUG variable is 'true'

func POrange

func POrange(frmt string, vars ...interface{})

func PPink

func PPink(frmt string, vars ...interface{})

func PPurple

func PPurple(frmt string, vars ...interface{})

func PRed

func PRed(frmt string, vars ...interface{})

func PWhite

func PWhite(frmt string, vars ...interface{})

func PYellow

func PYellow(frmt string, vars ...interface{})

func PanicIfError

func PanicIfError(err error, msg string)

Simple utility function to check the error status and, if it is not nil, log.Panic a message and exit

func Pink

func Pink(msg string) string

func ProgressBar

func ProgressBar(size, total, done int64) string

This returns a string for a progress bar that looks like so:

[###########=====]

Colorization might be a thing... we'll see Params:

  • size: Number of discrete units in the bar
  • total: Total items to be done
  • done: Number of items that ARE done

func Purple

func Purple(msg string) string

func Red

func Red(msg string) string

func RestorePosition

func RestorePosition()

func RestoreTerm

func RestoreTerm()

func S2B

func S2B(b []byte) string

func SPBlue

func SPBlue(frmt string, vars ...interface{}) string

func SPColorize

func SPColorize(frmt string, color aec.ANSI, vars ...interface{}) string

func SPCyan

func SPCyan(frmt string, vars ...interface{}) string

func SPOrange

func SPOrange(frmt string, vars ...interface{}) string

func SPPink

func SPPink(frmt string, vars ...interface{}) string

func SPPurple

func SPPurple(frmt string, vars ...interface{}) string

func SPRed

func SPRed(frmt string, vars ...interface{}) string

func SPWhite

func SPWhite(frmt string, vars ...interface{}) string

func SPYellow

func SPYellow(frmt string, vars ...interface{}) string

func SavePosition

func SavePosition()

func ScreenHeight

func ScreenHeight() int

func ScreenSize

func ScreenSize() (x, y int)

func ScreenWidth

func ScreenWidth() int

func TPClearScreen

func TPClearScreen() string

func TPClearToEndOfScreen

func TPClearToEndOfScreen() string

func TPClearToTopOfScreen

func TPClearToTopOfScreen() string

func TPCols

func TPCols() int

func TPCursorDown

func TPCursorDown(times int) string

func TPCursorLeft

func TPCursorLeft(times int) string

func TPCursorPosition

func TPCursorPosition(x, y int) string

func TPCursorRight

func TPCursorRight(times int) string

func TPCursorUp

func TPCursorUp(times int) string

func TPDeviceStatusReport

func TPDeviceStatusReport() string

func TPEraseLine

func TPEraseLine() string

func TPEraseLineBackward

func TPEraseLineBackward() string

func TPEraseLineForward

func TPEraseLineForward() string

func TPRestoreCursor

func TPRestoreCursor() string

func TPRows

func TPRows() int

func TPSaveCursor

func TPSaveCursor() string

func TPTermSize

func TPTermSize() (width, height int)

func TermCheck

func TermCheck(err error, msg string)

Works around race condition when using 'Check' from inside InitTerm (but after we start mucking with the terminal window)

func ToggleDebugIfNeeded

func ToggleDebugIfNeeded(flag bool)

This is used to allow for fine-grained DEBUG output with multiple flags. Caveats: - Do not overlap areas that flags are used. The intent is for flags to be specific to a function - This is intended used in conjunction with PDebug().

func UpdateCursorLocation

func UpdateCursorLocation() error

// Currently busted because I don't have a reliable way to get the results back // from TPDeviceStatusReport(). *IF* I get those results back, it works great. // TODO: Get reliable way to read buffer

func UpdateStatus

func UpdateStatus()

Use our cursor movement abilities to make a small status section in the upper right corner to print out whatever we thing is important up there.

func White

func White(msg string) string

func Yellow

func Yellow(msg string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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