@@ -1669,63 +1669,77 @@ func (h *BufPane) End() bool {
16691669
16701670// PageUp scrolls the view up a page
16711671func (h * BufPane ) PageUp () bool {
1672- h .ScrollUp (h .BufView ().Height )
1672+ pageOverlap := int (h .Buf .Settings ["pageoverlap" ].(float64 ))
1673+ h .ScrollUp (h .BufView ().Height - pageOverlap )
16731674 return true
16741675}
16751676
16761677// PageDown scrolls the view down a page
16771678func (h * BufPane ) PageDown () bool {
1678- h .ScrollDown (h .BufView ().Height )
1679+ pageOverlap := int (h .Buf .Settings ["pageoverlap" ].(float64 ))
1680+ h .ScrollDown (h .BufView ().Height - pageOverlap )
16791681 h .ScrollAdjust ()
16801682 return true
16811683}
16821684
16831685// SelectPageUp selects up one page
16841686func (h * BufPane ) SelectPageUp () bool {
1687+ pageOverlap := int (h .Buf .Settings ["pageoverlap" ].(float64 ))
1688+ scrollAmount := h .BufView ().Height - pageOverlap
16851689 if ! h .Cursor .HasSelection () {
16861690 h .Cursor .OrigSelection [0 ] = h .Cursor .Loc
16871691 }
1688- h .MoveCursorUp (h . BufView (). Height )
1692+ h .MoveCursorUp (scrollAmount )
16891693 h .Cursor .SelectTo (h .Cursor .Loc )
1694+ if h .Cursor .Num == 0 {
1695+ h .ScrollUp (scrollAmount )
1696+ }
16901697 h .Relocate ()
16911698 return true
16921699}
16931700
16941701// SelectPageDown selects down one page
16951702func (h * BufPane ) SelectPageDown () bool {
1703+ pageOverlap := int (h .Buf .Settings ["pageoverlap" ].(float64 ))
1704+ scrollAmount := h .BufView ().Height - pageOverlap
16961705 if ! h .Cursor .HasSelection () {
16971706 h .Cursor .OrigSelection [0 ] = h .Cursor .Loc
16981707 }
1699- h .MoveCursorDown (h . BufView (). Height )
1708+ h .MoveCursorDown (scrollAmount )
17001709 h .Cursor .SelectTo (h .Cursor .Loc )
1710+ if h .Cursor .Num == 0 {
1711+ h .ScrollDown (scrollAmount )
1712+ h .ScrollAdjust ()
1713+ }
17011714 h .Relocate ()
17021715 return true
17031716}
17041717
1705- // CursorPageUp places the cursor a page up
1718+ // CursorPageUp places the cursor a page up,
1719+ // moving the view to keep cursor at the same relative position in the view
17061720func (h * BufPane ) CursorPageUp () bool {
17071721 h .Cursor .Deselect (true )
1708-
1709- if h . Cursor . HasSelection () {
1710- h . Cursor . Loc = h . Cursor . CurSelection [ 0 ]
1711- h .Cursor .ResetSelection ()
1712- h .Cursor . StoreVisualX ( )
1722+ pageOverlap := int ( h . Buf . Settings [ "pageoverlap" ].( float64 ))
1723+ scrollAmount := h . BufView (). Height - pageOverlap
1724+ h . MoveCursorUp ( scrollAmount )
1725+ if h .Cursor .Num == 0 {
1726+ h .ScrollUp ( scrollAmount )
17131727 }
1714- h .MoveCursorUp (h .BufView ().Height )
17151728 h .Relocate ()
17161729 return true
17171730}
17181731
1719- // CursorPageDown places the cursor a page up
1732+ // CursorPageDown places the cursor a page down,
1733+ // moving the view to keep cursor at the same relative position in the view
17201734func (h * BufPane ) CursorPageDown () bool {
17211735 h .Cursor .Deselect (false )
1722-
1723- if h .Cursor .HasSelection () {
1724- h .Cursor .Loc = h .Cursor .CurSelection [1 ]
1725- h .Cursor .ResetSelection ()
1726- h .Cursor .StoreVisualX ()
1736+ pageOverlap := int (h .Buf .Settings ["pageoverlap" ].(float64 ))
1737+ scrollAmount := h .BufView ().Height - pageOverlap
1738+ h .MoveCursorDown (scrollAmount )
1739+ if h .Cursor .Num == 0 {
1740+ h .ScrollDown (scrollAmount )
1741+ h .ScrollAdjust ()
17271742 }
1728- h .MoveCursorDown (h .BufView ().Height )
17291743 h .Relocate ()
17301744 return true
17311745}
0 commit comments