Upgrade telepath

This commit is contained in:
Nathan Sobo 2013-06-28 04:22:22 -06:00
parent 8561bb34a8
commit 5a9e45f9d8
7 changed files with 25 additions and 27 deletions

View File

@ -270,7 +270,7 @@ window.atom =
console.warn "Error parsing window state: #{windowStatePath}", error.stack, error
windowState ?= {}
telepath.Document.fromObject(telepath.createSite(1), windowState)
telepath.Document.create(windowState, site: telepath.createSite(1))
saveWindowState: ->
windowStateJson = JSON.stringify(@getWindowState().toObject())

View File

@ -45,7 +45,7 @@ class EditSession
cursorScreenPosition = @state.getObject('cursorScreenPosition')
else
{@buffer, tabLength, softTabs, @softWrap} = optionsOrState
@state = telepath.Document.fromObject
@state = telepath.Document.create
deserializer: 'EditSession'
version: @constructor.version
scrollTop: 0
@ -75,12 +75,12 @@ class EditSession
@displayBuffer.on 'grammar-changed', => @handleGrammarChange()
@state.observe ({key, value, site}) =>
@state.observe ({key, newValue}) =>
switch key
when 'scrollTop'
@trigger 'scroll-top-changed', value
@trigger 'scroll-top-changed', newValue
when 'scrollLeft'
@trigger 'scroll-left-changed', value
@trigger 'scroll-left-changed', newValue
getViewClass: ->
require 'editor'

View File

@ -15,16 +15,15 @@ class PaneAxis extends View
@state = args[0]
@state.get('children').each (child, index) => @addChild(deserialize(child), index, updateState: false)
else
@state = telepath.Document.fromObject(deserializer: @className(), children: [])
@state = telepath.Document.create(deserializer: @className(), children: [])
@addChild(child) for child in args
@state.get('children').observe ({index, value, type, site}) =>
@state.get('children').observe ({index, inserted, removed, site}) =>
return if site is @state.site.id
switch type
when 'insert'
@addChild(deserialize(value), index, updateState: false)
when 'remove'
@removeChild(@children(":eq(#{index})").view(), updateState: false)
for childState in removed
@removeChild(@children(":eq(#{index})").view(), updateState: false)
for childState, i in inserted
@addChild(deserialize(childState), index + i, updateState: false)
addChild: (child, index=@children().length, options={}) ->
@insertAt(index, child)

View File

@ -22,12 +22,12 @@ class PaneContainer extends View
if @state?
@setRoot(deserialize(@state.get('root')), updateState: false)
else
@state = telepath.Document.fromObject(deserializer: 'PaneContainer')
@state = telepath.Document.create(deserializer: 'PaneContainer')
@state.observe ({key, value, type, site}) =>
@state.observe ({key, newValue, site}) =>
return if site is @state.site.id
if key is 'root' and type is 'set'
@setRoot(deserialize(value), updateState: false)
if key is 'root'
@setRoot(deserialize(newValue), updateState: false)
@destroyedItemStates = []

View File

@ -29,21 +29,20 @@ class Pane extends View
@items = @state.get('items').map (item) -> deserialize(item)
else
@items = args
@state = telepath.Document.fromObject
@state = telepath.Document.create
deserializer: 'Pane'
items: @items.map (item) -> item.getState?() ? item.serialize()
@state.get('items').observe ({index, value, type, site}) =>
@state.get('items').observe ({index, removed, inserted, site}) =>
return if site is @state.site.id
switch type
when 'insert'
@addItem(deserialize(value), index, updateState: false)
when 'remove'
@removeItemAtIndex(index, updateState: false)
for itemState in removed
@removeItemAtIndex(index, updateState: false)
for itemState, i in inserted
@addItem(deserialize(itemState), index + i, updateState: false)
@state.observe ({key, value, site}) =>
@state.observe ({key, newValue, site}) =>
return if site is @state.site.id
@showItemForUri(value) if key is 'activeItemUri'
@showItemForUri(newValue) if key is 'activeItemUri'
@viewsByClassName = {}
if activeItemUri = @state.get('activeItemUri')

View File

@ -41,7 +41,7 @@ class RootView extends View
if state instanceof telepath.Document
@state = state
else
@state = telepath.Document.fromObject(_.extend(version: RootView.version, deserializer: 'RootView', panes: @panes.serialize(), state))
@state = telepath.Document.create(_.extend({version: RootView.version, deserializer: 'RootView', panes: @panes.serialize()}, state))
@on 'focus', (e) => @handleFocus(e)
@subscribe $(window), 'focus', (e) =>

2
vendor/telepath vendored

@ -1 +1 @@
Subproject commit 87d078f948a728b1e395fc80f37adda522461f87
Subproject commit 3b465ef7e08c188621e3a30817650fbea38d3656