You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Replace hidecursorinactive with hook commands - #1763
This PR replaces the hidecursorinactive option introduced in #965 with the more generic on-focus-gained and on-focus-lost hook commands, allowing for greater customization for when the terminal gains or loses focus. This also properly solves #1673 by providing an option focusreport to explictly control terminal focus reporting only enabling terminal focus reporting if either of the hook commands are defined.
Examples
Hide the cursors completely when the terminal loses focus (same effect as set hidecursorinactive true):
# hook command which is invoked when the terminal gains focus
cmd on-focus-gained :{{
set cursorparentfmt "\033[7m"set cursoractivefmt "\033[7m"set cursorpreviewfmt "\033[4m"
}}
# hook command which is invoked when the terminal loses focus
cmd on-focus-lost :{{
set cursorparentfmt ""set cursoractivefmt ""set cursorpreviewfmt ""
}}
# set initial values upon startup
on-focus-gained
Dim the cursors when the terminal loses focus:
# hook command which is invoked when the terminal gains focus
cmd on-focus-gained :{{
set cursorparentfmt "\033[7m"set cursoractivefmt "\033[7m"set cursorpreviewfmt "\033[4m"
}}
# hook command which is invoked when the terminal loses focus
cmd on-focus-lost :{{
set cursorparentfmt "\033[7;2m"set cursoractivefmt "\033[7;2m"set cursorpreviewfmt "\033[4;2m"
}}
# set initial values upon startup
on-focus-gained
Very nice solution for cursorparentfmtinactive. Would it be possible to avoid explicitly setting focusreport by checking if the user has either on-focus-gained or on-focus-lost set?
Would it be possible to avoid explicitly setting focusreport by checking if the user has either on-focus-gained or on-focus-lost set?
I think this is debatable. On one hand it's nice to avoid adding yet another option (lf has too many), but on the other hand it also makes the code rather 'clever' (one can argue that cmd should only define commands, not do anything else like enabling/disabling focus reporting).
For now I think I will go with your suggestion as it isn't too complex to implement.
I think this is a better way than needing to enable focusreport. Similar to on-redraw, the user can extend app functionality just by adding the appropriate function. In the case of focus hooks, the app can simply skip observing these events if the user has not set callbacks. This way, the user does not need to worry about the app's inner behavior, as the app can determine if it is needed or not by itself.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
breakingPull requests that introduce breaking changes
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
^[[IorIin libvte-based terminals #1673Description
This PR replaces the
hidecursorinactiveoption introduced in #965 with the more genericon-focus-gainedandon-focus-losthook commands, allowing for greater customization for when the terminal gains or loses focus. This also properly solves #1673 byproviding an optiononly enabling terminal focus reporting if either of the hook commands are defined.focusreportto explictly control terminal focus reportingExamples
Hide the cursors completely when the terminal loses focus (same effect as
set hidecursorinactive true):Dim the cursors when the terminal loses focus: