Johan Rong 1 mesiac pred
rodič
commit
4734906af3
2 zmenil súbory, kde vykonal 28 pridanie a 27 odobranie
  1. 27 26
      internal/editor/action.go
  2. 1 1
      internal/editor/model.go

+ 27 - 26
internal/editor/action.go

@@ -33,13 +33,37 @@ func DefaultActionManager() ActionManager {
 			Action{
 				Binding: "left",
 				Callback: func(m *Model, args []string) {
-					m.BM.Current().MoveHoriz(-1)	
+					if m.Mode == ModePalette {
+						m.BM.PaletteBuffer.MoveHoriz(-1)
+					} else {
+						m.BM.Current().MoveHoriz(-1)
+					}
 				},
 			},
 			Action{
 				Binding: "right",
 				Callback: func(m *Model, args []string) {
-					m.BM.Current().MoveHoriz(1)
+					if m.Mode == ModePalette {
+						m.BM.PaletteBuffer.MoveHoriz(1)					
+					} else {
+						m.BM.Current().MoveHoriz(1)
+					}
+				},
+			},
+			Action{
+				Binding: "up",
+				Callback: func(m *Model, args []string) {
+					if m.Mode != ModePalette {
+						m.BM.Current().MoveVert(-1)
+					}
+				},
+			},
+			Action{
+				Binding: "down",
+				Callback: func(m *Model, args []string) {
+					if m.Mode != ModePalette {
+						m.BM.Current().MoveVert(1)
+					}
 				},
 			},
 			Action{
@@ -121,6 +145,7 @@ func DefaultActionManager() ActionManager {
 					m.BM.Current().Clear()
 					m.BM.Current().Rope = rope.New(content)
 					m.BM.Current().LI.Rebuild(m.BM.Current().Rope)
+					m.BM.Current().Path = args[0]
 				},
 			},
 		},
@@ -150,18 +175,6 @@ func DefaultActionManager() ActionManager {
 			},
 		},
 		Insert:  []Action{
-			Action{
-				Binding: "up",
-				Callback: func(m *Model, args []string) {
-					m.BM.Current().MoveVert(-1)
-				},
-			},
-			Action{
-				Binding: "down",
-				Callback: func(m *Model, args []string) {
-					m.BM.Current().MoveVert(1)
-				},
-			},
 			Action{
 				Binding: "shift+up",
 				Command: "TODO:",
@@ -225,18 +238,6 @@ func DefaultActionManager() ActionManager {
 					m.BM.PaletteBuffer.Delete()
 				},
 			},
-			Action{
-				Binding: "left",
-				Callback: func(m *Model, args []string) {
-					m.BM.PaletteBuffer.MoveHoriz(-1)
-				},
-			},
-			Action{
-				Binding: "right",
-				Callback: func(m *Model, args []string) {
-					m.BM.PaletteBuffer.MoveHoriz(1)
-				},
-			},
 			Action{
 				Binding: "enter",
 				Callback: func(m *Model, _ []string) {

+ 1 - 1
internal/editor/model.go

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