Add support for displaying lf options in the ruler (#1257)
* Add support for displaying lf options in the ruler * Print escape character as plain text * Document user defined options * Change escape rules * Use reflect instead of environment table * Factor out common option map logic * Improve error message slightly * Display blank option values
This commit is contained in:
1 parent
0ac1491bfb
commit
e08eebb115
6 files changed
+54
-28
No files matched your search
@@ -804,6 +804,18 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
||||
ui.promptWin.print(ui.screen, 0, 0, st, prompt)
|
||||
}
|
||||
|
||||
func formatRulerOpt(name string, val string) string {
|
||||
// handle escape character so it doesn't mess up the ruler
|
||||
val = strings.ReplaceAll(val, "\033", "\033[7m\\033\033[0m")
|
||||
|
||||
// display name of builtin options for clarity
|
||||
if !strings.HasPrefix(name, "lf_user_") {
|
||||
val = fmt.Sprintf("%s=%s", strings.TrimPrefix(name, "lf_"), val)
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
func (ui *ui) drawStatLine(nav *nav) {
|
||||
st := tcell.StyleDefault
|
||||
|
||||
@@ -855,6 +867,7 @@ func (ui *ui) drawStatLine(nav *nav) {
|
||||
progress = append(progress, fmt.Sprintf("[%d/%d]", nav.deleteCount, nav.deleteTotal))
|
||||
}
|
||||
|
||||
opts := getOptsMap()
|
||||
ruler := []string{}
|
||||
for _, s := range gOpts.ruler {
|
||||
switch s {
|
||||
@@ -875,8 +888,11 @@ func (ui *ui) drawStatLine(nav *nav) {
|
||||
}
|
||||
case "ind":
|
||||
ruler = append(ruler, fmt.Sprintf("%d/%d", ind, tot))
|
||||
default:
|
||||
if val, ok := opts[s]; ok {
|
||||
ruler = append(ruler, formatRulerOpt(s, val))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ui.msgWin.printRight(ui.screen, 0, st, strings.Join(ruler, " "))
|
||||
|
||||
Reference in new issue
Block a user