|
|
@@ -19,6 +19,7 @@ type ActionManager = struct {
|
|
|
Insert []Action
|
|
|
Palette []Action
|
|
|
CM ChordManager
|
|
|
+ RCM ChordManager
|
|
|
}
|
|
|
|
|
|
type Action = struct {
|
|
|
@@ -41,8 +42,8 @@ const (
|
|
|
)
|
|
|
|
|
|
type ChordManager = struct {
|
|
|
- Recording bool
|
|
|
- Recorded []string
|
|
|
+ Recording bool
|
|
|
+ Recorded []string
|
|
|
}
|
|
|
|
|
|
func NewChordManager() ChordManager {
|
|
|
@@ -56,6 +57,42 @@ func DefaultActionManager() ActionManager {
|
|
|
am := ActionManager{
|
|
|
CM: NewChordManager(),
|
|
|
Common: []Action{
|
|
|
+ Action{
|
|
|
+ Commands: []string{"bsel"},
|
|
|
+ AskArgs: true,
|
|
|
+ Callback: func(m *Model, args []string) {
|
|
|
+ if len(args) < 1 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ n, err := strconv.Atoi(args[0])
|
|
|
+ if err != nil || n < 1 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ targetTab := n - 1
|
|
|
+
|
|
|
+ ws, ok := m.LM.Workspaces[m.LM.ActiveIdx]
|
|
|
+ if !ok {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ selected := false
|
|
|
+ ws.RootContainer.WalkAndMutateActive(func(cb *layout.ContainerBuffers) layout.ContainerNode {
|
|
|
+ if targetTab >= 0 && targetTab < len(cb.Buffers) {
|
|
|
+ cb.ActiveIdx = targetTab
|
|
|
+ m.BM.CurrentIdx = cb.Buffers[targetTab]
|
|
|
+ selected = true
|
|
|
+ }
|
|
|
+ return *cb
|
|
|
+ })
|
|
|
+
|
|
|
+ if selected {
|
|
|
+ m.LM.Workspaces[m.LM.ActiveIdx] = ws
|
|
|
+ m.Mode = ModeNormal
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
Action{
|
|
|
Commands: []string{"version"},
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
@@ -257,109 +294,94 @@ func DefaultActionManager() ActionManager {
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
- },
|
|
|
- Normal: []Action{
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
- Type: BindingSingle,
|
|
|
- Single: "z",
|
|
|
+ Type: BindingChord,
|
|
|
+ Chord: []string{"ctrl+l", "enter"},
|
|
|
},
|
|
|
},
|
|
|
- Commands: []string{"u", "undo"},
|
|
|
- AskArgs: false,
|
|
|
+ Commands: []string{"lbuf"},
|
|
|
+ AskArgs: false,
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- if m.Mode == ModePalette {
|
|
|
- m.BM.PaletteBuffer.Undo()
|
|
|
- } else {
|
|
|
- m.BM.Current().Undo()
|
|
|
- }
|
|
|
+ m.AddBuffer(true)
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "y",
|
|
|
+ Single: "ctrl+left",
|
|
|
},
|
|
|
},
|
|
|
- Commands: []string{"r", "redo"},
|
|
|
- AskArgs: false,
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- if m.Mode == ModePalette {
|
|
|
- m.BM.PaletteBuffer.Redo()
|
|
|
- } else {
|
|
|
- m.BM.Current().Redo()
|
|
|
- }
|
|
|
+ m.CycleActiveBuffer(-1.0, 0.0)
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
- Type: BindingChord,
|
|
|
- Chord: []string{"d", "d"},
|
|
|
+ Type: BindingSingle,
|
|
|
+ Single: "ctrl+v",
|
|
|
},
|
|
|
},
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.BM.Current().DeleteLine()
|
|
|
+ if m.LM.CurrentSplit == layout.SplitHorizontal {
|
|
|
+ m.LM.CurrentSplit = layout.SplitVertical
|
|
|
+ } else {
|
|
|
+ m.LM.CurrentSplit = layout.SplitHorizontal
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "w",
|
|
|
+ Single: "ctrl+down",
|
|
|
},
|
|
|
},
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.Mode = ModeWrite
|
|
|
+ m.CycleActiveBuffer(0.0, 1.0)
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "q",
|
|
|
+ Single: "ctrl+up",
|
|
|
},
|
|
|
},
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.Mode = ModePalette
|
|
|
- m.BM.PaletteBuffer.Clear()
|
|
|
- m.BM.PaletteBuffer.Insert("/")
|
|
|
+ m.CycleActiveBuffer(0.0, -1.0)
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "f",
|
|
|
+ Single: "ctrl+right",
|
|
|
},
|
|
|
},
|
|
|
- AskArgs: true,
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.Mode = ModePalette
|
|
|
- m.BM.PaletteBuffer.Clear()
|
|
|
- m.BM.PaletteBuffer.Insert("?")
|
|
|
+ m.CycleActiveBuffer(1.0, 0.0)
|
|
|
},
|
|
|
},
|
|
|
+ },
|
|
|
+ Normal: []Action{
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "v",
|
|
|
+ Single: "z",
|
|
|
},
|
|
|
},
|
|
|
- Commands: []string{"p", "paste"},
|
|
|
- AskArgs: false,
|
|
|
+ Commands: []string{"u", "undo"},
|
|
|
+ AskArgs: false,
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- text := clipboard.Read(clipboard.FmtText)
|
|
|
-
|
|
|
- if string(text) != "" {
|
|
|
- if m.Mode == ModePalette {
|
|
|
- m.BM.PaletteBuffer.Insert(string(text))
|
|
|
- } else {
|
|
|
- m.BM.Current().Insert(string(text))
|
|
|
- }
|
|
|
+ if m.Mode == ModePalette {
|
|
|
+ m.BM.PaletteBuffer.Undo()
|
|
|
+ } else {
|
|
|
+ m.BM.Current().Undo()
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
@@ -367,85 +389,100 @@ func DefaultActionManager() ActionManager {
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "enter",
|
|
|
+ Single: "y",
|
|
|
},
|
|
|
},
|
|
|
- Commands: []string{"buf"},
|
|
|
- AskArgs: false,
|
|
|
+ Commands: []string{"r", "redo"},
|
|
|
+ AskArgs: false,
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.AddBuffer(false)
|
|
|
+ if m.Mode == ModePalette {
|
|
|
+ m.BM.PaletteBuffer.Redo()
|
|
|
+ } else {
|
|
|
+ m.BM.Current().Redo()
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingChord,
|
|
|
- Chord: []string{"l", "enter"},
|
|
|
+ Chord: []string{"d", "d"},
|
|
|
},
|
|
|
},
|
|
|
- Commands: []string{"lbuf"},
|
|
|
- AskArgs: false,
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.AddBuffer(true)
|
|
|
+ m.BM.Current().DeleteLine()
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "ctrl+left",
|
|
|
+ Single: "w",
|
|
|
},
|
|
|
},
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.CycleActiveBuffer(-1.0, 0.0)
|
|
|
+ m.Mode = ModeWrite
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "ctrl+v",
|
|
|
+ Single: "q",
|
|
|
},
|
|
|
},
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- if m.LM.CurrentSplit == layout.SplitHorizontal {
|
|
|
- m.LM.CurrentSplit = layout.SplitVertical
|
|
|
- } else {
|
|
|
- m.LM.CurrentSplit = layout.SplitHorizontal
|
|
|
- }
|
|
|
+ m.Mode = ModePalette
|
|
|
+ m.BM.PaletteBuffer.Clear()
|
|
|
+ m.BM.PaletteBuffer.Insert("/")
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "ctrl+down",
|
|
|
+ Single: "f",
|
|
|
},
|
|
|
},
|
|
|
+ AskArgs: true,
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.CycleActiveBuffer(0.0, 1.0)
|
|
|
+ m.Mode = ModePalette
|
|
|
+ m.BM.PaletteBuffer.Clear()
|
|
|
+ m.BM.PaletteBuffer.Insert("?")
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "ctrl+up",
|
|
|
+ Single: "v",
|
|
|
},
|
|
|
},
|
|
|
+ Commands: []string{"p", "paste"},
|
|
|
+ AskArgs: false,
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.CycleActiveBuffer(0.0, -1.0)
|
|
|
+ text := clipboard.Read(clipboard.FmtText)
|
|
|
+
|
|
|
+ if string(text) != "" {
|
|
|
+ if m.Mode == ModePalette {
|
|
|
+ m.BM.PaletteBuffer.Insert(string(text))
|
|
|
+ } else {
|
|
|
+ m.BM.Current().Insert(string(text))
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
Action{
|
|
|
Bindings: []Binding{
|
|
|
Binding{
|
|
|
Type: BindingSingle,
|
|
|
- Single: "ctrl+right",
|
|
|
+ Single: "enter",
|
|
|
},
|
|
|
},
|
|
|
+ Commands: []string{"buf"},
|
|
|
+ AskArgs: false,
|
|
|
Callback: func(m *Model, args []string) {
|
|
|
- m.CycleActiveBuffer(1.0, 0.0)
|
|
|
+ m.AddBuffer(false)
|
|
|
},
|
|
|
},
|
|
|
Action{
|