Add bindings for shiftup and shiftdown

This commit is contained in:
Zachary Yedidia 2016-04-28 21:00:46 -04:00
parent 536c96237c
commit 18b0b3e97d

View file

@ -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()