"github.com/zyedidia/tcell/v2"
)
+// BufKeyAction represents an action bound to a key.
type BufKeyAction func(*BufPane) bool
+
+// BufMouseAction is an action that must be bound to a mouse event.
type BufMouseAction func(*BufPane, *tcell.EventMouse) bool
+// BufBindings stores the bindings for the buffer pane type.
var BufBindings *KeyTree
+// BufKeyActionGeneral makes a general pane action from a BufKeyAction.
func BufKeyActionGeneral(a BufKeyAction) PaneKeyAction {
return func(p Pane) bool {
return a(p.(*BufPane))
}
}
+// BufMouseActionGeneral makes a general pane mouse action from a BufKeyAction.
func BufMouseActionGeneral(a BufMouseAction) PaneMouseAction {
return func(p Pane, me *tcell.EventMouse) bool {
return a(p.(*BufPane), me)
BufBindings = NewKeyTree()
}
+// LuaAction makes a BufKeyAction from a lua function.
func LuaAction(fn string) func(*BufPane) bool {
luaFn := strings.Split(fn, ".")
if len(luaFn) <= 1 {
searchOrig buffer.Loc
}
+// NewBufPane creates a new buffer pane with the given window.
func NewBufPane(buf *buffer.Buffer, win display.BWindow, tab *Tab) *BufPane {
h := new(BufPane)
h.Buf = buf
return h
}
+// NewBufPaneFromBuf constructs a new pane from the given buffer and automatically
+// creates a buf window.
func NewBufPaneFromBuf(buf *buffer.Buffer, tab *Tab) *BufPane {
w := display.NewBufWindow(0, 0, 0, 0, buf)
return NewBufPane(buf, w, tab)
}
+// SetTab sets this pane's tab.
func (h *BufPane) SetTab(t *Tab) {
h.tab = t
}
+// Tab returns this pane's tab.
func (h *BufPane) Tab() *Tab {
return h.tab
}
h.tab.Resize()
}
-// PluginCB calls all plugin callbacks with a certain name and
-// displays an error if there is one and returns the aggregrate
-// boolean response
+// PluginCB calls all plugin callbacks with a certain name and displays an
+// error if there is one and returns the aggregrate boolean response
func (h *BufPane) PluginCB(cb string) bool {
b, err := config.RunPluginFnBool(cb, luar.New(ulua.L, h))
if err != nil {
return b
}
-// PluginCBRune is the same as PluginCB but also passes a rune to
-// the plugins
+// PluginCBRune is the same as PluginCB but also passes a rune to the plugins
func (h *BufPane) PluginCBRune(cb string, r rune) bool {
b, err := config.RunPluginFnBool(cb, luar.New(ulua.L, h), luar.New(ulua.L, string(r)))
if err != nil {
return b
}
+// OpenBuffer opens the given buffer in this pane.
func (h *BufPane) OpenBuffer(b *buffer.Buffer) {
h.Buf.Close()
h.Buf = b
h.Cursor = b.GetActiveCursor()
h.Resize(h.GetView().Width, h.GetView().Height)
h.Relocate()
- // Set mouseReleased to true because we assume the mouse is not being pressed when
- // the editor is opened
+ // Set mouseReleased to true because we assume the mouse is not being
+ // pressed when the editor is opened
h.mouseReleased = true
- // Set isOverwriteMode to false, because we assume we are in the default mode when editor
- // is opened
+ // Set isOverwriteMode to false, because we assume we are in the default
+ // mode when editor is opened
h.isOverwriteMode = false
h.lastClickTime = time.Time{}
}
+// ID returns this pane's split id.
func (h *BufPane) ID() uint64 {
return h.splitID
}
+// SetID sets the split ID of this pane.
func (h *BufPane) SetID(i uint64) {
h.splitID = i
}
+// Name returns the BufPane's name.
func (h *BufPane) Name() string {
n := h.Buf.GetName()
if h.Buf.Modified() {
}
}
+// Bindings returns the current bindings tree for this buffer.
func (h *BufPane) Bindings() *KeyTree {
if h.bindings != nil {
return h.bindings
}
}
+// VSplitIndex opens the given buffer in a vertical split on the given side.
func (h *BufPane) VSplitIndex(buf *buffer.Buffer, right bool) *BufPane {
e := NewBufPaneFromBuf(buf, h.tab)
e.splitID = MainTab().GetNode(h.splitID).VSplit(right)
MainTab().SetActive(len(MainTab().Panes) - 1)
return e
}
+
+// HSplitIndex opens the given buffer in a horizontal split on the given side.
func (h *BufPane) HSplitIndex(buf *buffer.Buffer, bottom bool) *BufPane {
e := NewBufPaneFromBuf(buf, h.tab)
e.splitID = MainTab().GetNode(h.splitID).HSplit(bottom)
return e
}
+// VSplitBuf opens the given buffer in a new vertical split.
func (h *BufPane) VSplitBuf(buf *buffer.Buffer) *BufPane {
return h.VSplitIndex(buf, h.Buf.Settings["splitright"].(bool))
}
+
+// HSplitBuf opens the given buffer in a new horizontal split.
func (h *BufPane) HSplitBuf(buf *buffer.Buffer) *BufPane {
return h.HSplitIndex(buf, h.Buf.Settings["splitbottom"].(bool))
}
+
+// Close this pane.
func (h *BufPane) Close() {
h.Buf.Close()
}
+// SetActive marks this pane as active.
func (h *BufPane) SetActive(b bool) {
h.BWindow.SetActive(b)
if b {