mirror of
https://github.com/atom/atom.git
synced 2026-02-07 05:05:02 -05:00
Add fold-all event to editor
This commit is contained in:
@@ -120,6 +120,7 @@ class Editor extends View
|
||||
'undo': @undo
|
||||
'redo': @redo
|
||||
'toggle-soft-wrap': @toggleSoftWrap
|
||||
'fold-all': @foldAll
|
||||
'toggle-fold': @toggleFold
|
||||
'fold-selection': @foldSelection
|
||||
'unfold': => @unfoldRow(@getCursorBufferPosition().row)
|
||||
@@ -805,6 +806,9 @@ class Editor extends View
|
||||
for cursor in @getCursors()
|
||||
do (cursor) -> cursor.resetCursorAnimation()
|
||||
|
||||
foldAll: ->
|
||||
@renderer.foldAll()
|
||||
|
||||
toggleFold: ->
|
||||
@renderer.toggleFoldAtBufferRow(@getCursorBufferPosition().row)
|
||||
|
||||
|
||||
@@ -53,6 +53,13 @@ class Renderer
|
||||
bufferRowsForScreenRows: (startRow, endRow) ->
|
||||
@lineMap.bufferRowsForScreenRows(startRow, endRow)
|
||||
|
||||
foldAll: ->
|
||||
for currentRow in [@buffer.getLastRow()..0]
|
||||
[startRow, endRow] = @foldSuggester.rowRangeForFoldAtBufferRow(currentRow) ? []
|
||||
continue unless startRow?
|
||||
|
||||
@createFold(startRow, endRow)
|
||||
|
||||
toggleFoldAtBufferRow: (bufferRow) ->
|
||||
for currentRow in [bufferRow..0]
|
||||
[startRow, endRow] = @foldSuggester.rowRangeForFoldAtBufferRow(currentRow) ? []
|
||||
@@ -65,7 +72,12 @@ class Renderer
|
||||
|
||||
break
|
||||
|
||||
foldFor: (startRow, endRow) ->
|
||||
_.find @activeFolds[startRow] ? [], (fold) ->
|
||||
fold.startRow == startRow and fold.endRow == endRow
|
||||
|
||||
createFold: (startRow, endRow) ->
|
||||
return fold if fold = @foldFor(startRow, endRow)
|
||||
fold = new Fold(this, startRow, endRow)
|
||||
@registerFold(fold)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user