aboutsummaryrefslogtreecommitdiff
path: root/atom/packages/vim-mode/lib/scroll.coffee
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2019-03-14 23:19:58 +0100
committerBen Beltran <ben@nsovocal.com>2019-03-14 23:19:58 +0100
commitb009b50e81b6c1d0d691505b5f5c0418f559bfc0 (patch)
tree5fae800e76219eba28634cb236565f9b4bb7a2f7 /atom/packages/vim-mode/lib/scroll.coffee
parent4efcafab7f0aa454f9ebe767133654bc9f44e12c (diff)
Remove Atom config
Diffstat (limited to 'atom/packages/vim-mode/lib/scroll.coffee')
-rw-r--r--atom/packages/vim-mode/lib/scroll.coffee110
1 files changed, 0 insertions, 110 deletions
diff --git a/atom/packages/vim-mode/lib/scroll.coffee b/atom/packages/vim-mode/lib/scroll.coffee
deleted file mode 100644
index 275f0f9..0000000
--- a/atom/packages/vim-mode/lib/scroll.coffee
+++ /dev/null
@@ -1,110 +0,0 @@
-class Scroll
- isComplete: -> true
- isRecordable: -> false
- constructor: (@editorElement) ->
- @scrolloff = 2 # atom default
- @editor = @editorElement.getModel()
- @rows =
- first: @editorElement.getFirstVisibleScreenRow()
- last: @editorElement.getLastVisibleScreenRow()
- final: @editor.getLastScreenRow()
-
-class ScrollDown extends Scroll
- execute: (count=1) ->
- @keepCursorOnScreen(count)
- @scrollUp(count)
-
- keepCursorOnScreen: (count) ->
- {row, column} = @editor.getCursorScreenPosition()
- firstScreenRow = @rows.first + @scrolloff + 1
- if row - count <= firstScreenRow
- @editor.setCursorScreenPosition([firstScreenRow + count, column])
-
- scrollUp: (count) ->
- lastScreenRow = @rows.last - @scrolloff
- @editor.scrollToScreenPosition([lastScreenRow + count, 0])
-
-class ScrollUp extends Scroll
- execute: (count=1) ->
- @keepCursorOnScreen(count)
- @scrollDown(count)
-
- keepCursorOnScreen: (count) ->
- {row, column} = @editor.getCursorScreenPosition()
- lastScreenRow = @rows.last - @scrolloff - 1
- if row + count >= lastScreenRow
- @editor.setCursorScreenPosition([lastScreenRow - count, column])
-
- scrollDown: (count) ->
- firstScreenRow = @rows.first + @scrolloff
- @editor.scrollToScreenPosition([firstScreenRow - count, 0])
-
-class ScrollCursor extends Scroll
- constructor: (@editorElement, @opts={}) ->
- super
- cursor = @editor.getCursorScreenPosition()
- @pixel = @editorElement.pixelPositionForScreenPosition(cursor).top
-
-class ScrollCursorToTop extends ScrollCursor
- execute: ->
- @moveToFirstNonBlank() unless @opts.leaveCursor
- @scrollUp()
-
- scrollUp: ->
- return if @rows.last is @rows.final
- @pixel -= (@editor.getLineHeightInPixels() * @scrolloff)
- @editor.setScrollTop(@pixel)
-
- moveToFirstNonBlank: ->
- @editor.moveToFirstCharacterOfLine()
-
-class ScrollCursorToMiddle extends ScrollCursor
- execute: ->
- @moveToFirstNonBlank() unless @opts.leaveCursor
- @scrollMiddle()
-
- scrollMiddle: ->
- @pixel -= (@editor.getHeight() / 2)
- @editor.setScrollTop(@pixel)
-
- moveToFirstNonBlank: ->
- @editor.moveToFirstCharacterOfLine()
-
-class ScrollCursorToBottom extends ScrollCursor
- execute: ->
- @moveToFirstNonBlank() unless @opts.leaveCursor
- @scrollDown()
-
- scrollDown: ->
- return if @rows.first is 0
- offset = (@editor.getLineHeightInPixels() * (@scrolloff + 1))
- @pixel -= (@editor.getHeight() - offset)
- @editor.setScrollTop(@pixel)
-
- moveToFirstNonBlank: ->
- @editor.moveToFirstCharacterOfLine()
-
-class ScrollHorizontal
- isComplete: -> true
- isRecordable: -> false
- constructor: (@editorElement) ->
- @editor = @editorElement.getModel()
- cursorPos = @editor.getCursorScreenPosition()
- @pixel = @editorElement.pixelPositionForScreenPosition(cursorPos).left
- @cursor = @editor.getLastCursor()
-
- putCursorOnScreen: ->
- @editor.scrollToCursorPosition({center: false})
-
-class ScrollCursorToLeft extends ScrollHorizontal
- execute: ->
- @editor.setScrollLeft(@pixel)
- @putCursorOnScreen()
-
-class ScrollCursorToRight extends ScrollHorizontal
- execute: ->
- @editor.setScrollRight(@pixel)
- @putCursorOnScreen()
-
-module.exports = {ScrollDown, ScrollUp, ScrollCursorToTop, ScrollCursorToMiddle,
- ScrollCursorToBottom, ScrollCursorToLeft, ScrollCursorToRight}