mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-24 17:50:15 +09:00
Split improvements
This commit is contained in:
@@ -219,12 +219,14 @@ func (h *BufHandler) vsplit(buf *buffer.Buffer) {
|
||||
e.splitID = MainTab.GetNode(h.splitID).VSplit(h.Buf.Settings["splitright"].(bool))
|
||||
MainTab.Panes = append(MainTab.Panes, e)
|
||||
MainTab.Resize()
|
||||
MainTab.SetActive(len(MainTab.Panes) - 1)
|
||||
}
|
||||
func (h *BufHandler) hsplit(buf *buffer.Buffer) {
|
||||
e := NewBufEditPane(0, 0, 0, 0, buf)
|
||||
e.splitID = MainTab.GetNode(h.splitID).HSplit(h.Buf.Settings["splitbottom"].(bool))
|
||||
MainTab.Panes = append(MainTab.Panes, e)
|
||||
MainTab.Resize()
|
||||
MainTab.SetActive(len(MainTab.Panes) - 1)
|
||||
}
|
||||
|
||||
// BufKeyActions contains the list of all possible key actions the bufhandler could execute
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package action
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/zyedidia/micro/cmd/micro/views"
|
||||
"github.com/zyedidia/tcell"
|
||||
)
|
||||
@@ -16,12 +14,40 @@ type TabPane struct {
|
||||
}
|
||||
|
||||
func (t *TabPane) HandleEvent(event tcell.Event) {
|
||||
switch e := event.(type) {
|
||||
case *tcell.EventMouse:
|
||||
switch e.Buttons() {
|
||||
case tcell.Button1:
|
||||
mx, my := e.Position()
|
||||
|
||||
for i, p := range t.Panes {
|
||||
v := p.GetView()
|
||||
inpane := mx >= v.X && mx < v.X+v.Width && my >= v.Y && my < v.Y+v.Height
|
||||
if inpane {
|
||||
t.active = i
|
||||
p.SetActive(true)
|
||||
} else {
|
||||
p.SetActive(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
t.Panes[t.active].HandleEvent(event)
|
||||
}
|
||||
|
||||
func (t *TabPane) SetActive(i int) {
|
||||
t.active = i
|
||||
for j, p := range t.Panes {
|
||||
if j == i {
|
||||
p.SetActive(true)
|
||||
} else {
|
||||
p.SetActive(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TabPane) Resize() {
|
||||
for _, p := range t.Panes {
|
||||
log.Println(p.splitID)
|
||||
v := t.GetNode(p.splitID).GetView()
|
||||
pv := p.GetView()
|
||||
pv.X, pv.Y = v.X, v.Y
|
||||
|
||||
Reference in New Issue
Block a user