Add method for cutting text to the end of the buffer line

This commit is contained in:
Ivan Zuzak
2015-09-17 19:24:52 +02:00
parent 905ed246bf
commit 7e1a295f07
4 changed files with 52 additions and 3 deletions

View File

@@ -257,10 +257,15 @@ class Selection extends Model
@modifySelection => @cursor.moveToFirstCharacterOfLine()
# Public: Selects all the text from the current cursor position to the end of
# the line.
# the screen line.
selectToEndOfLine: ->
@modifySelection => @cursor.moveToEndOfScreenLine()
# Public: Selects all the text from the current cursor position to the end of
# the buffer line.
selectToEndOfBufferLine: ->
@modifySelection => @cursor.moveToEndOfLine()
# Public: Selects all the text from the current cursor position to the
# beginning of the word.
selectToBeginningOfWord: ->
@@ -572,11 +577,16 @@ class Selection extends Model
toggleLineComments: ->
@editor.toggleLineCommentsForBufferRows(@getBufferRowRange()...)
# Public: Cuts the selection until the end of the line.
# Public: Cuts the selection until the end of the screen line.
cutToEndOfLine: (maintainClipboard) ->
@selectToEndOfLine() if @isEmpty()
@cut(maintainClipboard)
# Public: Cuts the selection until the end of the buffer line.
cutToEndOfBufferLine: (maintainClipboard) ->
@selectToEndOfBufferLine() if @isEmpty()
@cut(maintainClipboard)
# Public: Copies the selection to the clipboard and then deletes it.
#
# * `maintainClipboard` {Boolean} (default: false) See {::copy}

View File

@@ -299,6 +299,7 @@ atom.commands.add 'atom-text-editor', stopEventPropagationAndGroupUndo(
'editor:delete-to-end-of-subword': -> @deleteToEndOfSubword()
'editor:delete-line': -> @deleteLine()
'editor:cut-to-end-of-line': -> @cutToEndOfLine()
'editor:cut-to-end-of-buffer-line': -> @cutToEndOfBufferLine()
'editor:transpose': -> @transpose()
'editor:upper-case': -> @upperCase()
'editor:lower-case': -> @lowerCase()

View File

@@ -2664,7 +2664,7 @@ class TextEditor extends Model
@emitter.emit 'did-insert-text', didInsertEvent
# Essential: For each selection, if the selection is empty, cut all characters
# of the containing line following the cursor. Otherwise cut the selected
# of the containing screen line following the cursor. Otherwise cut the selected
# text.
cutToEndOfLine: ->
maintainClipboard = false
@@ -2672,6 +2672,15 @@ class TextEditor extends Model
selection.cutToEndOfLine(maintainClipboard)
maintainClipboard = true
# Essential: For each selection, if the selection is empty, cut all characters
# of the containing buffer line following the cursor. Otherwise cut the
# selected text.
cutToEndOfBufferLine: ->
maintainClipboard = false
@mutateSelectedText (selection) ->
selection.cutToEndOfBufferLine(maintainClipboard)
maintainClipboard = true
###
Section: Folds
###