Meta-a selects everything

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-05-14 16:18:37 -06:00
parent 13553f79bc
commit 9079bcb103
5 changed files with 15 additions and 0 deletions

View File

@@ -407,6 +407,7 @@ describe "Editor", ->
otherEditor.simulateDomAttachment()
expect(otherEditor.setMaxLineLength).toHaveBeenCalled()
describe "when some lines at the end of the buffer are not visible on screen when the editor is attached", ->
beforeEach ->
editor.attachToDom(heightInLines: 5.5)
@@ -1330,6 +1331,11 @@ describe "Editor", ->
expect(editor.getSelection().getBufferRange()).toEqual [[9,3], [12,2]]
expect(editor.getSelection().isReversed()).toBeFalsy()
describe "select-all", ->
it "selects the entire buffer", ->
editor.trigger 'select-all'
expect(editor.getSelection().getBufferRange()).toEqual buffer.getRange()
describe "select-to-beginning-of-line", ->
it "selects text from cusor position to beginning of line", ->
editor.setCursorScreenPosition [12,2]

View File

@@ -127,6 +127,9 @@ class CompositeSeleciton
selectToTop: ->
@expandSelectionsBackward (selection) => selection.selectToTop()
selectAll: ->
@expandSelectionsForward (selection) => selection.selectAll()
selectToBottom: ->
@expandSelectionsForward (selection) => selection.selectToBottom()

View File

@@ -140,6 +140,7 @@ class Editor extends View
'select-to-beginning-of-line': @selectToBeginningOfLine
'select-to-end-of-word': @selectToEndOfWord
'select-to-beginning-of-word': @selectToBeginningOfWord
'select-all': @selectAll
for name, method of editorBindings
do (name, method) =>
@@ -588,6 +589,7 @@ class Editor extends View
selectDown: -> @compositeSelection.selectDown()
selectToTop: -> @compositeSelection.selectToTop()
selectToBottom: -> @compositeSelection.selectToBottom()
selectAll: -> @compositeSelection.selectAll()
selectToBeginningOfLine: -> @compositeSelection.selectToBeginningOfLine()
selectToEndOfLine: -> @compositeSelection.selectToEndOfLine()
selectToBeginningOfWord: -> @compositeSelection.selectToBeginningOfWord()

View File

@@ -16,6 +16,7 @@ window.keymap.bindKeys '.editor',
'shift-left': 'select-left'
'shift-up': 'select-up'
'shift-down': 'select-down'
'meta-a': 'select-all'
enter: 'newline'
tab: 'tab'
backspace: 'backspace'

View File

@@ -206,6 +206,9 @@ class Selection extends View
selectToBottom: ->
@modifySelection => @cursor.moveToBottom()
selectAll: ->
@setBufferRange(@editor.buffer.getRange())
selectToBeginningOfLine: ->
@modifySelection => @cursor.moveToBeginningOfLine()