mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Update classes for emissary API
This commit is contained in:
@@ -5,7 +5,7 @@ ConfigObserver = require './config-observer'
|
||||
{Subscriber} = require 'emissary'
|
||||
|
||||
_.extend spacePen.View.prototype, ConfigObserver
|
||||
_.extend spacePen.View.prototype, Subscriber
|
||||
Subscriber.includeInto(spacePen.View)
|
||||
|
||||
originalCleanData = jQuery.cleanData
|
||||
jQuery.cleanData = (elements) ->
|
||||
|
||||
@@ -38,7 +38,7 @@ class Syntax
|
||||
@grammarsByScopeName[grammar.scopeName] = grammar
|
||||
@injectionGrammars.push(grammar) if grammar.injectionSelector?
|
||||
@grammarUpdated(grammar.scopeName)
|
||||
@trigger 'grammar-added', grammar
|
||||
@emit 'grammar-added', grammar
|
||||
|
||||
removeGrammar: (grammar) ->
|
||||
_.remove(@grammars, grammar)
|
||||
@@ -48,7 +48,7 @@ class Syntax
|
||||
|
||||
grammarUpdated: (scopeName) ->
|
||||
for grammar in @grammars when grammar.scopeName isnt scopeName
|
||||
@trigger 'grammar-updated', grammar if grammar.grammarUpdated(scopeName)
|
||||
@emit 'grammar-updated', grammar if grammar.grammarUpdated(scopeName)
|
||||
|
||||
setGrammarOverrideForPath: (path, scopeName) ->
|
||||
@grammarOverridesByPath[path] = scopeName
|
||||
|
||||
@@ -26,7 +26,7 @@ class Task
|
||||
# The Array of arguments to pass to the exported function.
|
||||
@once: (taskPath, args...) ->
|
||||
task = new Task(taskPath)
|
||||
task.one 'task:completed', -> task.terminate()
|
||||
task.once 'task:completed', -> task.terminate()
|
||||
task.start(args...)
|
||||
task
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ class TextBuffer
|
||||
@loadFromDisk = not initialText
|
||||
|
||||
@subscribe @text, 'changed', @handleTextChange
|
||||
@subscribe @text, 'marker-created', (marker) => @trigger 'marker-created', marker
|
||||
@subscribe @text, 'markers-updated', => @trigger 'markers-updated'
|
||||
@subscribe @text, 'marker-created', (marker) => @emit 'marker-created', marker
|
||||
@subscribe @text, 'markers-updated', => @emit 'markers-updated'
|
||||
|
||||
@setPath(@project.resolve(filePath)) if @project
|
||||
|
||||
@@ -82,7 +82,7 @@ class TextBuffer
|
||||
@cachedMemoryContents = null
|
||||
@conflict = false if @conflict and !@isModified()
|
||||
bufferChangeEvent = _.pick(event, 'oldRange', 'newRange', 'oldText', 'newText')
|
||||
@trigger 'changed', bufferChangeEvent
|
||||
@emit 'changed', bufferChangeEvent
|
||||
@scheduleModifiedEvents()
|
||||
|
||||
destroy: ->
|
||||
@@ -91,7 +91,7 @@ class TextBuffer
|
||||
@unsubscribe()
|
||||
@destroyed = true
|
||||
@project?.removeBuffer(this)
|
||||
@trigger 'destroyed'
|
||||
@emit 'destroyed'
|
||||
|
||||
isRetained: -> @refcount > 0
|
||||
|
||||
@@ -118,17 +118,17 @@ class TextBuffer
|
||||
@conflict = true if @isModified()
|
||||
@updateCachedDiskContentsAsync().done =>
|
||||
if @conflict
|
||||
@trigger "contents-conflicted"
|
||||
@emit "contents-conflicted"
|
||||
else
|
||||
@reload()
|
||||
|
||||
@file.on "removed", =>
|
||||
@updateCachedDiskContentsAsync().done =>
|
||||
@triggerModifiedStatusChanged(@isModified())
|
||||
@emitModifiedStatusChanged(@isModified())
|
||||
|
||||
@file.on "moved", =>
|
||||
@state.set('relativePath', @project.relativize(@getPath()))
|
||||
@trigger "path-changed", this
|
||||
@emit "path-changed", this
|
||||
|
||||
### Public ###
|
||||
|
||||
@@ -143,10 +143,10 @@ class TextBuffer
|
||||
#
|
||||
# Sets the buffer's content to the cached disk contents
|
||||
reload: ->
|
||||
@trigger 'will-reload'
|
||||
@emit 'will-reload'
|
||||
@setText(@cachedDiskContents)
|
||||
@triggerModifiedStatusChanged(false)
|
||||
@trigger 'reloaded'
|
||||
@emitModifiedStatusChanged(false)
|
||||
@emit 'reloaded'
|
||||
|
||||
# Private: Rereads the contents of the file, and stores them in the cache.
|
||||
updateCachedDiskContents: ->
|
||||
@@ -190,7 +190,7 @@ class TextBuffer
|
||||
@file = null
|
||||
|
||||
@state.set('relativePath', @project.relativize(path))
|
||||
@trigger "path-changed", this
|
||||
@emit "path-changed", this
|
||||
|
||||
# Retrieves the current buffer's file extension.
|
||||
#
|
||||
@@ -398,12 +398,12 @@ class TextBuffer
|
||||
saveAs: (path) ->
|
||||
unless path then throw new Error("Can't save buffer with no file path")
|
||||
|
||||
@trigger 'will-be-saved'
|
||||
@emit 'will-be-saved'
|
||||
@setPath(path)
|
||||
@cachedDiskContents = @getText()
|
||||
@file.write(@getText())
|
||||
@triggerModifiedStatusChanged(false)
|
||||
@trigger 'saved'
|
||||
@emitModifiedStatusChanged(false)
|
||||
@emit 'saved'
|
||||
|
||||
# Identifies if the buffer was modified.
|
||||
#
|
||||
@@ -652,14 +652,14 @@ class TextBuffer
|
||||
stoppedChangingCallback = =>
|
||||
@stoppedChangingTimeout = null
|
||||
modifiedStatus = @isModified()
|
||||
@trigger 'contents-modified', modifiedStatus
|
||||
@triggerModifiedStatusChanged(modifiedStatus)
|
||||
@emit 'contents-modified', modifiedStatus
|
||||
@emitModifiedStatusChanged(modifiedStatus)
|
||||
@stoppedChangingTimeout = setTimeout(stoppedChangingCallback, @stoppedChangingDelay)
|
||||
|
||||
triggerModifiedStatusChanged: (modifiedStatus) ->
|
||||
emitModifiedStatusChanged: (modifiedStatus) ->
|
||||
return if modifiedStatus is @previousModifiedStatus
|
||||
@previousModifiedStatus = modifiedStatus
|
||||
@trigger 'modified-status-changed', modifiedStatus
|
||||
@emit 'modified-status-changed', modifiedStatus
|
||||
|
||||
logLines: (start=0, end=@getLastRow())->
|
||||
for row in [start..end]
|
||||
|
||||
@@ -128,7 +128,7 @@ class ThemeManager
|
||||
@activateTheme(themeName) for themeName in themeNames
|
||||
@loadUserStylesheet()
|
||||
@reloadBaseStylesheets()
|
||||
@trigger('reloaded')
|
||||
@emit('reloaded')
|
||||
|
||||
# Private:
|
||||
loadTheme: (name, options) ->
|
||||
@@ -167,7 +167,7 @@ class ThemeManager
|
||||
theme = @loadTheme(name)
|
||||
theme.activate()
|
||||
@activeThemes.push(theme)
|
||||
@trigger('theme-activated', theme)
|
||||
@emit('theme-activated', theme)
|
||||
catch error
|
||||
console.warn("Failed to load theme #{name}", error.stack ? error)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user