Add CursorPageUp and CursorPageDown actions

This commit is contained in:
JT Olds
2016-05-31 16:02:42 -06:00
parent 74cac8291a
commit 8bd23a575f
2 changed files with 49 additions and 18 deletions

View File

@@ -19,6 +19,8 @@ var helpBinding string
var bindingActions = map[string]func(*View) bool{
"CursorUp": (*View).CursorUp,
"CursorDown": (*View).CursorDown,
"CursorPageUp": (*View).CursorPageUp,
"CursorPageDown": (*View).CursorPageDown,
"CursorLeft": (*View).CursorLeft,
"CursorRight": (*View).CursorRight,
"CursorStart": (*View).CursorStart,
@@ -884,6 +886,26 @@ func (v *View) PageDown() bool {
return false
}
// CursorPageUp places the cursor a page up
func (v *View) CursorPageUp() bool {
if v.Cursor.HasSelection() {
v.Cursor.SetLoc(v.Cursor.CurSelection[0])
v.Cursor.ResetSelection()
}
v.Cursor.UpN(v.height)
return true
}
// CursorPageDown places the cursor a page up
func (v *View) CursorPageDown() bool {
if v.Cursor.HasSelection() {
v.Cursor.SetLoc(v.Cursor.CurSelection[1])
v.Cursor.ResetSelection()
}
v.Cursor.DownN(v.height)
return true
}
// HalfPageUp scrolls the view up half a page
func (v *View) HalfPageUp() bool {
if v.Topline > v.height/2 {