cfmt

package module
v0.0.0-...-8c612a5 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: Apache-2.0 Imports: 1 Imported by: 1

README

cfmt

Apache license Go Version

README | 中文文档

A lightweight packaging library for outputting color text on the terminal

Install

go get github.com/zhangboqi/cfmt

Usage

package main
import "github.com/zhangboqi/cfmt"

func main(){
	// green
	cfmt.Gprintln("green")

	// red
	cfmt.Rprintln("red")

	// yellow
	cfmt.Yprintln("yellow")

}

Custom


package main

import (
	"github.com/zhangboqi/cfmt"
)

func main() {
	bfmt := cfmt.New(cfmt.CODE_DEFAULT, cfmt.BG_BLACK, cfmt.FG_BLUE)
	bfmt.Println("Blue")
}

Documentation

Index

Constants

View Source
const (
	CODE_DEFAULT    = 0
	CODE_HIGH_LIGHT = 1
	CODE_UNDER_LINE = 4
	CODE_TWINKLE    = 5
	CODE_ALBEDO     = 7
	CODE_INVISIBLE  = 8
)

代码 意义 -------------------------

0  终端默认设置
1  高亮显示
4  使用下划线
5  闪烁
7  反白显示
8  不可见
View Source
const (
	BG_BLACK   = 40
	BG_RED     = 41
	BG_GREEN   = 42
	BG_YELLOW  = 43
	BG_BLUE    = 44
	BG_MAGENTA = 45
	BG_INDIGO  = 46
	BG_WHITE   = 47
)

前景 背景 颜色 --------------------------------------- 30 40 黑色 31 41 红色 32 42 绿色 33 43 黄色 34 44 蓝色 35 45 紫红色 36 46 青蓝色 37 47 白色

View Source
const (
	FG_BLACK   = 30
	FG_RED     = 31
	FG_GREEN   = 32
	FG_YELLOW  = 33
	FG_BLUE    = 34
	FG_MAGENTA = 35
	FG_INDIGO  = 36
	FG_WHITE   = 37
)

Variables

This section is empty.

Functions

func Gprint

func Gprint(a ...any)

func Gprintf

func Gprintf(format string, a ...any)

func Gprintln

func Gprintln(a ...any)

func Rprint

func Rprint(a ...any)

func Rprintf

func Rprintf(format string, a ...any)

func Rprintln

func Rprintln(a ...any)

func Yprint

func Yprint(a ...any)

func Yprintf

func Yprintf(format string, a ...any)

func Yprintln

func Yprintln(a ...any)

Types

type Cfmt

type Cfmt struct {
	Code       int
	Background int
	Foreground int
}

func New

func New(code int, background int, foreground int) *Cfmt

func (*Cfmt) Print

func (f *Cfmt) Print(a ...any)

func (*Cfmt) Printf

func (f *Cfmt) Printf(format string, a ...any)

func (*Cfmt) Println

func (f *Cfmt) Println(a ...any)

Jump to

Keyboard shortcuts

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