mirror of
https://github.com/atom/atom.git
synced 2026-02-14 08:35:11 -05:00
Add "Continuous Reflow" mode
This commit is contained in:
@@ -217,6 +217,10 @@ module.exports =
|
||||
type: 'boolean'
|
||||
default: process.platform isnt 'darwin'
|
||||
description: 'Increase/decrease the editor font size when pressing the Ctrl key and scrolling the mouse up/down.'
|
||||
continuousReflow:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: 'Track down expensive layouts or style recalculations by continously reflowing the editor. (Has performance overhead)'
|
||||
|
||||
if process.platform in ['win32', 'linux']
|
||||
module.exports.core.properties.autoHideMenuBar =
|
||||
|
||||
@@ -62,6 +62,9 @@ class LineNumberGutterComponent extends TiledComponent
|
||||
|
||||
buildComponentForTile: (id) -> new LineNumbersTileComponent({id})
|
||||
|
||||
shouldRecreateAllTilesOnUpdate: ->
|
||||
@newState.continuousReflow
|
||||
|
||||
###
|
||||
Section: Private Methods
|
||||
###
|
||||
|
||||
@@ -32,7 +32,7 @@ class LinesComponent extends TiledComponent
|
||||
@domNode
|
||||
|
||||
shouldRecreateAllTilesOnUpdate: ->
|
||||
@oldState.indentGuidesVisible isnt @newState.indentGuidesVisible
|
||||
@oldState.indentGuidesVisible isnt @newState.indentGuidesVisible or @newState.continuousReflow
|
||||
|
||||
beforeUpdateSync: (state) ->
|
||||
if @newState.maxHeight isnt @oldState.maxHeight
|
||||
|
||||
@@ -11,6 +11,7 @@ class TextEditorPresenter
|
||||
mouseWheelScreenRow: null
|
||||
scopedCharacterWidthsChangeCount: 0
|
||||
overlayDimensions: {}
|
||||
minimumReflowInterval: 200
|
||||
|
||||
constructor: (params) ->
|
||||
{@model, @autoHeight, @explicitHeight, @contentFrameWidth, @scrollTop, @scrollLeft, @boundingClientRect, @windowWidth, @windowHeight, @gutterWidth} = params
|
||||
@@ -35,6 +36,7 @@ class TextEditorPresenter
|
||||
@observeConfig()
|
||||
@buildState()
|
||||
@startBlinkingCursors() if @focused
|
||||
@startReflowing() if @continuousReflow
|
||||
@updating = false
|
||||
|
||||
destroy: ->
|
||||
@@ -72,6 +74,7 @@ class TextEditorPresenter
|
||||
@updateStartRow()
|
||||
@updateEndRow()
|
||||
@updateCommonGutterState()
|
||||
@updateReflowState()
|
||||
|
||||
@updateFocusedState() if @shouldUpdateFocusedState
|
||||
@updateHeightState() if @shouldUpdateHeightState
|
||||
@@ -169,6 +172,7 @@ class TextEditorPresenter
|
||||
observeConfig: ->
|
||||
configParams = {scope: @model.getRootScopeDescriptor()}
|
||||
|
||||
@continuousReflow = atom.config.get('editor.continuousReflow', configParams)
|
||||
@scrollPastEnd = atom.config.get('editor.scrollPastEnd', configParams)
|
||||
@showLineNumbers = atom.config.get('editor.showLineNumbers', configParams)
|
||||
@showIndentGuide = atom.config.get('editor.showIndentGuide', configParams)
|
||||
@@ -199,6 +203,16 @@ class TextEditorPresenter
|
||||
|
||||
@emitDidUpdateState()
|
||||
|
||||
@configDisposables.add atom.config.onDidChange 'editor.continuousReflow', configParams, ({newValue}) =>
|
||||
@continuousReflow = newValue
|
||||
|
||||
if @continuousReflow
|
||||
@startReflowing()
|
||||
else
|
||||
@stopReflowing()
|
||||
|
||||
@emitDidUpdateState()
|
||||
|
||||
didChangeGrammar: ->
|
||||
@observeConfig()
|
||||
@shouldUpdateContentState = true
|
||||
@@ -254,6 +268,17 @@ class TextEditorPresenter
|
||||
|
||||
@resetTrackedUpdates()
|
||||
|
||||
updateReflowState: ->
|
||||
@state.content.continuousReflow = @continuousReflow
|
||||
@lineNumberGutter.continuousReflow = @continuousReflow
|
||||
|
||||
startReflowing: ->
|
||||
@reflowingInterval = setInterval(@emitDidUpdateState.bind(this), @minimumReflowInterval)
|
||||
|
||||
stopReflowing: ->
|
||||
clearInterval(@reflowingInterval)
|
||||
@reflowingInterval = null
|
||||
|
||||
updateFocusedState: ->
|
||||
@state.focused = @focused
|
||||
|
||||
|
||||
Reference in New Issue
Block a user