Merge pull request #3245 from dmaluka/onsetactive-fix
Fix issues with `onSetActive` callback
This commit is contained in:
commit
18f3e1bf89
3 changed files with 33 additions and 8 deletions
|
@ -689,6 +689,10 @@ func (h *BufPane) Close() {
|
||||||
|
|
||||||
// SetActive marks this pane as active.
|
// SetActive marks this pane as active.
|
||||||
func (h *BufPane) SetActive(b bool) {
|
func (h *BufPane) SetActive(b bool) {
|
||||||
|
if h.IsActive() == b {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
h.BWindow.SetActive(b)
|
h.BWindow.SetActive(b)
|
||||||
if b {
|
if b {
|
||||||
// Display any gutter messages for this line
|
// Display any gutter messages for this line
|
||||||
|
@ -704,8 +708,12 @@ func (h *BufPane) SetActive(b bool) {
|
||||||
if none && InfoBar.HasGutter {
|
if none && InfoBar.HasGutter {
|
||||||
InfoBar.ClearGutter()
|
InfoBar.ClearGutter()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
err := config.RunPluginFn("onSetActive", luar.New(ulua.L, h))
|
||||||
|
if err != nil {
|
||||||
|
screen.TermMessage(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BufKeyActions contains the list of all possible key actions the bufhandler could execute
|
// BufKeyActions contains the list of all possible key actions the bufhandler could execute
|
||||||
|
|
|
@ -147,6 +147,25 @@ func (t *TabList) Display() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TabList) SetActive(a int) {
|
||||||
|
t.TabWindow.SetActive(a)
|
||||||
|
|
||||||
|
for i, p := range t.List {
|
||||||
|
if i == a {
|
||||||
|
if !p.isActive {
|
||||||
|
p.isActive = true
|
||||||
|
|
||||||
|
err := config.RunPluginFn("onSetActive", luar.New(ulua.L, p.CurPane()))
|
||||||
|
if err != nil {
|
||||||
|
screen.TermMessage(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.isActive = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tabs is the global tab list
|
// Tabs is the global tab list
|
||||||
var Tabs *TabList
|
var Tabs *TabList
|
||||||
|
|
||||||
|
@ -192,6 +211,9 @@ func MainTab() *Tab {
|
||||||
type Tab struct {
|
type Tab struct {
|
||||||
*views.Node
|
*views.Node
|
||||||
*display.UIWindow
|
*display.UIWindow
|
||||||
|
|
||||||
|
isActive bool
|
||||||
|
|
||||||
Panes []Pane
|
Panes []Pane
|
||||||
active int
|
active int
|
||||||
|
|
||||||
|
@ -305,11 +327,6 @@ func (t *Tab) SetActive(i int) {
|
||||||
p.SetActive(false)
|
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
|
// GetPane returns the pane with the given split index
|
||||||
|
|
|
@ -51,14 +51,14 @@ which micro defines:
|
||||||
|
|
||||||
* `postinit()`: initialization function called after `init()`.
|
* `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
|
* `onBufferOpen(buf)`: runs when a buffer is opened. The input contains
|
||||||
the buffer object.
|
the buffer object.
|
||||||
|
|
||||||
* `onBufPaneOpen(bufpane)`: runs when a bufpane is opened. The input
|
* `onBufPaneOpen(bufpane)`: runs when a bufpane is opened. The input
|
||||||
contains the bufpane object.
|
contains the bufpane object.
|
||||||
|
|
||||||
|
* `onSetActive(bufpane)`: runs when changing the currently active bufpane.
|
||||||
|
|
||||||
* `onAction(bufpane)`: runs when `Action` is triggered by the user, where
|
* `onAction(bufpane)`: runs when `Action` is triggered by the user, where
|
||||||
`Action` is a bindable action (see `> help keybindings`). A bufpane
|
`Action` is a bindable action (see `> help keybindings`). A bufpane
|
||||||
is passed as input and the function should return a boolean defining
|
is passed as input and the function should return a boolean defining
|
||||||
|
|
Loading…
Reference in a new issue