colorterm

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 3 Imported by: 1

README

go-colorterm

LICENSE Go Reference Go Report Card

Enable ANSI escape sequence handling on Windows.

Usage

package main

import "github.com/cions/go-colorterm"

func main() {
	if colorterm.Enabled {
		fmt.Printf("\x1b[31mred text\x1b[0m")
	} else {
		fmt.Printf("plain text")
	}
}

License

MIT

Documentation

Overview

colorterm enables ANSI escape sequence handling on Windows.

Index

Constants

This section is empty.

Variables

View Source
var (
	Escape = '\x1b'
	CSI    = "\x1b["
)
View Source
var (
	Reset = EscapeCode("\x1b[0m")

	FgBlack   = EscapeCode("\x1b[30m")
	FgRed     = EscapeCode("\x1b[31m")
	FgGreen   = EscapeCode("\x1b[32m")
	FgYellow  = EscapeCode("\x1b[33m")
	FgBlue    = EscapeCode("\x1b[34m")
	FgMagenta = EscapeCode("\x1b[35m")
	FgCyan    = EscapeCode("\x1b[36m")
	FgWhite   = EscapeCode("\x1b[37m")
	FgReset   = EscapeCode("\x1b[39m")

	BgBlack   = EscapeCode("\x1b[40m")
	BgRed     = EscapeCode("\x1b[41m")
	BgGreen   = EscapeCode("\x1b[42m")
	BgYellow  = EscapeCode("\x1b[43m")
	BgBlue    = EscapeCode("\x1b[44m")
	BgMagenta = EscapeCode("\x1b[45m")
	BgCyan    = EscapeCode("\x1b[46m")
	BgWhite   = EscapeCode("\x1b[47m")
	BgReset   = EscapeCode("\x1b[49m")
)
View Source
var Enabled = false

Functions

This section is empty.

Types

type EscapeCode added in v0.2.0

type EscapeCode string

func Bg256Color added in v0.2.0

func Bg256Color(c uint8) EscapeCode

func BgRGB added in v0.2.0

func BgRGB(r, g, b uint8) EscapeCode

func Fg256Color added in v0.2.0

func Fg256Color(c uint8) EscapeCode

func FgRGB added in v0.2.0

func FgRGB(r, g, b uint8) EscapeCode

func (EscapeCode) String added in v0.2.0

func (ec EscapeCode) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