mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-12 22:50:54 +03:00
Upgrade telepath
This commit is contained in:
parent
8561bb34a8
commit
5a9e45f9d8
@ -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())
|
||||
|
@ -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'
|
||||
|
@ -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)
|
||||
|
@ -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 = []
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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
2
vendor/telepath
vendored
@ -1 +1 @@
|
||||
Subproject commit 87d078f948a728b1e395fc80f37adda522461f87
|
||||
Subproject commit 3b465ef7e08c188621e3a30817650fbea38d3656
|
Loading…
Reference in New Issue
Block a user