-
Notifications
You must be signed in to change notification settings - Fork 0
/
titles.go
56 lines (44 loc) · 1.21 KB
/
titles.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package tcl
import (
"fmt"
"strings"
c "github.com/fatih/color"
"golang.org/x/crypto/ssh/terminal"
)
// Title prints a title with backgorund and text in uppercase.
func Title(title string) {
titleColor := c.New(c.BgBlue, c.FgBlack, c.Bold)
NewLines(1)
indent(0)
titleColor.Printf(" %s ", strings.ToUpper(title))
NewLines(2)
}
// TitleC is like Title() but is centered in the console.
func TitleC(title string) {
titleColor := c.New(c.BgBlue, c.FgBlack, c.Bold)
width, _, _ := terminal.GetSize(0)
leftOffset := (width - len(title)) / 2
NewLines(1)
indent(0)
fmt.Print(strings.Repeat(" ", leftOffset))
titleColor.Printf(" %s ", strings.ToUpper(title))
NewLines(2)
}
// SubTitle prints a subtitle that is bold and underlined.
func SubTitle(title string) {
titleColor := c.New(c.FgBlue, c.Bold, c.Underline)
NewLines(1)
indent(0)
titleColor.Print(title)
NewLines(1)
}
// FullTitle prints out a title that is as wide as your terminal is.
func FullTitle(title string) {
width, _, _ := terminal.GetSize(0)
titleColor := c.New(c.BgBlue, c.FgBlack, c.Bold)
NewLines(1)
indent(0)
titleColor.Printf(" %s", strings.ToUpper(title))
titleColor.Print(strings.Repeat(" ", width-len(title)-6))
NewLines(2)
}