From 18b0b3e97d49df1acf7e04c4f1a408f024ee9460 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 28 Apr 2016 21:00:46 -0400 Subject: [PATCH] Add bindings for shiftup and shiftdown --- cmd/micro/bindings.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index d699da0a..d5d956c0 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -29,6 +29,8 @@ func InitBindings() { "CursorEnd": (*View).CursorEnd, "SelectToStart": (*View).SelectToStart, "SelectToEnd": (*View).SelectToEnd, + "SelectUp": (*View).SelectUp, + "SelectDown": (*View).SelectDown, "SelectLeft": (*View).SelectLeft, "SelectRight": (*View).SelectRight, "WordRight": (*View).WordRight, @@ -245,6 +247,8 @@ func DefaultBindings() map[string]string { "Down": "CursorDown", "Right": "CursorRight", "Left": "CursorLeft", + "ShiftUp": "SelectUp", + "ShiftDown": "SelectDown", "ShiftLeft": "SelectLeft", "ShiftRight": "SelectRight", "AltLeft": "WordLeft", @@ -335,6 +339,28 @@ func (v *View) WordLeft() bool { return true } +// SelectUp selects up one line +func (v *View) SelectUp() bool { + loc := v.cursor.Loc() + if !v.cursor.HasSelection() { + v.cursor.origSelection[0] = loc + } + v.cursor.Up() + v.cursor.SelectTo(v.cursor.Loc()) + return true +} + +// SelectUp selects down one line +func (v *View) SelectDown() bool { + loc := v.cursor.Loc() + if !v.cursor.HasSelection() { + v.cursor.origSelection[0] = loc + } + v.cursor.Down() + v.cursor.SelectTo(v.cursor.Loc()) + return true +} + // SelectLeft selects the character to the left of the cursor func (v *View) SelectLeft() bool { loc := v.cursor.Loc()