Add on-init hook command (#1838)
This commit is contained in:
1 parent
0b51987044
commit
670343a23f
5 files changed
+27
-2
No files matched your search
@@ -117,7 +117,7 @@ func readExpr() <-chan expr {
|
||||
ch := make(chan expr)
|
||||
|
||||
go func() {
|
||||
duration := 1 * time.Second
|
||||
duration := 100 * time.Millisecond
|
||||
|
||||
c, err := net.Dial(gSocketProt, gSocketPath)
|
||||
for err != nil {
|
||||
@@ -130,6 +130,7 @@ func readExpr() <-chan expr {
|
||||
fmt.Fprintf(c, "conn %d\n", gClientID)
|
||||
|
||||
ch <- &callExpr{"sync", nil, 1}
|
||||
ch <- &callExpr{"on-init", nil, 1}
|
||||
|
||||
s := bufio.NewScanner(c)
|
||||
for s.Scan() {
|
||||
|
||||
@@ -239,6 +239,7 @@ The following special shell commands are used to customize the behavior of lf wh
|
||||
on-cd
|
||||
on-focus-gained
|
||||
on-focus-lost
|
||||
on-init
|
||||
on-select
|
||||
on-redraw
|
||||
on-quit
|
||||
@@ -1143,6 +1144,10 @@ This shell command can be defined to be executed when the terminal gains focus.
|
||||
|
||||
This shell command can be defined to be executed when the terminal loses focus.
|
||||
|
||||
## on-init
|
||||
|
||||
This shell command can be defined to be executed after initializing and connecting to the server.
|
||||
|
||||
## on-select
|
||||
|
||||
This shell command can be defined to be executed after the selection changes.
|
||||
|
||||
@@ -230,6 +230,7 @@ of lf when defined:
|
||||
on-cd
|
||||
on-focus-gained
|
||||
on-focus-lost
|
||||
on-init
|
||||
on-select
|
||||
on-redraw
|
||||
on-quit
|
||||
@@ -1262,6 +1263,11 @@ on-focus-lost
|
||||
This shell command can be defined to be executed when the terminal loses
|
||||
focus.
|
||||
|
||||
on-init
|
||||
|
||||
This shell command can be defined to be executed after initializing and
|
||||
connecting to the server.
|
||||
|
||||
on-select
|
||||
|
||||
This shell command can be defined to be executed after the selection
|
||||
|
||||
@@ -600,6 +600,12 @@ func onFocusLost(app *app) {
|
||||
}
|
||||
}
|
||||
|
||||
func onInit(app *app) {
|
||||
if cmd, ok := gOpts.cmds["on-init"]; ok {
|
||||
cmd.eval(app, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func onRedraw(app *app) {
|
||||
if cmd, ok := gOpts.cmds["on-redraw"]; ok {
|
||||
cmd.eval(app, nil)
|
||||
@@ -1801,6 +1807,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
onFocusGained(app)
|
||||
case "on-focus-lost":
|
||||
onFocusLost(app)
|
||||
case "on-init":
|
||||
onInit(app)
|
||||
case "cmd-insert":
|
||||
if len(e.args) == 0 {
|
||||
return
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.\" Automatically generated by Pandoc 2.11.4
|
||||
.\"
|
||||
.TH "LF" "1" "2024-11-01" "" "DOCUMENTATION"
|
||||
.TH "LF" "1" "2024-11-06" "" "DOCUMENTATION"
|
||||
.hy
|
||||
.SH NAME
|
||||
.PP
|
||||
@@ -256,6 +256,7 @@ pre-cd
|
||||
on-cd
|
||||
on-focus-gained
|
||||
on-focus-lost
|
||||
on-init
|
||||
on-select
|
||||
on-redraw
|
||||
on-quit
|
||||
@@ -1262,6 +1263,10 @@ focus.
|
||||
.PP
|
||||
This shell command can be defined to be executed when the terminal loses
|
||||
focus.
|
||||
.SS on-init
|
||||
.PP
|
||||
This shell command can be defined to be executed after initializing and
|
||||
connecting to the server.
|
||||
.SS on-select
|
||||
.PP
|
||||
This shell command can be defined to be executed after the selection
|
||||
|
||||
Reference in new issue
Block a user