From 6cd51210e30b24dcc51afcfa75ebe87e2a963f7f Mon Sep 17 00:00:00 2001 From: yarik <158273159+dazzywi@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:45:48 +0000 Subject: [PATCH] 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 --- doc.md | 7 ++++++- doc.txt | 7 ++++++- eval.go | 2 ++ lf.1 | 6 +++++- opts.go | 2 ++ ui.go | 4 +++- 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/doc.md b/doc.md index 3e2fe0b8..6bab8801 100644 --- a/doc.md +++ b/doc.md @@ -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) shellflag string (default '-c' for Unix and '/c' for Windows) shellopts []string (default '') + showbinds bool (default true) sixel bool (default false) smartcase bool (default true) 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. +## showbinds (bool) (default true) + +Show bindings associated with pressed keys. + ## sixel (bool) (default false) 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 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 \ No newline at end of file diff --git a/doc.txt b/doc.txt index 399ae5ce..c30793ed 100644 --- a/doc.txt +++ b/doc.txt @@ -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) shellflag string (default '-c' for Unix and '/c' for Windows) shellopts []string (default '') + showbinds bool (default true) sixel bool (default false) smartcase bool (default true) smartdia bool (default false) @@ -1010,6 +1011,10 @@ shellopts ([]string) (default ``) List of shell options to pass to the shell executable. +showbinds (bool) (default true) + +Show bindings associated with pressed keys. + sixel (bool) (default false) 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 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 \ No newline at end of file diff --git a/eval.go b/eval.go index 445d0813..f68eb22a 100644 --- a/eval.go +++ b/eval.go @@ -169,6 +169,8 @@ func (e *setExpr) eval(app *app, args []string) { } case "roundbox", "noroundbox", "roundbox!": err = applyBoolOpt(&gOpts.roundbox, e) + case "showbinds", "noshowbinds", "showbinds!": + err = applyBoolOpt(&gOpts.showbinds, e) case "sixel", "nosixel", "sixel!": err = applyBoolOpt(&gOpts.sixel, e) case "smartcase", "nosmartcase", "smartcase!": diff --git a/lf.1 b/lf.1 index 9d63563d..fcd3889e 100644 --- a/lf.1 +++ b/lf.1 @@ -196,6 +196,7 @@ selmode string (default \[aq]all\[aq]) 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) shellopts []string (default \[aq]\[aq]) +showbinds bool (default true) sixel bool (default false) smartcase bool (default true) smartdia bool (default false) @@ -1027,6 +1028,9 @@ Command line flag used to pass shell commands. .SS shellopts ([]string) (default \[ga]\[ga]) .PP 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) .PP Render sixel images in preview. @@ -2419,4 +2423,4 @@ A sample icons file can be found at .PP A sample colored icons file can be found at - + \ No newline at end of file diff --git a/opts.go b/opts.go index 50db7b15..2a7fdb96 100644 --- a/opts.go +++ b/opts.go @@ -60,6 +60,7 @@ var gOpts struct { reverse bool roundbox bool selectfmt string + showbinds bool sixel bool sortby sortMethod smartcase bool @@ -206,6 +207,7 @@ func init() { gOpts.reverse = false gOpts.roundbox = false gOpts.selectfmt = "\033[7;35m" + gOpts.showbinds = true gOpts.sixel = false gOpts.sortby = naturalSort gOpts.smartcase = true diff --git a/ui.go b/ui.go index 03303cbe..6fb9dc89 100644 --- a/ui.go +++ b/ui.go @@ -1359,7 +1359,9 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr { ui.menuBuf = nil return expr } - ui.menuBuf = listBinds(binds) + if gOpts.showbinds { + ui.menuBuf = listBinds(binds) + } return draw } case *tcell.EventMouse: