Rename ‘blinkCursorsOff’ to ‘cursorsVisible’ in presenter state

This commit is contained in:
Nathan Sobo
2015-02-26 14:50:59 -07:00
parent ddcb874f6b
commit cd310dbe58
3 changed files with 21 additions and 21 deletions

View File

@@ -1135,49 +1135,49 @@ describe "TextEditorPresenter", ->
presenter = buildPresenter(explicitHeight: 20, scrollTop: 0)
expect(stateForCursor(presenter, 0).width).toBe 10
describe ".blinkCursorsOff", ->
describe ".cursorsVisible", ->
it "alternates between true and false twice per ::cursorBlinkPeriod", ->
cursorBlinkPeriod = 100
cursorBlinkResumeDelay = 200
presenter = buildPresenter({cursorBlinkPeriod, cursorBlinkResumeDelay})
expect(presenter.state.content.blinkCursorsOff).toBe false
expect(presenter.state.content.cursorsVisible).toBe true
expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2)
expect(presenter.state.content.blinkCursorsOff).toBe true
expect(presenter.state.content.cursorsVisible).toBe false
expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2)
expect(presenter.state.content.blinkCursorsOff).toBe false
expect(presenter.state.content.cursorsVisible).toBe true
expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2)
expect(presenter.state.content.blinkCursorsOff).toBe true
expect(presenter.state.content.cursorsVisible).toBe false
it "stops alternating for ::cursorBlinkResumeDelay when a cursor moves or a cursor is added", ->
cursorBlinkPeriod = 100
cursorBlinkResumeDelay = 200
presenter = buildPresenter({cursorBlinkPeriod, cursorBlinkResumeDelay})
expect(presenter.state.content.blinkCursorsOff).toBe false
expect(presenter.state.content.cursorsVisible).toBe true
expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2)
expect(presenter.state.content.blinkCursorsOff).toBe true
expect(presenter.state.content.cursorsVisible).toBe false
expectStateUpdate presenter, -> editor.moveRight()
expect(presenter.state.content.blinkCursorsOff).toBe false
expect(presenter.state.content.cursorsVisible).toBe true
expectStateUpdate presenter, ->
advanceClock(cursorBlinkResumeDelay)
advanceClock(cursorBlinkPeriod / 2)
expect(presenter.state.content.blinkCursorsOff).toBe true
expect(presenter.state.content.cursorsVisible).toBe false
expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2)
expect(presenter.state.content.blinkCursorsOff).toBe false
expect(presenter.state.content.cursorsVisible).toBe true
expectStateUpdate presenter, -> advanceClock(cursorBlinkPeriod / 2)
expect(presenter.state.content.blinkCursorsOff).toBe true
expect(presenter.state.content.cursorsVisible).toBe false
expectStateUpdate presenter, -> editor.addCursorAtBufferPosition([1, 0])
expect(presenter.state.content.blinkCursorsOff).toBe false
expect(presenter.state.content.cursorsVisible).toBe true
expectStateUpdate presenter, ->
advanceClock(cursorBlinkResumeDelay)
advanceClock(cursorBlinkPeriod / 2)
expect(presenter.state.content.blinkCursorsOff).toBe true
expect(presenter.state.content.cursorsVisible).toBe false
describe ".highlights", ->
stateForHighlight = (presenter, decoration) ->

View File

@@ -13,12 +13,12 @@ class CursorsComponent
@oldState ?= {cursors: {}}
# update blink class
if newState.blinkCursorsOff isnt @oldState.blinkCursorsOff
if newState.blinkCursorsOff
@domNode.classList.add 'blink-off'
else
if newState.cursorsVisible isnt @oldState.cursorsVisible
if newState.cursorsVisible
@domNode.classList.remove 'blink-off'
@oldState.blinkCursorsOff = newState.blinkCursorsOff
else
@domNode.classList.add 'blink-off'
@oldState.cursorsVisible = newState.cursorsVisible
# remove cursors
for id of @oldState.cursors

View File

@@ -113,7 +113,7 @@ class TextEditorPresenter
hiddenInput: {}
content:
scrollingVertically: false
blinkCursorsOff: false
cursorsVisible: true
lines: {}
highlights: {}
overlays: {}
@@ -983,11 +983,11 @@ class TextEditorPresenter
clearInterval(@toggleCursorBlinkHandle)
toggleCursorBlink: ->
@state.content.blinkCursorsOff = not @state.content.blinkCursorsOff
@state.content.cursorsVisible = not @state.content.cursorsVisible
@emitter.emit 'did-update-state'
pauseCursorBlinking: ->
@state.content.blinkCursorsOff = false
@state.content.cursorsVisible = true
@stopBlinkingCursors()
@startBlinkingCursorsAfterDelay ?= _.debounce(@startBlinkingCursors, @getCursorBlinkResumeDelay())
@startBlinkingCursorsAfterDelay()