]> git.lizzy.rs Git - micro.git/commitdiff
Expose OpenLogBuf to plugins
authorZachary Yedidia <zyedidia@gmail.com>
Wed, 12 Feb 2020 17:35:40 +0000 (12:35 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Wed, 12 Feb 2020 17:35:40 +0000 (12:35 -0500)
internal/action/command.go
internal/action/globals.go
runtime/help/plugins.md

index c92b782c0331529fca20e5f091c59f919351a7cb..667de11b921b2f04400b7b1902bfada08f70b17e 100644 (file)
@@ -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()
        }
index 3884c212bcfecf633398e3c7e4d30b0bd7f01a25..7de14d5f3478562a008197da3ed74ecd07e84a56 100644 (file)
@@ -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()
 
index dd76f8c6b48bce24d1d98c4ace0e9d017991a3e3..b94adcd1b632e2107fb5d659923330b1ff495268 100644 (file)
@@ -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)`: