~poldi1405/go-ansi

ref: 76d320c6afe7577b81dc9a9196484bbcad5057a9 go-ansi/fonts.go -rw-r--r-- 977 bytes
76d320c6 — Moritz Poldrack added function to remove all ANSI-Codes from a string 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package ansi

import (
	"fmt"
	"strconv"
)

// Fraktur is equivalent to SetFraktur() + content + UnsetFraktur(), content
// will thereby be printed in Frakturschrift. This is very rarely support.
func Fraktur(content ...interface{}) string {
	return SetFraktur() + fmt.Sprint(content...) + UnsetFraktur()
}

// SetFraktur makes the following text be printed printed in Frakturschrift
func SetFraktur() string {
	return escape + fraktur + set
}

// UnsetFraktur resets the font to the default
func UnsetFraktur() string {
	return escape + frakturOff + set
}

// Font applies the specified fontface to the text
func Font(font int, content ...interface{}) string {
	return SetFont(font) + fmt.Sprint(content...) + UnsetFont()
}

// SetFont starts a block written in the specified font
func SetFont(font int) string {
	return escape + strconv.Itoa(font+10) + set
}

// UnsetFont resets the fontface back to the default
func UnsetFont() string {
	return escape + frakturOff + set
}