micro/internal/action/globals.go

37 lines
882 B
Go
Raw Normal View History

2019-01-02 06:36:12 +03:00
package action
2020-05-04 17:16:15 +03:00
import "github.com/zyedidia/micro/v2/internal/buffer"
2019-08-06 06:43:34 +03:00
2021-08-22 00:58:30 +03:00
// InfoBar is the global info bar.
2019-01-02 06:36:12 +03:00
var InfoBar *InfoPane
2021-08-22 00:58:30 +03:00
// LogBufPane is a global log buffer.
2019-08-06 06:43:34 +03:00
var LogBufPane *BufPane
2019-01-02 06:36:12 +03:00
2020-02-12 20:35:40 +03:00
// InitGlobals initializes the log buffer and the info bar
2019-01-02 06:36:12 +03:00
func InitGlobals() {
InfoBar = NewInfoBar()
2019-08-06 06:43:34 +03:00
buffer.LogBuf = buffer.NewBufferFromString("", "Log", buffer.BTLog)
2019-01-02 06:36:12 +03:00
}
2019-03-20 01:28:51 +03:00
2020-02-12 20:35:40 +03:00
// GetInfoBar returns the infobar pane
2019-03-20 01:28:51 +03:00
func GetInfoBar() *InfoPane {
return InfoBar
}
2019-08-06 06:43:34 +03:00
2020-02-12 20:35:40 +03:00
// WriteLog writes a string to the log buffer
2019-08-06 06:43:34 +03:00
func WriteLog(s string) {
buffer.WriteLog(s)
if LogBufPane != nil {
LogBufPane.CursorEnd()
}
}
2020-02-12 20:35:40 +03:00
// 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() {
2019-08-06 06:43:34 +03:00
LogBufPane = h.HSplitBuf(buffer.LogBuf)
LogBufPane.CursorEnd()
}