Expose OpenLogBuf to plugins

This commit is contained in:
Zachary Yedidia 2020-02-12 12:35:40 -05:00
parent 6588f02f7b
commit bf1258578c
3 changed files with 15 additions and 14 deletions

View 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()
}

View 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()

View 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)`: