mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
Funnel cursor and selection updates through EditorComponent
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
React = require 'react'
|
||||
{div} = require 'reactionary'
|
||||
SubscriberMixin = require './subscriber-mixin'
|
||||
|
||||
module.exports =
|
||||
CursorComponent = React.createClass
|
||||
displayName: 'CursorComponent'
|
||||
mixins: [SubscriberMixin]
|
||||
|
||||
render: ->
|
||||
{top, left, height, width} = @props.cursor.getPixelRect()
|
||||
@@ -13,9 +11,3 @@ CursorComponent = React.createClass
|
||||
className += ' blink-off' if @props.blinkOff
|
||||
|
||||
div className: className, style: {top, left, height, width}
|
||||
|
||||
componentDidMount: ->
|
||||
@subscribe @props.cursor, 'moved', => @forceUpdate()
|
||||
|
||||
componentWillUnmount: ->
|
||||
@unsubscribe()
|
||||
|
||||
@@ -75,6 +75,7 @@ EditorCompont = React.createClass
|
||||
observeEditor: ->
|
||||
{editor} = @props
|
||||
@subscribe editor, 'screen-lines-changed', @onScreenLinesChanged
|
||||
@subscribe editor, 'selection-screen-range-changed', @requestUpdate
|
||||
@subscribe editor, 'selection-added', @onSelectionAdded
|
||||
@subscribe editor, 'selection-removed', @onSelectionAdded
|
||||
@subscribe editor.$scrollTop.changes, @requestUpdate
|
||||
|
||||
@@ -1246,6 +1246,9 @@ class Editor extends Model
|
||||
else
|
||||
false
|
||||
|
||||
selectionScreenRangeChanged: (selection) ->
|
||||
@emit 'selection-screen-range-changed', selection
|
||||
|
||||
# Public: Get current {Selection}s.
|
||||
#
|
||||
# Returns: An {Array} of {Selection}s.
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
React = require 'react'
|
||||
{div} = require 'reactionary'
|
||||
SubscriberMixin = require './subscriber-mixin'
|
||||
|
||||
module.exports =
|
||||
SelectionComponent = React.createClass
|
||||
displayName: 'SelectionComponent'
|
||||
mixins: [SubscriberMixin]
|
||||
|
||||
render: ->
|
||||
div className: 'selection',
|
||||
for regionRect, i in @props.selection.getRegionRects()
|
||||
div className: 'region', key: i, style: regionRect
|
||||
|
||||
componentDidMount: ->
|
||||
@subscribe @props.selection, 'screen-range-changed', => @forceUpdate()
|
||||
|
||||
componentWillUnmount: ->
|
||||
@unsubscribe()
|
||||
|
||||
@@ -613,3 +613,4 @@ class Selection extends Model
|
||||
screenRangeChanged: ->
|
||||
screenRange = @getScreenRange()
|
||||
@emit 'screen-range-changed', screenRange
|
||||
@editor.selectionScreenRangeChanged(this)
|
||||
|
||||
Reference in New Issue
Block a user