From 75b9a6cefed4fc325888ad93e356ec4f2ea1341d Mon Sep 17 00:00:00 2001 From: taconi <44283700+taconi@users.noreply.github.com> Date: Thu, 31 Aug 2023 13:29:07 -0300 Subject: [PATCH] Add onSetActive callback (#2885) Co-authored-by: taconi --- internal/action/tab.go | 8 ++++++++ runtime/help/plugins.md | 2 ++ 2 files changed, 10 insertions(+) diff --git a/internal/action/tab.go b/internal/action/tab.go index 07a866ce..600ccc55 100644 --- a/internal/action/tab.go +++ b/internal/action/tab.go @@ -1,9 +1,12 @@ package action import ( + luar "layeh.com/gopher-luar" + "github.com/zyedidia/micro/v2/internal/buffer" "github.com/zyedidia/micro/v2/internal/config" "github.com/zyedidia/micro/v2/internal/display" + ulua "github.com/zyedidia/micro/v2/internal/lua" "github.com/zyedidia/micro/v2/internal/screen" "github.com/zyedidia/micro/v2/internal/views" "github.com/zyedidia/tcell/v2" @@ -276,6 +279,11 @@ func (t *Tab) SetActive(i int) { p.SetActive(false) } } + + err := config.RunPluginFn("onSetActive", luar.New(ulua.L, MainTab().CurPane())) + if err != nil { + screen.TermMessage(err) + } } // GetPane returns the pane with the given split index diff --git a/runtime/help/plugins.md b/runtime/help/plugins.md index 3201e63c..dc87476f 100644 --- a/runtime/help/plugins.md +++ b/runtime/help/plugins.md @@ -50,6 +50,8 @@ which micro defines: * `postinit()`: initialization function called after `init()`. +* `onSetActive(bufpane)`: runs when changing the currently active panel. + * `onBufferOpen(buf)`: runs when a buffer is opened. The input contains the buffer object.