Prechádzať zdrojové kódy

Layout work, the layout stuff seems finished, just need the layout manipulation stuff: movement, change active, etc

Johan Rong 1 mesiac pred
rodič
commit
7fa37e7d94

+ 1 - 1
internal/editor/draw.go

@@ -14,7 +14,7 @@ func (m *Model) Draw() {
 	screen := layout.RectFromScren(m.Screen)
 	main := layout.Rect{
 		X: screen.X,
-		Y: screen.Y,
+		Y: screen.Y + 1,
 		Width: screen.Width,
 		Height: screen.Height - 2,
 	}

+ 4 - 0
internal/editor/keyinput.go

@@ -15,6 +15,10 @@ func (m *Model) HandleKeyInput(ev *tcell.EventKey) {
 		for _, binding := range action.Bindings {
 			switch binding.Type {
 			case BindingSingle:
+				if m.AM.CM.Recording {
+					continue
+				}
+
 				if util.StandardizeBinding(binding.Single) == util.StandardizeBinding(ev.Name()) {
 					m.AM.CM = NewChordManager()
 

+ 1 - 1
internal/editor/model.go

@@ -23,7 +23,7 @@ func NewModel(screen tcell.Screen, style tcell.Style) Model {
 		Style:		   style,
 		Mode:		   ModeNormal,
 		BM:            buffer.BufferManager{
-			Buffers:       []buffer.Buffer{},
+			Buffers:       []buffer.Buffer{buffer.NewBuffer()},
 			CurrentIdx:    0,
 			PaletteBuffer: buffer.NewBuffer(),
 		},

+ 23 - 7
internal/layout/layout.go

@@ -1,8 +1,9 @@
 package layout
 
 type LayoutManager struct {
-	Workspaces map[int]Workspace
-	ActiveIdx  int
+	Workspaces   map[int]Workspace
+	ActiveIdx    int
+	CurrentSplit SplitType
 }
 
 type Workspace struct {
@@ -15,6 +16,15 @@ const (
 	SplitVertical
 )
 
+func (s *SplitType) SetOpposite()  SplitType{
+	if *s == SplitHorizontal {
+		*s = SplitVertical
+	} else {
+		*s = SplitHorizontal
+	}
+	return *s
+}
+
 type ContainerNode interface {
 	isContainerNode()
 }
@@ -37,6 +47,7 @@ func (Container) isContainerNode() {}
 func NewLayoutManager() LayoutManager {
 	return LayoutManager{
 		Workspaces: map[int]Workspace{0: NewWorkspace()},
+		CurrentSplit: SplitVertical,
 	}
 }
 
@@ -48,8 +59,13 @@ func NewWorkspace() Workspace {
 
 func NewContainerEmpty() Container {
 	return Container{
-		Children: 	    [2]ContainerNode{},
-		Split:	  	    SplitVertical,
+		Children: 	    [2]ContainerNode{
+			ContainerBuffers{
+				Buffers: []int{0},
+				ActiveIdx: 0,
+			},
+		},
+		Split:	  	    SplitHorizontal,
 		ActiveChildIdx: 0,
 	}
 }
@@ -83,9 +99,9 @@ func (lm *LayoutManager) InsertBuffer(bufferIdx int, newNode bool) {
 		}
 
 		return Container{
-			Children:       [2]ContainerNode{cbNew, *cb},
-			Split:          SplitHorizontal,
-			ActiveChildIdx: 0,
+			Children:       [2]ContainerNode{*cb, cbNew},
+			Split:          lm.CurrentSplit.SetOpposite(),
+			ActiveChildIdx: 1,
 		}
 	})
 

+ 4 - 4
internal/layout/rect.go

@@ -33,15 +33,15 @@ func RectDisplace(rect Rect, split SplitType, idx int) Rect {
 	switch split {
 	case SplitHorizontal: return Rect{
 		X: rect.X + (rect.Width * idx),
-		Y: rect.Y + 1,
+		Y: rect.Y,// + 1,
 		Width: rect.Width,
-		Height: rect.Height - 1,
+		Height: rect.Height,// - 1,
 	}
 	case SplitVertical: return Rect{
 		X: rect.X,
-		Y: rect.Y + (rect.Height * idx) + 1,
+		Y: rect.Y + (rect.Height * idx),// + 1,
 		Width: rect.Width,
-		Height: rect.Height - 1,
+		Height: rect.Height,// - 1,
 	}
 	default: panic("[moose-error] impossible split type")
 	}