Add some commands

This commit is contained in:
Zachary Yedidia
2019-01-14 00:57:39 -05:00
parent 23926af9f7
commit 01f618627b
9 changed files with 160 additions and 15 deletions

View File

@@ -53,7 +53,7 @@ func BufMapMouse(k MouseEvent, action string) {
// The ActionHandler can access the window for necessary info about
// visual positions for mouse clicks and scrolling
type BufHandler struct {
display.Window
display.BWindow
Buf *buffer.Buffer
@@ -98,10 +98,10 @@ type BufHandler struct {
splitID uint64
}
func NewBufHandler(buf *buffer.Buffer, win display.Window) *BufHandler {
func NewBufHandler(buf *buffer.Buffer, win display.BWindow) *BufHandler {
h := new(BufHandler)
h.Buf = buf
h.Window = win
h.BWindow = win
h.Cursor = h.Buf.GetActiveCursor()
h.mouseReleased = true
@@ -109,6 +109,23 @@ func NewBufHandler(buf *buffer.Buffer, win display.Window) *BufHandler {
return h
}
func (h *BufHandler) OpenBuffer(b *buffer.Buffer) {
h.Buf.Close()
h.Buf = b
h.BWindow.SetBuffer(b)
h.Cursor = b.GetActiveCursor()
v := new(display.View)
h.SetView(v)
h.Relocate()
// 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
h.isOverwriteMode = false
h.lastClickTime = time.Time{}
}
func (h *BufHandler) ID() uint64 {
return h.splitID
}