-
Notifications
You must be signed in to change notification settings - Fork 31
/
constants.go
119 lines (108 loc) Β· 3.12 KB
/
constants.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package tui
import (
"strings"
"time"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/progress"
"github.com/charmbracelet/lipgloss"
)
const (
MARGIN = 2
PADDING = 1
MAX_WIDTH = 80
PRIMARY_COLOR = "#B8BABA"
SECONDARY_COLOR = "#626262"
DARK_COLOR = "#232323"
ELEMENT_COLOR = "#EE9F40"
SECONDARY_ELEMENT_COLOR = "#e87d3e"
ERROR_COLOR = "#CC0000"
WARNING_COLOR = "#EE9F5C"
CHECK_COLOR = "#34B233"
SHUTDOWN_PERIOD = 500 * time.Millisecond
TEMP_UI_MESSAGE_DURATION = 2 * time.Second
)
type KeyMap struct {
Quit key.Binding
CopyPassword key.Binding
FileListUp key.Binding
FileListDown key.Binding
OverwritePromptYes key.Binding
OverwritePromptNo key.Binding
OverwritePromptConfirm key.Binding
}
func (k KeyMap) ShortHelp() []key.Binding {
return []key.Binding{
k.Quit,
k.CopyPassword,
k.FileListUp,
k.FileListDown,
k.OverwritePromptYes,
k.OverwritePromptNo,
k.OverwritePromptConfirm,
}
}
func (k KeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{
{
k.Quit,
k.CopyPassword,
k.FileListUp,
k.FileListDown,
k.OverwritePromptYes,
k.OverwritePromptNo,
k.OverwritePromptConfirm,
},
}
}
func NewProgressBar() progress.Model {
p := progress.New(progress.WithGradient(SECONDARY_ELEMENT_COLOR, ELEMENT_COLOR))
p.PercentFormat = " %.2f%%"
return p
}
var Keys = KeyMap{
Quit: key.NewBinding(
key.WithKeys("q", "esc", "ctrl+c"),
key.WithHelp("(q)", "quit"),
),
CopyPassword: key.NewBinding(
key.WithKeys("c"),
key.WithHelp("(c)", CopyKeyHelpText),
key.WithDisabled(),
),
FileListUp: key.NewBinding(
key.WithKeys("up", "k"),
key.WithHelp("(β/k)", "file summary up"),
key.WithDisabled(),
),
FileListDown: key.NewBinding(
key.WithKeys("down", "j"),
key.WithHelp("(β/j)", "file summary down"),
key.WithDisabled(),
),
OverwritePromptYes: key.NewBinding(
key.WithKeys("y", "Y"),
key.WithHelp("(Y/y)", "accept overwrite"),
key.WithDisabled(),
),
OverwritePromptNo: key.NewBinding(
key.WithKeys("n", "N"),
key.WithHelp("(N/n)", "deny overwrite"),
key.WithDisabled(),
),
OverwritePromptConfirm: key.NewBinding(
key.WithKeys("enter"),
key.WithHelp("(β )", "confirm choice"),
key.WithDisabled(),
),
}
var PadText = strings.Repeat(" ", MARGIN)
var BaseStyle = lipgloss.NewStyle()
var InfoStyle = BaseStyle.Copy().Foreground(lipgloss.Color(PRIMARY_COLOR)).Render
var HelpStyle = BaseStyle.Copy().Foreground(lipgloss.Color(SECONDARY_COLOR)).Render
var ItalicText = BaseStyle.Copy().Italic(true).Render
var BoldText = BaseStyle.Copy().Bold(true).Render
var ErrorText = BaseStyle.Copy().Foreground(lipgloss.Color(ERROR_COLOR)).Render
var WarningText = BaseStyle.Copy().Foreground(lipgloss.Color(WARNING_COLOR)).Render
var SuccessText = BaseStyle.Copy().Foreground(lipgloss.Color(CHECK_COLOR)).Render
var CopyKeyHelpText = BaseStyle.Render("password β clipboard")
var CopyKeyActiveHelpText = SuccessText("β") + HelpStyle(" password β clipboard")