Skip to content

Commit 3499acb

Browse files
feat(tasklist): display dynamic palette keybinding
- Pass keymap to tasklist model - Use keymap to render palette shortcut in tip
1 parent 7082604 commit 3499acb

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

internal/app/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func New(ctx context.Context, cfg config.Config, svc service.TaskService) (tea.M
162162
mode: ModeList,
163163
tagFilterInput: tagInput,
164164
}
165-
m.list = tasklist.New(m.s, cfg.App.VimMode)
165+
m.list = tasklist.New(m.s, cfg.App.VimMode, m.km)
166166
m.pal = palette.New(m.s)
167167
m.det = detail.New(m.s)
168168
m.hlp = help.New(m.s, m.km)
@@ -1087,7 +1087,7 @@ func (m *Model) fetchOpenEditCmd(id string) tea.Cmd {
10871087

10881088
func (m *Model) refreshStyles() {
10891089
m.s = styles.New(m.theme)
1090-
m.list = tasklist.New(m.s, m.cfg.App.VimMode)
1090+
m.list = tasklist.New(m.s, m.cfg.App.VimMode, m.km)
10911091
m.list.SetTasks(m.tasks)
10921092
m.pal = palette.New(m.s)
10931093
m.det = detail.New(m.s)

internal/ui/tasklist/model.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import (
99
"github.com/charmbracelet/lipgloss"
1010

1111
"github.com/programmersd21/kairo/internal/core"
12+
"github.com/programmersd21/kairo/internal/ui/keymap"
1213
"github.com/programmersd21/kairo/internal/ui/render"
1314
"github.com/programmersd21/kairo/internal/ui/styles"
1415
)
1516

1617
type Model struct {
1718
styles styles.Styles
1819
vimMode bool
20+
km keymap.Keymap
1921

2022
width int
2123
height int
@@ -30,8 +32,8 @@ type Model struct {
3032
animationReverse bool
3133
}
3234

33-
func New(s styles.Styles, vimMode bool) Model {
34-
return Model{styles: s, vimMode: vimMode}
35+
func New(s styles.Styles, vimMode bool, km keymap.Keymap) Model {
36+
return Model{styles: s, vimMode: vimMode, km: km}
3537
}
3638

3739
func (m Model) Selected() (core.Task, bool) {
@@ -157,12 +159,13 @@ func (m Model) renderEmpty() string {
157159
Margin(1, 0, 0, 0).
158160
Render("Press 'n' to create a new task and start your journey")
159161

162+
paletteKeys := strings.Join(m.km.Palette.Keys(), ", ")
160163
hint := lipgloss.NewStyle().
161164
Foreground(m.styles.Theme.Muted).
162165
Background(m.styles.Theme.Bg).
163166
Italic(true).
164167
Margin(2, 0, 0, 0).
165-
Render("Tip: Use the command palette (Ctrl+P) to access all features")
168+
Render(fmt.Sprintf("Tip: Use the command palette (%s) to access all features", paletteKeys))
166169

167170
content := lipgloss.JoinVertical(lipgloss.Center,
168171
icon,

0 commit comments

Comments
 (0)