gokcehan/lf

Feature request: highlighting of cursors when inactive

Opened this issue · 3 comments

Option hidecursorinactive just hides the cursor when the terminal loses focus, so the information of currently selected file/directory is available only when the terminal is focused.

It would be nice to have the option to just change colors for inactive cursors (for example choose slightly dimmed colors, still indicating inactive status, while retaining information about selected file/directory).

Don't know whether it would be best to have standalone options like cursorparentfmtinactive, or extend functionality of cursorparentfmt-like options to accept also (optional) format string applicable for inactive terminal status.

Now that you mention the desire to change the style for inactive cursors rather than hiding it completely, I am starting to think that hidecursorinactive is not a good design choice because of how inflexible it is. I'm also not a fan of adding more options like cursorparentfmtinactive because it increases the complexity without really addressing the original problem.

Instead I would suggest to implement the idea I originally suggested which utilizes hook commands, so that custom behavior can be invoked when the terminal loses/gains focus. The end-user configuration would look something like below:

# boolean option which calls `Screen.EnableFocus()` or `Screen.DisableFocus()`
set focusreport true

# hook command which is invoked when the terminal gains focus
cmd on-focus :{{
    set cursorparentfmt '...'
    set cursoractivefmt '...'
    set cursorpreviewfmt '...'
}}

# hook command which is invoked when the terminal loses focus
cmd on-unfocus :{{
    set cursorparentfmt '...'
    set cursoractivefmt '...'
    set cursorpreviewfmt '...'
}}

If you're willing to have a go on this, I can oversee the changes.

I ended up implementing this myself, see #1763. I decided to use the names on-focus-gained and on-focus-lost for the actual implementation.

Works great, thanks @joelim-work!