Skip to content

Commit

Permalink
Add on-redraw hook command (gokcehan#1479)
Browse files Browse the repository at this point in the history
* Add `on-redraw` hook command

* Add documentation
  • Loading branch information
joelim-work authored Oct 29, 2023
1 parent 7c23c27 commit b3cb2dc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ The following special shell commands are used to customize the behavior of lf wh
pre-cd
on-cd
on-select
on-redraw
on-quit
The following commands/keybindings are provided by default:
Expand Down Expand Up @@ -1110,6 +1111,10 @@ This shell command can be defined to be executed after changing a directory.
This shell command can be defined to be executed after the selection changes.
on-redraw
This shell command can be defined to be executed after the screen is redrawn or if the terminal is resized.
on-quit
This shell command can be defined to be executed before quit.
Expand Down
6 changes: 6 additions & 0 deletions docstring.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,12 @@ func onChdir(app *app) {
}
}

func onRedraw(app *app) {
if cmd, ok := gOpts.cmds["on-redraw"]; ok {
cmd.eval(app, nil)
}
}

func onSelect(app *app) {
if cmd, ok := gOpts.cmds["on-select"]; ok {
cmd.eval(app, nil)
Expand Down Expand Up @@ -1944,6 +1950,7 @@ func (e *callExpr) eval(app *app, args []string) {
dir.boundPos(app.nav.height)
}
app.ui.loadFile(app, true)
onRedraw(app)
case "load":
if !app.nav.init {
return
Expand Down
7 changes: 7 additions & 0 deletions lf.1
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ The following special shell commands are used to customize the behavior of lf wh
pre-cd
on-cd
on-select
on-redraw
on-quit
.EE
.PP
Expand Down Expand Up @@ -1332,6 +1333,12 @@ This shell command can be defined to be executed after changing a directory.
.PP
This shell command can be defined to be executed after the selection changes.
.PP
.EX
on-redraw
.EE
.PP
This shell command can be defined to be executed after the screen is redrawn or if the terminal is resized.
.PP
.EX
on-quit
.EE
Expand Down

0 comments on commit b3cb2dc

Please sign in to comment.