File tree Expand file tree Collapse file tree 3 files changed +33
-8
lines changed
Expand file tree Collapse file tree 3 files changed +33
-8
lines changed Original file line number Diff line number Diff line change @@ -689,6 +689,10 @@ func (h *BufPane) Close() {
689689
690690// SetActive marks this pane as active.
691691func (h * BufPane ) SetActive (b bool ) {
692+ if h .IsActive () == b {
693+ return
694+ }
695+
692696 h .BWindow .SetActive (b )
693697 if b {
694698 // Display any gutter messages for this line
@@ -704,8 +708,12 @@ func (h *BufPane) SetActive(b bool) {
704708 if none && InfoBar .HasGutter {
705709 InfoBar .ClearGutter ()
706710 }
707- }
708711
712+ err := config .RunPluginFn ("onSetActive" , luar .New (ulua .L , h ))
713+ if err != nil {
714+ screen .TermMessage (err )
715+ }
716+ }
709717}
710718
711719// BufKeyActions contains the list of all possible key actions the bufhandler could execute
Original file line number Diff line number Diff line change @@ -147,6 +147,25 @@ func (t *TabList) Display() {
147147 }
148148}
149149
150+ func (t * TabList ) SetActive (a int ) {
151+ t .TabWindow .SetActive (a )
152+
153+ for i , p := range t .List {
154+ if i == a {
155+ if ! p .isActive {
156+ p .isActive = true
157+
158+ err := config .RunPluginFn ("onSetActive" , luar .New (ulua .L , p .CurPane ()))
159+ if err != nil {
160+ screen .TermMessage (err )
161+ }
162+ }
163+ } else {
164+ p .isActive = false
165+ }
166+ }
167+ }
168+
150169// Tabs is the global tab list
151170var Tabs * TabList
152171
@@ -192,6 +211,9 @@ func MainTab() *Tab {
192211type Tab struct {
193212 * views.Node
194213 * display.UIWindow
214+
215+ isActive bool
216+
195217 Panes []Pane
196218 active int
197219
@@ -305,11 +327,6 @@ func (t *Tab) SetActive(i int) {
305327 p .SetActive (false )
306328 }
307329 }
308-
309- err := config .RunPluginFn ("onSetActive" , luar .New (ulua .L , MainTab ().CurPane ()))
310- if err != nil {
311- screen .TermMessage (err )
312- }
313330}
314331
315332// GetPane returns the pane with the given split index
Original file line number Diff line number Diff line change @@ -51,14 +51,14 @@ which micro defines:
5151
5252* ` postinit() ` : initialization function called after ` init() ` .
5353
54- * ` onSetActive(bufpane) ` : runs when changing the currently active panel.
55-
5654* ` onBufferOpen(buf) ` : runs when a buffer is opened. The input contains
5755 the buffer object.
5856
5957* ` onBufPaneOpen(bufpane) ` : runs when a bufpane is opened. The input
6058 contains the bufpane object.
6159
60+ * ` onSetActive(bufpane) ` : runs when changing the currently active bufpane.
61+
6262* ` onAction(bufpane) ` : runs when ` Action ` is triggered by the user, where
6363 ` Action ` is a bindable action (see ` > help keybindings ` ). A bufpane
6464 is passed as input and the function should return a boolean defining
You can’t perform that action at this time.
0 commit comments