diff --git a/doc.md b/doc.md index 5092a9b6..eed6e0c0 100644 --- a/doc.md +++ b/doc.md @@ -136,76 +136,75 @@ The following command line commands are provided by lf: The following options can be used to customize the behavior of lf: - anchorfind bool (default true) - autoquit bool (default false) - borderfmt string (default "\033[0m") - cleaner string (default '') - copyfmt string (default "\033[7;33m") - cursoractivefmt string (default "\033[7m") - cursorparentfmt string (default "\033[7m") - cursorpreviewfmt string (default "\033[4m") - cutfmt string (default "\033[7;31m") - dircache bool (default true) - dircounts bool (default false) - dirfirst bool (default true) - dironly bool (default false) - dirpreviews bool (default false) - drawbox bool (default false) - dupfilefmt string (default '%f.~%n~') - errorfmt string (default "\033[7;31;47m") - filesep string (default "\n") - findlen int (default 1) - globfilter bool (default false) - globsearch bool (default false) - hidden bool (default false) - hiddenfiles []string (default '.*' for Unix and '' for Windows) - hidecursorinactive bool (default false) - history bool (default true) - icons bool (default false) - ifs string (default '') - ignorecase bool (default true) - ignoredia bool (default true) - incfilter bool (default false) - incsearch bool (default false) - info []string (default '') - infotimefmtnew string (default 'Jan _2 15:04') - infotimefmtold string (default 'Jan _2 2006') - mouse bool (default false) - number bool (default false) - numberfmt string (default "\033[33m") - period int (default 0) - preserve []string (default "mode") - preview bool (default true) - previewer string (default '') - promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") - ratios []int (default '1:2:3') - relativenumber bool (default false) - reverse bool (default false) - roundbox bool (default false) - ruler []string (default 'acc:progress:selection:filter:ind') - rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") - scrolloff int (default 0) - selectfmt string (default "\033[7;35m") - selmode string (default 'all') - shell string (default 'sh' for Unix and 'cmd' for Windows) - shellflag string (default '-c' for Unix and '/c' for Windows) - shellopts []string (default '') - sixel bool (default false) - smartcase bool (default true) - smartdia bool (default false) - sortby string (default 'natural') - statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") - tabstop int (default 8) - tagfmt string (default "\033[31m") - tempmarks string (default '') - timefmt string (default 'Mon Jan _2 15:04:05 2006') - truncatechar string (default '~') - truncatepct int (default 100) - waitmsg string (default 'Press any key to continue') - watch bool (default false) - wrapscan bool (default true) - wrapscroll bool (default false) - user_{option} string (default none) + anchorfind bool (default true) + autoquit bool (default false) + borderfmt string (default "\033[0m") + cleaner string (default '') + copyfmt string (default "\033[7;33m") + cursoractivefmt string (default "\033[7m") + cursorparentfmt string (default "\033[7m") + cursorpreviewfmt string (default "\033[4m") + cutfmt string (default "\033[7;31m") + dircache bool (default true) + dircounts bool (default false) + dirfirst bool (default true) + dironly bool (default false) + dirpreviews bool (default false) + drawbox bool (default false) + dupfilefmt string (default '%f.~%n~') + errorfmt string (default "\033[7;31;47m") + filesep string (default "\n") + findlen int (default 1) + globfilter bool (default false) + globsearch bool (default false) + hidden bool (default false) + hiddenfiles []string (default '.*' for Unix and '' for Windows) + history bool (default true) + icons bool (default false) + ifs string (default '') + ignorecase bool (default true) + ignoredia bool (default true) + incfilter bool (default false) + incsearch bool (default false) + info []string (default '') + infotimefmtnew string (default 'Jan _2 15:04') + infotimefmtold string (default 'Jan _2 2006') + mouse bool (default false) + number bool (default false) + numberfmt string (default "\033[33m") + period int (default 0) + preserve []string (default "mode") + preview bool (default true) + previewer string (default '') + promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") + ratios []int (default '1:2:3') + relativenumber bool (default false) + reverse bool (default false) + roundbox bool (default false) + ruler []string (default 'acc:progress:selection:filter:ind') + rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") + scrolloff int (default 0) + selectfmt string (default "\033[7;35m") + selmode string (default 'all') + shell string (default 'sh' for Unix and 'cmd' for Windows) + shellflag string (default '-c' for Unix and '/c' for Windows) + shellopts []string (default '') + sixel bool (default false) + smartcase bool (default true) + smartdia bool (default false) + sortby string (default 'natural') + statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") + tabstop int (default 8) + tagfmt string (default "\033[31m") + tempmarks string (default '') + timefmt string (default 'Mon Jan _2 15:04:05 2006') + truncatechar string (default '~') + truncatepct int (default 100) + waitmsg string (default 'Press any key to continue') + watch bool (default false) + wrapscan bool (default true) + wrapscroll bool (default false) + user_{option} string (default none) The following environment variables are exported for shell commands: @@ -237,6 +236,8 @@ The following special shell commands are used to customize the behavior of lf wh delete pre-cd on-cd + on-focus-gained + on-focus-lost on-select on-redraw on-quit @@ -775,10 +776,6 @@ Patterns can be given as relative or absolute paths. Globbing supports the usual special characters, `*` to match any sequence, `?` to match any character, and `[...]` or `[^...]` to match character sets or ranges. In addition, if a pattern starts with `!`, then its matches are excluded from hidden files. To add multiple patterns, use `:` as a separator. Example: `.*:lost+found:*.bak` -## hidecursorinactive (bool) (default false) - -Hide the cursor when the terminal or tmux pane loses focus. - ## history (bool) (default true) Save command history. @@ -1141,6 +1138,14 @@ This shell command can be defined to be executed before changing a directory. This shell command can be defined to be executed after changing a directory. +## on-focus-gained + +This shell command can be defined to be executed when the terminal gains focus. + +## on-focus-lost + +This shell command can be defined to be executed when the terminal loses focus. + ## on-select This shell command can be defined to be executed after the selection changes. diff --git a/doc.txt b/doc.txt index fa509c90..97364f2f 100644 --- a/doc.txt +++ b/doc.txt @@ -126,76 +126,75 @@ The following command line commands are provided by lf: The following options can be used to customize the behavior of lf: - anchorfind bool (default true) - autoquit bool (default false) - borderfmt string (default "\033[0m") - cleaner string (default '') - copyfmt string (default "\033[7;33m") - cursoractivefmt string (default "\033[7m") - cursorparentfmt string (default "\033[7m") - cursorpreviewfmt string (default "\033[4m") - cutfmt string (default "\033[7;31m") - dircache bool (default true) - dircounts bool (default false) - dirfirst bool (default true) - dironly bool (default false) - dirpreviews bool (default false) - drawbox bool (default false) - dupfilefmt string (default '%f.~%n~') - errorfmt string (default "\033[7;31;47m") - filesep string (default "\n") - findlen int (default 1) - globfilter bool (default false) - globsearch bool (default false) - hidden bool (default false) - hiddenfiles []string (default '.*' for Unix and '' for Windows) - hidecursorinactive bool (default false) - history bool (default true) - icons bool (default false) - ifs string (default '') - ignorecase bool (default true) - ignoredia bool (default true) - incfilter bool (default false) - incsearch bool (default false) - info []string (default '') - infotimefmtnew string (default 'Jan _2 15:04') - infotimefmtold string (default 'Jan _2 2006') - mouse bool (default false) - number bool (default false) - numberfmt string (default "\033[33m") - period int (default 0) - preserve []string (default "mode") - preview bool (default true) - previewer string (default '') - promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") - ratios []int (default '1:2:3') - relativenumber bool (default false) - reverse bool (default false) - roundbox bool (default false) - ruler []string (default 'acc:progress:selection:filter:ind') - rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") - scrolloff int (default 0) - selectfmt string (default "\033[7;35m") - selmode string (default 'all') - shell string (default 'sh' for Unix and 'cmd' for Windows) - shellflag string (default '-c' for Unix and '/c' for Windows) - shellopts []string (default '') - sixel bool (default false) - smartcase bool (default true) - smartdia bool (default false) - sortby string (default 'natural') - statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") - tabstop int (default 8) - tagfmt string (default "\033[31m") - tempmarks string (default '') - timefmt string (default 'Mon Jan _2 15:04:05 2006') - truncatechar string (default '~') - truncatepct int (default 100) - waitmsg string (default 'Press any key to continue') - watch bool (default false) - wrapscan bool (default true) - wrapscroll bool (default false) - user_{option} string (default none) + anchorfind bool (default true) + autoquit bool (default false) + borderfmt string (default "\033[0m") + cleaner string (default '') + copyfmt string (default "\033[7;33m") + cursoractivefmt string (default "\033[7m") + cursorparentfmt string (default "\033[7m") + cursorpreviewfmt string (default "\033[4m") + cutfmt string (default "\033[7;31m") + dircache bool (default true) + dircounts bool (default false) + dirfirst bool (default true) + dironly bool (default false) + dirpreviews bool (default false) + drawbox bool (default false) + dupfilefmt string (default '%f.~%n~') + errorfmt string (default "\033[7;31;47m") + filesep string (default "\n") + findlen int (default 1) + globfilter bool (default false) + globsearch bool (default false) + hidden bool (default false) + hiddenfiles []string (default '.*' for Unix and '' for Windows) + history bool (default true) + icons bool (default false) + ifs string (default '') + ignorecase bool (default true) + ignoredia bool (default true) + incfilter bool (default false) + incsearch bool (default false) + info []string (default '') + infotimefmtnew string (default 'Jan _2 15:04') + infotimefmtold string (default 'Jan _2 2006') + mouse bool (default false) + number bool (default false) + numberfmt string (default "\033[33m") + period int (default 0) + preserve []string (default "mode") + preview bool (default true) + previewer string (default '') + promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") + ratios []int (default '1:2:3') + relativenumber bool (default false) + reverse bool (default false) + roundbox bool (default false) + ruler []string (default 'acc:progress:selection:filter:ind') + rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") + scrolloff int (default 0) + selectfmt string (default "\033[7;35m") + selmode string (default 'all') + shell string (default 'sh' for Unix and 'cmd' for Windows) + shellflag string (default '-c' for Unix and '/c' for Windows) + shellopts []string (default '') + sixel bool (default false) + smartcase bool (default true) + smartdia bool (default false) + sortby string (default 'natural') + statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") + tabstop int (default 8) + tagfmt string (default "\033[31m") + tempmarks string (default '') + timefmt string (default 'Mon Jan _2 15:04:05 2006') + truncatechar string (default '~') + truncatepct int (default 100) + waitmsg string (default 'Press any key to continue') + watch bool (default false) + wrapscan bool (default true) + wrapscroll bool (default false) + user_{option} string (default none) The following environment variables are exported for shell commands: @@ -228,6 +227,8 @@ of lf when defined: delete pre-cd on-cd + on-focus-gained + on-focus-lost on-select on-redraw on-quit @@ -827,10 +828,6 @@ match character sets or ranges. In addition, if a pattern starts with !, then its matches are excluded from hidden files. To add multiple patterns, use : as a separator. Example: .*:lost+found:*.bak -hidecursorinactive (bool) (default false) - -Hide the cursor when the terminal or tmux pane loses focus. - history (bool) (default true) Save command history. @@ -1260,6 +1257,16 @@ on-cd This shell command can be defined to be executed after changing a directory. +on-focus-gained + +This shell command can be defined to be executed when the terminal gains +focus. + +on-focus-lost + +This shell command can be defined to be executed when the terminal loses +focus. + on-select This shell command can be defined to be executed after the selection diff --git a/eval.go b/eval.go index 8e19cac3..df8b2720 100644 --- a/eval.go +++ b/eval.go @@ -114,15 +114,6 @@ func (e *setExpr) eval(app *app, args []string) { app.ui.sort() app.ui.loadFile(app, true) } - case "hidecursorinactive", "nohidecursorinactive", "hidecursorinactive!": - err = applyBoolOpt(&gOpts.hidecursorinactive, e) - if err == nil { - if gOpts.hidecursorinactive { - app.ui.screen.EnableFocus() - } else { - app.ui.screen.DisableFocus() - } - } case "history", "nohistory", "history!": err = applyBoolOpt(&gOpts.history, e) case "icons", "noicons", "icons!": @@ -562,6 +553,18 @@ func (e *cmdExpr) eval(app *app, args []string) { } else { gOpts.cmds[e.name] = e.expr } + + // only enable focus reporting if required by the user + if e.name == "on-focus-gained" || e.name == "on-focus-lost" { + _, onFocusGainedExists := gOpts.cmds["on-focus-gained"] + _, onFocusLostExists := gOpts.cmds["on-focus-lost"] + if onFocusGainedExists || onFocusLostExists { + app.ui.screen.EnableFocus() + } else { + app.ui.screen.DisableFocus() + } + } + app.ui.loadFileInfo(app.nav) } @@ -579,6 +582,18 @@ func onChdir(app *app) { } } +func onFocusGained(app *app) { + if cmd, ok := gOpts.cmds["on-focus-gained"]; ok { + cmd.eval(app, nil) + } +} + +func onFocusLost(app *app) { + if cmd, ok := gOpts.cmds["on-focus-lost"]; ok { + cmd.eval(app, nil) + } +} + func onRedraw(app *app) { if cmd, ok := gOpts.cmds["on-redraw"]; ok { cmd.eval(app, nil) @@ -1774,6 +1789,10 @@ func (e *callExpr) eval(app *app, args []string) { for _, val := range splitKeys(e.args[0]) { app.ui.keyChan <- val } + case "on-focus-gained": + onFocusGained(app) + case "on-focus-lost": + onFocusLost(app) case "cmd-insert": if len(e.args) == 0 { return diff --git a/lf.1 b/lf.1 index 5fef3078..c826a930 100644 --- a/lf.1 +++ b/lf.1 @@ -1,6 +1,6 @@ .\" Automatically generated by Pandoc 2.11.4 .\" -.TH "LF" "1" "2024-06-22" "" "DOCUMENTATION" +.TH "LF" "1" "2024-06-30" "" "DOCUMENTATION" .hy .SH NAME .PP @@ -144,76 +144,75 @@ The following options can be used to customize the behavior of lf: .IP .nf \f[C] -anchorfind bool (default true) -autoquit bool (default false) -borderfmt string (default \[dq]\[rs]033[0m\[dq]) -cleaner string (default \[aq]\[aq]) -copyfmt string (default \[dq]\[rs]033[7;33m\[dq]) -cursoractivefmt string (default \[dq]\[rs]033[7m\[dq]) -cursorparentfmt string (default \[dq]\[rs]033[7m\[dq]) -cursorpreviewfmt string (default \[dq]\[rs]033[4m\[dq]) -cutfmt string (default \[dq]\[rs]033[7;31m\[dq]) -dircache bool (default true) -dircounts bool (default false) -dirfirst bool (default true) -dironly bool (default false) -dirpreviews bool (default false) -drawbox bool (default false) -dupfilefmt string (default \[aq]%f.\[ti]%n\[ti]\[aq]) -errorfmt string (default \[dq]\[rs]033[7;31;47m\[dq]) -filesep string (default \[dq]\[rs]n\[dq]) -findlen int (default 1) -globfilter bool (default false) -globsearch bool (default false) -hidden bool (default false) -hiddenfiles []string (default \[aq].*\[aq] for Unix and \[aq]\[aq] for Windows) -hidecursorinactive bool (default false) -history bool (default true) -icons bool (default false) -ifs string (default \[aq]\[aq]) -ignorecase bool (default true) -ignoredia bool (default true) -incfilter bool (default false) -incsearch bool (default false) -info []string (default \[aq]\[aq]) -infotimefmtnew string (default \[aq]Jan _2 15:04\[aq]) -infotimefmtold string (default \[aq]Jan _2 2006\[aq]) -mouse bool (default false) -number bool (default false) -numberfmt string (default \[dq]\[rs]033[33m\[dq]) -period int (default 0) -preserve []string (default \[dq]mode\[dq]) -preview bool (default true) -previewer string (default \[aq]\[aq]) -promptfmt string (default \[dq]\[rs]033[32;1m%u\[at]%h\[rs]033[0m:\[rs]033[34;1m%d\[rs]033[0m\[rs]033[1m%f\[rs]033[0m\[dq]) -ratios []int (default \[aq]1:2:3\[aq]) -relativenumber bool (default false) -reverse bool (default false) -roundbox bool (default false) -ruler []string (default \[aq]acc:progress:selection:filter:ind\[aq]) -rulerfmt string (default \[dq] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\[dq]) -scrolloff int (default 0) -selectfmt string (default \[dq]\[rs]033[7;35m\[dq]) -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]) -sixel bool (default false) -smartcase bool (default true) -smartdia bool (default false) -sortby string (default \[aq]natural\[aq]) -statfmt string (default \[dq]\[rs]033[36m%p\[rs]033[0m| %c| %u| %g| %S| %t| -> %l\[dq]) -tabstop int (default 8) -tagfmt string (default \[dq]\[rs]033[31m\[dq]) -tempmarks string (default \[aq]\[aq]) -timefmt string (default \[aq]Mon Jan _2 15:04:05 2006\[aq]) -truncatechar string (default \[aq]\[ti]\[aq]) -truncatepct int (default 100) -waitmsg string (default \[aq]Press any key to continue\[aq]) -watch bool (default false) -wrapscan bool (default true) -wrapscroll bool (default false) -user_{option} string (default none) +anchorfind bool (default true) +autoquit bool (default false) +borderfmt string (default \[dq]\[rs]033[0m\[dq]) +cleaner string (default \[aq]\[aq]) +copyfmt string (default \[dq]\[rs]033[7;33m\[dq]) +cursoractivefmt string (default \[dq]\[rs]033[7m\[dq]) +cursorparentfmt string (default \[dq]\[rs]033[7m\[dq]) +cursorpreviewfmt string (default \[dq]\[rs]033[4m\[dq]) +cutfmt string (default \[dq]\[rs]033[7;31m\[dq]) +dircache bool (default true) +dircounts bool (default false) +dirfirst bool (default true) +dironly bool (default false) +dirpreviews bool (default false) +drawbox bool (default false) +dupfilefmt string (default \[aq]%f.\[ti]%n\[ti]\[aq]) +errorfmt string (default \[dq]\[rs]033[7;31;47m\[dq]) +filesep string (default \[dq]\[rs]n\[dq]) +findlen int (default 1) +globfilter bool (default false) +globsearch bool (default false) +hidden bool (default false) +hiddenfiles []string (default \[aq].*\[aq] for Unix and \[aq]\[aq] for Windows) +history bool (default true) +icons bool (default false) +ifs string (default \[aq]\[aq]) +ignorecase bool (default true) +ignoredia bool (default true) +incfilter bool (default false) +incsearch bool (default false) +info []string (default \[aq]\[aq]) +infotimefmtnew string (default \[aq]Jan _2 15:04\[aq]) +infotimefmtold string (default \[aq]Jan _2 2006\[aq]) +mouse bool (default false) +number bool (default false) +numberfmt string (default \[dq]\[rs]033[33m\[dq]) +period int (default 0) +preserve []string (default \[dq]mode\[dq]) +preview bool (default true) +previewer string (default \[aq]\[aq]) +promptfmt string (default \[dq]\[rs]033[32;1m%u\[at]%h\[rs]033[0m:\[rs]033[34;1m%d\[rs]033[0m\[rs]033[1m%f\[rs]033[0m\[dq]) +ratios []int (default \[aq]1:2:3\[aq]) +relativenumber bool (default false) +reverse bool (default false) +roundbox bool (default false) +ruler []string (default \[aq]acc:progress:selection:filter:ind\[aq]) +rulerfmt string (default \[dq] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\[dq]) +scrolloff int (default 0) +selectfmt string (default \[dq]\[rs]033[7;35m\[dq]) +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]) +sixel bool (default false) +smartcase bool (default true) +smartdia bool (default false) +sortby string (default \[aq]natural\[aq]) +statfmt string (default \[dq]\[rs]033[36m%p\[rs]033[0m| %c| %u| %g| %S| %t| -> %l\[dq]) +tabstop int (default 8) +tagfmt string (default \[dq]\[rs]033[31m\[dq]) +tempmarks string (default \[aq]\[aq]) +timefmt string (default \[aq]Mon Jan _2 15:04:05 2006\[aq]) +truncatechar string (default \[aq]\[ti]\[aq]) +truncatepct int (default 100) +waitmsg string (default \[aq]Press any key to continue\[aq]) +watch bool (default false) +wrapscan bool (default true) +wrapscroll bool (default false) +user_{option} string (default none) \f[R] .fi .PP @@ -254,6 +253,8 @@ rename delete pre-cd on-cd +on-focus-gained +on-focus-lost on-select on-redraw on-quit @@ -848,9 +849,6 @@ In addition, if a pattern starts with \f[C]!\f[R], then its matches are excluded from hidden files. To add multiple patterns, use \f[C]:\f[R] as a separator. Example: \f[C].*:lost+found:*.bak\f[R] -.SS hidecursorinactive (bool) (default false) -.PP -Hide the cursor when the terminal or tmux pane loses focus. .SS history (bool) (default true) .PP Save command history. @@ -1269,6 +1267,14 @@ directory. .PP This shell command can be defined to be executed after changing a directory. +.SS on-focus-gained +.PP +This shell command can be defined to be executed when the terminal gains +focus. +.SS on-focus-lost +.PP +This shell command can be defined to be executed when the terminal loses +focus. .SS on-select .PP This shell command can be defined to be executed after the selection diff --git a/opts.go b/opts.go index 66f71a26..8e52baf2 100644 --- a/opts.go +++ b/opts.go @@ -30,79 +30,78 @@ func isValidSortMethod(method sortMethod) bool { const invalidSortErrorMessage = `sortby: value should either be 'natural', 'name', 'size', 'time', 'atime', 'ctime' or 'ext'` var gOpts struct { - anchorfind bool - autoquit bool - borderfmt string - copyfmt string - cursoractivefmt string - cursorparentfmt string - cursorpreviewfmt string - cutfmt string - hidecursorinactive bool - dircache bool - dircounts bool - dirfirst bool - dironly bool - dirpreviews bool - drawbox bool - dupfilefmt string - globfilter bool - globsearch bool - hidden bool - icons bool - ignorecase bool - ignoredia bool - incfilter bool - incsearch bool - mouse bool - number bool - preview bool - relativenumber bool - reverse bool - roundbox bool - selectfmt string - sixel bool - sortby sortMethod - smartcase bool - smartdia bool - waitmsg string - watch bool - wrapscan bool - wrapscroll bool - findlen int - period int - scrolloff int - tabstop int - errorfmt string - filesep string - ifs string - previewer string - cleaner string - promptfmt string - selmode string - shell string - shellflag string - statfmt string - timefmt string - infotimefmtnew string - infotimefmtold string - truncatechar string - truncatepct int - ratios []int - hiddenfiles []string - history bool - info []string - ruler []string - rulerfmt string - preserve []string - shellopts []string - keys map[string]expr - cmdkeys map[string]expr - cmds map[string]expr - user map[string]string - tempmarks string - numberfmt string - tagfmt string + anchorfind bool + autoquit bool + borderfmt string + copyfmt string + cursoractivefmt string + cursorparentfmt string + cursorpreviewfmt string + cutfmt string + dircache bool + dircounts bool + dirfirst bool + dironly bool + dirpreviews bool + drawbox bool + dupfilefmt string + globfilter bool + globsearch bool + hidden bool + icons bool + ignorecase bool + ignoredia bool + incfilter bool + incsearch bool + mouse bool + number bool + preview bool + relativenumber bool + reverse bool + roundbox bool + selectfmt string + sixel bool + sortby sortMethod + smartcase bool + smartdia bool + waitmsg string + watch bool + wrapscan bool + wrapscroll bool + findlen int + period int + scrolloff int + tabstop int + errorfmt string + filesep string + ifs string + previewer string + cleaner string + promptfmt string + selmode string + shell string + shellflag string + statfmt string + timefmt string + infotimefmtnew string + infotimefmtold string + truncatechar string + truncatepct int + ratios []int + hiddenfiles []string + history bool + info []string + ruler []string + rulerfmt string + preserve []string + shellopts []string + keys map[string]expr + cmdkeys map[string]expr + cmds map[string]expr + user map[string]string + tempmarks string + numberfmt string + tagfmt string } var gLocalOpts struct { @@ -193,7 +192,6 @@ func init() { gOpts.cursorparentfmt = "\033[7m" gOpts.cursorpreviewfmt = "\033[4m" gOpts.cutfmt = "\033[7;31m" - gOpts.hidecursorinactive = false gOpts.globfilter = false gOpts.globsearch = false gOpts.hidden = false diff --git a/ui.go b/ui.go index f7684ece..70d02d92 100644 --- a/ui.go +++ b/ui.go @@ -484,7 +484,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty } ce := "" - if i == dir.pos && (ui.focused || !gOpts.hidecursorinactive) { + if i == dir.pos { switch dirStyle.role { case Active: ce = gOpts.cursoractivefmt @@ -564,7 +564,6 @@ type ui struct { screen tcell.Screen sxScreen sixelScreen polling bool - focused bool wins []*win promptWin *win msgWin *win @@ -596,7 +595,6 @@ func newUI(screen tcell.Screen) *ui { ui := &ui{ screen: screen, polling: true, - focused: true, wins: getWins(screen), promptWin: newWin(wtot, 1, 0, 0), msgWin: newWin(wtot, 1, 0, htot-1), @@ -1463,8 +1461,11 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr { case *tcell.EventInterrupt: log.Printf("Got EventInterrupt: at %s", tev.When()) case *tcell.EventFocus: - ui.focused = tev.Focused - return draw + if tev.Focused { + return &callExpr{"on-focus-gained", nil, 1} + } else { + return &callExpr{"on-focus-lost", nil, 1} + } } return nil }