From bf1258578c9fbcfa8603876b905036df174e8d2b Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Wed, 12 Feb 2020 12:35:40 -0500 Subject: [PATCH] Expose OpenLogBuf to plugins --- internal/action/command.go | 4 ++-- internal/action/globals.go | 8 +++++++- runtime/help/plugins.md | 17 ++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/internal/action/command.go b/internal/action/command.go index c92b782c..667de11b 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -106,7 +106,7 @@ func (h *BufPane) PluginCmd(args []string) { } if h.Buf.Type != buffer.BTLog { - OpenLogBuf(h) + h.OpenLogBuf() } config.PluginCommand(buffer.LogBuf, args[0], args[1:]) @@ -272,7 +272,7 @@ func (h *BufPane) OpenCmd(args []string) { // ToggleLogCmd toggles the log view func (h *BufPane) ToggleLogCmd(args []string) { if h.Buf.Type != buffer.BTLog { - OpenLogBuf(h) + h.OpenLogBuf() } else { h.Quit() } diff --git a/internal/action/globals.go b/internal/action/globals.go index 3884c212..7de14d5f 100644 --- a/internal/action/globals.go +++ b/internal/action/globals.go @@ -5,15 +5,18 @@ import "github.com/zyedidia/micro/internal/buffer" var InfoBar *InfoPane var LogBufPane *BufPane +// InitGlobals initializes the log buffer and the info bar func InitGlobals() { InfoBar = NewInfoBar() buffer.LogBuf = buffer.NewBufferFromString("", "Log", buffer.BTLog) } +// GetInfoBar returns the infobar pane func GetInfoBar() *InfoPane { return InfoBar } +// WriteLog writes a string to the log buffer func WriteLog(s string) { buffer.WriteLog(s) if LogBufPane != nil { @@ -28,7 +31,10 @@ func WriteLog(s string) { } } -func OpenLogBuf(h *BufPane) { +// OpenLogBuf opens the log buffer from the current bufpane +// If the current bufpane is a log buffer nothing happens, +// otherwise the log buffer is opened in a horizontal split +func (h *BufPane) OpenLogBuf() { LogBufPane = h.HSplitBuf(buffer.LogBuf) LogBufPane.CursorEnd() diff --git a/runtime/help/plugins.md b/runtime/help/plugins.md index dd76f8c6..b94adcd1 100644 --- a/runtime/help/plugins.md +++ b/runtime/help/plugins.md @@ -74,16 +74,6 @@ within. This is almost always the current bufpane. All available actions are listed in the keybindings section of the help. -For callbacks to mouse actions, you are also given the event info: - -```lua -function onMousePress(view, event) - local x, y = event:Position() - - return false -end -``` - These functions should also return a boolean specifying whether the bufpane should be relocated to the cursor or not after the action is complete. @@ -113,7 +103,12 @@ The packages and functions are listed below (in Go type signatures): `-debug` flag, or binary built with `build-dbg`). - `SetStatusInfoFn(fn string)`: register the given lua function as - accessible from the statusline formatting options + accessible from the statusline formatting options. + + - `CurPane() *BufPane`: returns the current BufPane, or nil if the + current pane is not a BufPane. + + - `CurTab() *Tab`: returns the current tab. * `micro/config` - `MakeCommand(name string, action func(bp *BufPane, args[]string), completer buffer.Completer)`: