Show path at the end of the fzf line, to emphasis title instead

pull/6/head
Mickaël Menu 3 years ago
parent 14bf4d507c
commit 5f88eba68f
No known key found for this signature in database
GPG Key ID: 53D73664CD359895

@ -86,7 +86,7 @@ func (f *NoteFinder) Find(opts note.FinderOpts) ([]note.Match, error) {
}
fzf, err := New(Opts{
PreviewCmd: f.opts.PreviewCmd.OrString("cat {1}").NonEmpty(),
PreviewCmd: f.opts.PreviewCmd.OrString("cat {-1}").NonEmpty(),
Padding: 2,
Bindings: bindings,
})
@ -95,10 +95,14 @@ func (f *NoteFinder) Find(opts note.FinderOpts) ([]note.Match, error) {
}
for i, match := range matches {
title := match.Title
if title == "" {
title = relPaths[i]
}
fzf.Add([]string{
relPaths[i],
f.terminal.MustStyle(match.Title, style.RuleYellow),
f.terminal.MustStyle(stringsutil.JoinLines(match.Body), style.RuleBlack),
f.terminal.MustStyle(title, style.RuleYellow),
f.terminal.MustStyle(stringsutil.JoinLines(match.Body), style.RuleUnderstate),
f.terminal.MustStyle(relPaths[i], style.RuleUnderstate),
})
}
@ -108,7 +112,7 @@ func (f *NoteFinder) Find(opts note.FinderOpts) ([]note.Match, error) {
}
for _, s := range selection {
path := s[0]
path := s[len(s)-1]
for i, m := range matches {
if relPaths[i] == path {
selectedMatches = append(selectedMatches, m)

@ -32,10 +32,11 @@ func (t *Terminal) MustStyle(text string, rules ...style.Rule) string {
// FIXME: User config
var themeAliases = map[style.Rule][]style.Rule{
"title": {"bold", "yellow"},
"path": {"underline", "cyan"},
"term": {"red"},
"emphasis": {"bold", "cyan"},
"title": {"bold", "yellow"},
"path": {"underline", "cyan"},
"term": {"red"},
"emphasis": {"bold", "cyan"},
"understate": {"faint"},
}
func expandThemeAliases(rules []style.Rule) []style.Rule {

@ -54,6 +54,7 @@ func TestStyleAllRules(t *testing.T) {
test("path", "4;36m")
test("term", "31m")
test("emphasis", "1;36m")
test("understate", "2m")
test("bold", "1m")
test("faint", "2m")

@ -21,6 +21,8 @@ var (
RuleTerm = Rule("term")
// Element to emphasize, for example the short version of a prompt response: [y]es.
RuleEmphasis = Rule("emphasis")
// Element to understate, for example the content of the note in fzf.
RuleUnderstate = Rule("understate")
RuleBold = Rule("bold")
RuleItalic = Rule("italic")

Loading…
Cancel
Save