]> git.r.bdr.sh - rbdr/dotfiles/blobdiff - atom/packages/vim-mode/lib/scroll.coffee
Adds atom packages
[rbdr/dotfiles] / atom / packages / vim-mode / lib / scroll.coffee
index 1bc1258c7cf1b37e4b042b79113a9687c543f197..275f0f9f2b907d9bdbc5ac2f8cbb1d7545aefc58 100644 (file)
@@ -84,5 +84,27 @@ class ScrollCursorToBottom extends ScrollCursor
   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}
+  ScrollCursorToBottom, ScrollCursorToLeft, ScrollCursorToRight}