mirror of
https://github.com/atom/atom.git
synced 2026-02-14 00:25:08 -05:00
Add autoflow package w/ autoflow:reflow-paragraph command
This commit is contained in:
@@ -175,6 +175,23 @@ class Cursor
|
||||
getCurrentLineBufferRange: (options) ->
|
||||
@editSession.bufferRangeForBufferRow(@getBufferRow(), options)
|
||||
|
||||
getCurrentParagraphBufferRange: ->
|
||||
row = @getBufferRow()
|
||||
return unless /\w/.test(@editSession.lineForBufferRow(row))
|
||||
|
||||
startRow = row
|
||||
while startRow > 0
|
||||
break unless /\w/.test(@editSession.lineForBufferRow(startRow - 1))
|
||||
startRow--
|
||||
|
||||
endRow = row
|
||||
lastRow = @editSession.getLastBufferRow()
|
||||
while endRow < lastRow
|
||||
break unless /\w/.test(@editSession.lineForBufferRow(endRow + 1))
|
||||
endRow++
|
||||
|
||||
new Range([startRow, 0], [endRow, @editSession.lineLengthForBufferRow(endRow)])
|
||||
|
||||
getCurrentWordPrefix: ->
|
||||
@editSession.getTextInBufferRange([@getBeginningOfCurrentWordBufferPosition(), @getBufferPosition()])
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ class EditSession
|
||||
getLastBufferRow: -> @buffer.getLastRow()
|
||||
bufferRangeForBufferRow: (row, options) -> @buffer.rangeForRow(row, options)
|
||||
lineForBufferRow: (row) -> @buffer.lineForRow(row)
|
||||
lineLengthForBufferRow: (row) -> @buffer.lineLengthForRow(row)
|
||||
scanInRange: (args...) -> @buffer.scanInRange(args...)
|
||||
backwardsScanInRange: (args...) -> @buffer.backwardsScanInRange(args...)
|
||||
|
||||
@@ -489,6 +490,9 @@ class EditSession
|
||||
getTextInBufferRange: (range) ->
|
||||
@buffer.getTextInRange(range)
|
||||
|
||||
getCurrentParagraphBufferRange: ->
|
||||
@getCursor().getCurrentParagraphBufferRange()
|
||||
|
||||
moveCursorUp: (lineCount) ->
|
||||
@moveCursors (cursor) -> cursor.moveUp(lineCount)
|
||||
|
||||
|
||||
@@ -206,6 +206,7 @@ class Editor extends View
|
||||
getCursorScreenRow: -> @activeEditSession.getCursorScreenRow()
|
||||
setCursorBufferPosition: (position, options) -> @activeEditSession.setCursorBufferPosition(position, options)
|
||||
getCursorBufferPosition: -> @activeEditSession.getCursorBufferPosition()
|
||||
getCurrentParagraphBufferRange: -> @activeEditSession.getCurrentParagraphBufferRange()
|
||||
|
||||
getSelection: (index) -> @activeEditSession.getSelection(index)
|
||||
getSelections: -> @activeEditSession.getSelections()
|
||||
|
||||
Reference in New Issue
Block a user