Skip to content

Commit 72a9d15

Browse files
committed
formatting
1 parent b1428ca commit 72a9d15

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

main.go

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ import (
1010
tea "github.com/charmbracelet/bubbletea"
1111
)
1212

13-
var style = lipgloss.NewStyle().
14-
Bold(true).
15-
Foreground(lipgloss.Color("#7D56F4")).
16-
PaddingTop(2).
17-
PaddingLeft(4).
18-
Width(22)
13+
var border = lipgloss.NewStyle().
14+
BorderStyle(lipgloss.RoundedBorder()).
15+
BorderForeground(lipgloss.Color("63")).
16+
MarginLeft(2).
17+
PaddingLeft(2).
18+
PaddingRight(3).
19+
PaddingTop(1).
20+
PaddingBottom(1)
1921

2022
var heading = lipgloss.NewStyle().
2123
Bold(true).
22-
PaddingTop(2).
24+
PaddingTop(1).
2325
PaddingLeft(2)
2426

2527
var footer = lipgloss.NewStyle().
2628
Faint(true).
2729
PaddingTop(2).
2830
PaddingLeft(2).
29-
PaddingBottom(2)
31+
PaddingBottom(1)
3032

3133
var alternative = lipgloss.NewStyle().
3234
Faint(true).
33-
Bold(false).
34-
PaddingLeft(2)
35+
Bold(false)
3536

3637
var active_alternative = lipgloss.NewStyle().
37-
Bold(true).
38-
PaddingLeft(2)
38+
Bold(true)
3939

4040
type Display struct {
4141
name string
@@ -153,6 +153,7 @@ func (m model) View() string {
153153
s += heading.Render("Which screen do you want to use?")
154154
s += "\n\n"
155155

156+
alternatives := ""
156157
for i := 0; i < len(m.displays); i++ {
157158
display := m.displays[i]
158159
current := ""
@@ -161,35 +162,44 @@ func (m model) View() string {
161162
}
162163

163164
if m.selected == i {
164-
s += fmt.Sprintf(active_alternative.Render("> %s %s"), display.name, current)
165+
alternatives += fmt.Sprintf(active_alternative.Render("> %s %s"), display.name, current)
165166
} else {
166-
s += fmt.Sprintf(alternative.Render(" %s %s"), display.name, current)
167+
alternatives += fmt.Sprintf(alternative.Render(" %s %s"), display.name, current)
168+
}
169+
170+
if (i < len(m.displays)-1) {
171+
alternatives += "\n"
167172
}
168-
s += "\n"
169173
}
170-
}
171-
172-
if m.screen != "" {
174+
175+
s += border.Render(alternatives)
176+
} else {
173177
s = heading.Render("Which resolution do you want?")
174178
s += "\n\n"
175179

180+
alternatives := ""
176181
for i := 0; i < len(m.resolutions); i++ {
177182
resolution := get_res(m.resolutions[i])
178183
if m.selected == i {
179-
s += active_alternative.Render(fmt.Sprintf("> %s", resolution))
184+
alternatives += active_alternative.Render(fmt.Sprintf("> %s", resolution))
180185
} else {
181-
s += alternative.Render(fmt.Sprintf(" %s", resolution))
186+
alternatives += alternative.Render(fmt.Sprintf(" %s", resolution))
187+
}
188+
if (i < len(m.resolutions)-1) {
189+
alternatives += "\n"
182190
}
183-
s += "\n"
191+
184192
}
193+
194+
s += border.Render(alternatives)
185195
}
186196

187197
s += footer.Render("Press q to quit.\n")
188198
return s
189199
}
190200

191201
func main() {
192-
p := tea.NewProgram(initialModel())
202+
p := tea.NewProgram(initialModel(), tea.WithAltScreen())
193203
if _, err := p.Run(); err != nil {
194204
fmt.Printf("Alas, there's been an error: %v", err)
195205
os.Exit(1)

0 commit comments

Comments
 (0)