Bind meta-= to autoindent currently selected rows

Closes #142
This commit is contained in:
Andy Delcambre
2013-01-17 16:15:20 -08:00
committed by Kevin Sawicki
parent 176ca529e3
commit 759fe2dd5b
5 changed files with 21 additions and 0 deletions

View File

@@ -208,6 +208,9 @@ class EditSession
toggleLineCommentsInSelection: ->
@mutateSelectedText (selection) -> selection.toggleLineComments()
autoIndentSelectedRows: ->
@mutateSelectedText (selection) -> selection.autoIndentSelectedRows()
cutToEndOfLine: ->
maintainPasteboard = false
@mutateSelectedText (selection) ->

View File

@@ -117,6 +117,7 @@ class Editor extends View
'editor:select-word': @selectWord
'editor:newline': @insertNewline
'editor:indent': @indent
'editor:auto-indent': @autoIndent
'editor:indent-selected-rows': @indentSelectedRows
'editor:outdent-selected-rows': @outdentSelectedRows
'editor:backspace-to-beginning-of-word': @backspaceToBeginningOfWord
@@ -248,6 +249,7 @@ class Editor extends View
insertNewline: -> @activeEditSession.insertNewline()
insertNewlineBelow: -> @activeEditSession.insertNewlineBelow()
indent: (options) -> @activeEditSession.indent(options)
autoIndent: (options) -> @activeEditSession.autoIndentSelectedRows(options)
indentSelectedRows: -> @activeEditSession.indentSelectedRows()
outdentSelectedRows: -> @activeEditSession.outdentSelectedRows()
cutSelection: -> @activeEditSession.cutSelectedText()

View File

@@ -4,6 +4,7 @@
'enter': 'editor:newline'
'meta-enter': 'editor:newline-below'
'tab': 'editor:indent'
'meta-=': 'editor:auto-indent'
'meta-d': 'editor:delete-line'
'ctrl-[': 'editor:fold-current-row'
'ctrl-]': 'editor:unfold-current-row'

View File

@@ -307,6 +307,10 @@ class Selection
if matchLength = buffer.lineForRow(row).match(leadingTabRegex)?[0].length
buffer.delete [[row, 0], [row, matchLength]]
autoIndentSelectedRows: ->
[start, end] = @getBufferRowRange()
@editSession.autoIndentBufferRows(start, end)
toggleLineComments: ->
@modifySelection =>
@editSession.toggleLineCommentsForBufferRows(@getBufferRowRange()...)