oigiki

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

README

oigiki

fast ansi color tagging lib, inspired by blessed from node
uses https://github.com/fatih/color
extracted from axefetch

usage

/// coloring will run until overridden
/// chaining works too uwu
oigiki.ProcessTags("{red}red{green}green{/green}red") /// "\x1b[31mred\x1b[32mgreen\x1b[31mred\x1b[0m"
/// unknown tags are ignored
oigiki.ProcessTags("{red}red {totallyrealcolor}still red") /// "\x1b[31mred still red\x1b[0m"

oigiki.TagString("this should be red", "red") /// "{red}this should be red"
oigiki.StripLine("{red}{bold}whos that {bg#f100f1}{underline}knockin{/underline} at my door?") /// whos that knockin at my door?

supported colors

everything fatih/color supports, with rgb as hex

/// hex must be the full rrggb
"{#ff00ff}ff00ff"
/// bg is easy too
"{bg#ff00ff}{black}ff00ff"

todo

  • rgb tagging? {r,g,b}?

Documentation

Overview

fast ansi color tagging system similar to blessed from node

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessTags

func ProcessTags(input string) string

process a tagged string into ansi

func StripTags added in v1.0.0

func StripTags(s string) string

strip format tags (NOT ansi) from line

func TagString

func TagString(s, tag string) string

add a format tag to a string

Types

type TagType added in v1.0.0

type TagType int
const (
	TagTypeUnknown TagType = iota
	TagTypeReset
	TagTypeColor
	TagTypeBold
	TagTypeItalic
	TagTypeUnderline
)

func GetTagEscapeCode added in v1.0.0

func GetTagEscapeCode(tagName string) (string, TagType)

this might be useful, maybe for rgb? returns the ansi escape code for a tag (and its type)

Jump to

Keyboard shortcuts

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