mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Rename ‘blinkCursorsOff’ to ‘cursorsVisible’ in presenter state
This commit is contained in:
@@ -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) ->
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user