Skip to content

Commit a6780b7

Browse files
committed
feat: adapt v2 colors and lipgloss integration
1 parent 08a1b55 commit a6780b7

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

lazynx/internal/tui/components/help.go

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/charmbracelet/bubbles/v2/key"
77
tea "github.com/charmbracelet/bubbletea/v2"
88
"github.com/charmbracelet/lipgloss/v2"
9+
"github.com/lazyengs/lazynx/internal/tui/utils"
910
)
1011

1112
type HelpComponent struct {
@@ -26,7 +27,7 @@ func (h *HelpComponent) Init() tea.Cmd {
2627
}
2728

2829
func (h *HelpComponent) SetBindings(keys []key.Binding) {
29-
h.keys = removeDuplicateBindings(keys)
30+
h.keys = utils.RemoveDuplicateBindings(keys)
3031
}
3132

3233
func (h *HelpComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
@@ -41,33 +42,6 @@ func (h *HelpComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
4142
return h, nil
4243
}
4344

44-
func removeDuplicateBindings(bindings []key.Binding) []key.Binding {
45-
seen := make(map[string]struct{})
46-
result := make([]key.Binding, 0, len(bindings))
47-
48-
// Process bindings in reverse order
49-
for i := len(bindings) - 1; i >= 0; i-- {
50-
b := bindings[i]
51-
k := strings.Join(b.Keys(), " ")
52-
if _, ok := seen[k]; ok {
53-
// duplicate, skip
54-
continue
55-
}
56-
seen[k] = struct{}{}
57-
// Add to the beginning of result to maintain original order
58-
result = append([]key.Binding{b}, result...)
59-
}
60-
61-
return result
62-
}
63-
64-
func min(a, b int) int {
65-
if a < b {
66-
return a
67-
}
68-
return b
69-
}
70-
7145
func (h *HelpComponent) renderContent() string {
7246
baseStyle := lipgloss.NewStyle()
7347

lazynx/internal/tui/tui.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,5 +267,9 @@ func (m ProgramModel) View() string {
267267
}
268268

269269
func Create(client *nxlsclient.Client, logger *zap.SugaredLogger, workspacePath string) *tea.Program {
270-
return tea.NewProgram(createProgram(client, logger, workspacePath), tea.WithAltScreen(), tea.WithKeyboardEnhancements(tea.WithUniformKeyLayout))
270+
return tea.NewProgram(
271+
createProgram(client, logger, workspacePath),
272+
tea.WithAltScreen(),
273+
tea.WithKeyboardEnhancements(tea.WithUniformKeyLayout),
274+
tea.WithGraphemeClustering())
271275
}

lazynx/internal/tui/utils/keymap.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package utils
22

33
import (
44
"reflect"
5+
"strings"
56

67
"github.com/charmbracelet/bubbles/v2/key"
78
)
@@ -23,3 +24,23 @@ func KeyMapToSlice(keymap any) []key.Binding {
2324
}
2425
return bindings
2526
}
27+
28+
func RemoveDuplicateBindings(bindings []key.Binding) []key.Binding {
29+
seen := make(map[string]struct{})
30+
result := make([]key.Binding, 0, len(bindings))
31+
32+
// Process bindings in reverse order
33+
for i := len(bindings) - 1; i >= 0; i-- {
34+
b := bindings[i]
35+
k := strings.Join(b.Keys(), " ")
36+
if _, ok := seen[k]; ok {
37+
// duplicate, skip
38+
continue
39+
}
40+
seen[k] = struct{}{}
41+
// Add to the beginning of result to maintain original order
42+
result = append([]key.Binding{b}, result...)
43+
}
44+
45+
return result
46+
}

0 commit comments

Comments
 (0)