tic

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 6 Imported by: 1

README

TIC

[!WARNING] This module is deprecated.

The project has moved to:

https://github.com/ams-soft/tic

┌─┴─┴─┴─┴─┴─┴─┴─┴─┐
🭲○  ♦ AMS TIC ♦   🭲
└─┬─┬─┬─┬─┬─┬─┬─┬─┘

TIC is a Go library for terminal styling with ANSI colors, inspired by the VIC-II (Commodore 64) and Atari 800 color palettes.

Features

  • Complete VIC-II color palette from Commodore 64
  • Atari 800 colors
  • Support for 16 and 256 ANSI colors
  • Text styles (bold, italic, underline, blink, etc.)
  • Style Builder for fluent style composition
  • Foreground and background control
  • Functions to clear and paint the entire screen
  • Utilities for stripping ANSI codes

Installation

go get github.com/ams-tech-fin/tic

Basic Usage

Applying Colors
package main

import (
    "fmt"
    "github.com/ams-tech-fin/tic"
)

func main() {
    // Text with foreground color
    fmt.Println(tic.ColorText("Hello, World!", tic.ColorCyan))

    // Text with background color
    fmt.Println(tic.ColorBg("Colored background", tic.ColorYellow))

    // Text with foreground and background
    fmt.Println(tic.WithColors("Styled text", tic.ColorWhite, tic.ColorBlue))
}
Text Styles
// Simple styles
fmt.Println(tic.Bold("Bold text"))
fmt.Println(tic.Italic("Italic text"))
fmt.Println(tic.Underline("Underlined text"))
fmt.Println(tic.Blink("Blinking text"))
fmt.Println(tic.Reverse("Reversed text"))
fmt.Println(tic.Strike("Strikethrough text"))
fmt.Println(tic.Dim("Dimmed text"))

// Combining color with style
colored := tic.ColorText("Green and bold", tic.ColorLightGreen)
fmt.Println(tic.Bold(colored))
Style Builder (Fluent Composition)
// Compose multiple styles fluently
success := tic.Style().
    Fg(tic.ColorLightGreen).
    Bg(tic.ColorBlack).
    Bold().
    Sprint("SUCCESS: operation completed")

error := tic.Style().
    Fg(tic.ColorLightRed).
    Bg(tic.ColorBlack).
    Bold().
    Underline().
    Sprint("ERROR: operation failed")

fmt.Println(success)
fmt.Println(error)
Terminal Control
// Set foreground color globally
tic.SetFg(tic.ColorCyan)
fmt.Println("This text is cyan")

// Set background color globally
tic.SetBg(tic.ColorBlack)
fmt.Println("This text has black background")

// Reset all colors and styles
tic.ResetAll()

// Clear screen
tic.ClearScreen()

// Clear and paint entire screen with a color
tic.ClearScreenWithBg(tic.ColorC64BG)

Color Palette

The library includes the complete VIC-II palette:

  • ColorBlack, ColorWhite
  • ColorRed, ColorCyan, ColorPurple, ColorGreen, ColorBlue, ColorYellow
  • ColorOrange, ColorBrown
  • ColorLightRed, ColorLightGreen, ColorLightBlue
  • ColorDarkGray, ColorMediumGray, ColorLightGray
  • ColorLightPurple, ColorDarkPurple

Thematic colors:

  • ColorC64BG, ColorC64FG - Classic Commodore 64 colors
  • ColorA800BG, ColorA800FG - Classic Atari 800 colors

Demo

To run the interactive demo:

make dev

Or directly:

go run ./cmd/tic-demo/main.go

The demo shows:

  • Retro themes (C64, A800, CRT)
  • Complete color showroom
  • Text style examples
  • Style Builder demonstration
  • Visual terminal effects
  • Complete ANSI 256 color table

Utility Functions

// Strip ANSI codes from a string
text := tic.ColorText("Colored", tic.ColorRed)
clean := tic.StripANSI(text) // "Colored"

// Print ANSI 256 color table
tic.PrintANSI256Table()

// Redefine output writer (useful for testing)
tic.SetOutput(customWriter)
tic.ResetOutput() // back to os.Stdout

License

