diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index c3af4cb9..8ef5ada4 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -76,6 +76,8 @@ var bindingActions = map[string]func(*View) bool{ "AddTab": (*View).AddTab, "PreviousTab": (*View).PreviousTab, "NextTab": (*View).NextTab, + "NextSplit": (*View).NextSplit, + "PreviousSplit": (*View).PreviousSplit, } var bindingKeys = map[string]tcell.Key{ @@ -398,6 +400,7 @@ func DefaultBindings() map[string]string { "CtrlB": "ShellMode", "CtrlQ": "Quit", "CtrlE": "CommandMode", + "CtrlW": "NextSplit", // Emacs-style keybindings "Alt-f": "WordRight", @@ -1170,6 +1173,28 @@ func (v *View) NextTab() bool { return false } +// Changes the view to the next split +func (v *View) NextSplit() bool { + tab := tabs[curTab] + if tab.curView < len(tab.views)-1 { + tab.curView++ + } else { + tab.curView = 0 + } + return false +} + +// Changes the view to the previous split +func (v *View) PreviousSplit() bool { + tab := tabs[curTab] + if tab.curView > 0 { + tab.curView-- + } else { + tab.curView = len(tab.views) - 1 + } + return false +} + // None is no action func None() bool { return false diff --git a/cmd/micro/view.go b/cmd/micro/view.go index 79d1dfa3..2f5a15a4 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -689,7 +689,7 @@ func (v *View) DisplayView() { lineIndentStyle = style } } - if settings["cursorline"].(bool) && !v.Cursor.HasSelection() && v.Cursor.Y == lineN+v.Topline { + if settings["cursorline"].(bool) && tabs[curTab].curView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == lineN+v.Topline { if style, ok := colorscheme["cursor-line"]; ok { fg, _, _ := style.Decompose() lineIndentStyle = lineIndentStyle.Background(fg) @@ -745,7 +745,7 @@ func (v *View) DisplayView() { for i := 0; i < v.width-((x-v.x)-v.leftCol); i++ { lineStyle := defStyle - if settings["cursorline"].(bool) && !v.Cursor.HasSelection() && v.Cursor.Y == lineN+v.Topline { + if settings["cursorline"].(bool) && tabs[curTab].curView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == lineN+v.Topline { if style, ok := colorscheme["cursor-line"]; ok { fg, _, _ := style.Decompose() lineStyle = lineStyle.Background(fg)