mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Add TextEditorPresenter::state.content.backgroundColor
This commit is contained in:
@@ -153,6 +153,26 @@ describe "TextEditorPresenter", ->
|
||||
expectStateUpdate presenter, -> editor.setGrammar(atom.grammars.selectGrammar('.txt'))
|
||||
expect(presenter.state.content.indentGuidesVisible).toBe false
|
||||
|
||||
describe ".backgroundColor", ->
|
||||
it "is assigned to ::backgroundColor unless the editor is mini", ->
|
||||
presenter = new TextEditorPresenter(model: editor, backgroundColor: 'rgba(255, 0, 0, 0)')
|
||||
expect(presenter.state.content.backgroundColor).toBe 'rgba(255, 0, 0, 0)'
|
||||
editor.setMini(true)
|
||||
presenter = new TextEditorPresenter(model: editor, backgroundColor: 'rgba(255, 0, 0, 0)')
|
||||
expect(presenter.state.content.backgroundColor).toBeNull()
|
||||
|
||||
it "updates when ::backgroundColor changes", ->
|
||||
presenter = new TextEditorPresenter(model: editor, backgroundColor: 'rgba(255, 0, 0, 0)')
|
||||
expect(presenter.state.content.backgroundColor).toBe 'rgba(255, 0, 0, 0)'
|
||||
expectStateUpdate presenter, -> presenter.setBackgroundColor('rgba(0, 0, 255, 0)')
|
||||
expect(presenter.state.content.backgroundColor).toBe 'rgba(0, 0, 255, 0)'
|
||||
|
||||
it "updates when ::mini changes", ->
|
||||
presenter = new TextEditorPresenter(model: editor, backgroundColor: 'rgba(255, 0, 0, 0)')
|
||||
expect(presenter.state.content.backgroundColor).toBe 'rgba(255, 0, 0, 0)'
|
||||
expectStateUpdate presenter, -> editor.setMini(true)
|
||||
expect(presenter.state.content.backgroundColor).toBeNull()
|
||||
|
||||
describe ".lines", ->
|
||||
lineStateForScreenRow = (presenter, screenRow) ->
|
||||
presenter.state.content.lines[presenter.model.tokenizedLineForScreenRow(screenRow).id]
|
||||
|
||||
@@ -7,7 +7,7 @@ class TextEditorPresenter
|
||||
toggleCursorBlinkHandle: null
|
||||
startBlinkingCursorsAfterDelay: null
|
||||
|
||||
constructor: ({@model, @clientHeight, @clientWidth, @scrollTop, @scrollLeft, @lineHeight, @baseCharacterWidth, @lineOverdrawMargin, @cursorBlinkPeriod, @cursorBlinkResumeDelay}) ->
|
||||
constructor: ({@model, @clientHeight, @clientWidth, @scrollTop, @scrollLeft, @lineHeight, @baseCharacterWidth, @lineOverdrawMargin, @cursorBlinkPeriod, @cursorBlinkResumeDelay, @backgroundColor}) ->
|
||||
@disposables = new CompositeDisposable
|
||||
@emitter = new Emitter
|
||||
@charWidthsByScope = {}
|
||||
@@ -27,6 +27,7 @@ class TextEditorPresenter
|
||||
@disposables.add @model.onDidChangeSoftWrapped(@updateState.bind(this))
|
||||
@disposables.add @model.onDidChangeGrammar(@updateContentState.bind(this))
|
||||
@disposables.add @model.onDidChangeMini =>
|
||||
@updateContentState()
|
||||
@updateLinesState()
|
||||
@updateLineNumbersState()
|
||||
@disposables.add @model.onDidAddDecoration(@didAddDecoration.bind(this))
|
||||
@@ -68,6 +69,7 @@ class TextEditorPresenter
|
||||
@state.content.scrollWidth = @computeScrollWidth()
|
||||
@state.content.scrollLeft = @getScrollLeft()
|
||||
@state.content.indentGuidesVisible = atom.config.get('editor.showIndentGuide', scope: @model.getRootScopeDescriptor())
|
||||
@state.content.backgroundColor = if @model.isMini() then null else @getBackgroundColor()
|
||||
@emitter.emit 'did-update-state'
|
||||
|
||||
updateLinesState: ->
|
||||
@@ -348,6 +350,11 @@ class TextEditorPresenter
|
||||
|
||||
getClientWidth: -> @clientWidth
|
||||
|
||||
setBackgroundColor: (@backgroundColor) ->
|
||||
@updateContentState()
|
||||
|
||||
getBackgroundColor: -> @backgroundColor
|
||||
|
||||
setLineHeight: (@lineHeight) ->
|
||||
@updateVerticalScrollState()
|
||||
@updateLinesState()
|
||||
|
||||
Reference in New Issue
Block a user