Skip to content

Commit 334a88d

Browse files
committed
feat: add ability to define selected item indicator
1 parent 6361407 commit 334a88d

3 files changed

Lines changed: 45 additions & 34 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ There is an additional `comet.json` file that includes the prefixes and descript
7979
"versionStyle": {
8080
"light": "#9b9b9b",
8181
"dark": "#5c5c5c"
82-
}
82+
},
83+
"selectedItemIndicator": ""
8384
}
8485
```
8586
- Available fields:
@@ -96,6 +97,7 @@ There is an additional `comet.json` file that includes the prefixes and descript
9697
- `helpStyle`: paddingLeft, paddingBottom
9798
- `quitTextStyle`: margin, marginTop, marginBottom, marginLeft
9899
- `versionStyle`: light, dark
100+
- `selectedItemIndicator`: string (e.g. ">", "→", "*")
99101

100102
There is also a `-m` flag that takes a string that will be used as the basis for a search among all commit messages. For example: if you're committing something of a chore and always just use the message "update dependencies", you can do `cometary -m update` (use quotation marks if argument to `-m` includes spaces) and Cometary will populate the list of possible messages with those that include "update", which can then be cycled through with the Tab key. This is similar to the search you could make with `git log --grep="update"`.
101103

defaults.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@ import (
1111
)
1212

1313
type colors struct {
14-
TitleTextStyle styleConfig `json:"titleTextStyle"`
15-
TitleStyle styleConfig `json:"titleStyle"`
16-
ItemStyle styleConfig `json:"itemStyle"`
17-
CharacterCountColors colorConfig `json:"characterCountColors"`
18-
OverflowCharColor colorConfig `json:"overflowCharColor"`
19-
SelectedItemColors colorConfig `json:"selectedItemColors"`
20-
SelectedItemStyle styleConfig `json:"selectedItemStyle"`
21-
SelectedItemPadded styleConfig `json:"selectedItemPadded"`
22-
ItemDescriptionStyle styleConfig `json:"itemDescriptionStyle"`
23-
PaginationStyle styleConfig `json:"paginationStyle"`
24-
HelpStyle styleConfig `json:"helpStyle"`
25-
QuitTextStyle styleConfig `json:"quitTextStyle"`
26-
VersionStyle colorConfig `json:"versionStyle"`
14+
TitleTextStyle styleConfig `json:"titleTextStyle"`
15+
TitleStyle styleConfig `json:"titleStyle"`
16+
ItemStyle styleConfig `json:"itemStyle"`
17+
CharacterCountColors colorConfig `json:"characterCountColors"`
18+
OverflowCharColor colorConfig `json:"overflowCharColor"`
19+
SelectedItemColors colorConfig `json:"selectedItemColors"`
20+
SelectedItemStyle styleConfig `json:"selectedItemStyle"`
21+
SelectedItemPadded styleConfig `json:"selectedItemPadded"`
22+
ItemDescriptionStyle styleConfig `json:"itemDescriptionStyle"`
23+
PaginationStyle styleConfig `json:"paginationStyle"`
24+
HelpStyle styleConfig `json:"helpStyle"`
25+
QuitTextStyle styleConfig `json:"quitTextStyle"`
26+
VersionStyle colorConfig `json:"versionStyle"`
27+
SelectedItemIndicator string `json:"selectedItemIndicator,omitempty"`
2728
}
2829

2930
type styleConfig struct {
@@ -101,6 +102,7 @@ func defaultColors() colors {
101102
Light: "#9b9b9b",
102103
Dark: "#5c5c5c",
103104
},
105+
SelectedItemIndicator: ">",
104106
}
105107
}
106108

@@ -167,6 +169,9 @@ func applyColors(c colors) {
167169
Light: lipgloss.Color(c.VersionStyle.Light),
168170
Dark: lipgloss.Color(c.VersionStyle.Dark),
169171
}).Render
172+
if c.SelectedItemIndicator != "" {
173+
selectedItemIndicator = c.SelectedItemIndicator + " "
174+
}
170175
}
171176

172177
func orDefault[T any](ptr *T, defaultVal T) T {
@@ -256,5 +261,8 @@ func mergeColors(defaults, loaded colors) colors {
256261
if loaded.VersionStyle.Light != "" || loaded.VersionStyle.Dark != "" {
257262
defaults.VersionStyle = loaded.VersionStyle
258263
}
264+
if loaded.SelectedItemIndicator != "" {
265+
defaults.SelectedItemIndicator = loaded.SelectedItemIndicator
266+
}
259267
return defaults
260268
}

gui.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,26 @@ const (
2424
)
2525

2626
var (
27-
titleTextStyle lipgloss.Style
28-
titleStyle lipgloss.Style
29-
itemStyle lipgloss.Style
30-
characterCountColors compat.AdaptiveColor
31-
overflowCharColor compat.AdaptiveColor
32-
selectedItemColors compat.AdaptiveColor
33-
selectedItemStyle lipgloss.Style
34-
selectedItemPadded lipgloss.Style
35-
itemDescriptionStyle lipgloss.Style
36-
listStyles list.Styles
37-
paginationStyle lipgloss.Style
38-
helpStyle lipgloss.Style
39-
quitTextStyle lipgloss.Style
40-
versionStyle func(...string) string
41-
scopeInputText = "What is the scope?"
42-
msgInputText = "What is the commit message?"
43-
bodyInputText = "Do you need to specify a body/footer?"
44-
constrainInput bool
45-
totalInputCharLimit int
27+
titleTextStyle lipgloss.Style
28+
titleStyle lipgloss.Style
29+
itemStyle lipgloss.Style
30+
characterCountColors compat.AdaptiveColor
31+
overflowCharColor compat.AdaptiveColor
32+
selectedItemColors compat.AdaptiveColor
33+
selectedItemStyle lipgloss.Style
34+
selectedItemPadded lipgloss.Style
35+
itemDescriptionStyle lipgloss.Style
36+
listStyles list.Styles
37+
paginationStyle lipgloss.Style
38+
helpStyle lipgloss.Style
39+
quitTextStyle lipgloss.Style
40+
versionStyle func(...string) string
41+
selectedItemIndicator string
42+
scopeInputText = "What is the scope?"
43+
msgInputText = "What is the commit message?"
44+
bodyInputText = "Do you need to specify a body/footer?"
45+
constrainInput bool
46+
totalInputCharLimit int
4647
)
4748

4849
type itemDelegate struct{}
@@ -60,7 +61,7 @@ func (d itemDelegate) Render(w io.Writer, m list.Model, index int, listItem list
6061

6162
var output string
6263
if index == m.Index() {
63-
output = selectedItemPadded.Render("> " + str)
64+
output = selectedItemPadded.Render(selectedItemIndicator + str)
6465
} else {
6566
output = itemStyle.Render(str)
6667
}

0 commit comments

Comments
 (0)