protip

package
v13.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package protip provides methods for displaying usage tips

Index

Examples

Constants

This section is empty.

Variables

View Source
var ColorTag = "{#75}"

ColorTag is default panel color tag

Options contains default panel options

View Source
var Probability = 0.25

Probability is showing probability coefficient (0 ← less | more → 1)

Functions

func Add

func Add(tips ...*Tip)

Add adds one or more tips to collection

Example
// Add simple tip
Add(&Tip{
	Title:   "Tip #1",
	Message: `Tip message`,
})

// Add tip with custom weight (≠ 0.5)
Add(&Tip{
	Title:   "Tip #2",
	Message: `Tip message`,
	Weight:  0.1,
})

// Add tip with custom weight (≠ 0.5) and color
Add(&Tip{
	Title:    "Tip #3",
	Message:  `Tip message`,
	Weight:   0.8,
	ColorTag: "{b}",
})
Output:

func Show

func Show(force bool) bool

Show shows random tip if required

Example
// Add simple tip
Add(&Tip{
	Title:   "Tip #1",
	Message: `Tip message`,
})

// Increase default probability to 50%
Probability = 0.5

// Set default color to green
ColorTag = "{g}"

// Try to show tip
Show(false)

// Force show
Show(true)
Output:

Types

type Tip

type Tip struct {
	Title   string // Tip title (required)
	Message string // Tip message (required)

	ColorTag string  // Custom tip color (optional)
	Weight   float64 // Custom tip weight (optional)
}

Tip contains basic tip content

type Tips

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

Tips contains tips data

Jump to

Keyboard shortcuts

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