mirror of
https://github.com/atom/atom.git
synced 2026-02-09 14:15:24 -05:00
Add basic top/bottom cursor/selection commands
This commit is contained in:
@@ -60,6 +60,12 @@ class CompositeCursor
|
||||
moveToNextWord: ->
|
||||
@modifyCursors (cursor) -> cursor.moveToNextWord()
|
||||
|
||||
moveToTop: ->
|
||||
@modifyCursors (cursor) -> cursor.moveToTop()
|
||||
|
||||
moveToBottom: ->
|
||||
@modifyCursors (cursor) -> cursor.moveToBottom()
|
||||
|
||||
handleBufferChange: (e) ->
|
||||
@modifyCursors (cursor) -> cursor.handleBufferChange(e)
|
||||
|
||||
|
||||
@@ -79,6 +79,14 @@ class CompositeSeleciton
|
||||
selection.selectDown() for selection in @getSelections()
|
||||
@mergeIntersectingSelections()
|
||||
|
||||
selectToTop: ->
|
||||
selection.selectToTop() for selection in @getSelections()
|
||||
@mergeIntersectingSelections reverse: true
|
||||
|
||||
selectToBottom: ->
|
||||
selection.selectToBottom() for selection in @getSelections()
|
||||
@mergeIntersectingSelections()
|
||||
|
||||
setBufferRange: (bufferRange, options) ->
|
||||
@getLastSelection().setBufferRange(bufferRange, options)
|
||||
|
||||
|
||||
@@ -139,6 +139,12 @@ class Cursor extends View
|
||||
|
||||
@setScreenPosition({row, column})
|
||||
|
||||
moveToTop: ->
|
||||
@setBufferPosition [0,0]
|
||||
|
||||
moveToBottom: ->
|
||||
@setBufferPosition @editor.getEofPosition()
|
||||
|
||||
moveLeftUntilMatch: (regex) ->
|
||||
row = @getScreenRow()
|
||||
column = @getScreenColumn()
|
||||
|
||||
@@ -42,6 +42,7 @@ class Editor extends View
|
||||
requireStylesheet 'editor.css'
|
||||
requireStylesheet 'theme/twilight.css'
|
||||
require 'keybindings/emacs'
|
||||
require 'keybindings/apple'
|
||||
|
||||
@id = Editor.idCounter++
|
||||
@editSessionsByBufferId = {}
|
||||
@@ -103,6 +104,11 @@ class Editor extends View
|
||||
@on 'split-down', => @splitDown()
|
||||
@on 'close', => @remove(); false
|
||||
|
||||
@on 'move-to-top', => @moveCursorToTop()
|
||||
@on 'select-to-top', => @selectToTop()
|
||||
@on 'move-to-bottom', => @moveCursorToBottom()
|
||||
@on 'select-to-bottom', => @selectToBottom()
|
||||
|
||||
buildCursorAndSelection: ->
|
||||
@compositeSelection = new CompositeSelection(this)
|
||||
@compositeCursor = new CompositeCursor(this)
|
||||
@@ -357,6 +363,8 @@ class Editor extends View
|
||||
moveCursorRight: -> @compositeCursor.moveRight()
|
||||
moveCursorLeft: -> @compositeCursor.moveLeft()
|
||||
moveCursorToNextWord: -> @compositeCursor.moveToNextWord()
|
||||
moveCursorToTop: -> @compositeCursor.moveToTop()
|
||||
moveCursorToBottom: -> @compositeCursor.moveToBottom()
|
||||
setCursorScreenPosition: (position) -> @compositeCursor.setScreenPosition(position)
|
||||
getCursorScreenPosition: -> @compositeCursor.getCursor().getScreenPosition()
|
||||
setCursorBufferPosition: (position) -> @compositeCursor.setBufferPosition(position)
|
||||
@@ -372,6 +380,8 @@ class Editor extends View
|
||||
selectLeft: -> @compositeSelection.selectLeft()
|
||||
selectUp: -> @compositeSelection.selectUp()
|
||||
selectDown: -> @compositeSelection.selectDown()
|
||||
selectToTop: -> @compositeSelection.selectToTop()
|
||||
selectToBottom: -> @compositeSelection.selectToBottom()
|
||||
selectToScreenPosition: (position) -> @compositeSelection.selectToScreenPosition(position)
|
||||
clearSelections: -> @compositeSelection.clearSelections()
|
||||
|
||||
|
||||
6
src/atom/keybindings/apple.coffee
Normal file
6
src/atom/keybindings/apple.coffee
Normal file
@@ -0,0 +1,6 @@
|
||||
window.keymap.bindKeys '.editor'
|
||||
'meta-up': 'move-to-top'
|
||||
'meta-shift-up': 'select-to-top'
|
||||
'meta-down': 'move-to-bottom'
|
||||
'meta-shift-down': 'select-to-bottom'
|
||||
'alt-up': 'move-to-start-of-paragraph'
|
||||
@@ -212,6 +212,14 @@ class Selection extends View
|
||||
@modifySelection =>
|
||||
@cursor.moveDown()
|
||||
|
||||
selectToTop: ->
|
||||
@modifySelection =>
|
||||
@cursor.moveToTop()
|
||||
|
||||
selectToBottom: ->
|
||||
@modifySelection =>
|
||||
@cursor.moveToBottom()
|
||||
|
||||
selectLeftUntilMatch: (regex) ->
|
||||
@modifySelection =>
|
||||
@cursor.moveLeftUntilMatch(regex)
|
||||
|
||||
Reference in New Issue
Block a user