©2025 - AMS SOFT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorList = []ColorEntry{
	{ColorBlack, "Black"},
	{ColorWhite, "White"},
	{ColorRed, "Red"},
	{ColorCyan, "Cyan"},
	{ColorPurple, "Purple"},
	{ColorGreen, "Green"},
	{ColorBlue, "Blue"},
	{ColorYellow, "Yellow"},
	{ColorOrange, "Orange"},
	{ColorBrown, "Brown"},
	{ColorLightRed, "LightRed"},
	{ColorDarkGray, "DarkGray"},
	{ColorMediumGray, "MediumGray"},
	{ColorLightGreen, "LightGreen"},
	{ColorLightBlue, "LightBlue"},
	{ColorLightGray, "LightGray"},
	{ColorLightPurple, "LightPurple"},
	{ColorDarkPurple, "DarkPurple"},
	{ColorC64BG, "C64BG"},
	{ColorC64FG, "C64FG"},
	{ColorA800BG, "A800BG"},
	{ColorA800FG, "A800FG"},
}

Functions

func Blink(t string) string

func Bold

func Bold(t string) string

func ClearScreen

func ClearScreen()

func ClearScreenWithBg

func ClearScreenWithBg(c Color)

ClearScreenWithBg pinta a tela inteira com uma cor VIC-II.

func ColorBg

func ColorBg(text string, bg Color) string

func ColorText

func ColorText(text string, fg Color) string

func Colorize

func Colorize(text string, fg Color, bg Color) string

func Dim

func Dim(t string) string

func Italic

func Italic(t string) string

func PrintANSI256Table

func PrintANSI256Table()

imprime tabela ANSI 256 com ♦, RGB e "38;5;N"

func PrintLine

func PrintLine(line string, fg Color, bg Color)

PrintLine imprime uma linha com fg/bg e reseta tudo no final.

func Reset

func Reset()

Reset reseta todos os atributos (cores + estilos).

func ResetAll

func ResetAll()

Alias semântico

func ResetBg

func ResetBg()

ResetBg reseta só o background para o default do terminal.

func ResetFg

func ResetFg()

ResetFg reseta só o foreground para o default do terminal.

func ResetOutput

func ResetOutput()

func ResetScreenBg

func ResetScreenBg()

ResetScreenBg reseta fundo da tela inteira e limpa.

func ResetStyle

func ResetStyle() string

ResetStyle só devolve o escape de reset.

func Reverse

func Reverse(t string) string

func SetBg

func SetBg(c Color)

func SetFg

func SetFg(c Color)

func SetOutput

func SetOutput(w io.Writer)

func Strike

func Strike(t string) string

func StripANSI

func StripANSI(s string) string

StripANSI remove todos os estilos e cores ANSI da string e retorna apenas o texto puro.

func Underline

func Underline(t string) string

func WithColors

func WithColors(text string, fg Color, bg Color) string

Types

type Color

type Color int
const (
	ColorBlack Color = iota
	ColorWhite
	ColorRed
	ColorCyan
	ColorPurple
	ColorGreen
	ColorBlue
	ColorYellow
	ColorOrange
	ColorBrown
	ColorLightRed
	ColorDarkGray
	ColorMediumGray
	ColorLightGreen
	ColorLightBlue
	ColorLightGray
	ColorLightPurple
	ColorDarkPurple
	ColorC64BG // NOVA
	ColorC64FG
	ColorA800BG // NOVA
	ColorA800FG
)

type ColorEntry

type ColorEntry struct {
	Color Color
	Name  string
}

type StyleBuilder

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

StyleBuilder permite compor estilos (cores + atributos ANSI) de forma fluente.

func NewStyle

func NewStyle() *StyleBuilder

func Style

func Style() *StyleBuilder

Atalho

func (*StyleBuilder) Bg

func (s *StyleBuilder) Bg(c Color) *StyleBuilder

Bg define a cor de background.

func (s *StyleBuilder) Blink() *StyleBuilder

func (*StyleBuilder) Bold

func (s *StyleBuilder) Bold() *StyleBuilder

func (*StyleBuilder) Dim

func (s *StyleBuilder) Dim() *StyleBuilder

func (*StyleBuilder) Fg

func (s *StyleBuilder) Fg(c Color) *StyleBuilder

Fg define a cor de foreground (texto).

func (*StyleBuilder) Italic

func (s *StyleBuilder) Italic() *StyleBuilder

func (*StyleBuilder) Reverse

func (s *StyleBuilder) Reverse() *StyleBuilder

func (*StyleBuilder) Sprint

func (s *StyleBuilder) Sprint(text string) string

Sprint aplica o estilo ao texto e retorna ANSI + reset.

func (*StyleBuilder) Sprintln

func (s *StyleBuilder) Sprintln(text string) string

func (*StyleBuilder) Strike

func (s *StyleBuilder) Strike() *StyleBuilder

func (*StyleBuilder) Underline

func (s *StyleBuilder) Underline() *StyleBuilder

Directories

Path Synopsis
cmd
tic-demo command

Jump to

Keyboard shortcuts

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