-
Notifications
You must be signed in to change notification settings - Fork 0
/
term.go
66 lines (51 loc) · 1.6 KB
/
term.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
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"strings"
"github.com/charmbracelet/lipgloss"
)
func drawTitle() {
divider := lipgloss.NewStyle().Padding(0, 1).Foreground(borderStyle).SetString("•").String()
info := lipgloss.NewStyle().Foreground(specialStyle).Render
welcome := strings.Builder{}
onlineStatus := "[Status: Online]"
if offline { onlineStatus = "[Status: Offline]" }
title := lipgloss.NewStyle().
Padding(0, 0, 0, 0).
Width(80).
BorderStyle(lipgloss.DoubleBorder()).
BorderTop(true).
BorderBottom(true).
BorderForeground(borderStyle).
Render("Enter a Command" + divider + info("[ Use 'help' ] v1.3.4 Supermario ") + info(onlineStatus))
welcome.WriteString(title)
fmt.Println(appStyle.Render(welcome.String()))
}
func drawStatus() {
width := 14
statusBarStyle := lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#343433", Dark: "#C1C6B2"}).
Background(lipgloss.AdaptiveColor{Light: "#D9DCCF", Dark: "#353533"})
statusStyle := lipgloss.NewStyle().
Inherit(statusBarStyle).
Foreground(lipgloss.Color("#FFFDF5")).
Background(lipgloss.Color("#FF5F87")).
Padding(0, 1).
MarginRight(1)
statusText := lipgloss.NewStyle().Inherit(statusBarStyle).Align(lipgloss.Center)
docStyle := lipgloss.NewStyle().Blink(true)
doc := strings.Builder{}
{
w := lipgloss.Width
statusKey := statusStyle.Render("COMMAND")
statusVal := statusText.Copy().
Width(width - w(statusKey)).
Render("> ")
bar := lipgloss.JoinHorizontal(lipgloss.Top,
statusKey,
statusVal,
)
doc.WriteString(statusBarStyle.Width(width).Render(bar))
}
fmt.Print(docStyle.Render(doc.String()))
}