ct

package module
v0.0.0-...-9cd201a Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: BSD-3-Clause, MIT Imports: 4 Imported by: 0

README

go-colortext package GoSearch

This is a package to change the color of the text and background in the console, working both under Windows and other systems.

Under Windows, the console APIs are used. Otherwise, ANSI texts are output.

Docs: http://godoc.org/github.com/daviddengcn/go-colortext (packages that import ct)

Usage:

ct.Foreground(Green, false)
fmt.Println("Green text starts here...")
ct.ChangeColor(Red, true, White, false)
fmt.Println(...)
ct.ResetColor()

LICENSE

BSD/MIT license

Documentation

Overview

ct package provides functions to change the color of console text.

Under windows platform, the Console API is used. Under other systems, ANSI text mode is used.

Index

Constants

View Source
const (
	// No change of color
	None = Color(iota)
	Black
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)

Variables

This section is empty.

Functions

func Background

func Background(writer io.Writer, cl Color, bright bool)

Background changes the background color.

func ChangeColor

func ChangeColor(writer io.Writer, fg Color, fgBright bool, bg Color, bgBright bool)

ChangeColor sets the foreground and background colors. If the value of the color is None, the corresponding color keeps unchanged. If fgBright or bgBright is set true, corresponding color use bright color. bgBright may be ignored in some OS environment.

func ChangeStyle

func ChangeStyle(writer io.Writer, styles ...Style)

ChangeStyle changes the style of printed text

func Foreground

func Foreground(writer io.Writer, cl Color, bright bool)

Foreground changes the foreground color.

func Reset

func Reset(writer io.Writer)

Reset resets the foreground, background and style

Types

type Color

type Color int

Color is the type of color to be set.

type Style

type Style int

Style is the type of style to be set.

const (
	Bold Style = iota
	Underline
)

Directories

Path Synopsis
Package ctfmt is a handful wrapping of go-colortext (ct) package and fmt package.
Package ctfmt is a handful wrapping of go-colortext (ct) package and fmt package.

Jump to

Keyboard shortcuts

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