Add option to hide listBinds when pressing keys (#1815)

* add drawbinds option

* rename drawbinds to showbinds and change its place in docs

* minor changes in wording of showbinds option

* fix missing newlines

---------

Co-authored-by: yarik <dazzywi@github.com>
This commit is contained in:
yarikandyarik authored and GitHub committed 2024-10-22 23:45:48 +11:00
1 parent 440c258287
commit 6cd51210e3
6 files changed
+24 -4

No files matched your search

+6 -1
View File
@@ -188,6 +188,7 @@ The following options can be used to customize the behavior of lf:
shell string (default 'sh' for Unix and 'cmd' for Windows) shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows) shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '') shellopts []string (default '')
showbinds bool (default true)
sixel bool (default false) sixel bool (default false)
smartcase bool (default true) smartcase bool (default true)
smartdia bool (default false) smartdia bool (default false)
@@ -928,6 +929,10 @@ Command line flag used to pass shell commands.
List of shell options to pass to the shell executable. List of shell options to pass to the shell executable.
## showbinds (bool) (default true)
Show bindings associated with pressed keys.
## sixel (bool) (default false) ## sixel (bool) (default false)
Render sixel images in preview. Render sixel images in preview.
@@ -1834,4 +1839,4 @@ A sample icons file can be found at
https://github.com/gokcehan/lf/blob/master/etc/icons.example https://github.com/gokcehan/lf/blob/master/etc/icons.example
A sample colored icons file can be found at A sample colored icons file can be found at
https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example
+6 -1
View File
@@ -178,6 +178,7 @@ The following options can be used to customize the behavior of lf:
shell string (default 'sh' for Unix and 'cmd' for Windows) shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows) shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '') shellopts []string (default '')
showbinds bool (default true)
sixel bool (default false) sixel bool (default false)
smartcase bool (default true) smartcase bool (default true)
smartdia bool (default false) smartdia bool (default false)
@@ -1010,6 +1011,10 @@ shellopts ([]string) (default ``)
List of shell options to pass to the shell executable. List of shell options to pass to the shell executable.
showbinds (bool) (default true)
Show bindings associated with pressed keys.
sixel (bool) (default false) sixel (bool) (default false)
Render sixel images in preview. Render sixel images in preview.
@@ -2078,4 +2083,4 @@ A sample icons file can be found at
https://github.com/gokcehan/lf/blob/master/etc/icons.example https://github.com/gokcehan/lf/blob/master/etc/icons.example
A sample colored icons file can be found at A sample colored icons file can be found at
https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example
+2
View File
@@ -169,6 +169,8 @@ func (e *setExpr) eval(app *app, args []string) {
} }
case "roundbox", "noroundbox", "roundbox!": case "roundbox", "noroundbox", "roundbox!":
err = applyBoolOpt(&gOpts.roundbox, e) err = applyBoolOpt(&gOpts.roundbox, e)
case "showbinds", "noshowbinds", "showbinds!":
err = applyBoolOpt(&gOpts.showbinds, e)
case "sixel", "nosixel", "sixel!": case "sixel", "nosixel", "sixel!":
err = applyBoolOpt(&gOpts.sixel, e) err = applyBoolOpt(&gOpts.sixel, e)
case "smartcase", "nosmartcase", "smartcase!": case "smartcase", "nosmartcase", "smartcase!":
+5 -1
View File
@@ -196,6 +196,7 @@ selmode string (default \[aq]all\[aq])
shell string (default \[aq]sh\[aq] for Unix and \[aq]cmd\[aq] for Windows) shell string (default \[aq]sh\[aq] for Unix and \[aq]cmd\[aq] for Windows)
shellflag string (default \[aq]-c\[aq] for Unix and \[aq]/c\[aq] for Windows) shellflag string (default \[aq]-c\[aq] for Unix and \[aq]/c\[aq] for Windows)
shellopts []string (default \[aq]\[aq]) shellopts []string (default \[aq]\[aq])
showbinds bool (default true)
sixel bool (default false) sixel bool (default false)
smartcase bool (default true) smartcase bool (default true)
smartdia bool (default false) smartdia bool (default false)
@@ -1027,6 +1028,9 @@ Command line flag used to pass shell commands.
.SS shellopts ([]string) (default \[ga]\[ga]) .SS shellopts ([]string) (default \[ga]\[ga])
.PP .PP
List of shell options to pass to the shell executable. List of shell options to pass to the shell executable.
.SS showbinds (bool) (default true)
.PP
Show bindings associated with pressed keys.
.SS sixel (bool) (default false) .SS sixel (bool) (default false)
.PP .PP
Render sixel images in preview. Render sixel images in preview.
@@ -2419,4 +2423,4 @@ A sample icons file can be found at
<https://github.com/gokcehan/lf/blob/master/etc/icons.example> <https://github.com/gokcehan/lf/blob/master/etc/icons.example>
.PP .PP
A sample colored icons file can be found at A sample colored icons file can be found at
<https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example> <https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example>
+2
View File
@@ -60,6 +60,7 @@ var gOpts struct {
reverse bool reverse bool
roundbox bool roundbox bool
selectfmt string selectfmt string
showbinds bool
sixel bool sixel bool
sortby sortMethod sortby sortMethod
smartcase bool smartcase bool
@@ -206,6 +207,7 @@ func init() {
gOpts.reverse = false gOpts.reverse = false
gOpts.roundbox = false gOpts.roundbox = false
gOpts.selectfmt = "\033[7;35m" gOpts.selectfmt = "\033[7;35m"
gOpts.showbinds = true
gOpts.sixel = false gOpts.sixel = false
gOpts.sortby = naturalSort gOpts.sortby = naturalSort
gOpts.smartcase = true gOpts.smartcase = true
+3 -1
View File
@@ -1359,7 +1359,9 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
ui.menuBuf = nil ui.menuBuf = nil
return expr return expr
} }
ui.menuBuf = listBinds(binds) if gOpts.showbinds {
ui.menuBuf = listBinds(binds)
}
return draw return draw
} }
case *tcell.EventMouse: case *tcell.EventMouse: