mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Add and use Editor::observeSelections() and ::observeCursors()
This commit is contained in:
@@ -345,8 +345,8 @@ EditorComponent = React.createClass
|
||||
observeEditor: ->
|
||||
{editor} = @props
|
||||
@subscribe editor.onDidChangeScreenLines(@onScreenLinesChanged)
|
||||
@subscribe editor.onDidAddCursor(@onCursorAdded)
|
||||
@subscribe editor.onDidAddSelection(@onSelectionAdded)
|
||||
@subscribe editor.observeCursors(@onCursorAdded)
|
||||
@subscribe editor.observeSelections(@onSelectionAdded)
|
||||
@subscribe editor.observeDecorations(@onDecorationAdded)
|
||||
@subscribe editor.onDidRemoveDecoration(@onDecorationRemoved)
|
||||
@subscribe editor.onDidChangeCharacterWidths(@onCharacterWidthsChanged)
|
||||
|
||||
@@ -239,6 +239,15 @@ class Editor extends Model
|
||||
onDidInsertText: (callback) ->
|
||||
@emitter.on 'did-insert-text', callback
|
||||
|
||||
# Extended: Calls your `callback` when a {Cursor} is added to the editor.
|
||||
# Immediately calls your callback for each existing cursor.
|
||||
#
|
||||
# * `callback` {Function}
|
||||
# * `selection` {Selection} that was added
|
||||
observeCursors: (callback) ->
|
||||
callback(cursor) for cursor in @getCursors()
|
||||
@onDidAddCursor(callback)
|
||||
|
||||
# Extended: Calls your `callback` when a {Cursor} is added to the editor.
|
||||
#
|
||||
# * `callback` {Function}
|
||||
@@ -266,6 +275,15 @@ class Editor extends Model
|
||||
onDidChangeCursorPosition: (callback) ->
|
||||
@emitter.on 'did-change-cursor-position', callback
|
||||
|
||||
# Extended: Calls your `callback` when a {Selection} is added to the editor.
|
||||
# Immediately calls your callback for each existing selection.
|
||||
#
|
||||
# * `callback` {Function}
|
||||
# * `selection` {Selection} that was added
|
||||
observeSelections: (callback) ->
|
||||
callback(selection) for selection in @getSelections()
|
||||
@onDidAddSelection(callback)
|
||||
|
||||
# Extended: Calls your `callback` when a {Selection} is added to the editor.
|
||||
#
|
||||
# * `callback` {Function}
|
||||
|
||||
Reference in New Issue
Block a user