From cd310dbe58b8e45e0b4f954df13b701b9439949e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 26 Feb 2015 14:50:59 -0700 Subject: [PATCH] =?UTF-8?q?Rename=20=E2=80=98blinkCursorsOff=E2=80=99=20to?= =?UTF-8?q?=20=E2=80=98cursorsVisible=E2=80=99=20in=20presenter=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/text-editor-presenter-spec.coffee | 26 +++++++++++++------------- src/cursors-component.coffee | 10 +++++----- src/text-editor-presenter.coffee | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 163521c32..0d526b5f2 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -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) -> diff --git a/src/cursors-component.coffee b/src/cursors-component.coffee index e11019d6c..ae844bfe0 100644 --- a/src/cursors-component.coffee +++ b/src/cursors-component.coffee @@ -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 diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 955b63cc4..20f575407 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -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()