mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Add site global used to create all telepath documents
This commit is contained in:
parent
0370eb9236
commit
501a6b7d11
@ -275,8 +275,7 @@ window.atom =
|
||||
console.warn "Error parsing window state: #{windowStatePath}", error.stack, error
|
||||
|
||||
windowState ?= {}
|
||||
site = telepath.createSite(1)
|
||||
telepath.Document.deserialize(windowState, {site}) ? telepath.Document.create({}, {site})
|
||||
site.deserializeDocument(windowState) ? site.createDocument({})
|
||||
|
||||
saveWindowState: ->
|
||||
windowStateJson = JSON.stringify(@getWindowState().serialize())
|
||||
|
@ -36,7 +36,7 @@ class DisplayBuffer
|
||||
{@buffer, softWrapColumn} = optionsOrState
|
||||
@id = guid.create().toString()
|
||||
@tokenizedBuffer = new TokenizedBuffer(optionsOrState)
|
||||
@state = telepath.create
|
||||
@state = site.createDocument
|
||||
deserializer: @constructor.name
|
||||
id: @id
|
||||
tokenizedBuffer: @tokenizedBuffer.getState()
|
||||
|
@ -52,7 +52,7 @@ class EditSession
|
||||
{buffer, displayBuffer, tabLength, softTabs, softWrap, suppressCursorCreation} = optionsOrState
|
||||
@id = guid.create().toString()
|
||||
displayBuffer ?= new DisplayBuffer({buffer, tabLength})
|
||||
@state = telepath.Document.create
|
||||
@state = site.createDocument
|
||||
deserializer: 'EditSession'
|
||||
version: @constructor.version
|
||||
id: @id
|
||||
|
@ -15,7 +15,7 @@ class PaneAxis extends View
|
||||
@state = args[0]
|
||||
@state.get('children').each (child, index) => @addChild(deserialize(child), index, updateState: false)
|
||||
else
|
||||
@state = telepath.create(deserializer: @className(), children: [])
|
||||
@state = site.createDocument(deserializer: @className(), children: [])
|
||||
@addChild(child) for child in args
|
||||
|
||||
@state.get('children').on 'changed', ({index, inserted, removed, site}) =>
|
||||
|
@ -23,7 +23,7 @@ class PaneContainer extends View
|
||||
@state = state
|
||||
@setRoot(deserialize(@state.get('root')))
|
||||
else
|
||||
@state = telepath.create(deserializer: 'PaneContainer')
|
||||
@state = site.createDocument(deserializer: 'PaneContainer')
|
||||
|
||||
@state.on 'changed', ({key, newValue, site}) =>
|
||||
return if site is @state.site.id
|
||||
|
@ -32,7 +32,7 @@ class Pane extends View
|
||||
@items = _.compact(@state.get('items').map (item) -> deserialize(item))
|
||||
else
|
||||
@items = args
|
||||
@state = telepath.Document.create
|
||||
@state = site.createDocument
|
||||
deserializer: 'Pane'
|
||||
items: @items.map (item) -> item.getState?() ? item.serialize()
|
||||
|
||||
|
@ -69,7 +69,7 @@ class Project
|
||||
if buffer = deserialize(bufferState, project: this)
|
||||
@addBuffer(buffer, updateState: false)
|
||||
else
|
||||
@state = telepath.Document.create(deserializer: @constructor.name, version: @constructor.version, buffers: [])
|
||||
@state = site.createDocument(deserializer: @constructor.name, version: @constructor.version, buffers: [])
|
||||
@setPath(pathOrState)
|
||||
|
||||
@state.get('buffers').on 'changed', ({inserted, removed, index, site}) =>
|
||||
|
@ -45,7 +45,7 @@ class RootView extends View
|
||||
panes = deserialize(state.get('panes'))
|
||||
else
|
||||
panes = new PaneContainer
|
||||
@state = telepath.create
|
||||
@state = site.createDocument
|
||||
deserializer: @constructor.name
|
||||
version: @constructor.version
|
||||
panes: panes.getState()
|
||||
|
@ -43,9 +43,9 @@ class TextBuffer
|
||||
@id = @state.get('id')
|
||||
else
|
||||
{@project, filePath, initialText} = optionsOrState
|
||||
@text = telepath.Document.create(initialText, shareStrings: true) if initialText
|
||||
@text = site.createDocument(initialText, shareStrings: true) if initialText
|
||||
@id = guid.create().toString()
|
||||
@state = telepath.Document.create
|
||||
@state = site.createDocument
|
||||
id: @id
|
||||
deserializer: @constructor.name
|
||||
version: @constructor.version
|
||||
@ -55,10 +55,10 @@ class TextBuffer
|
||||
if @text
|
||||
@updateCachedDiskContents()
|
||||
else
|
||||
@text = telepath.Document.create('', shareStrings: true)
|
||||
@text = site.createDocument('', shareStrings: true)
|
||||
@reload() if fsUtils.exists(filePath)
|
||||
else
|
||||
@text ?= telepath.Document.create('', shareStrings: true)
|
||||
@text ?= site.createDocument('', shareStrings: true)
|
||||
|
||||
@state.set('text', @text)
|
||||
@text.on 'changed', @handleTextChange
|
||||
|
@ -31,7 +31,7 @@ class TokenizedBuffer
|
||||
@buffer = project.bufferForId(optionsOrState.get('bufferId'))
|
||||
else
|
||||
{ @buffer, tabLength } = optionsOrState
|
||||
@state = telepath.create
|
||||
@state = site.createDocument
|
||||
deserializer: @constructor.name
|
||||
bufferId: @buffer.id
|
||||
tabLength: tabLength ? 2
|
||||
|
@ -20,6 +20,7 @@ windowEventHandler = null
|
||||
|
||||
# This method is called in any window needing a general environment, including specs
|
||||
window.setUpEnvironment = (windowMode) ->
|
||||
window.site = new telepath.Site(1)
|
||||
atom.windowMode = windowMode
|
||||
window.resourcePath = remote.getCurrentWindow().loadSettings.resourcePath
|
||||
|
||||
|
@ -31,8 +31,8 @@ class GuestSession
|
||||
@createTelepathDocument(data, connection)
|
||||
|
||||
createTelepathDocument: (data, connection) ->
|
||||
doc = telepath.Document.deserialize(data.doc, site: telepath.createSite(@getId()))
|
||||
|
||||
window.site = new telepath.Site(@getId())
|
||||
doc = window.site.deserializeDocument(data.doc)
|
||||
|
||||
servers = null
|
||||
mediaConnection = new webkitRTCPeerConnection(servers)
|
||||
|
@ -35,7 +35,7 @@ class HostSession
|
||||
navigator.webkitGetUserMedia constraints, success, console.error
|
||||
|
||||
@peer = createPeer()
|
||||
@doc = telepath.Document.create({}, site: telepath.createSite(@getId()))
|
||||
@doc = site.createDocument({})
|
||||
@doc.set('windowState', atom.windowState)
|
||||
patrick.snapshot project.getPath(), (error, repoSnapshot) =>
|
||||
if error?
|
||||
|
2
vendor/telepath
vendored
2
vendor/telepath
vendored
@ -1 +1 @@
|
||||
Subproject commit c1b07c50444a3e5f617ae45699b2140db74b3537
|
||||
Subproject commit 8ce1bbfaa3a65650dad5e750bd465b9f96a2f43e
|
Loading…
Reference in New Issue
Block a user