Skip to content

Commit

Permalink
Merge pull request #489 from rsteube/delimiter-style
Browse files Browse the repository at this point in the history
delimiter style
  • Loading branch information
rsteube committed Apr 10, 2022
2 parents 1a01c7c + 0ce1e93 commit d0dcb78
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example/cmd/_test/elvish.elv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set edit:completion:arg-completer[example] = {|@arg|
if (eq $c[Description] "") {
edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style]) &code-suffix=$c[CodeSuffix]
} else {
edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style])" "(styled "("$c[Description]")" $c[DescriptionStyle]) &code-suffix=$c[CodeSuffix]
edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style])(styled " " $c[DescriptionStyle]" bg-default")(styled "("$c[Description]")" $c[DescriptionStyle]) &code-suffix=$c[CodeSuffix]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/shell/elvish/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func Snippet(cmd *cobra.Command) string {
if (eq $c[Description] "") {
edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style]) &code-suffix=$c[CodeSuffix]
} else {
edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style])" "(styled "("$c[Description]")" $c[DescriptionStyle]) &code-suffix=$c[CodeSuffix]
edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style])(styled " " $c[DescriptionStyle]" bg-default")(styled "("$c[Description]")" $c[DescriptionStyle]) &code-suffix=$c[CodeSuffix]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/shell/powershell/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func ActionRawValues(currentWord string, nospace bool, values common.RawValues)

listItemText := fmt.Sprintf("`e[21;22;23;24;25;29m`e[%vm%v`e[21;22;23;24;25;29;39;49m", sgr(val.Style), sanitizer.Replace(val.Display))
if val.Description != "" {
listItemText = listItemText + fmt.Sprintf(" `e[%vm(%v)`e[21;22;23;24;25;29;39;49m", sgr(descriptionStyle), sanitizer.Replace(val.TrimmedDescription()))
listItemText = listItemText + fmt.Sprintf("`e[%vm `e[%vm(%v)`e[21;22;23;24;25;29;39;49m", sgr(descriptionStyle+" bg-default"), sgr(descriptionStyle), sanitizer.Replace(val.TrimmedDescription()))
}
listItemText = listItemText + "`e[0m"

Expand Down
6 changes: 3 additions & 3 deletions internal/shell/zsh/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func ActionRawValues(currentWord string, nospace bool, values common.RawValues)
vals[index] = fmt.Sprintf("%v\t%v", val.Value, val.Display)
zstyles = append(zstyles, formatZstyle(fmt.Sprintf("(%v)()", zstyleQuoter.Replace(val.Display)), val.Style, descriptionStyle))
} else {
vals[index] = fmt.Sprintf("%v\t%v %v-- %v", val.Value, val.Display, strings.Repeat(" ", maxLength-len(val.Display)), val.TrimmedDescription())
zstyles = append(zstyles, formatZstyle(fmt.Sprintf("(%v) %v(-- %v)", zstyleQuoter.Replace(val.Display), strings.Repeat(" ", maxLength-len(val.Display)), zstyleQuoter.Replace(val.TrimmedDescription())), val.Style, descriptionStyle))
vals[index] = fmt.Sprintf("%v\t%v%v-- %v", val.Value, val.Display, strings.Repeat(" ", maxLength-len(val.Display)+1), val.TrimmedDescription())
zstyles = append(zstyles, formatZstyle(fmt.Sprintf("(%v)(%v)(-- %v)", zstyleQuoter.Replace(val.Display), strings.Repeat(" ", maxLength-len(val.Display)+1), zstyleQuoter.Replace(val.TrimmedDescription())), val.Style, descriptionStyle))
}
}

Expand All @@ -85,5 +85,5 @@ var zstyleQuoter = strings.NewReplacer(
// `compadd -l` (one per line) accepts ansi escape sequences in display value but it seems in tabular view these are removed.
// To ease matching in list mode, the display values have a hidden `\002` suffix.
func formatZstyle(s, _styleValue, _styleDescription string) string {
return fmt.Sprintf("=(#b)%v=0=%v=%v", s, style.SGR(_styleValue), style.SGR(_styleDescription))
return fmt.Sprintf("=(#b)%v=0=%v=%v=%v", s, style.SGR(_styleValue), style.SGR(_styleDescription+" bg-default"), style.SGR(_styleDescription))
}

0 comments on commit d0dcb78

Please sign in to comment.