From f4f3002e6dbcc317b17eb85958c2ad15e1cddc9f Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 2 Jan 2013 13:37:25 -0700 Subject: [PATCH] Rename `Cursor` and `CursorView` events to passive-voice scheme Any events emitted from DOM nodes should be prefixed with an identifier for the node that emits them. This eliminates the possibility of ambiguity when the events bubble up the DOM away from their emitter. --- src/app/cursor-view.coffee | 6 +++--- src/app/cursor.coffee | 4 ++-- src/app/gutter.coffee | 2 +- src/app/selection.coffee | 2 +- src/packages/status-bar/src/status-bar.coffee | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/cursor-view.coffee b/src/app/cursor-view.coffee index b4ad022d3..402d74748 100644 --- a/src/app/cursor-view.coffee +++ b/src/app/cursor-view.coffee @@ -23,11 +23,11 @@ class CursorView extends View @shouldPauseBlinking = true @editor.requestDisplayUpdate() - @cursor.on 'change-visibility.cursor-view', (visible) => + @cursor.on 'visibility-changed.cursor-view', (visible) => @needsUpdate = true @editor.requestDisplayUpdate() - @cursor.on 'destroy.cursor-view', => + @cursor.on 'destroyed.cursor-view', => @needsRemoval = true @editor.requestDisplayUpdate() @@ -43,7 +43,7 @@ class CursorView extends View unless _.isEqual(@lastPixelPosition, pixelPosition) changedPosition = true @css(pixelPosition) - @trigger 'cursor-move' + @trigger 'cursor:moved' if @shouldPauseBlinking @resetBlinking() diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index 49f4631b9..2a0a9b60c 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -27,7 +27,7 @@ class Cursor destroy: -> @anchor.destroy() @editSession.removeCursor(this) - @trigger 'destroy' + @trigger 'destroyed' setScreenPosition: (screenPosition, options) -> @goalColumn = null @@ -52,7 +52,7 @@ class Cursor if @visible != visible @visible = visible @needsAutoscroll = @visible and @isLastCursor() - @trigger 'change-visibility', @visible + @trigger 'visibility-changed', @visible isVisible: -> @visible diff --git a/src/app/gutter.coffee b/src/app/gutter.coffee index 19e63708b..b789a9781 100644 --- a/src/app/gutter.coffee +++ b/src/app/gutter.coffee @@ -21,7 +21,7 @@ class Gutter extends View editor = @editor() highlightLines = => @highlightLines() - editor.on 'cursor-move', highlightLines + editor.on 'cursor:moved', highlightLines editor.on 'selection-change', highlightLines @on 'click', '.line-number', (e) => row = parseInt($(e.target).text()) - 1 diff --git a/src/app/selection.coffee b/src/app/selection.coffee index 06c48790e..45538cc61 100644 --- a/src/app/selection.coffee +++ b/src/app/selection.coffee @@ -15,7 +15,7 @@ class Selection @cursor.on 'moved.selection', ({bufferChange}) => @screenRangeChanged() unless bufferChange - @cursor.on 'destroy.selection', => + @cursor.on 'destroyed.selection', => @cursor = null @destroy() diff --git a/src/packages/status-bar/src/status-bar.coffee b/src/packages/status-bar/src/status-bar.coffee index 3a378f1ab..68256f1f6 100644 --- a/src/packages/status-bar/src/status-bar.coffee +++ b/src/packages/status-bar/src/status-bar.coffee @@ -36,7 +36,7 @@ class StatusBar extends View @updatePathText() @updateCursorPositionText() - @subscribe @editor, 'cursor-move', => @updateCursorPositionText() + @subscribe @editor, 'cursor:moved', => @updateCursorPositionText() @subscribe $(window), 'focus', => @updateStatusBar() @subscribeToBuffer()