Merge branch 'master' into as-fix-delete-line

This commit is contained in:
Antonio Scandurra 2015-04-07 12:12:36 +02:00
commit 59a5dc42a8
43 changed files with 1297 additions and 1165 deletions

View File

@ -7,7 +7,7 @@
},
"dependencies": {
"async": "~0.2.9",
"donna": "1.0.7",
"donna": "1.0.10",
"formidable": "~1.0.14",
"fs-plus": "2.x",
"github-releases": "~0.2.0",

View File

@ -1,7 +1,7 @@
TextBuffer = require 'text-buffer'
{Point, Range} = TextBuffer
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
{deprecate} = require 'grim'
{includeDeprecatedAPIs, deprecate} = require 'grim'
module.exports =
BufferedNodeProcess: require '../src/buffered-node-process'
@ -21,109 +21,111 @@ unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE
module.exports.Task = require '../src/task'
module.exports.TextEditor = require '../src/text-editor'
{$, $$, $$$, View} = require '../src/space-pen-extensions'
if includeDeprecatedAPIs
{$, $$, $$$, View} = require '../src/space-pen-extensions'
Object.defineProperty module.exports, 'Workspace', get: ->
deprecate """
Requiring `Workspace` from `atom` is no longer supported.
If you need this, please open an issue on
https://github.com/atom/atom/issues/new
And let us know what you are using it for.
"""
require '../src/workspace'
Object.defineProperty module.exports, 'Workspace', get: ->
deprecate """
Requiring `Workspace` from `atom` is no longer supported.
If you need this, please open an issue on
https://github.com/atom/atom/issues/new
And let us know what you are using it for.
"""
require '../src/workspace'
Object.defineProperty module.exports, 'WorkspaceView', get: ->
deprecate """
Requiring `WorkspaceView` from `atom` is no longer supported.
Use `atom.views.getView(atom.workspace)` instead.
"""
require '../src/workspace-view'
Object.defineProperty module.exports, 'WorkspaceView', get: ->
deprecate """
Requiring `WorkspaceView` from `atom` is no longer supported.
Use `atom.views.getView(atom.workspace)` instead.
"""
require '../src/workspace-view'
Object.defineProperty module.exports, '$', get: ->
deprecate """
Requiring `$` from `atom` is no longer supported.
If you are using `space-pen`, please require `$` from `atom-space-pen-views`. Otherwise require `jquery` instead:
`{$} = require 'atom-space-pen-views'`
or
`$ = require 'jquery'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
Or add `"jquery": "^2"` to your package dependencies.
"""
$
Object.defineProperty module.exports, '$', get: ->
deprecate """
Requiring `$` from `atom` is no longer supported.
If you are using `space-pen`, please require `$` from `atom-space-pen-views`. Otherwise require `jquery` instead:
`{$} = require 'atom-space-pen-views'`
or
`$ = require 'jquery'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
Or add `"jquery": "^2"` to your package dependencies.
"""
$
Object.defineProperty module.exports, '$$', get: ->
deprecate """
Requiring `$$` from `atom` is no longer supported.
Please require `atom-space-pen-views` instead:
`{$$} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
$$
Object.defineProperty module.exports, '$$', get: ->
deprecate """
Requiring `$$` from `atom` is no longer supported.
Please require `atom-space-pen-views` instead:
`{$$} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
$$
Object.defineProperty module.exports, '$$$', get: ->
deprecate """
Requiring `$$$` from `atom` is no longer supported.
Please require `atom-space-pen-views` instead:
`{$$$} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
$$$
Object.defineProperty module.exports, '$$$', get: ->
deprecate """
Requiring `$$$` from `atom` is no longer supported.
Please require `atom-space-pen-views` instead:
`{$$$} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
$$$
Object.defineProperty module.exports, 'View', get: ->
deprecate """
Requiring `View` from `atom` is no longer supported.
Please require `atom-space-pen-views` instead:
`{View} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
View
Object.defineProperty module.exports, 'View', get: ->
deprecate """
Requiring `View` from `atom` is no longer supported.
Please require `atom-space-pen-views` instead:
`{View} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
View
Object.defineProperty module.exports, 'EditorView', get: ->
deprecate """
Requiring `EditorView` from `atom` is no longer supported.
Please require `TextEditorView` from `atom-space-pen-view` instead:
`{TextEditorView} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
require '../src/text-editor-view'
Object.defineProperty module.exports, 'EditorView', get: ->
deprecate """
Requiring `EditorView` from `atom` is no longer supported.
Please require `TextEditorView` from `atom-space-pen-view` instead:
`{TextEditorView} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
require '../src/text-editor-view'
Object.defineProperty module.exports, 'TextEditorView', get: ->
deprecate """
Requiring `TextEditorView` from `atom` is no longer supported.
Please require `TextEditorView` from `atom-space-pen-view` instead:
`{TextEditorView} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
require '../src/text-editor-view'
Object.defineProperty module.exports, 'TextEditorView', get: ->
deprecate """
Requiring `TextEditorView` from `atom` is no longer supported.
Please require `TextEditorView` from `atom-space-pen-view` instead:
`{TextEditorView} = require 'atom-space-pen-views'`
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
require '../src/text-editor-view'
Object.defineProperty module.exports, 'ScrollView', get: ->
deprecate """
Requiring `ScrollView` from `atom` is no longer supported.
Please require `ScrollView` from `atom-space-pen-view` instead:
`{ScrollView} = require 'atom-space-pen-views'`
Note that the API has changed slightly! Please read the docs at https://github.com/atom/atom-space-pen-views
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
require '../src/scroll-view'
Object.defineProperty module.exports, 'ScrollView', get: ->
deprecate """
Requiring `ScrollView` from `atom` is no longer supported.
Please require `ScrollView` from `atom-space-pen-view` instead:
`{ScrollView} = require 'atom-space-pen-views'`
Note that the API has changed slightly! Please read the docs at https://github.com/atom/atom-space-pen-views
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
require '../src/scroll-view'
Object.defineProperty module.exports, 'SelectListView', get: ->
deprecate """
Requiring `SelectListView` from `atom` is no longer supported.
Please require `SelectListView` from `atom-space-pen-view` instead:
`{SelectListView} = require 'atom-space-pen-views'`
Note that the API has changed slightly! Please read the docs at https://github.com/atom/atom-space-pen-views
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
require '../src/select-list-view'
Object.defineProperty module.exports, 'SelectListView', get: ->
deprecate """
Requiring `SelectListView` from `atom` is no longer supported.
Please require `SelectListView` from `atom-space-pen-view` instead:
`{SelectListView} = require 'atom-space-pen-views'`
Note that the API has changed slightly! Please read the docs at https://github.com/atom/atom-space-pen-views
Add `"atom-space-pen-views": "^2.0.3"` to your package dependencies.
"""
require '../src/select-list-view'
Object.defineProperty module.exports, 'React', get: ->
deprecate "Please require `react-atom-fork` instead: `React = require 'react-atom-fork'`. Add `\"react-atom-fork\": \"^0.11\"` to your package dependencies."
require 'react-atom-fork'
Object.defineProperty module.exports, 'React', get: ->
deprecate "Please require `react-atom-fork` instead: `React = require 'react-atom-fork'`. Add `\"react-atom-fork\": \"^0.11\"` to your package dependencies."
require 'react-atom-fork'
Object.defineProperty module.exports, 'Reactionary', get: ->
deprecate "Please require `reactionary-atom-fork` instead: `Reactionary = require 'reactionary-atom-fork'`. Add `\"reactionary-atom-fork\": \"^0.9\"` to your package dependencies."
require 'reactionary-atom-fork'
Object.defineProperty module.exports, 'Reactionary', get: ->
deprecate "Please require `reactionary-atom-fork` instead: `Reactionary = require 'reactionary-atom-fork'`. Add `\"reactionary-atom-fork\": \"^0.9\"` to your package dependencies."
require 'reactionary-atom-fork'
Object.defineProperty module.exports, 'Git', get: ->
deprecate "Please require `GitRepository` instead of `Git`: `{GitRepository} = require 'atom'`"
module.exports.GitRepository
if includeDeprecatedAPIs
Object.defineProperty module.exports, 'Git', get: ->
deprecate "Please require `GitRepository` instead of `Git`: `{GitRepository} = require 'atom'`"
module.exports.GitRepository

View File

@ -20,7 +20,7 @@
"atomShellVersion": "0.22.3",
"dependencies": {
"async": "0.2.6",
"atom-keymap": "^5",
"atom-keymap": "^5.1",
"atom-space-pen-views": "^2.0.4",
"babel-core": "^4.0.2",
"bootstrap": "git+https://github.com/atom/bootstrap.git#6af81906189f1747fd6c93479e3d998ebe041372",
@ -31,8 +31,8 @@
"color": "^0.7.3",
"delegato": "^1",
"emissary": "^1.3.3",
"event-kit": "^1.0.3",
"first-mate": "^3.0.1",
"event-kit": "^1.1",
"first-mate": "^3.1",
"fs-plus": "^2.6",
"fstream": "0.1.24",
"fuzzaldrin": "^2.1",
@ -47,7 +47,7 @@
"nslog": "^2.0.0",
"oniguruma": "^4.1",
"optimist": "0.4.0",
"pathwatcher": "^4.3.1",
"pathwatcher": "^4.4",
"property-accessors": "^1.1.3",
"q": "^1.1.2",
"random-words": "0.0.1",
@ -55,7 +55,7 @@
"reactionary-atom-fork": "^1.0.0",
"runas": "2.0.0",
"scandal": "2.0.0",
"scoped-property-store": "^0.16.2",
"scoped-property-store": "^0.17.0",
"scrollbar-style": "^2.0.0",
"season": "^5.1.4",
"semver": "~4.2",
@ -64,7 +64,7 @@
"space-pen": "3.8.2",
"stacktrace-parser": "0.1.1",
"temp": "0.8.1",
"text-buffer": "^5.1.1",
"text-buffer": "^5.2",
"theorist": "^1.0.2",
"typescript-simple": "1.0.0",
"underscore-plus": "^1.6.6"
@ -76,10 +76,10 @@
"atom-light-ui": "0.41.0",
"base16-tomorrow-dark-theme": "0.25.0",
"base16-tomorrow-light-theme": "0.8.0",
"one-dark-ui": "0.5.0",
"one-dark-ui": "0.6.1",
"one-dark-syntax": "0.3.0",
"one-light-syntax": "0.4.0",
"one-light-ui": "0.4.0",
"one-light-ui": "0.5.1",
"solarized-dark-syntax": "0.32.0",
"solarized-light-syntax": "0.19.0",
"archive-view": "0.55.0",
@ -89,13 +89,13 @@
"background-tips": "0.23.0",
"bookmarks": "0.35.0",
"bracket-matcher": "0.73.0",
"command-palette": "0.34.0",
"command-palette": "0.35.0",
"deprecation-cop": "0.39.0",
"dev-live-reload": "0.45.0",
"encoding-selector": "0.19.0",
"exception-reporting": "0.24.0",
"feedback": "0.38.0",
"find-and-replace": "0.159.0",
"find-and-replace": "0.160.0",
"fuzzy-finder": "0.72.0",
"git-diff": "0.54.0",
"go-to-line": "0.30.0",
@ -104,27 +104,27 @@
"incompatible-packages": "0.24.0",
"keybinding-resolver": "0.30.0",
"link": "0.30.0",
"markdown-preview": "0.146.0",
"markdown-preview": "0.148.0",
"metrics": "0.45.0",
"notifications": "0.35.0",
"open-on-github": "0.36.0",
"package-generator": "0.38.0",
"release-notes": "0.52.0",
"settings-view": "0.187.0",
"snippets": "0.87.0",
"snippets": "0.88.0",
"spell-check": "0.55.0",
"status-bar": "0.66.0",
"status-bar": "0.67.0",
"styleguide": "0.44.0",
"symbols-view": "0.93.0",
"tabs": "0.67.0",
"timecop": "0.31.0",
"tree-view": "0.168.0",
"tree-view": "0.169.0",
"update-package-dependencies": "0.9.0",
"welcome": "0.26.0",
"whitespace": "0.29.0",
"wrap-guide": "0.31.0",
"language-c": "0.43.0",
"language-clojure": "0.13.0",
"wrap-guide": "0.32.0",
"language-c": "0.44.0",
"language-clojure": "0.14.0",
"language-coffee-script": "0.39.0",
"language-csharp": "0.5.0",
"language-css": "0.28.0",
@ -134,7 +134,7 @@
"language-html": "0.31.0",
"language-hyperlink": "0.12.2",
"language-java": "0.14.0",
"language-javascript": "0.67.0",
"language-javascript": "0.69.0",
"language-json": "0.14.0",
"language-less": "0.25.0",
"language-make": "0.14.0",
@ -144,7 +144,7 @@
"language-php": "0.22.0",
"language-property-list": "0.8.0",
"language-python": "0.33.0",
"language-ruby": "0.50.0",
"language-ruby": "0.51.0",
"language-ruby-on-rails": "0.21.0",
"language-sass": "0.36.0",
"language-shellscript": "0.13.0",

View File

@ -180,3 +180,19 @@ describe "the `atom` global", ->
it "does not open an empty buffer", ->
atom.openInitialEmptyEditorIfNecessary()
expect(atom.workspace.open).not.toHaveBeenCalled()
describe "adding a root folder", ->
it "adds a second path to the project", ->
initialPaths = atom.project.getPaths()
tempDirectory = temp.mkdirSync("a-new-directory")
spyOn(atom, "pickFolder").andCallFake (callback) ->
callback([tempDirectory])
atom.addRootFolder()
expect(atom.project.getPaths()).toEqual(initialPaths.concat([tempDirectory]))
it "does nothing if the user dismisses the file picker", ->
initialPaths = atom.project.getPaths()
tempDirectory = temp.mkdirSync("a-new-directory")
spyOn(atom, "pickFolder").andCallFake (callback) -> callback(null)
atom.addRootFolder()
expect(atom.project.getPaths()).toEqual(initialPaths)

View File

@ -221,7 +221,7 @@ describe "Project", ->
beforeEach ->
absolutePath = require.resolve('./fixtures/dir/a')
newBufferHandler = jasmine.createSpy('newBufferHandler')
atom.project.on 'buffer-created', newBufferHandler
atom.project.onDidAddBuffer(newBufferHandler)
describe "when given an absolute path that isn't currently open", ->
it "returns a new edit session for the given path and emits 'buffer-created'", ->
@ -502,8 +502,12 @@ describe "Project", ->
describe ".eachBuffer(callback)", ->
beforeEach ->
jasmine.snapshotDeprecations()
atom.project.bufferForPathSync('a')
afterEach ->
jasmine.restoreDeprecationsSnapshot()
it "invokes the callback for existing buffer", ->
count = 0
count = 0

View File

@ -72,7 +72,6 @@ if specDirectory
isCoreSpec = specDirectory == fs.realpathSync(__dirname)
beforeEach ->
Grim.clearDeprecations() if isCoreSpec
$.fx.off = true
documentTitle = null
projectPath = specProjectPath ? path.join(@specDirectory, 'fixtures')

View File

@ -728,7 +728,7 @@ describe "TextEditorComponent", ->
expect(cursorNodes[0].style['-webkit-transform']).toBe "translate(#{10 * charWidth}px, #{4 * lineHeightInPixels}px)"
expect(cursorNodes[1].style['-webkit-transform']).toBe "translate(#{11 * charWidth}px, #{8 * lineHeightInPixels}px)"
wrapperView.on 'cursor:moved', cursorMovedListener = jasmine.createSpy('cursorMovedListener')
editor.onDidChangeCursorPosition cursorMovedListener = jasmine.createSpy('cursorMovedListener')
cursor3.setScreenPosition([4, 11], autoscroll: false)
nextAnimationFrame()
expect(cursorNodes[0].style['-webkit-transform']).toBe "translate(#{11 * charWidth}px, #{4 * lineHeightInPixels}px)"

View File

@ -831,35 +831,29 @@ describe "TextEditor", ->
describe ".moveToBeginningOfNextParagraph()", ->
it "moves the cursor before the first line of the next paragraph", ->
editor.setCursorBufferPosition [0,6]
cursor = editor.getLastCursor()
editor.setCursorBufferPosition [0, 6]
editor.foldBufferRow(4)
editor.moveToBeginningOfNextParagraph()
expect(cursor.getBufferPosition()).toEqual { row : 10, column : 0 }
expect(editor.getCursorBufferPosition()).toEqual [10, 0]
editor.setText("")
editor.setCursorBufferPosition [0,0]
cursor = editor.getLastCursor()
editor.setCursorBufferPosition [0, 0]
editor.moveToBeginningOfNextParagraph()
expect(cursor.getBufferPosition()).toEqual [0, 0]
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
describe ".moveToBeginningOfPreviousParagraph()", ->
it "moves the cursor before the first line of the pevious paragraph", ->
editor.setCursorBufferPosition [10,0]
cursor = editor.getLastCursor()
editor.setCursorBufferPosition [10, 0]
editor.foldBufferRow(4)
editor.moveToBeginningOfPreviousParagraph()
expect(cursor.getBufferPosition()).toEqual { row : 0, column : 0 }
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
editor.setText("")
editor.setCursorBufferPosition [0,0]
cursor = editor.getLastCursor()
editor.setCursorBufferPosition [0, 0]
editor.moveToBeginningOfPreviousParagraph()
expect(cursor.getBufferPosition()).toEqual [0, 0]
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
describe ".getCurrentParagraphBufferRange()", ->
it "returns the buffer range of the current paragraph, delimited by blank lines or the beginning / end of the file", ->

View File

@ -6,12 +6,11 @@ remote = require 'remote'
shell = require 'shell'
_ = require 'underscore-plus'
{deprecate} = require 'grim'
{Emitter} = require 'event-kit'
{Model} = require 'theorist'
{deprecate, includeDeprecatedAPIs} = require 'grim'
{CompositeDisposable, Emitter} = require 'event-kit'
fs = require 'fs-plus'
{convertStackTrace, convertLine} = require 'coffeestack'
Model = require './model'
{$} = require './space-pen-extensions'
WindowEventHandler = require './window-event-handler'
StylesElement = require './styles-element'
@ -34,35 +33,36 @@ class Atom extends Model
atom = @deserialize(@loadState(mode)) ? new this({mode, @version})
atom.deserializeTimings.atom = Date.now() - startTime
workspaceViewDeprecationMessage = """
atom.workspaceView is no longer available.
In most cases you will not need the view. See the Workspace docs for
alternatives: https://atom.io/docs/api/latest/Workspace.
If you do need the view, please use `atom.views.getView(atom.workspace)`,
which returns an HTMLElement.
"""
if includeDeprecatedAPIs
workspaceViewDeprecationMessage = """
atom.workspaceView is no longer available.
In most cases you will not need the view. See the Workspace docs for
alternatives: https://atom.io/docs/api/latest/Workspace.
If you do need the view, please use `atom.views.getView(atom.workspace)`,
which returns an HTMLElement.
"""
serviceHubDeprecationMessage = """
atom.services is no longer available. To register service providers and
consumers, use the `providedServices` and `consumedServices` fields in
your package's package.json.
"""
serviceHubDeprecationMessage = """
atom.services is no longer available. To register service providers and
consumers, use the `providedServices` and `consumedServices` fields in
your package's package.json.
"""
Object.defineProperty atom, 'workspaceView',
get: ->
deprecate(workspaceViewDeprecationMessage)
atom.__workspaceView
set: (newValue) ->
deprecate(workspaceViewDeprecationMessage)
atom.__workspaceView = newValue
Object.defineProperty atom, 'workspaceView',
get: ->
deprecate(workspaceViewDeprecationMessage)
atom.__workspaceView
set: (newValue) ->
deprecate(workspaceViewDeprecationMessage)
atom.__workspaceView = newValue
Object.defineProperty atom, 'services',
get: ->
deprecate(serviceHubDeprecationMessage)
atom.packages.serviceHub
set: (newValue) ->
deprecate(serviceHubDeprecationMessage)
atom.packages.serviceHub = newValue
Object.defineProperty atom, 'services',
get: ->
deprecate(serviceHubDeprecationMessage)
atom.packages.serviceHub
set: (newValue) ->
deprecate(serviceHubDeprecationMessage)
atom.packages.serviceHub = newValue
atom
@ -197,6 +197,7 @@ class Atom extends Model
# Call .loadOrCreate instead
constructor: (@state) ->
@emitter = new Emitter
@disposables = new CompositeDisposable
{@mode} = @state
DeserializerManager = require './deserializer-manager'
@deserializers = new DeserializerManager()
@ -228,10 +229,12 @@ class Atom extends Model
@openDevTools()
@executeJavaScriptInDevTools('InspectorFrontendAPI.showConsole()')
@emit 'uncaught-error', arguments...
@emit 'uncaught-error', arguments... if includeDeprecatedAPIs
@emitter.emit 'did-throw-error', {message, url, line, column, originalError}
@unsubscribe()
@disposables?.dispose()
@disposables = new CompositeDisposable
@setBodyPlatformClass()
@loadTime = null
@ -263,7 +266,10 @@ class Atom extends Model
@config = new Config({configDirPath, resourcePath})
@keymaps = new KeymapManager({configDirPath, resourcePath})
@keymap = @keymaps # Deprecated
if includeDeprecatedAPIs
@keymap = @keymaps # Deprecated
@keymaps.subscribeToFileReadFailure()
@tooltips = new TooltipManager
@notifications = new NotificationManager
@ -279,11 +285,12 @@ class Atom extends Model
@grammars = @deserializers.deserialize(@state.grammars ? @state.syntax) ? new GrammarRegistry()
Object.defineProperty this, 'syntax', get: ->
deprecate "The atom.syntax global is deprecated. Use atom.grammars instead."
@grammars
if includeDeprecatedAPIs
Object.defineProperty this, 'syntax', get: ->
deprecate "The atom.syntax global is deprecated. Use atom.grammars instead."
@grammars
@subscribe @packages.onDidActivateInitialPackages => @watchThemes()
@disposables.add @packages.onDidActivateInitialPackages => @watchThemes()
Project = require './project'
TextBuffer = require 'text-buffer'
@ -342,15 +349,15 @@ class Atom extends Model
# Public: Is the current window in development mode?
inDevMode: ->
@getLoadSettings().devMode
@devMode ?= @getLoadSettings().devMode
# Public: Is the current window in safe mode?
inSafeMode: ->
@getLoadSettings().safeMode
@safeMode ?= @getLoadSettings().safeMode
# Public: Is the current window running specs?
inSpecMode: ->
@getLoadSettings().isSpec
@specMode ?= @getLoadSettings().isSpec
# Public: Get the version of the Atom application.
#
@ -405,10 +412,11 @@ class Atom extends Model
open: (options) ->
ipc.send('open', options)
# Extended: Show the native dialog to prompt the user to select a folder.
# Extended: Prompt the user to select one or more folders.
#
# * `callback` A {Function} to call once the user has selected a folder.
# * `path` {String} the path to the folder the user selected.
# * `callback` A {Function} to call once the user has confirmed the selection.
# * `paths` An {Array} of {String} paths that the user selected, or `null`
# if the user dismissed the dialog.
pickFolder: (callback) ->
responseChannel = "atom-pick-folder-response"
ipc.on responseChannel, (path) ->
@ -600,7 +608,7 @@ class Atom extends Model
@requireUserInitScript() unless safeMode
@menu.update()
@subscribe @config.onDidChange 'core.autoHideMenuBar', ({newValue}) =>
@disposables.add @config.onDidChange 'core.autoHideMenuBar', ({newValue}) =>
@setAutoHideMenuBar(newValue)
@setAutoHideMenuBar(true) if @config.get('core.autoHideMenuBar')
@ -713,7 +721,9 @@ class Atom extends Model
deserializeWorkspaceView: ->
Workspace = require './workspace'
WorkspaceView = require './workspace-view'
if includeDeprecatedAPIs
WorkspaceView = require './workspace-view'
startTime = Date.now()
@workspace = Workspace.deserialize(@state.workspace) ? new Workspace
@ -750,7 +760,7 @@ class Atom extends Model
# Notify the browser project of the window's current project path
watchProjectPath: ->
@subscribe @project.onDidChangePaths =>
@disposables.add @project.onDidChangePaths =>
@constructor.updateLoadSetting('initialPaths', @project.getPaths())
exit: (status) ->
@ -764,6 +774,10 @@ class Atom extends Model
setRepresentedFilename: (filename) ->
ipc.send('call-window-method', 'setRepresentedFilename', filename)
addRootFolder: ->
@pickFolder (selectedPaths = []) =>
@project.addPath(selectedPath) for selectedPath in selectedPaths
showSaveDialog: (callback) ->
callback(showSaveDialogSync())
@ -827,17 +841,18 @@ class Atom extends Model
updateAvailable: (details) ->
@emitter.emit 'update-available', details
# Deprecated: Callers should be converted to use atom.deserializers
registerRepresentationClass: ->
deprecate("Callers should be converted to use atom.deserializers")
# Deprecated: Callers should be converted to use atom.deserializers
registerRepresentationClasses: ->
deprecate("Callers should be converted to use atom.deserializers")
setBodyPlatformClass: ->
document.body.classList.add("platform-#{process.platform}")
setAutoHideMenuBar: (autoHide) ->
ipc.send('call-window-method', 'setAutoHideMenuBar', autoHide)
ipc.send('call-window-method', 'setMenuBarVisibility', !autoHide)
if includeDeprecatedAPIs
# Deprecated: Callers should be converted to use atom.deserializers
Atom::registerRepresentationClass = ->
deprecate("Callers should be converted to use atom.deserializers")
# Deprecated: Callers should be converted to use atom.deserializers
Atom::registerRepresentationClasses = ->
deprecate("Callers should be converted to use atom.deserializers")

View File

@ -60,7 +60,7 @@ class AtomApplication
exit: (status) -> app.exit(status)
constructor: (options) ->
{@resourcePath, @version, @devMode, @safeMode, @socketPath} = options
{@resourcePath, @version, @devMode, @safeMode, @apiPreviewMode, @socketPath} = options
# Normalize to make sure drive letter case is consistent on Windows
@resourcePath = path.normalize(@resourcePath) if @resourcePath
@ -82,15 +82,15 @@ class AtomApplication
@openWithOptions(options)
# Opens a new window based on the options provided.
openWithOptions: ({pathsToOpen, urlsToOpen, test, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory, logFile}) ->
openWithOptions: ({pathsToOpen, urlsToOpen, test, pidToKillWhenClosed, devMode, safeMode, apiPreviewMode, newWindow, specDirectory, logFile}) ->
if test
@runSpecs({exitWhenDone: true, @resourcePath, specDirectory, logFile})
else if pathsToOpen.length > 0
@openPaths({pathsToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode})
@openPaths({pathsToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode, apiPreviewMode})
else if urlsToOpen.length > 0
@openUrl({urlToOpen, devMode, safeMode}) for urlToOpen in urlsToOpen
@openUrl({urlToOpen, devMode, safeMode, apiPreviewMode}) for urlToOpen in urlsToOpen
else
@openPath({pidToKillWhenClosed, newWindow, devMode, safeMode}) # Always open a editor window if this is the first instance of Atom.
@openPath({pidToKillWhenClosed, newWindow, devMode, safeMode, apiPreviewMode}) # Always open a editor window if this is the first instance of Atom.
# Public: Removes the {AtomWindow} from the global window list.
removeWindow: (window) ->
@ -146,6 +146,7 @@ class AtomApplication
getLoadSettings = =>
devMode: @focusedWindow()?.devMode
safeMode: @focusedWindow()?.safeMode
apiPreviewMode: @focusedWindow()?.apiPreviewMode
@on 'application:run-all-specs', -> @runSpecs(exitWhenDone: false, resourcePath: global.devResourcePath, safeMode: @focusedWindow()?.safeMode)
@on 'application:run-benchmarks', -> @runBenchmarks()
@ -157,6 +158,8 @@ class AtomApplication
@on 'application:open-folder', -> @promptForPathToOpen('folder', getLoadSettings())
@on 'application:open-dev', -> @promptForPathToOpen('all', devMode: true)
@on 'application:open-safe', -> @promptForPathToOpen('all', safeMode: true)
@on 'application:open-api-preview', -> @promptForPathToOpen('all', apiPreviewMode: true)
@on 'application:open-dev-api-preview', -> @promptForPathToOpen('all', {apiPreviewMode: true, devMode: true})
@on 'application:inspect', ({x,y, atomWindow}) ->
atomWindow ?= @focusedWindow()
atomWindow?.browserWindow.inspectElement(x, y)
@ -209,7 +212,7 @@ class AtomApplication
app.on 'open-url', (event, urlToOpen) =>
event.preventDefault()
@openUrl({urlToOpen, @devMode, @safeMode})
@openUrl({urlToOpen, @devMode, @safeMode, @apiPreviewMode})
app.on 'activate-with-no-open-windows', (event) =>
event.preventDefault()
@ -333,9 +336,10 @@ class AtomApplication
# :newWindow - Boolean of whether this should be opened in a new window.
# :devMode - Boolean to control the opened window's dev mode.
# :safeMode - Boolean to control the opened window's safe mode.
# :apiPreviewMode - Boolean to control the opened window's 1.0 API preview mode.
# :window - {AtomWindow} to open file paths in.
openPath: ({pathToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode, window}) ->
@openPaths({pathsToOpen: [pathToOpen], pidToKillWhenClosed, newWindow, devMode, safeMode, window})
openPath: ({pathToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode, apiPreviewMode, window}) ->
@openPaths({pathsToOpen: [pathToOpen], pidToKillWhenClosed, newWindow, devMode, safeMode, apiPreviewMode, window})
# Public: Opens a single path, in an existing window if possible.
#
@ -345,9 +349,10 @@ class AtomApplication
# :newWindow - Boolean of whether this should be opened in a new window.
# :devMode - Boolean to control the opened window's dev mode.
# :safeMode - Boolean to control the opened window's safe mode.
# :apiPreviewMode - Boolean to control the opened window's 1.0 API preview mode.
# :windowDimensions - Object with height and width keys.
# :window - {AtomWindow} to open file paths in.
openPaths: ({pathsToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode, windowDimensions, window}={}) ->
openPaths: ({pathsToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode, apiPreviewMode, windowDimensions, window}={}) ->
pathsToOpen = (fs.normalize(pathToOpen) for pathToOpen in pathsToOpen)
locationsToOpen = (@locationForPathToOpen(pathToOpen) for pathToOpen in pathsToOpen)
@ -377,7 +382,7 @@ class AtomApplication
bootstrapScript ?= require.resolve('../window-bootstrap')
resourcePath ?= @resourcePath
openedWindow = new AtomWindow({locationsToOpen, bootstrapScript, resourcePath, devMode, safeMode, windowDimensions})
openedWindow = new AtomWindow({locationsToOpen, bootstrapScript, resourcePath, devMode, safeMode, apiPreviewMode, windowDimensions})
if pidToKillWhenClosed?
@pidsToOpenWindows[pidToKillWhenClosed] = openedWindow
@ -498,9 +503,9 @@ class AtomApplication
# :safeMode - A Boolean which controls whether any newly opened windows
# should be in safe mode or not.
# :window - An {AtomWindow} to use for opening a selected file path.
promptForPathToOpen: (type, {devMode, safeMode, window}) ->
promptForPathToOpen: (type, {devMode, safeMode, apiPreviewMode, window}) ->
@promptForPath type, (pathsToOpen) =>
@openPaths({pathsToOpen, devMode, safeMode, window})
@openPaths({pathsToOpen, devMode, safeMode, apiPreviewMode, window})
promptForPath: (type, callback) ->
properties =

View File

@ -18,7 +18,7 @@ class AtomWindow
isSpec: null
constructor: (settings={}) ->
{@resourcePath, pathToOpen, locationsToOpen, @isSpec, @exitWhenDone, @safeMode, @devMode} = settings
{@resourcePath, pathToOpen, locationsToOpen, @isSpec, @exitWhenDone, @safeMode, @devMode, @apiPreviewMode} = settings
locationsToOpen ?= [{pathToOpen}] if pathToOpen
locationsToOpen ?= []
@ -47,6 +47,7 @@ class AtomWindow
loadSettings.resourcePath = @resourcePath
loadSettings.devMode ?= false
loadSettings.safeMode ?= false
loadSettings.apiPreviewMode ?= false
# Only send to the first non-spec window created
if @constructor.includeShellLoadTime and not @isSpec

View File

@ -106,6 +106,7 @@ parseCommandLine = ->
ATOM_HOME The root path for all configuration files and folders.
Defaults to `~/.atom`.
"""
options.alias('1', 'one').boolean('1').describe('1', 'Run in 1.0 API preview mode.')
options.alias('d', 'dev').boolean('d').describe('d', 'Run in development mode.')
options.alias('f', 'foreground').boolean('f').describe('f', 'Keep the browser process in the foreground.')
options.alias('h', 'help').boolean('h').describe('h', 'Print this usage message.')
@ -131,6 +132,7 @@ parseCommandLine = ->
executedFrom = args['executed-from']
devMode = args['dev']
safeMode = args['safe']
apiPreviewMode = args['one']
pathsToOpen = args._
pathsToOpen = [executedFrom] if executedFrom and pathsToOpen.length is 0
test = args['test']
@ -164,6 +166,7 @@ parseCommandLine = ->
process.env.PATH = args['path-environment'] if args['path-environment']
{resourcePath, pathsToOpen, executedFrom, test, version, pidToKillWhenClosed,
devMode, safeMode, newWindow, specDirectory, logFile, socketPath}
devMode, apiPreviewMode, safeMode, newWindow, specDirectory, logFile,
socketPath}
start()

View File

@ -1,6 +1,12 @@
clipboard = require 'clipboard'
crypto = require 'crypto'
# Using clipboard in renderer process is not safe on Linux.
clipboard =
if process.platform is 'linux'
require('remote').require 'clipboard'
else
require 'clipboard'
# Extended: Represents the clipboard used for copying and pasting in Atom.
#
# An instance of this class is always available as the `atom.clipboard` global.

View File

@ -371,7 +371,7 @@ class Config
observe: ->
if arguments.length is 2
[keyPath, callback] = arguments
else if arguments.length is 3 and (_.isArray(arguments[0]) or arguments[0] instanceof ScopeDescriptor)
else if Grim.includeDeprecatedAPIs and arguments.length is 3 and (_.isArray(arguments[0]) or arguments[0] instanceof ScopeDescriptor)
Grim.deprecate """
Passing a scope descriptor as the first argument to Config::observe is deprecated.
Pass a `scope` in an options hash as the third argument instead.
@ -380,7 +380,7 @@ class Config
else if arguments.length is 3 and (_.isString(arguments[0]) and _.isObject(arguments[1]))
[keyPath, options, callback] = arguments
scopeDescriptor = options.scope
if options.callNow?
if Grim.includeDeprecatedAPIs and options.callNow?
Grim.deprecate """
Config::observe no longer takes a `callNow` option. Use ::onDidChange instead.
Note that ::onDidChange passes its callback different arguments.
@ -419,7 +419,7 @@ class Config
[callback] = arguments
else if arguments.length is 2
[keyPath, callback] = arguments
else if _.isArray(arguments[0]) or arguments[0] instanceof ScopeDescriptor
else if Grim.includeDeprecatedAPIs and _.isArray(arguments[0]) or arguments[0] instanceof ScopeDescriptor
Grim.deprecate """
Passing a scope descriptor as the first argument to Config::onDidChange is deprecated.
Pass a `scope` in an options hash as the third argument instead.
@ -498,7 +498,7 @@ class Config
if typeof arguments[0] is 'string' or not arguments[0]?
[keyPath, options] = arguments
{scope} = options
else
else if Grim.includeDeprecatedAPIs
Grim.deprecate """
Passing a scope descriptor as the first argument to Config::get is deprecated.
Pass a `scope` in an options hash as the final argument instead.
@ -578,7 +578,7 @@ class Config
# * `true` if the value was set.
# * `false` if the value was not able to be coerced to the type specified in the setting's schema.
set: ->
if arguments[0]?[0] is '.'
if Grim.includeDeprecatedAPIs and arguments[0]?[0] is '.'
Grim.deprecate """
Passing a scope selector as the first argument to Config::set is deprecated.
Pass a `scopeSelector` in an options hash as the final argument instead.
@ -617,7 +617,7 @@ class Config
# * `scopeSelector` (optional) {String}. See {::set}
# * `source` (optional) {String}. See {::set}
unset: (keyPath, options) ->
if typeof options is 'string'
if Grim.includeDeprecatedAPIs and typeof options is 'string'
Grim.deprecate """
Passing a scope selector as the first argument to Config::unset is deprecated.
Pass a `scopeSelector` in an options hash as the second argument instead.
@ -652,47 +652,6 @@ class Config
getSources: ->
_.uniq(_.pluck(@scopedSettingsStore.propertySets, 'source')).sort()
# Deprecated: Restore the global setting at `keyPath` to its default value.
#
# Returns the new value.
restoreDefault: (scopeSelector, keyPath) ->
Grim.deprecate("Use ::unset instead.")
@unset(scopeSelector, keyPath)
@get(keyPath)
# Deprecated: Get the global default value of the key path. _Please note_ that in most
# cases calling this is not necessary! {::get} returns the default value when
# a custom value is not specified.
#
# * `scopeSelector` (optional) {String}. eg. '.source.ruby'
# * `keyPath` The {String} name of the key.
#
# Returns the default value.
getDefault: ->
Grim.deprecate("Use `::get(keyPath, {scope, excludeSources: [atom.config.getUserConfigPath()]})` instead")
if arguments.length is 1
[keyPath] = arguments
else
[scopeSelector, keyPath] = arguments
scope = [scopeSelector]
@get(keyPath, {scope, excludeSources: [@getUserConfigPath()]})
# Deprecated: Is the value at `keyPath` its default value?
#
# * `scopeSelector` (optional) {String}. eg. '.source.ruby'
# * `keyPath` The {String} name of the key.
#
# Returns a {Boolean}, `true` if the current value is the default, `false`
# otherwise.
isDefault: ->
Grim.deprecate("Use `not ::get(keyPath, {scope, sources: [atom.config.getUserConfigPath()]})?` instead")
if arguments.length is 1
[keyPath] = arguments
else
[scopeSelector, keyPath] = arguments
scope = [scopeSelector]
not @get(keyPath, {scope, sources: [@getUserConfigPath()]})?
# Extended: Retrieve the schema for a specific key path. The schema will tell
# you what type the keyPath expects, and other metadata about the config
# option.
@ -709,12 +668,6 @@ class Config
schema = schema.properties?[key]
schema
# Deprecated: Returns a new {Object} containing all of the global settings and
# defaults. Returns the scoped settings when a `scopeSelector` is specified.
getSettings: ->
Grim.deprecate "Use ::get(keyPath) instead"
_.deepExtend({}, @settings, @defaultSettings)
# Extended: Get the {String} path to the config file being used.
getUserConfigPath: ->
@configFilePath
@ -732,31 +685,6 @@ class Config
@transactDepth--
@emitChangeEvent()
###
Section: Deprecated
###
getInt: (keyPath) ->
Grim.deprecate '''Config::getInt is no longer necessary. Use ::get instead.
Make sure the config option you are accessing has specified an `integer`
schema. See the schema section of
https://atom.io/docs/api/latest/Config for more info.'''
parseInt(@get(keyPath))
getPositiveInt: (keyPath, defaultValue=0) ->
Grim.deprecate '''Config::getPositiveInt is no longer necessary. Use ::get instead.
Make sure the config option you are accessing has specified an `integer`
schema with `minimum: 1`. See the schema section of
https://atom.io/docs/api/latest/Config for more info.'''
Math.max(@getInt(keyPath), 0) or defaultValue
toggle: (keyPath) ->
Grim.deprecate 'Config::toggle is no longer supported. Please remove from your code.'
@set(keyPath, !@get(keyPath))
unobserve: (keyPath) ->
Grim.deprecate 'Config::unobserve no longer does anything. Call `.dispose()` on the object returned by Config::observe instead.'
###
Section: Internal methods used by core
###
@ -1056,16 +984,6 @@ class Config
@emitChangeEvent()
addScopedSettings: (source, selector, value, options) ->
Grim.deprecate("Use ::set instead")
settingsBySelector = {}
settingsBySelector[selector] = value
disposable = @scopedSettingsStore.addProperties(source, settingsBySelector, options)
@emitChangeEvent()
new Disposable =>
disposable.dispose()
@emitChangeEvent()
setRawScopedValue: (keyPath, value, source, selector, options) ->
if keyPath?
newValue = {}
@ -1094,11 +1012,6 @@ class Config
oldValue = newValue
callback(event)
settingsForScopeDescriptor: (scopeDescriptor, keyPath) ->
Grim.deprecate("Use Config::getAll instead")
entries = @getAll(null, scope: scopeDescriptor)
value for {value} in entries when _.valueForKeyPath(value, keyPath)?
# Base schema enforcers. These will coerce raw input into the specified type,
# and will throw an error when the value cannot be coerced. Throwing the error
# will indicate that the value should not be set.
@ -1232,3 +1145,67 @@ withoutEmptyObjects = (object) ->
else
resultObject = object
resultObject
if Grim.includeDeprecatedAPIs
Config::restoreDefault = (scopeSelector, keyPath) ->
Grim.deprecate("Use ::unset instead.")
@unset(scopeSelector, keyPath)
@get(keyPath)
Config::getDefault = ->
Grim.deprecate("Use `::get(keyPath, {scope, excludeSources: [atom.config.getUserConfigPath()]})` instead")
if arguments.length is 1
[keyPath] = arguments
else
[scopeSelector, keyPath] = arguments
scope = [scopeSelector]
@get(keyPath, {scope, excludeSources: [@getUserConfigPath()]})
Config::isDefault = ->
Grim.deprecate("Use `not ::get(keyPath, {scope, sources: [atom.config.getUserConfigPath()]})?` instead")
if arguments.length is 1
[keyPath] = arguments
else
[scopeSelector, keyPath] = arguments
scope = [scopeSelector]
not @get(keyPath, {scope, sources: [@getUserConfigPath()]})?
Config::getSettings = ->
Grim.deprecate "Use ::get(keyPath) instead"
_.deepExtend({}, @settings, @defaultSettings)
Config::getInt = (keyPath) ->
Grim.deprecate '''Config::getInt is no longer necessary. Use ::get instead.
Make sure the config option you are accessing has specified an `integer`
schema. See the schema section of
https://atom.io/docs/api/latest/Config for more info.'''
parseInt(@get(keyPath))
Config::getPositiveInt = (keyPath, defaultValue=0) ->
Grim.deprecate '''Config::getPositiveInt is no longer necessary. Use ::get instead.
Make sure the config option you are accessing has specified an `integer`
schema with `minimum: 1`. See the schema section of
https://atom.io/docs/api/latest/Config for more info.'''
Math.max(@getInt(keyPath), 0) or defaultValue
Config::toggle = (keyPath) ->
Grim.deprecate 'Config::toggle is no longer supported. Please remove from your code.'
@set(keyPath, !@get(keyPath))
Config::unobserve = (keyPath) ->
Grim.deprecate 'Config::unobserve no longer does anything. Call `.dispose()` on the object returned by Config::observe instead.'
Config::addScopedSettings = (source, selector, value, options) ->
Grim.deprecate("Use ::set instead")
settingsBySelector = {}
settingsBySelector[selector] = value
disposable = @scopedSettingsStore.addProperties(source, settingsBySelector, options)
@emitChangeEvent()
new Disposable =>
disposable.dispose()
@emitChangeEvent()
Config::settingsForScopeDescriptor = (scopeDescriptor, keyPath) ->
Grim.deprecate("Use Config::getAll instead")
entries = @getAll(null, scope: scopeDescriptor)
value for {value} in entries when _.valueForKeyPath(value, keyPath)?

View File

@ -1,6 +1,4 @@
{$} = require './space-pen-extensions'
_ = require 'underscore-plus'
remote = require 'remote'
path = require 'path'
CSON = require 'season'
fs = require 'fs-plus'
@ -101,25 +99,26 @@ class ContextMenuManager
# with the following argument:
# * `event` The click event that deployed the context menu.
add: (itemsBySelector) ->
# Detect deprecated file path as first argument
if itemsBySelector? and typeof itemsBySelector isnt 'object'
Grim.deprecate """
ContextMenuManager::add has changed to take a single object as its
argument. Please see
https://atom.io/docs/api/latest/ContextMenuManager for more info.
"""
itemsBySelector = arguments[1]
devMode = arguments[2]?.devMode
# Detect deprecated format for items object
for key, value of itemsBySelector
unless _.isArray(value)
if Grim.includeDeprecatedAPIs
# Detect deprecated file path as first argument
if itemsBySelector? and typeof itemsBySelector isnt 'object'
Grim.deprecate """
ContextMenuManager::add has changed to take a single object as its
argument. Please see
https://atom.io/docs/api/latest/ContextMenuManager for more info.
"""
itemsBySelector = @convertLegacyItemsBySelector(itemsBySelector, devMode)
itemsBySelector = arguments[1]
devMode = arguments[2]?.devMode
# Detect deprecated format for items object
for key, value of itemsBySelector
unless _.isArray(value)
Grim.deprecate """
ContextMenuManager::add has changed to take a single object as its
argument. Please see
https://atom.io/docs/api/latest/ContextMenuManager for more info.
"""
itemsBySelector = @convertLegacyItemsBySelector(itemsBySelector, devMode)
addedItemSets = []
@ -188,7 +187,7 @@ class ContextMenuManager
menuTemplate = @templateForEvent(event)
return unless menuTemplate?.length > 0
remote.getCurrentWindow().emit('context-menu', menuTemplate)
atom.getCurrentWindow().emit('context-menu', menuTemplate)
return
clear: ->

View File

@ -1,8 +1,8 @@
{Point, Range} = require 'text-buffer'
{Model} = require 'theorist'
{Emitter} = require 'event-kit'
_ = require 'underscore-plus'
Grim = require 'grim'
Model = require './model'
# Extended: The `Cursor` class represents the little blinking line identifying
# where text can be inserted.
@ -39,13 +39,13 @@ class Cursor extends Model
textChanged: textChanged
cursor: this
@emit 'moved', movedEvent
@emit 'moved', movedEvent if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-position', movedEvent
@editor.cursorMoved(movedEvent)
@marker.onDidDestroy =>
@destroyed = true
@editor.removeCursor(this)
@emit 'destroyed'
@emit 'destroyed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-destroy'
@emitter.dispose()
@ -89,6 +89,8 @@ class Cursor extends Model
@emitter.on 'did-change-visibility', callback
on: (eventName) ->
return unless Grim.includeDeprecatedAPIs
switch eventName
when 'moved'
Grim.deprecate("Use Cursor::onDidChangePosition instead")
@ -222,9 +224,6 @@ class Cursor extends Model
# Returns a {ScopeDescriptor}
getScopeDescriptor: ->
@editor.scopeDescriptorForBufferPosition(@getBufferPosition())
getScopes: ->
Grim.deprecate 'Use Cursor::getScopeDescriptor() instead'
@getScopeDescriptor().getScopesArray()
# Public: Returns true if this cursor has no non-whitespace characters before
# its current position.
@ -476,10 +475,6 @@ class Cursor extends Model
endOfWordPosition or currentBufferPosition
getMoveNextWordBoundaryBufferPosition: (options) ->
Grim.deprecate 'Use `::getNextWordBoundaryBufferPosition(options)` instead'
@getNextWordBoundaryBufferPosition(options)
# Public: Retrieves the buffer position of where the current word starts.
#
# * `options` (optional) An {Object} with the following keys:
@ -593,7 +588,7 @@ class Cursor extends Model
setVisible: (visible) ->
if @visible != visible
@visible = visible
@emit 'visibility-changed', @visible
@emit 'visibility-changed', @visible if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-visibility', @visible
# Public: Returns the visibility of the cursor.
@ -672,7 +667,7 @@ class Cursor extends Model
if !range.start.isEqual(start)
position = range.start
stop()
@editor.screenPositionForBufferPosition(position)
position
getBeginningOfPreviousParagraphBufferPosition: ->
start = @getBufferPosition()
@ -685,4 +680,13 @@ class Cursor extends Model
if !range.start.isEqual(zero)
position = range.start
stop()
@editor.screenPositionForBufferPosition(position)
position
if Grim.includeDeprecatedAPIs
Cursor::getScopes = ->
Grim.deprecate 'Use Cursor::getScopeDescriptor() instead'
@getScopeDescriptor().getScopesArray()
Cursor::getMoveNextWordBoundaryBufferPosition = (options) ->
Grim.deprecate 'Use `::getNextWordBoundaryBufferPosition(options)` instead'
@getNextWordBoundaryBufferPosition(options)

View File

@ -1,5 +1,4 @@
_ = require 'underscore-plus'
EmitterMixin = require('emissary').Emitter
{Emitter} = require 'event-kit'
Grim = require 'grim'
@ -30,7 +29,6 @@ nextId = -> idCounter++
# the marker.
module.exports =
class Decoration
EmitterMixin.includeInto(this)
# Private: Check if the `decorationProperties.type` matches `type`
#
@ -67,7 +65,7 @@ class Decoration
@markerDestroyDisposable.dispose()
@markerDestroyDisposable = null
@destroyed = true
@emit 'destroyed'
@emit 'destroyed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-destroy'
@emitter.dispose()
@ -123,9 +121,6 @@ class Decoration
# Essential: Returns the {Decoration}'s properties.
getProperties: ->
@properties
getParams: ->
Grim.deprecate 'Use Decoration::getProperties instead'
@getProperties()
# Essential: Update the marker with new Properties. Allows you to change the decoration's class.
#
@ -141,11 +136,8 @@ class Decoration
oldProperties = @properties
@properties = newProperties
@properties.id = @id
@emit 'updated', {oldParams: oldProperties, newParams: newProperties}
@emit 'updated', {oldParams: oldProperties, newParams: newProperties} if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-properties', {oldProperties, newProperties}
update: (newProperties) ->
Grim.deprecate 'Use Decoration::setProperties instead'
@setProperties(newProperties)
###
Section: Private methods
@ -164,14 +156,18 @@ class Decoration
flashObject = {class: klass, duration}
@flashQueue ?= []
@flashQueue.push(flashObject)
@emit 'flash'
@emit 'flash' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-flash'
consumeNextFlash: ->
return @flashQueue.shift() if @flashQueue?.length > 0
null
on: (eventName) ->
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(Decoration)
Decoration::on = (eventName) ->
switch eventName
when 'updated'
Grim.deprecate 'Use Decoration::onDidChangeProperties instead'
@ -183,3 +179,11 @@ class Decoration
Grim.deprecate 'Decoration::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
Decoration::getParams = ->
Grim.deprecate 'Use Decoration::getProperties instead'
@getProperties()
Decoration::update = -> (newProperties) ->
Grim.deprecate 'Use Decoration::setProperties instead'
@setProperties(newProperties)

View File

@ -37,11 +37,6 @@ class DeserializerManager
delete @deserializers[deserializer.name] for deserializer in deserializers
return
remove: (classes...) ->
Grim.deprecate("Call .dispose() on the Disposable return from ::add instead")
delete @deserializers[name] for {name} in classes
return
# Public: Deserialize the state and params.
#
# * `state` The state {Object} to deserialize.
@ -65,3 +60,9 @@ class DeserializerManager
name = state.get?('deserializer') ? state.deserializer
@deserializers[name]
if Grim.includeDeprecatedAPIs
DeserializerManager::remove = (classes...) ->
Grim.deprecate("Call .dispose() on the Disposable return from ::add instead")
delete @deserializers[name] for {name} in classes
return

View File

@ -1,12 +1,11 @@
_ = require 'underscore-plus'
EmitterMixin = require('emissary').Emitter
Serializable = require 'serializable'
{Model} = require 'theorist'
{CompositeDisposable, Emitter} = require 'event-kit'
{Point, Range} = require 'text-buffer'
TokenizedBuffer = require './tokenized-buffer'
RowMap = require './row-map'
Fold = require './fold'
Model = require './model'
Token = require './token'
Decoration = require './decoration'
Marker = require './marker'
@ -21,19 +20,6 @@ module.exports =
class DisplayBuffer extends Model
Serializable.includeInto(this)
@properties
softWrapped: null
editorWidthInChars: null
lineHeightInPixels: null
defaultCharWidth: null
height: null
width: null
scrollTop: 0
scrollLeft: 0
scrollWidth: 0
verticalScrollbarWidth: 15
horizontalScrollbarHeight: 15
verticalScrollMargin: 2
horizontalScrollMargin: 6
scopedCharacterWidthsChangeCount: 0
@ -42,6 +28,7 @@ class DisplayBuffer extends Model
super
@emitter = new Emitter
@disposables = new CompositeDisposable
@tokenizedBuffer ?= new TokenizedBuffer({tabLength, buffer, @invisibles})
@buffer = @tokenizedBuffer.buffer
@ -50,10 +37,10 @@ class DisplayBuffer extends Model
@foldsByMarkerId = {}
@decorationsById = {}
@decorationsByMarkerId = {}
@subscribe @tokenizedBuffer.observeGrammar @subscribeToScopedConfigSettings
@subscribe @tokenizedBuffer.onDidChange @handleTokenizedBufferChange
@subscribe @buffer.onDidUpdateMarkers @handleBufferMarkersUpdated
@subscribe @buffer.onDidCreateMarker @handleBufferMarkerCreated
@disposables.add @tokenizedBuffer.observeGrammar @subscribeToScopedConfigSettings
@disposables.add @tokenizedBuffer.onDidChange @handleTokenizedBufferChange
@disposables.add @buffer.onDidUpdateMarkers @handleBufferMarkersUpdated
@disposables.add @buffer.onDidCreateMarker @handleBufferMarkerCreated
@updateAllScreenLines()
@createFoldForMarker(marker) for marker in @buffer.findMarkers(@getFoldMarkerAttributes())
@ -135,6 +122,20 @@ class DisplayBuffer extends Model
onDidChangeCharacterWidths: (callback) ->
@emitter.on 'did-change-character-widths', callback
onDidChangeScrollTop: (callback) ->
@emitter.on 'did-change-scroll-top', callback
onDidChangeScrollLeft: (callback) ->
@emitter.on 'did-change-scroll-left', callback
observeScrollTop: (callback) ->
callback(@scrollTop)
@onDidChangeScrollTop(callback)
observeScrollLeft: (callback) ->
callback(@scrollLeft)
@onDidChangeScrollLeft(callback)
observeDecorations: (callback) ->
callback(decoration) for decoration in @getDecorations()
@onDidAddDecoration(callback)
@ -151,38 +152,11 @@ class DisplayBuffer extends Model
onDidUpdateMarkers: (callback) ->
@emitter.on 'did-update-markers', callback
on: (eventName) ->
switch eventName
when 'changed'
Grim.deprecate("Use DisplayBuffer::onDidChange instead")
when 'grammar-changed'
Grim.deprecate("Use DisplayBuffer::onDidChangeGrammar instead")
when 'soft-wrap-changed'
Grim.deprecate("Use DisplayBuffer::onDidChangeSoftWrap instead")
when 'character-widths-changed'
Grim.deprecate("Use DisplayBuffer::onDidChangeCharacterWidths instead")
when 'decoration-added'
Grim.deprecate("Use DisplayBuffer::onDidAddDecoration instead")
when 'decoration-removed'
Grim.deprecate("Use DisplayBuffer::onDidRemoveDecoration instead")
when 'decoration-changed'
Grim.deprecate("Use decoration.getMarker().onDidChange() instead")
when 'decoration-updated'
Grim.deprecate("Use Decoration::onDidChangeProperties instead")
when 'marker-created'
Grim.deprecate("Use Decoration::onDidCreateMarker instead")
when 'markers-updated'
Grim.deprecate("Use Decoration::onDidUpdateMarkers instead")
else
Grim.deprecate("DisplayBuffer::on is deprecated. Use event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
emitDidChange: (eventProperties, refreshMarkers=true) ->
if refreshMarkers
@pauseMarkerChangeEvents()
@refreshMarkerScreenPositions()
@emit 'changed', eventProperties
@emit 'changed', eventProperties if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', eventProperties
@resumeMarkerChangeEvents()
@ -277,7 +251,11 @@ class DisplayBuffer extends Model
getScrollTop: -> @scrollTop
setScrollTop: (scrollTop) ->
@scrollTop = Math.round(Math.max(0, Math.min(@getMaxScrollTop(), scrollTop)))
scrollTop = Math.round(Math.max(0, Math.min(@getMaxScrollTop(), scrollTop)))
unless scrollTop is @scrollTop
@scrollTop = scrollTop
@emitter.emit 'did-change-scroll-top', @scrollTop
@scrollTop
getMaxScrollTop: ->
@getScrollHeight() - @getClientHeight()
@ -289,7 +267,11 @@ class DisplayBuffer extends Model
getScrollLeft: -> @scrollLeft
setScrollLeft: (scrollLeft) ->
@scrollLeft = Math.round(Math.max(0, Math.min(@getScrollWidth() - @getClientWidth(), scrollLeft)))
scrollLeft = Math.round(Math.max(0, Math.min(@getScrollWidth() - @getClientWidth(), scrollLeft)))
unless scrollLeft is @scrollLeft
@scrollLeft = scrollLeft
@emitter.emit 'did-change-scroll-left', @scrollLeft
@scrollLeft
getMaxScrollLeft: ->
@getScrollWidth() - @getClientWidth()
@ -336,7 +318,7 @@ class DisplayBuffer extends Model
characterWidthsChanged: ->
@computeScrollWidth()
@emit 'character-widths-changed', @scopedCharacterWidthsChangeCount
@emit 'character-widths-changed', @scopedCharacterWidthsChangeCount if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-character-widths', @scopedCharacterWidthsChangeCount
clearScopedCharWidths: ->
@ -454,7 +436,7 @@ class DisplayBuffer extends Model
@softWrapped = softWrapped
@updateWrappedScreenLines()
softWrapped = @isSoftWrapped()
@emit 'soft-wrap-changed', softWrapped
@emit 'soft-wrap-changed', softWrapped if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-soft-wrapped', softWrapped
softWrapped
else
@ -934,11 +916,11 @@ class DisplayBuffer extends Model
decorateMarker: (marker, decorationParams) ->
marker = @getMarker(marker.id)
decoration = new Decoration(marker, this, decorationParams)
@subscribe decoration.onDidDestroy => @removeDecoration(decoration)
@disposables.add decoration.onDidDestroy => @removeDecoration(decoration)
@decorationsByMarkerId[marker.id] ?= []
@decorationsByMarkerId[marker.id].push(decoration)
@decorationsById[decoration.id] = decoration
@emit 'decoration-added', decoration
@emit 'decoration-added', decoration if Grim.includeDeprecatedAPIs
@emitter.emit 'did-add-decoration', decoration
decoration
@ -950,7 +932,7 @@ class DisplayBuffer extends Model
if index > -1
decorations.splice(index, 1)
delete @decorationsById[decoration.id]
@emit 'decoration-removed', decoration
@emit 'decoration-removed', decoration if Grim.includeDeprecatedAPIs
@emitter.emit 'did-remove-decoration', decoration
delete @decorationsByMarkerId[marker.id] if decorations.length is 0
@ -1102,7 +1084,7 @@ class DisplayBuffer extends Model
resumeMarkerChangeEvents: ->
marker.resumeChangeEvents() for marker in @getMarkers()
@emit 'markers-updated'
@emit 'markers-updated' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-update-markers'
refreshMarkerScreenPositions: ->
@ -1111,9 +1093,9 @@ class DisplayBuffer extends Model
return
destroyed: ->
marker.unsubscribe() for id, marker of @markers
marker.disposables.dispose() for id, marker of @markers
@scopedConfigSubscriptions.dispose()
@unsubscribe()
@disposables.dispose()
@tokenizedBuffer.destroy()
logLines: (start=0, end=@getLastRow()) ->
@ -1244,7 +1226,7 @@ class DisplayBuffer extends Model
if marker = @getMarker(textBufferMarker.id)
# The marker might have been removed in some other handler called before
# this one. Only emit when the marker still exists.
@emit 'marker-created', marker
@emit 'marker-created', marker if Grim.includeDeprecatedAPIs
@emitter.emit 'did-create-marker', marker
createFoldForMarker: (marker) ->
@ -1253,3 +1235,58 @@ class DisplayBuffer extends Model
foldForMarker: (marker) ->
@foldsByMarkerId[marker.id]
if Grim.includeDeprecatedAPIs
DisplayBuffer.properties
softWrapped: null
editorWidthInChars: null
lineHeightInPixels: null
defaultCharWidth: null
height: null
width: null
scrollTop: 0
scrollLeft: 0
scrollWidth: 0
verticalScrollbarWidth: 15
horizontalScrollbarHeight: 15
EmitterMixin = require('emissary').Emitter
DisplayBuffer::on = (eventName) ->
switch eventName
when 'changed'
Grim.deprecate("Use DisplayBuffer::onDidChange instead")
when 'grammar-changed'
Grim.deprecate("Use DisplayBuffer::onDidChangeGrammar instead")
when 'soft-wrap-changed'
Grim.deprecate("Use DisplayBuffer::onDidChangeSoftWrap instead")
when 'character-widths-changed'
Grim.deprecate("Use DisplayBuffer::onDidChangeCharacterWidths instead")
when 'decoration-added'
Grim.deprecate("Use DisplayBuffer::onDidAddDecoration instead")
when 'decoration-removed'
Grim.deprecate("Use DisplayBuffer::onDidRemoveDecoration instead")
when 'decoration-changed'
Grim.deprecate("Use decoration.getMarker().onDidChange() instead")
when 'decoration-updated'
Grim.deprecate("Use Decoration::onDidChangeProperties instead")
when 'marker-created'
Grim.deprecate("Use Decoration::onDidCreateMarker instead")
when 'markers-updated'
Grim.deprecate("Use Decoration::onDidUpdateMarkers instead")
else
Grim.deprecate("DisplayBuffer::on is deprecated. Use event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
else
DisplayBuffer::softWrapped = null
DisplayBuffer::editorWidthInChars = null
DisplayBuffer::lineHeightInPixels = null
DisplayBuffer::defaultCharWidth = null
DisplayBuffer::height = null
DisplayBuffer::width = null
DisplayBuffer::scrollTop = 0
DisplayBuffer::scrollLeft = 0
DisplayBuffer::scrollWidth = 0
DisplayBuffer::verticalScrollbarWidth = 15
DisplayBuffer::horizontalScrollbarHeight = 15

View File

@ -1,11 +1,10 @@
{basename, join} = require 'path'
_ = require 'underscore-plus'
EmitterMixin = require('emissary').Emitter
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
fs = require 'fs-plus'
GitUtils = require 'git-utils'
{deprecate} = require 'grim'
{includeDeprecatedAPIs, deprecate} = require 'grim'
Task = require './task'
@ -43,8 +42,6 @@ Task = require './task'
# ```
module.exports =
class GitRepository
EmitterMixin.includeInto(this)
@exists: (path) ->
if git = @open(path)
git.destroy()
@ -155,16 +152,6 @@ class GitRepository
onDidChangeStatuses: (callback) ->
@emitter.on 'did-change-statuses', callback
on: (eventName) ->
switch eventName
when 'status-changed'
deprecate 'Use GitRepository::onDidChangeStatus instead'
when 'statuses-changed'
deprecate 'Use GitRepository::onDidChangeStatuses instead'
else
deprecate 'GitRepository::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
###
Section: Repository Details
###
@ -252,9 +239,6 @@ class GitRepository
# * `path` (optional) {String} path in the repository to get this information
# for, only needed if the repository has submodules.
getOriginURL: (path) -> @getConfigValue('remote.origin.url', path)
getOriginUrl: (path) ->
deprecate 'Use ::getOriginURL instead.'
@getOriginURL(path)
# Public: Returns the upstream branch for the current HEAD, or null if there
# is no upstream branch for the current HEAD.
@ -329,7 +313,7 @@ class GitRepository
else
delete @statuses[relativePath]
if currentPathStatus isnt pathStatus
@emit 'status-changed', path, pathStatus
@emit 'status-changed', path, pathStatus if includeDeprecatedAPIs
@emitter.emit 'did-change-status', {path, pathStatus}
pathStatus
@ -490,5 +474,23 @@ class GitRepository
submoduleRepo.upstream = submodules[submodulePath]?.upstream ? {ahead: 0, behind: 0}
unless statusesUnchanged
@emit 'statuses-changed'
@emit 'statuses-changed' if includeDeprecatedAPIs
@emitter.emit 'did-change-statuses'
if includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(GitRepository)
GitRepository::on = (eventName) ->
switch eventName
when 'status-changed'
deprecate 'Use GitRepository::onDidChangeStatus instead'
when 'statuses-changed'
deprecate 'Use GitRepository::onDidChangeStatuses instead'
else
deprecate 'GitRepository::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
GitRepository::getOriginUrl = (path) ->
deprecate 'Use ::getOriginURL instead.'
@getOriginURL(path)

View File

@ -1,14 +1,6 @@
_ = require 'underscore-plus'
{deprecate} = require 'grim'
{specificity} = require 'clear-cut'
{Subscriber} = require 'emissary'
{Emitter} = require 'event-kit'
{includeDeprecatedAPIs, deprecate} = require 'grim'
FirstMate = require 'first-mate'
{ScopeSelector} = FirstMate
ScopedPropertyStore = require 'scoped-property-store'
PropertyAccessors = require 'property-accessors'
{$, $$} = require './space-pen-extensions'
Token = require './token'
# Extended: Syntax class holding the grammars used for tokenizing.
@ -19,16 +11,12 @@ Token = require './token'
# language-specific comment regexes. See {::getProperty} for more details.
module.exports =
class GrammarRegistry extends FirstMate.GrammarRegistry
PropertyAccessors.includeInto(this)
Subscriber.includeInto(this)
@deserialize: ({grammarOverridesByPath}) ->
grammarRegistry = new GrammarRegistry()
grammarRegistry.grammarOverridesByPath = grammarOverridesByPath
grammarRegistry
atom.deserializers.add(this)
atom.deserializers.add(name: 'Syntax', deserialize: @deserialize) # Support old serialization
constructor: ->
super(maxTokensPerLine: 100)
@ -49,28 +37,38 @@ class GrammarRegistry extends FirstMate.GrammarRegistry
# Returns a {Grammar}, never null.
selectGrammar: (filePath, fileContents) -> super
clearObservers: ->
@off() if includeDeprecatedAPIs
@emitter = new Emitter
if includeDeprecatedAPIs
PropertyAccessors = require 'property-accessors'
PropertyAccessors.includeInto(GrammarRegistry)
{Subscriber} = require 'emissary'
Subscriber.includeInto(GrammarRegistry)
# Support old serialization
atom.deserializers.add(name: 'Syntax', deserialize: GrammarRegistry.deserialize)
# Deprecated: Used by settings-view to display snippets for packages
@::accessor 'propertyStore', ->
GrammarRegistry::accessor 'propertyStore', ->
deprecate("Do not use this. Use a public method on Config")
atom.config.scopedSettingsStore
addProperties: (args...) ->
GrammarRegistry::addProperties = (args...) ->
args.unshift(null) if args.length == 2
deprecate 'Consider using atom.config.set() instead. A direct (but private) replacement is available at atom.config.addScopedSettings().'
atom.config.addScopedSettings(args...)
removeProperties: (name) ->
GrammarRegistry::removeProperties = (name) ->
deprecate 'atom.config.addScopedSettings() now returns a disposable you can call .dispose() on'
atom.config.scopedSettingsStore.removeProperties(name)
getProperty: (scope, keyPath) ->
GrammarRegistry::getProperty = (scope, keyPath) ->
deprecate 'A direct (but private) replacement is available at atom.config.getRawScopedValue().'
atom.config.getRawScopedValue(scope, keyPath)
propertiesForScope: (scope, keyPath) ->
GrammarRegistry::propertiesForScope = (scope, keyPath) ->
deprecate 'Use atom.config.getAll instead.'
atom.config.settingsForScopeDescriptor(scope, keyPath)
clearObservers: ->
@off()
@emitter = new Emitter

View File

@ -3,13 +3,14 @@ path = require 'path'
KeymapManager = require 'atom-keymap'
CSON = require 'season'
{jQuery} = require 'space-pen'
Grim = require 'grim'
KeymapManager::onDidLoadBundledKeymaps = (callback) ->
@emitter.on 'did-load-bundled-keymaps', callback
KeymapManager::loadBundledKeymaps = ->
@loadKeymap(path.join(@resourcePath, 'keymaps'))
@emit 'bundled-keymaps-loaded'
@emit 'bundled-keymaps-loaded' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-load-bundled-keymaps'
KeymapManager::getUserKeymapPath = ->

View File

@ -1,8 +1,5 @@
{Range} = require 'text-buffer'
_ = require 'underscore-plus'
{Subscriber} = require 'emissary'
EmitterMixin = require('emissary').Emitter
{Emitter} = require 'event-kit'
{CompositeDisposable, Emitter} = require 'event-kit'
Grim = require 'grim'
# Essential: Represents a buffer annotation that remains logically stationary
@ -45,9 +42,6 @@ Grim = require 'grim'
# See {TextEditor::markBufferRange} for usage.
module.exports =
class Marker
EmitterMixin.includeInto(this)
Subscriber.includeInto(this)
bufferMarkerSubscription: null
oldHeadBufferPosition: null
oldHeadScreenPosition: null
@ -62,6 +56,7 @@ class Marker
constructor: ({@bufferMarker, @displayBuffer}) ->
@emitter = new Emitter
@disposables = new CompositeDisposable
@id = @bufferMarker.id
@oldHeadBufferPosition = @getHeadBufferPosition()
@oldHeadScreenPosition = @getHeadScreenPosition()
@ -69,14 +64,14 @@ class Marker
@oldTailScreenPosition = @getTailScreenPosition()
@wasValid = @isValid()
@subscribe @bufferMarker.onDidDestroy => @destroyed()
@subscribe @bufferMarker.onDidChange (event) => @notifyObservers(event)
@disposables.add @bufferMarker.onDidDestroy => @destroyed()
@disposables.add @bufferMarker.onDidChange (event) => @notifyObservers(event)
# Essential: Destroys the marker, causing it to emit the 'destroyed' event. Once
# destroyed, a marker cannot be restored by undo/redo operations.
destroy: ->
@bufferMarker.destroy()
@unsubscribe()
@disposables.dispose()
# Essential: Creates and returns a new {Marker} with the same properties as this
# marker.
@ -118,17 +113,6 @@ class Marker
onDidDestroy: (callback) ->
@emitter.on 'did-destroy', callback
on: (eventName) ->
switch eventName
when 'changed'
Grim.deprecate("Use Marker::onDidChange instead")
when 'destroyed'
Grim.deprecate("Use Marker::onDidDestroy instead")
else
Grim.deprecate("Marker::on is deprecated. Use documented event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
###
Section: Marker Details
###
@ -161,9 +145,6 @@ class Marker
# the marker.
getProperties: ->
@bufferMarker.getProperties()
getAttributes: ->
Grim.deprecate 'Use Marker::getProperties instead'
@getProperties()
# Essential: Merges an {Object} containing new properties into the marker's
# existing properties.
@ -171,16 +152,10 @@ class Marker
# * `properties` {Object}
setProperties: (properties) ->
@bufferMarker.setProperties(properties)
setAttributes: (properties) ->
Grim.deprecate 'Use Marker::getProperties instead'
@setProperties(properties)
matchesProperties: (attributes) ->
attributes = @displayBuffer.translateToBufferMarkerParams(attributes)
@bufferMarker.matchesParams(attributes)
matchesAttributes: (attributes) ->
Grim.deprecate 'Use Marker::matchesProperties instead'
@matchesProperties(attributes)
###
Section: Comparing to other markers
@ -344,7 +319,7 @@ class Marker
destroyed: ->
delete @displayBuffer.markers[@id]
@emit 'destroyed'
@emit 'destroyed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-destroy'
@emitter.dispose()
@ -375,7 +350,7 @@ class Marker
if @deferredChangeEvents?
@deferredChangeEvents.push(changeEvent)
else
@emit 'changed', changeEvent
@emit 'changed', changeEvent if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', changeEvent
@oldHeadBufferPosition = newHeadBufferPosition
@ -392,9 +367,36 @@ class Marker
@deferredChangeEvents = null
for event in deferredChangeEvents
@emit 'changed', event
@emit 'changed', event if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', event
return
getPixelRange: ->
@displayBuffer.pixelRangeForScreenRange(@getScreenRange(), false)
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(Marker)
Marker::on = (eventName) ->
switch eventName
when 'changed'
Grim.deprecate("Use Marker::onDidChange instead")
when 'destroyed'
Grim.deprecate("Use Marker::onDidDestroy instead")
else
Grim.deprecate("Marker::on is deprecated. Use documented event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
Marker::getAttributes = ->
Grim.deprecate 'Use Marker::getProperties instead'
@getProperties()
Marker::setAttributes = (properties) ->
Grim.deprecate 'Use Marker::setProperties instead'
@setProperties(properties)
Marker::matchesAttributes = (attributes) ->
Grim.deprecate 'Use Marker::matchesProperties instead'
@matchesProperties(attributes)

34
src/model.coffee Normal file
View File

@ -0,0 +1,34 @@
Grim = require 'grim'
if Grim.includeDeprecatedAPIs
module.exports = require('theorist').Model
return
PropertyAccessors = require 'property-accessors'
nextInstanceId = 1
module.exports =
class Model
PropertyAccessors.includeInto(this)
@resetNextInstanceId: -> nextInstanceId = 1
alive: true
constructor: (params) ->
@assignId(params?.id)
assignId: (id) ->
@id ?= id ? nextInstanceId++
@::advisedAccessor 'id',
set: (id) -> nextInstanceId = id + 1 if id >= nextInstanceId
destroy: ->
return unless @isAlive()
@alive = false
@destroyed?()
isAlive: -> @alive
isDestroyed: -> not @isAlive()

View File

@ -1,7 +1,6 @@
path = require 'path'
_ = require 'underscore-plus'
EmitterMixin = require('emissary').Emitter
{Emitter} = require 'event-kit'
fs = require 'fs-plus'
Q = require 'q'
@ -28,8 +27,6 @@ ThemePackage = require './theme-package'
# settings and also by calling `enablePackage()/disablePackage()`.
module.exports =
class PackageManager
EmitterMixin.includeInto(this)
constructor: ({configDirPath, @devMode, safeMode, @resourcePath}) ->
@emitter = new Emitter
@packageDirPaths = []
@ -57,11 +54,6 @@ class PackageManager
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidLoadInitialPackages: (callback) ->
@emitter.on 'did-load-initial-packages', callback
@emitter.on 'did-load-all', callback # TODO: Remove once deprecated pre-1.0 APIs are gone
onDidLoadAll: (callback) ->
Grim.deprecate("Use `::onDidLoadInitialPackages` instead.")
@onDidLoadInitialPackages(callback)
# Public: Invoke the given callback when all packages have been activated.
#
@ -70,11 +62,6 @@ class PackageManager
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidActivateInitialPackages: (callback) ->
@emitter.on 'did-activate-initial-packages', callback
@emitter.on 'did-activate-all', callback # TODO: Remove once deprecated pre-1.0 APIs are gone
onDidActivateAll: (callback) ->
Grim.deprecate("Use `::onDidActivateInitialPackages` instead.")
@onDidActivateInitialPackages(callback)
# Public: Invoke the given callback when a package is activated.
#
@ -112,16 +99,6 @@ class PackageManager
onDidUnloadPackage: (callback) ->
@emitter.on 'did-unload-package', callback
on: (eventName) ->
switch eventName
when 'loaded'
Grim.deprecate 'Use PackageManager::onDidLoadInitialPackages instead'
when 'activated'
Grim.deprecate 'Use PackageManager::onDidActivateInitialPackages instead'
else
Grim.deprecate 'PackageManager::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
###
Section: Package system data
###
@ -331,7 +308,7 @@ class PackageManager
packagePaths = packagePaths.filter (packagePath) => not @isPackageDisabled(path.basename(packagePath))
packagePaths = _.uniq packagePaths, (packagePath) -> path.basename(packagePath)
@loadPackage(packagePath) for packagePath in packagePaths
@emit 'loaded'
@emit 'loaded' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-load-initial-packages'
loadPackage: (nameOrPath) ->
@ -380,7 +357,7 @@ class PackageManager
packages = @getLoadedPackagesForTypes(types)
promises = promises.concat(activator.activatePackages(packages))
Q.all(promises).then =>
@emit 'activated'
@emit 'activated' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-activate-initial-packages'
# another type of package manager can handle other package types.
@ -432,3 +409,25 @@ class PackageManager
stack = "#{error.stack}\n at #{metadataPath}:1:1"
message = "Failed to load the #{path.basename(packagePath)} package"
atom.notifications.addError(message, {stack, detail, dismissable: true})
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(PackageManager)
PackageManager::on = (eventName) ->
switch eventName
when 'loaded'
Grim.deprecate 'Use PackageManager::onDidLoadInitialPackages instead'
when 'activated'
Grim.deprecate 'Use PackageManager::onDidActivateInitialPackages instead'
else
Grim.deprecate 'PackageManager::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
PackageManager::onDidLoadAll = (callback) ->
Grim.deprecate("Use `::onDidLoadInitialPackages` instead.")
@onDidLoadInitialPackages(callback)
PackageManager::onDidActivateAll = (callback) ->
Grim.deprecate("Use `::onDidActivateInitialPackages` instead.")
@onDidActivateInitialPackages(callback)

View File

@ -4,10 +4,9 @@ _ = require 'underscore-plus'
async = require 'async'
CSON = require 'season'
fs = require 'fs-plus'
EmitterMixin = require('emissary').Emitter
{Emitter, CompositeDisposable} = require 'event-kit'
Q = require 'q'
{deprecate} = require 'grim'
{includeDeprecatedAPIs, deprecate} = require 'grim'
ModuleCache = require './module-cache'
ScopedProperties = require './scoped-properties'
@ -21,8 +20,6 @@ catch error
# stylesheets, keymaps, grammar, editor properties, and menus.
module.exports =
class Package
EmitterMixin.includeInto(this)
@isBundledPackagePath: (packagePath) ->
if atom.packages.devMode
return false unless atom.packages.resourcePath.startsWith("#{process.resourcesPath}#{path.sep}")
@ -43,11 +40,11 @@ class Package
metadata ?= {}
metadata.name = packageName
if metadata.stylesheetMain?
if includeDeprecatedAPIs and metadata.stylesheetMain?
deprecate("Use the `mainStyleSheet` key instead of `stylesheetMain` in the `package.json` of `#{packageName}`", {packageName})
metadata.mainStyleSheet = metadata.stylesheetMain
if metadata.stylesheets?
if includeDeprecatedAPIs and metadata.stylesheets?
deprecate("Use the `styleSheets` key instead of `stylesheets` in the `package.json` of `#{packageName}`", {packageName})
metadata.styleSheets = metadata.stylesheets
@ -87,14 +84,6 @@ class Package
onDidDeactivate: (callback) ->
@emitter.on 'did-deactivate', callback
on: (eventName) ->
switch eventName
when 'deactivated'
deprecate 'Use Package::onDidDeactivate instead'
else
deprecate 'Package::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
###
Section: Instance Methods
###
@ -174,7 +163,7 @@ class Package
if @mainModule?
if @mainModule.config? and typeof @mainModule.config is 'object'
atom.config.setSchema @name, {type: 'object', properties: @mainModule.config}
else if @mainModule.configDefaults? and typeof @mainModule.configDefaults is 'object'
else if includeDeprecatedAPIs and @mainModule.configDefaults? and typeof @mainModule.configDefaults is 'object'
deprecate """Use a config schema instead. See the configuration section
of https://atom.io/docs/latest/hacking-atom-package-word-count and
https://atom.io/docs/api/latest/Config for more details"""
@ -268,7 +257,7 @@ class Package
[stylesheetPath, atom.themes.loadStylesheet(stylesheetPath, true)]
getStylesheetsPath: ->
if fs.isDirectorySync(path.join(@path, 'stylesheets'))
if includeDeprecatedAPIs and fs.isDirectorySync(path.join(@path, 'stylesheets'))
deprecate("Store package style sheets in the `styles/` directory instead of `stylesheets/` in the `#{@name}` package", packageName: @name)
path.join(@path, 'stylesheets')
else
@ -339,7 +328,7 @@ class Package
deferred = Q.defer()
if fs.isDirectorySync(path.join(@path, 'scoped-properties'))
if includeDeprecatedAPIs and fs.isDirectorySync(path.join(@path, 'scoped-properties'))
settingsDirPath = path.join(@path, 'scoped-properties')
deprecate("Store package settings files in the `settings/` directory instead of `scoped-properties/`", packageName: @name)
else
@ -367,7 +356,7 @@ class Package
@mainModule?.deactivate?()
catch e
console.error "Error deactivating package '#{@name}'", e.stack
@emit 'deactivated'
@emit 'deactivated' if includeDeprecatedAPIs
@emitter.emit 'did-deactivate'
deactivateConfig: ->
@ -467,7 +456,7 @@ class Package
else if _.isArray(commands)
@activationCommands[selector].push(commands...)
if @metadata.activationEvents?
if includeDeprecatedAPIs and @metadata.activationEvents?
deprecate """
Use `activationCommands` instead of `activationEvents` in your package.json
Commands should be grouped by selector as follows:
@ -585,3 +574,15 @@ class Package
stack = error.stack ? error
atom.notifications.addFatalError(message, {stack, detail, dismissable: true})
if includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(Package)
Package::on = (eventName) ->
switch eventName
when 'deactivated'
deprecate 'Use Package::onDidDeactivate instead'
else
deprecate 'Package::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)

View File

@ -1,7 +1,7 @@
{Model} = require 'theorist'
{Emitter, CompositeDisposable} = require 'event-kit'
{flatten} = require 'underscore-plus'
Serializable = require 'serializable'
Model = require './model'
module.exports =
class PaneAxis extends Model

View File

@ -1,4 +1,5 @@
{CompositeDisposable} = require 'event-kit'
Grim = require 'grim'
{callAttachHooks} = require './space-pen-extensions'
PaneContainerView = null
_ = require 'underscore-plus'
@ -8,12 +9,14 @@ class PaneContainerElement extends HTMLElement
createdCallback: ->
@subscriptions = new CompositeDisposable
@classList.add 'panes'
PaneContainerView ?= require './pane-container-view'
@__spacePenView = new PaneContainerView(this)
if Grim.includeDeprecatedAPIs
PaneContainerView ?= require './pane-container-view'
@__spacePenView = new PaneContainerView(this)
initialize: (@model) ->
@subscriptions.add @model.observeRoot(@rootChanged.bind(this))
@__spacePenView.setModel(@model)
@__spacePenView.setModel(@model) if Grim.includeDeprecatedAPIs
this
rootChanged: (root) ->

View File

@ -1,7 +1,8 @@
{find, flatten} = require 'underscore-plus'
{Model} = require 'theorist'
Grim = require 'grim'
{Emitter, CompositeDisposable} = require 'event-kit'
Serializable = require 'serializable'
Model = require './model'
Pane = require './pane'
PaneElement = require './pane-element'
PaneContainerElement = require './pane-container-element'
@ -18,19 +19,14 @@ class PaneContainer extends Model
@version: 1
@properties
activePane: null
root: null
@behavior 'activePaneItem', ->
@$activePane
.switch((activePane) -> activePane?.$activeItem)
.distinctUntilChanged()
constructor: (params) ->
super
unless Grim.includeDeprecatedAPIs
@activePane = params?.activePane
@emitter = new Emitter
@subscriptions = new CompositeDisposable
@ -236,3 +232,12 @@ class PaneContainer extends Model
removedPaneItem: (item) ->
@itemRegistry.removeItem(item)
if Grim.includeDeprecatedAPIs
PaneContainer.properties
activePane: null
PaneContainer.behavior 'activePaneItem', ->
@$activePane
.switch((activePane) -> activePane?.$activeItem)
.distinctUntilChanged()

View File

@ -1,6 +1,7 @@
{CompositeDisposable} = require 'event-kit'
Grim = require 'grim'
{$, callAttachHooks, callRemoveHooks} = require './space-pen-extensions'
PaneView = require './pane-view'
PaneView = null
class PaneElement extends HTMLElement
attached: false
@ -12,7 +13,7 @@ class PaneElement extends HTMLElement
@initializeContent()
@subscribeToDOMEvents()
@createSpacePenShim()
@createSpacePenShim() if Grim.includeDeprecatedAPIs
attachedCallback: ->
@attached = true
@ -41,6 +42,7 @@ class PaneElement extends HTMLElement
@addEventListener 'blur', handleBlur, true
createSpacePenShim: ->
PaneView ?= require './pane-view'
@__spacePenView = new PaneView(this)
initialize: (@model) ->
@ -49,7 +51,7 @@ class PaneElement extends HTMLElement
@subscriptions.add @model.observeActiveItem(@activeItemChanged.bind(this))
@subscriptions.add @model.onDidRemoveItem(@itemRemoved.bind(this))
@subscriptions.add @model.onDidDestroy(@paneDestroyed.bind(this))
@__spacePenView.setModel(@model)
@__spacePenView.setModel(@model) if Grim.includeDeprecatedAPIs
this
getModel: -> @model

View File

@ -1,11 +1,10 @@
{find, compact, extend, last} = require 'underscore-plus'
{Model} = require 'theorist'
{Emitter} = require 'event-kit'
Serializable = require 'serializable'
Grim = require 'grim'
Model = require './model'
PaneAxis = require './pane-axis'
TextEditor = require './text-editor'
PaneView = null
# Extended: A container for presenting content in the center of the workspace.
# Panes can contain multiple items, one of which is *active* at a given time.
@ -16,23 +15,13 @@ class Pane extends Model
atom.deserializers.add(this)
Serializable.includeInto(this)
@properties
container: undefined
activeItem: undefined
focused: false
# Public: Only one pane is considered *active* at a time. A pane is activated
# when it is focused, and when focus returns to the pane container after
# moving to another element such as a panel, it returns to the active pane.
@behavior 'active', ->
@$container
.switch((container) -> container?.$activePane)
.map((activePane) => activePane is this)
.distinctUntilChanged()
constructor: (params) ->
super
unless Grim.includeDeprecatedAPIs
@container = params?.container
@activeItem = params?.activeItem
@emitter = new Emitter
@itemSubscriptions = new WeakMap
@items = []
@ -44,7 +33,7 @@ class Pane extends Model
serializeParams: ->
if typeof @activeItem?.getURI is 'function'
activeItemURI = @activeItem.getURI()
else if typeof @activeItem?.getUri is 'function'
else if Grim.includeDeprecatedAPIs and typeof @activeItem?.getUri is 'function'
activeItemURI = @activeItem.getUri()
id: @id
@ -60,7 +49,7 @@ class Pane extends Model
params.activeItem = find params.items, (item) ->
if typeof item.getURI is 'function'
itemURI = item.getURI()
else if typeof item.getUri is 'function'
else if Grim.includeDeprecatedAPIs and typeof item.getUri is 'function'
itemURI = item.getUri()
itemURI is activeItemURI
@ -203,39 +192,6 @@ class Pane extends Model
onWillDestroyItem: (callback) ->
@emitter.on 'will-destroy-item', callback
on: (eventName) ->
switch eventName
when 'activated'
Grim.deprecate("Use Pane::onDidActivate instead")
when 'destroyed'
Grim.deprecate("Use Pane::onDidDestroy instead")
when 'item-added'
Grim.deprecate("Use Pane::onDidAddItem instead")
when 'item-removed'
Grim.deprecate("Use Pane::onDidRemoveItem instead")
when 'item-moved'
Grim.deprecate("Use Pane::onDidMoveItem instead")
when 'before-item-destroyed'
Grim.deprecate("Use Pane::onWillDestroyItem instead")
else
Grim.deprecate("Subscribing via ::on is deprecated. Use documented event subscription methods instead.")
super
behavior: (behaviorName) ->
switch behaviorName
when 'active'
Grim.deprecate("The $active behavior property is deprecated. Use ::observeActive or ::onDidChangeActive instead.")
when 'container'
Grim.deprecate("The $container behavior property is deprecated.")
when 'activeItem'
Grim.deprecate("The $activeItem behavior property is deprecated. Use ::observeActiveItem or ::onDidChangeActiveItem instead.")
when 'focused'
Grim.deprecate("The $focused behavior property is deprecated.")
else
Grim.deprecate("Pane::behavior is deprecated. Use event subscription methods instead.")
super
# Called by the view layer to indicate that the pane has gained focus.
focus: ->
@focused = true
@ -347,11 +303,11 @@ class Pane extends Model
if typeof item.onDidDestroy is 'function'
@itemSubscriptions.set item, item.onDidDestroy => @removeItem(item, true)
else if typeof item.on is 'function'
else if Grim.includeDeprecatedAPIs and typeof item.on is 'function'
@subscribe item, 'destroyed', => @removeItem(item, true)
@items.splice(index, 0, item)
@emit 'item-added', item, index
@emit 'item-added', item, index if Grim.includeDeprecatedAPIs
@emitter.emit 'did-add-item', {item, index}
@setActiveItem(item) unless @getActiveItem()?
item
@ -374,7 +330,7 @@ class Pane extends Model
index = @items.indexOf(item)
return if index is -1
if typeof item.on is 'function'
if Grim.includeDeprecatedAPIs and typeof item.on is 'function'
@unsubscribe item
@unsubscribeFromItem(item)
@ -386,7 +342,7 @@ class Pane extends Model
else
@activatePreviousItem()
@items.splice(index, 1)
@emit 'item-removed', item, index, destroyed
@emit 'item-removed', item, index, destroyed if Grim.includeDeprecatedAPIs
@emitter.emit 'did-remove-item', {item, index, destroyed}
@container?.didDestroyPaneItem({item, index, pane: this}) if destroyed
@destroy() if @items.length is 0 and atom.config.get('core.destroyEmptyPanes')
@ -399,7 +355,7 @@ class Pane extends Model
oldIndex = @items.indexOf(item)
@items.splice(oldIndex, 1)
@items.splice(newIndex, 0, item)
@emit 'item-moved', item, newIndex
@emit 'item-moved', item, newIndex if Grim.includeDeprecatedAPIs
@emitter.emit 'did-move-item', {item, oldIndex, newIndex}
# Public: Move the given item to the given index on another pane.
@ -427,7 +383,7 @@ class Pane extends Model
destroyItem: (item) ->
index = @items.indexOf(item)
if index isnt -1
@emit 'before-item-destroyed', item
@emit 'before-item-destroyed', item if Grim.includeDeprecatedAPIs
@emitter.emit 'will-destroy-item', {item, index}
@container?.willDestroyPaneItem({item, index, pane: this})
if @promptToSaveItem(item)
@ -535,10 +491,6 @@ class Pane extends Model
itemUri is uri
itemForUri: (uri) ->
Grim.deprecate("Use `::itemForURI` instead.")
@itemForURI(uri)
# Public: Activate the first item that matches the given URI.
#
# Returns a {Boolean} indicating whether an item matching the URI was found.
@ -549,10 +501,6 @@ class Pane extends Model
else
false
activateItemForUri: (uri) ->
Grim.deprecate("Use `::activateItemForURI` instead.")
@activateItemForURI(uri)
copyActiveItem: ->
if @activeItem?
@activeItem.copy?() ? atom.deserializers.deserialize(@activeItem.serialize())
@ -572,7 +520,7 @@ class Pane extends Model
throw new Error("Pane has been destroyed") if @isDestroyed()
@container?.setActivePane(this)
@emit 'activated'
@emit 'activated' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-activate'
# Public: Close the pane and destroy all its items.
@ -701,3 +649,60 @@ class Pane extends Model
atom.notifications.addWarning("Unable to save file: A directory in the path '#{fileName}' could not be written to")
else
throw error
if Grim.includeDeprecatedAPIs
Pane.properties
container: undefined
activeItem: undefined
focused: false
Pane.behavior 'active', ->
@$container
.switch((container) -> container?.$activePane)
.map((activePane) => activePane is this)
.distinctUntilChanged()
Pane::on = (eventName) ->
switch eventName
when 'activated'
Grim.deprecate("Use Pane::onDidActivate instead")
when 'destroyed'
Grim.deprecate("Use Pane::onDidDestroy instead")
when 'item-added'
Grim.deprecate("Use Pane::onDidAddItem instead")
when 'item-removed'
Grim.deprecate("Use Pane::onDidRemoveItem instead")
when 'item-moved'
Grim.deprecate("Use Pane::onDidMoveItem instead")
when 'before-item-destroyed'
Grim.deprecate("Use Pane::onWillDestroyItem instead")
else
Grim.deprecate("Subscribing via ::on is deprecated. Use documented event subscription methods instead.")
super
Pane::behavior = (behaviorName) ->
switch behaviorName
when 'active'
Grim.deprecate("The $active behavior property is deprecated. Use ::observeActive or ::onDidChangeActive instead.")
when 'container'
Grim.deprecate("The $container behavior property is deprecated.")
when 'activeItem'
Grim.deprecate("The $activeItem behavior property is deprecated. Use ::observeActiveItem or ::onDidChangeActiveItem instead.")
when 'focused'
Grim.deprecate("The $focused behavior property is deprecated.")
else
Grim.deprecate("Pane::behavior is deprecated. Use event subscription methods instead.")
super
Pane::itemForUri = (uri) ->
Grim.deprecate("Use `::itemForURI` instead.")
@itemForURI(uri)
Pane::activateItemForUri = (uri) ->
Grim.deprecate("Use `::activateItemForURI` instead.")
@activateItemForURI(uri)
else
Pane::container = undefined
Pane::activeItem = undefined
Pane::focused = undefined

View File

@ -4,15 +4,15 @@ url = require 'url'
_ = require 'underscore-plus'
fs = require 'fs-plus'
Q = require 'q'
{deprecate} = require 'grim'
{Model} = require 'theorist'
{includeDeprecatedAPIs, deprecate} = require 'grim'
{Subscriber} = require 'emissary'
{Emitter} = require 'event-kit'
DefaultDirectoryProvider = require './default-directory-provider'
Serializable = require 'serializable'
TextBuffer = require 'text-buffer'
Grim = require 'grim'
DefaultDirectoryProvider = require './default-directory-provider'
Model = require './model'
TextEditor = require './text-editor'
Task = require './task'
GitRepositoryProvider = require './git-repository-provider'
@ -25,12 +25,6 @@ class Project extends Model
atom.deserializers.add(this)
Serializable.includeInto(this)
@pathForRepositoryUrl: (repoUrl) ->
deprecate '::pathForRepositoryUrl will be removed. Please remove from your code.'
[repoName] = url.parse(repoUrl).path.split('/')[-1..]
repoName = repoName.replace(/\.git$/, '')
path.join(atom.config.get('core.projectHome'), repoName)
###
Section: Construction and Destruction
###
@ -73,7 +67,9 @@ class Project extends Model
@subscribeToBuffer(buffer) for buffer in @buffers
Grim.deprecate("Pass 'paths' array instead of 'path' to project constructor") if path?
if Grim.includeDeprecatedAPIs and path?
Grim.deprecate("Pass 'paths' array instead of 'path' to project constructor")
paths ?= _.compact([path])
@setPaths(paths)
@ -122,13 +118,6 @@ class Project extends Model
onDidAddBuffer: (callback) ->
@emitter.on 'did-add-buffer', callback
on: (eventName) ->
if eventName is 'path-changed'
Grim.deprecate("Use Project::onDidChangePaths instead")
else
Grim.deprecate("Project::on is deprecated. Use documented event subscription methods instead.")
super
###
Section: Accessing the git repository
###
@ -144,9 +133,6 @@ class Project extends Model
# project.repositoryForDirectory.bind(project)))
# ```
getRepositories: -> @repositories
getRepo: ->
Grim.deprecate("Use ::getRepositories instead")
@getRepositories()[0]
# Public: Get the repository for a given directory asynchronously.
#
@ -180,28 +166,23 @@ class Project extends Model
# Public: Get an {Array} of {String}s containing the paths of the project's
# directories.
getPaths: -> rootDirectory.getPath() for rootDirectory in @rootDirectories
getPath: ->
Grim.deprecate("Use ::getPaths instead")
@getPaths()[0]
# Public: Set the paths of the project's directories.
#
# * `projectPaths` {Array} of {String} paths.
setPaths: (projectPaths) ->
rootDirectory.off() for rootDirectory in @rootDirectories
if includeDeprecatedAPIs
rootDirectory.off() for rootDirectory in @rootDirectories
repository?.destroy() for repository in @repositories
@rootDirectories = []
@repositories = []
@addPath(projectPath, emitEvent: false) for projectPath in projectPaths
@emit "path-changed"
@emit "path-changed" if includeDeprecatedAPIs
@emitter.emit 'did-change-paths', projectPaths
setPath: (path) ->
Grim.deprecate("Use ::setPaths instead")
@setPaths([path])
# Public: Add a path to the project's list of root paths
#
# * `projectPath` {String} The path to the directory to add.
@ -226,7 +207,7 @@ class Project extends Model
@repositories.push(repo ? null)
unless options?.emitEvent is false
@emit "path-changed"
@emit "path-changed" if includeDeprecatedAPIs
@emitter.emit 'did-change-paths', @getPaths()
# Public: remove a path from the project's list of root paths.
@ -246,9 +227,9 @@ class Project extends Model
if indexToRemove?
[removedDirectory] = @rootDirectories.splice(indexToRemove, 1)
[removedRepository] = @repositories.splice(indexToRemove, 1)
removedDirectory.off()
removedDirectory.off() if includeDeprecatedAPIs
removedRepository?.destroy() unless removedRepository in @repositories
@emit "path-changed"
@emit "path-changed" if includeDeprecatedAPIs
@emitter.emit "did-change-paths", @getPaths()
true
else
@ -257,13 +238,6 @@ class Project extends Model
# Public: Get an {Array} of {Directory}s associated with this project.
getDirectories: ->
@rootDirectories
getRootDirectory: ->
Grim.deprecate("Use ::getDirectories instead")
@getDirectories()[0]
resolve: (uri) ->
Grim.deprecate("Use `Project::getDirectories()[0]?.resolve()` instead")
@resolvePath(uri)
resolvePath: (uri) ->
return unless uri
@ -329,18 +303,6 @@ class Project extends Model
contains: (pathToCheck) ->
@rootDirectories.some (dir) -> dir.contains(pathToCheck)
###
Section: Searching and Replacing
###
scan: (regex, options={}, iterator) ->
Grim.deprecate("Use atom.workspace.scan instead of atom.project.scan")
atom.workspace.scan(regex, options, iterator)
replace: (regex, replacementText, filePaths, iterator) ->
Grim.deprecate("Use atom.workspace.replace instead of atom.project.replace")
atom.workspace.replace(regex, replacementText, filePaths, iterator)
###
Section: Private
###
@ -365,12 +327,6 @@ class Project extends Model
@bufferForPath(filePath).then (buffer) =>
@buildEditorForBuffer(buffer, options)
# Deprecated
openSync: (filePath, options={}) ->
deprecate("Use Project::open instead")
filePath = @resolvePath(filePath)
@buildEditorForBuffer(@bufferForPathSync(filePath), options)
# Retrieves all the {TextBuffer}s in the project; that is, the
# buffers for all open files.
#
@ -439,7 +395,7 @@ class Project extends Model
addBufferAtIndex: (buffer, index, options={}) ->
@buffers.splice(index, 0, buffer)
@subscribeToBuffer(buffer)
@emit 'buffer-created', buffer
@emit 'buffer-created', buffer if includeDeprecatedAPIs
@emitter.emit 'did-add-buffer', buffer
buffer
@ -479,22 +435,65 @@ class Project extends Model
detail: error.message
dismissable: true
# Deprecated: delegate
registerOpener: (opener) ->
if includeDeprecatedAPIs
Project.pathForRepositoryUrl = (repoUrl) ->
deprecate '::pathForRepositoryUrl will be removed. Please remove from your code.'
[repoName] = url.parse(repoUrl).path.split('/')[-1..]
repoName = repoName.replace(/\.git$/, '')
path.join(atom.config.get('core.projectHome'), repoName)
Project::registerOpener = (opener) ->
deprecate("Use Workspace::addOpener instead")
atom.workspace.addOpener(opener)
# Deprecated: delegate
unregisterOpener: (opener) ->
Project::unregisterOpener = (opener) ->
deprecate("Call .dispose() on the Disposable returned from ::addOpener instead")
atom.workspace.unregisterOpener(opener)
# Deprecated: delegate
eachEditor: (callback) ->
Project::eachEditor = (callback) ->
deprecate("Use Workspace::observeTextEditors instead")
atom.workspace.observeTextEditors(callback)
# Deprecated: delegate
getEditors: ->
Project::getEditors = ->
deprecate("Use Workspace::getTextEditors instead")
atom.workspace.getTextEditors()
Project::on = (eventName) ->
if eventName is 'path-changed'
Grim.deprecate("Use Project::onDidChangePaths instead")
else
Grim.deprecate("Project::on is deprecated. Use documented event subscription methods instead.")
super
Project::getRepo = ->
Grim.deprecate("Use ::getRepositories instead")
@getRepositories()[0]
Project::getPath = ->
Grim.deprecate("Use ::getPaths instead")
@getPaths()[0]
Project::setPath = (path) ->
Grim.deprecate("Use ::setPaths instead")
@setPaths([path])
Project::getRootDirectory = ->
Grim.deprecate("Use ::getDirectories instead")
@getDirectories()[0]
Project::resolve = (uri) ->
Grim.deprecate("Use `Project::getDirectories()[0]?.resolve()` instead")
@resolvePath(uri)
Project::scan = (regex, options={}, iterator) ->
Grim.deprecate("Use atom.workspace.scan instead of atom.project.scan")
atom.workspace.scan(regex, options, iterator)
Project::replace = (regex, replacementText, filePaths, iterator) ->
Grim.deprecate("Use atom.workspace.replace instead of atom.project.replace")
atom.workspace.replace(regex, replacementText, filePaths, iterator)
Project::openSync = (filePath, options={}) ->
deprecate("Use Project::open instead")
filePath = @resolvePath(filePath)
@buildEditorForBuffer(@bufferForPathSync(filePath), options)

View File

@ -1,8 +1,8 @@
{Point, Range} = require 'text-buffer'
{Model} = require 'theorist'
{pick} = _ = require 'underscore-plus'
{Emitter} = require 'event-kit'
Grim = require 'grim'
Model = require './model'
NonWhitespaceRegExp = /\S/
@ -27,7 +27,7 @@ class Selection extends Model
unless @editor.isDestroyed()
@destroyed = true
@editor.removeSelection(this)
@emit 'destroyed'
@emit 'destroyed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-destroy'
@emitter.dispose()
@ -63,18 +63,6 @@ class Selection extends Model
onDidDestroy: (callback) ->
@emitter.on 'did-destroy', callback
on: (eventName) ->
switch eventName
when 'screen-range-changed'
Grim.deprecate("Use Selection::onDidChangeRange instead. Call ::getScreenRange() yourself in your callback if you need the range.")
when 'destroyed'
Grim.deprecate("Use Selection::onDidDestroy instead.")
else
Grim.deprecate("Selection::on is deprecated. Use documented event subscription methods instead.")
super
###
Section: Managing the selection range
###
@ -428,16 +416,6 @@ class Selection extends Model
@selectLeft() if @isEmpty() and not @editor.isFoldedAtScreenRow(@cursor.getScreenRow())
@deleteSelectedText()
# Deprecated: Use {::deleteToBeginningOfWord} instead.
backspaceToBeginningOfWord: ->
deprecate("Use Selection::deleteToBeginningOfWord() instead")
@deleteToBeginningOfWord()
# Deprecated: Use {::deleteToBeginningOfLine} instead.
backspaceToBeginningOfLine: ->
deprecate("Use Selection::deleteToBeginningOfLine() instead")
@deleteToBeginningOfLine()
# Public: Removes from the start of the selection to the beginning of the
# current word if the selection is empty otherwise it deletes the selection.
deleteToBeginningOfWord: ->
@ -766,7 +744,7 @@ class Selection extends Model
newScreenRange: @getScreenRange()
selection: this
@emit 'screen-range-changed', @getScreenRange() # old event
@emit 'screen-range-changed', @getScreenRange() if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-range'
@editor.selectionRangeChanged(eventObject)
@ -801,3 +779,25 @@ class Selection extends Model
getGoalScreenRange: ->
if goalScreenRange = @marker.getProperties().goalScreenRange
Range.fromObject(goalScreenRange)
if Grim.includeDeprecatedAPIs
Selection::on = (eventName) ->
switch eventName
when 'screen-range-changed'
Grim.deprecate("Use Selection::onDidChangeRange instead. Call ::getScreenRange() yourself in your callback if you need the range.")
when 'destroyed'
Grim.deprecate("Use Selection::onDidDestroy instead.")
else
Grim.deprecate("Selection::on is deprecated. Use documented event subscription methods instead.")
super
# Deprecated: Use {::deleteToBeginningOfWord} instead.
Selection::backspaceToBeginningOfWord = ->
deprecate("Use Selection::deleteToBeginningOfWord() instead")
@deleteToBeginningOfWord()
# Deprecated: Use {::deleteToBeginningOfLine} instead.
Selection::backspaceToBeginningOfLine = ->
deprecate("Use Selection::deleteToBeginningOfLine() instead")
@deleteToBeginningOfLine()

View File

@ -1,4 +1,5 @@
{Emitter, CompositeDisposable} = require 'event-kit'
{includeDeprecatedAPIs} = require 'grim'
class StylesElement extends HTMLElement
subscriptions: null
@ -18,7 +19,7 @@ class StylesElement extends HTMLElement
@styleElementClonesByOriginalElement = new WeakMap
attachedCallback: ->
if @context is 'atom-text-editor'
if includeDeprecatedAPIs and @context is 'atom-text-editor'
for styleElement in @children
@upgradeDeprecatedSelectors(styleElement)
@initialize()
@ -66,7 +67,7 @@ class StylesElement extends HTMLElement
@insertBefore(styleElementClone, insertBefore)
if @context is 'atom-text-editor'
if includeDeprecatedAPIs and @context is 'atom-text-editor'
@upgradeDeprecatedSelectors(styleElementClone)
@emitter.emit 'did-add-style-element', styleElementClone

View File

@ -152,9 +152,10 @@ class TextEditorComponent
if @editor.isAlive()
@updateParentViewFocusedClassIfNeeded()
@updateParentViewMiniClass()
@hostElement.__spacePenView.trigger 'cursor:moved' if cursorMoved
@hostElement.__spacePenView.trigger 'selection:changed' if selectionChanged
@hostElement.__spacePenView.trigger 'editor:display-updated'
if grim.includeDeprecatedAPIs
@hostElement.__spacePenView.trigger 'cursor:moved' if cursorMoved
@hostElement.__spacePenView.trigger 'selection:changed' if selectionChanged
@hostElement.__spacePenView.trigger 'editor:display-updated'
readAfterUpdateSync: =>
@linesComponent.measureCharactersInNewLines() if @isVisible() and not @newState.content.scrollingVertically
@ -747,15 +748,6 @@ class TextEditorComponent
setShowIndentGuide: (showIndentGuide) ->
atom.config.set("editor.showIndentGuide", showIndentGuide)
# Deprecated
setInvisibles: (invisibles={}) ->
grim.deprecate "Use config.set('editor.invisibles', invisibles) instead"
atom.config.set('editor.invisibles', invisibles)
# Deprecated
setShowInvisibles: (showInvisibles) ->
atom.config.set('editor.showInvisibles', showInvisibles)
setScrollSensitivity: (scrollSensitivity) =>
if scrollSensitivity = parseInt(scrollSensitivity)
@scrollSensitivity = Math.abs(scrollSensitivity) / 100
@ -788,3 +780,12 @@ class TextEditorComponent
updateParentViewMiniClass: ->
@hostElement.classList.toggle('mini', @editor.isMini())
@rootElement.classList.toggle('mini', @editor.isMini())
if grim.includeDeprecatedAPIs
TextEditorComponent::setInvisibles = (invisibles={}) ->
grim.deprecate "Use config.set('editor.invisibles', invisibles) instead"
atom.config.set('editor.invisibles', invisibles)
TextEditorComponent::setShowInvisibles = (showInvisibles) ->
grim.deprecate "Use config.set('editor.showInvisibles', showInvisibles) instead"
atom.config.set('editor.showInvisibles', showInvisibles)

View File

@ -3,6 +3,7 @@
Path = require 'path'
{defaults} = require 'underscore-plus'
TextBuffer = require 'text-buffer'
Grim = require 'grim'
TextEditor = require './text-editor'
TextEditorComponent = require './text-editor-component'
TextEditorView = null
@ -20,7 +21,7 @@ class TextEditorElement extends HTMLElement
createdCallback: ->
@emitter = new Emitter
@initializeContent()
@createSpacePenShim()
@createSpacePenShim() if Grim.includeDeprecatedAPIs
@addEventListener 'focus', @focused.bind(this)
@addEventListener 'blur', @blurred.bind(this)
@ -86,7 +87,7 @@ class TextEditorElement extends HTMLElement
@model.onDidChangeGrammar => @addGrammarScopeAttribute()
@model.onDidChangeEncoding => @addEncodingAttribute()
@model.onDidDestroy => @unmountComponent()
@__spacePenView.setModel(@model)
@__spacePenView.setModel(@model) if Grim.includeDeprecatedAPIs
@model
getModel: ->

View File

@ -2,14 +2,14 @@ _ = require 'underscore-plus'
path = require 'path'
Serializable = require 'serializable'
Delegator = require 'delegato'
{deprecate} = require 'grim'
{Model} = require 'theorist'
{includeDeprecatedAPIs, deprecate} = require 'grim'
EmitterMixin = require('emissary').Emitter
{CompositeDisposable, Emitter} = require 'event-kit'
{Point, Range} = TextBuffer = require 'text-buffer'
LanguageMode = require './language-mode'
DisplayBuffer = require './display-buffer'
Cursor = require './cursor'
Model = require './model'
Selection = require './selection'
TextMateScopeSelector = require('first-mate').ScopeSelector
{Directory} = require "pathwatcher"
@ -74,14 +74,11 @@ class TextEditor extends Model
'autoDecreaseIndentForBufferRow', 'toggleLineCommentForBufferRow', 'toggleLineCommentsForBufferRows',
toProperty: 'languageMode'
@delegatesProperties '$lineHeightInPixels', '$defaultCharWidth', '$height', '$width',
'$verticalScrollbarWidth', '$horizontalScrollbarHeight', '$scrollTop', '$scrollLeft',
toProperty: 'displayBuffer'
constructor: ({@softTabs, initialLine, initialColumn, tabLength, softWrapped, @displayBuffer, buffer, registerEditor, suppressCursorCreation, @mini, @placeholderText, @gutterVisible}) ->
super
@emitter = new Emitter
@disposables = new CompositeDisposable
@cursors = []
@selections = []
@ -108,11 +105,12 @@ class TextEditor extends Model
@setEncoding(atom.config.get('core.fileEncoding', scope: @getRootScopeDescriptor()))
@subscribe @$scrollTop, (scrollTop) =>
@emit 'scroll-top-changed', scrollTop
@disposables.add @displayBuffer.onDidChangeScrollTop (scrollTop) =>
@emit 'scroll-top-changed', scrollTop if includeDeprecatedAPIs
@emitter.emit 'did-change-scroll-top', scrollTop
@subscribe @$scrollLeft, (scrollLeft) =>
@emit 'scroll-left-changed', scrollLeft
@disposables.add @displayBuffer.onDidChangeScrollLeft (scrollLeft) =>
@emit 'scroll-left-changed', scrollLeft if includeDeprecatedAPIs
@emitter.emit 'did-change-scroll-left', scrollLeft
atom.workspace?.editorAdded(this) if registerEditor
@ -131,37 +129,39 @@ class TextEditor extends Model
subscribeToBuffer: ->
@buffer.retain()
@subscribe @buffer.onDidChangePath =>
@disposables.add @buffer.onDidChangePath =>
unless atom.project.getPaths().length > 0
atom.project.setPaths([path.dirname(@getPath())])
@emit "title-changed"
@emit "title-changed" if includeDeprecatedAPIs
@emitter.emit 'did-change-title', @getTitle()
@emit "path-changed"
@emit "path-changed" if includeDeprecatedAPIs
@emitter.emit 'did-change-path', @getPath()
@subscribe @buffer.onDidChangeEncoding =>
@disposables.add @buffer.onDidChangeEncoding =>
@emitter.emit 'did-change-encoding', @getEncoding()
@subscribe @buffer.onDidDestroy => @destroy()
@disposables.add @buffer.onDidDestroy => @destroy()
# TODO: remove these when we remove the deprecations. They are old events.
@subscribe @buffer.onDidStopChanging => @emit "contents-modified"
@subscribe @buffer.onDidConflict => @emit "contents-conflicted"
@subscribe @buffer.onDidChangeModified => @emit "modified-status-changed"
if includeDeprecatedAPIs
@subscribe @buffer.onDidStopChanging => @emit "contents-modified"
@subscribe @buffer.onDidConflict => @emit "contents-conflicted"
@subscribe @buffer.onDidChangeModified => @emit "modified-status-changed"
@preserveCursorPositionOnBufferReload()
subscribeToDisplayBuffer: ->
@subscribe @displayBuffer.onDidCreateMarker @handleMarkerCreated
@subscribe @displayBuffer.onDidUpdateMarkers => @mergeIntersectingSelections()
@subscribe @displayBuffer.onDidChangeGrammar => @handleGrammarChange()
@subscribe @displayBuffer.onDidTokenize => @handleTokenization()
@subscribe @displayBuffer.onDidChange (e) =>
@emit 'screen-lines-changed', e
@disposables.add @displayBuffer.onDidCreateMarker @handleMarkerCreated
@disposables.add @displayBuffer.onDidUpdateMarkers => @mergeIntersectingSelections()
@disposables.add @displayBuffer.onDidChangeGrammar => @handleGrammarChange()
@disposables.add @displayBuffer.onDidTokenize => @handleTokenization()
@disposables.add @displayBuffer.onDidChange (e) =>
@emit 'screen-lines-changed', e if includeDeprecatedAPIs
@emitter.emit 'did-change', e
# TODO: remove these when we remove the deprecations. Though, no one is likely using them
@subscribe @displayBuffer.onDidChangeSoftWrapped (softWrapped) => @emit 'soft-wrap-changed', softWrapped
@subscribe @displayBuffer.onDidAddDecoration (decoration) => @emit 'decoration-added', decoration
@subscribe @displayBuffer.onDidRemoveDecoration (decoration) => @emit 'decoration-removed', decoration
if includeDeprecatedAPIs
@subscribe @displayBuffer.onDidChangeSoftWrapped (softWrapped) => @emit 'soft-wrap-changed', softWrapped
@subscribe @displayBuffer.onDidAddDecoration (decoration) => @emit 'decoration-added', decoration
@subscribe @displayBuffer.onDidRemoveDecoration (decoration) => @emit 'decoration-removed', decoration
@subscribeToScopedConfigSettings()
@ -174,11 +174,9 @@ class TextEditor extends Model
subscriptions.add atom.config.onDidChange 'editor.showInvisibles', scope: scopeDescriptor, => @updateInvisibles()
subscriptions.add atom.config.onDidChange 'editor.invisibles', scope: scopeDescriptor, => @updateInvisibles()
getViewClass: ->
require './text-editor-view'
destroyed: ->
@unsubscribe()
@unsubscribe() if includeDeprecatedAPIs
@disposables.dispose()
@scopedConfigSubscriptions.dispose()
selection.destroy() for selection in @getSelections()
@buffer.release()
@ -461,76 +459,12 @@ class TextEditor extends Model
onDidChangeIcon: (callback) ->
@emitter.on 'did-change-icon', callback
on: (eventName) ->
switch eventName
when 'title-changed'
deprecate("Use TextEditor::onDidChangeTitle instead")
when 'path-changed'
deprecate("Use TextEditor::onDidChangePath instead")
when 'modified-status-changed'
deprecate("Use TextEditor::onDidChangeModified instead")
when 'soft-wrap-changed'
deprecate("Use TextEditor::onDidChangeSoftWrapped instead")
when 'grammar-changed'
deprecate("Use TextEditor::onDidChangeGrammar instead")
when 'character-widths-changed'
deprecate("Use TextEditor::onDidChangeCharacterWidths instead")
when 'contents-modified'
deprecate("Use TextEditor::onDidStopChanging instead")
when 'contents-conflicted'
deprecate("Use TextEditor::onDidConflict instead")
when 'will-insert-text'
deprecate("Use TextEditor::onWillInsertText instead")
when 'did-insert-text'
deprecate("Use TextEditor::onDidInsertText instead")
when 'cursor-added'
deprecate("Use TextEditor::onDidAddCursor instead")
when 'cursor-removed'
deprecate("Use TextEditor::onDidRemoveCursor instead")
when 'cursor-moved'
deprecate("Use TextEditor::onDidChangeCursorPosition instead")
when 'selection-added'
deprecate("Use TextEditor::onDidAddSelection instead")
when 'selection-removed'
deprecate("Use TextEditor::onDidRemoveSelection instead")
when 'selection-screen-range-changed'
deprecate("Use TextEditor::onDidChangeSelectionRange instead")
when 'decoration-added'
deprecate("Use TextEditor::onDidAddDecoration instead")
when 'decoration-removed'
deprecate("Use TextEditor::onDidRemoveDecoration instead")
when 'decoration-updated'
deprecate("Use Decoration::onDidChangeProperties instead. You will get the decoration back from `TextEditor::decorateMarker()`")
when 'decoration-changed'
deprecate("Use Marker::onDidChange instead. e.g. `editor::decorateMarker(...).getMarker().onDidChange()`")
when 'screen-lines-changed'
deprecate("Use TextEditor::onDidChange instead")
when 'scroll-top-changed'
deprecate("Use TextEditor::onDidChangeScrollTop instead")
when 'scroll-left-changed'
deprecate("Use TextEditor::onDidChangeScrollLeft instead")
else
deprecate("TextEditor::on is deprecated. Use documented event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
# Retrieves the current {TextBuffer}.
# Public: Retrieves the current {TextBuffer}.
getBuffer: -> @buffer
# Retrieves the current buffer's URI.
getURI: -> @buffer.getUri()
getUri: ->
deprecate("Use `::getURI` instead")
@getURI()
# Create an {TextEditor} with its initial state based on this object
copy: ->
displayBuffer = @displayBuffer.copy()
@ -698,9 +632,6 @@ class TextEditor extends Model
#
# * `bufferRow` A {Number} representing a zero-indexed buffer row.
lineTextForBufferRow: (bufferRow) -> @buffer.lineForRow(bufferRow)
lineForBufferRow: (bufferRow) ->
deprecate 'Use TextEditor::lineTextForBufferRow(bufferRow) instead'
@lineTextForBufferRow(bufferRow)
# Essential: Returns a {String} representing the contents of the line at the
# given screen row.
@ -714,23 +645,9 @@ class TextEditor extends Model
#
# Returns {TokenizedLine}
tokenizedLineForScreenRow: (screenRow) -> @displayBuffer.tokenizedLineForScreenRow(screenRow)
lineForScreenRow: (screenRow) ->
deprecate "TextEditor::tokenizedLineForScreenRow(bufferRow) is the new name. But it's private. Try to use TextEditor::lineTextForScreenRow instead"
@tokenizedLineForScreenRow(screenRow)
# {Delegates to: DisplayBuffer.tokenizedLinesForScreenRows}
tokenizedLinesForScreenRows: (start, end) -> @displayBuffer.tokenizedLinesForScreenRows(start, end)
linesForScreenRows: (start, end) ->
deprecate "Use TextEditor::tokenizedLinesForScreenRows instead"
@tokenizedLinesForScreenRows(start, end)
# Returns a {Number} representing the line length for the given
# buffer row, exclusive of its line-ending character(s).
#
# * `row` A {Number} indicating the buffer row.
lineLengthForBufferRow: (row) ->
deprecate "Use editor.lineTextForBufferRow(row).length instead"
@lineTextForBufferRow(row).length
bufferRowForScreenRow: (row) -> @displayBuffer.bufferRowForScreenRow(row)
@ -803,7 +720,7 @@ class TextEditor extends Model
willInsert = true
cancel = -> willInsert = false
willInsertEvent = {cancel, text}
@emit('will-insert-text', willInsertEvent)
@emit('will-insert-text', willInsertEvent) if includeDeprecatedAPIs
@emitter.emit 'will-insert-text', willInsertEvent
if willInsert
@ -812,7 +729,7 @@ class TextEditor extends Model
@mutateSelectedText (selection) =>
range = selection.insertText(text, options)
didInsertEvent = {text, range}
@emit('did-insert-text', didInsertEvent)
@emit('did-insert-text', didInsertEvent) if includeDeprecatedAPIs
@emitter.emit 'did-insert-text', didInsertEvent
range
else
@ -981,11 +898,6 @@ class TextEditor extends Model
@createFold(foldStartRow + delta, foldEndRow + delta)
return
# Deprecated: Use {::duplicateLines} instead.
duplicateLine: ->
deprecate("Use TextEditor::duplicateLines() instead")
@duplicateLines()
replaceSelectedText: (options={}, fn) ->
{selectWordIfEmpty} = options
@mutateSelectedText (selection) ->
@ -1117,16 +1029,6 @@ class TextEditor extends Model
@mergeIntersectingSelectionsByRow()
@mutateSelectedText (selection) -> selection.deleteLine()
# Deprecated: Use {::deleteToBeginningOfWord} instead.
backspaceToBeginningOfWord: ->
deprecate("Use TextEditor::deleteToBeginningOfWord() instead")
@deleteToBeginningOfWord()
# Deprecated: Use {::deleteToBeginningOfLine} instead.
backspaceToBeginningOfLine: ->
deprecate("Use TextEditor::deleteToBeginningOfLine() instead")
@deleteToBeginningOfLine()
###
Section: History
###
@ -1352,7 +1254,7 @@ class TextEditor extends Model
#
# Returns a {Decoration} object
decorateMarker: (marker, decorationParams) ->
if decorationParams.type is 'gutter'
if includeDeprecatedAPIs and decorationParams.type is 'gutter'
deprecate("Decorations of `type: 'gutter'` have been renamed to `type: 'line-number'`.")
decorationParams.type = 'line-number'
@displayBuffer.decorateMarker(marker, decorationParams)
@ -1388,11 +1290,6 @@ class TextEditor extends Model
getLineDecorations: (propertyFilter) ->
@displayBuffer.getLineDecorations(propertyFilter)
# Soft-deprecated (forgot to deprecated this pre 1.0)
getGutterDecorations: (propertyFilter) ->
deprecate("Use ::getLineNumberDecorations instead")
@getLineNumberDecorations(propertyFilter)
# Extended: Get all decorations of type 'line-number'.
#
# * `propertyFilter` (optional) An {Object} containing key value pairs that
@ -1586,13 +1483,6 @@ class TextEditor extends Model
getCursorScreenPositions: ->
cursor.getScreenPosition() for cursor in @getCursors()
# Get the row of the most recently added cursor in screen coordinates.
#
# Returns the screen row {Number}.
getCursorScreenRow: ->
deprecate('Use `editor.getCursorScreenPosition().row` instead')
@getCursorScreenPosition().row
# Essential: Move the cursor to the given position in screen coordinates.
#
# If there are multiple cursors, they will be consolidated to a single cursor.
@ -1633,85 +1523,52 @@ class TextEditor extends Model
# * `lineCount` (optional) {Number} number of lines to move
moveUp: (lineCount) ->
@moveCursors (cursor) -> cursor.moveUp(lineCount, moveToEndOfSelection: true)
moveCursorUp: (lineCount) ->
deprecate("Use TextEditor::moveUp() instead")
@moveUp(lineCount)
# Essential: Move every cursor down one row in screen coordinates.
#
# * `lineCount` (optional) {Number} number of lines to move
moveDown: (lineCount) ->
@moveCursors (cursor) -> cursor.moveDown(lineCount, moveToEndOfSelection: true)
moveCursorDown: (lineCount) ->
deprecate("Use TextEditor::moveDown() instead")
@moveDown(lineCount)
# Essential: Move every cursor left one column.
#
# * `columnCount` (optional) {Number} number of columns to move (default: 1)
moveLeft: (columnCount) ->
@moveCursors (cursor) -> cursor.moveLeft(columnCount, moveToEndOfSelection: true)
moveCursorLeft: ->
deprecate("Use TextEditor::moveLeft() instead")
@moveLeft()
# Essential: Move every cursor right one column.
#
# * `columnCount` (optional) {Number} number of columns to move (default: 1)
moveRight: (columnCount) ->
@moveCursors (cursor) -> cursor.moveRight(columnCount, moveToEndOfSelection: true)
moveCursorRight: ->
deprecate("Use TextEditor::moveRight() instead")
@moveRight()
# Essential: Move every cursor to the beginning of its line in buffer coordinates.
moveToBeginningOfLine: ->
@moveCursors (cursor) -> cursor.moveToBeginningOfLine()
moveCursorToBeginningOfLine: ->
deprecate("Use TextEditor::moveToBeginningOfLine() instead")
@moveToBeginningOfLine()
# Essential: Move every cursor to the beginning of its line in screen coordinates.
moveToBeginningOfScreenLine: ->
@moveCursors (cursor) -> cursor.moveToBeginningOfScreenLine()
moveCursorToBeginningOfScreenLine: ->
deprecate("Use TextEditor::moveToBeginningOfScreenLine() instead")
@moveToBeginningOfScreenLine()
# Essential: Move every cursor to the first non-whitespace character of its line.
moveToFirstCharacterOfLine: ->
@moveCursors (cursor) -> cursor.moveToFirstCharacterOfLine()
moveCursorToFirstCharacterOfLine: ->
deprecate("Use TextEditor::moveToFirstCharacterOfLine() instead")
@moveToFirstCharacterOfLine()
# Essential: Move every cursor to the end of its line in buffer coordinates.
moveToEndOfLine: ->
@moveCursors (cursor) -> cursor.moveToEndOfLine()
moveCursorToEndOfLine: ->
deprecate("Use TextEditor::moveToEndOfLine() instead")
@moveToEndOfLine()
# Essential: Move every cursor to the end of its line in screen coordinates.
moveToEndOfScreenLine: ->
@moveCursors (cursor) -> cursor.moveToEndOfScreenLine()
moveCursorToEndOfScreenLine: ->
deprecate("Use TextEditor::moveToEndOfScreenLine() instead")
@moveToEndOfScreenLine()
# Essential: Move every cursor to the beginning of its surrounding word.
moveToBeginningOfWord: ->
@moveCursors (cursor) -> cursor.moveToBeginningOfWord()
moveCursorToBeginningOfWord: ->
deprecate("Use TextEditor::moveToBeginningOfWord() instead")
@moveToBeginningOfWord()
# Essential: Move every cursor to the end of its surrounding word.
moveToEndOfWord: ->
@moveCursors (cursor) -> cursor.moveToEndOfWord()
moveCursorToEndOfWord: ->
deprecate("Use TextEditor::moveToEndOfWord() instead")
@moveToEndOfWord()
# Cursor Extended
@ -1720,63 +1577,37 @@ class TextEditor extends Model
# If there are multiple cursors, they will be merged into a single cursor.
moveToTop: ->
@moveCursors (cursor) -> cursor.moveToTop()
moveCursorToTop: ->
deprecate("Use TextEditor::moveToTop() instead")
@moveToTop()
# Extended: Move every cursor to the bottom of the buffer.
#
# If there are multiple cursors, they will be merged into a single cursor.
moveToBottom: ->
@moveCursors (cursor) -> cursor.moveToBottom()
moveCursorToBottom: ->
deprecate("Use TextEditor::moveToBottom() instead")
@moveToBottom()
# Extended: Move every cursor to the beginning of the next word.
moveToBeginningOfNextWord: ->
@moveCursors (cursor) -> cursor.moveToBeginningOfNextWord()
moveCursorToBeginningOfNextWord: ->
deprecate("Use TextEditor::moveToBeginningOfNextWord() instead")
@moveToBeginningOfNextWord()
# Extended: Move every cursor to the previous word boundary.
moveToPreviousWordBoundary: ->
@moveCursors (cursor) -> cursor.moveToPreviousWordBoundary()
moveCursorToPreviousWordBoundary: ->
deprecate("Use TextEditor::moveToPreviousWordBoundary() instead")
@moveToPreviousWordBoundary()
# Extended: Move every cursor to the next word boundary.
moveToNextWordBoundary: ->
@moveCursors (cursor) -> cursor.moveToNextWordBoundary()
moveCursorToNextWordBoundary: ->
deprecate("Use TextEditor::moveToNextWordBoundary() instead")
@moveToNextWordBoundary()
# Extended: Move every cursor to the beginning of the next paragraph.
moveToBeginningOfNextParagraph: ->
@moveCursors (cursor) -> cursor.moveToBeginningOfNextParagraph()
moveCursorToBeginningOfNextParagraph: ->
deprecate("Use TextEditor::moveToBeginningOfNextParagraph() instead")
@moveToBeginningOfNextParagraph()
# Extended: Move every cursor to the beginning of the previous paragraph.
moveToBeginningOfPreviousParagraph: ->
@moveCursors (cursor) -> cursor.moveToBeginningOfPreviousParagraph()
moveCursorToBeginningOfPreviousParagraph: ->
deprecate("Use TextEditor::moveToBeginningOfPreviousParagraph() instead")
@moveToBeginningOfPreviousParagraph()
# Extended: Returns the most recently added {Cursor}
getLastCursor: ->
_.last(@cursors)
# Deprecated:
getCursor: ->
deprecate("Use TextEditor::getLastCursor() instead")
@getLastCursor()
# Extended: Returns the word surrounding the most recently added cursor.
#
# * `options` (optional) See {Cursor::getBeginningOfCurrentWordBufferPosition}.
@ -1801,14 +1632,14 @@ class TextEditor extends Model
@decorateMarker(marker, type: 'line-number', class: 'cursor-line')
@decorateMarker(marker, type: 'line-number', class: 'cursor-line-no-selection', onlyHead: true, onlyEmpty: true)
@decorateMarker(marker, type: 'line', class: 'cursor-line', onlyEmpty: true)
@emit 'cursor-added', cursor
@emit 'cursor-added', cursor if includeDeprecatedAPIs
@emitter.emit 'did-add-cursor', cursor
cursor
# Remove the given cursor from this editor.
removeCursor: (cursor) ->
_.remove(@cursors, cursor)
@emit 'cursor-removed', cursor
@emit 'cursor-removed', cursor if includeDeprecatedAPIs
@emitter.emit 'did-remove-cursor', cursor
moveCursors: (fn) ->
@ -1816,7 +1647,7 @@ class TextEditor extends Model
@mergeCursors()
cursorMoved: (event) ->
@emit 'cursor-moved', event
@emit 'cursor-moved', event if includeDeprecatedAPIs
@emitter.emit 'did-change-cursor-position', event
# Merge cursors that have the same screen position
@ -1832,9 +1663,9 @@ class TextEditor extends Model
preserveCursorPositionOnBufferReload: ->
cursorPosition = null
@subscribe @buffer.onWillReload =>
@disposables.add @buffer.onWillReload =>
cursorPosition = @getCursorBufferPosition()
@subscribe @buffer.onDidReload =>
@disposables.add @buffer.onDidReload =>
@setCursorBufferPosition(cursorPosition) if cursorPosition
cursorPosition = null
@ -2088,16 +1919,10 @@ class TextEditor extends Model
# This method merges selections on successive lines.
selectLinesContainingCursors: ->
@expandSelectionsForward (selection) -> selection.selectLine()
selectLine: ->
deprecate('Use TextEditor::selectLinesContainingCursors instead')
@selectLinesContainingCursors()
# Essential: Select the word surrounding each cursor.
selectWordsContainingCursors: ->
@expandSelectionsForward (selection) -> selection.selectWord()
selectWord: ->
deprecate('Use TextEditor::selectWordsContainingCursors instead')
@selectWordsContainingCursors()
# Selection Extended
@ -2153,15 +1978,6 @@ class TextEditor extends Model
getLastSelection: ->
_.last(@selections)
# Deprecated:
getSelection: (index) ->
if index?
deprecate("Use TextEditor::getSelections()[index] instead when getting a specific selection")
@getSelections()[index]
else
deprecate("Use TextEditor::getLastSelection() instead")
@getLastSelection()
# Extended: Get current {Selection}s.
#
# Returns: An {Array} of {Selection}s.
@ -2286,14 +2102,14 @@ class TextEditor extends Model
if selection.intersectsBufferRange(selectionBufferRange)
return selection
else
@emit 'selection-added', selection
@emit 'selection-added', selection if includeDeprecatedAPIs
@emitter.emit 'did-add-selection', selection
selection
# Remove the given selection.
removeSelection: (selection) ->
_.remove(@selections, selection)
@emit 'selection-removed', selection
@emit 'selection-removed', selection if includeDeprecatedAPIs
@emitter.emit 'did-remove-selection', selection
# Reduce one or more selections to a single empty selection based on the most
@ -2313,7 +2129,7 @@ class TextEditor extends Model
# Called by the selection
selectionRangeChanged: (event) ->
@emit 'selection-screen-range-changed', event
@emit 'selection-screen-range-changed', event if includeDeprecatedAPIs
@emitter.emit 'did-change-selection-range', event
###
@ -2437,9 +2253,6 @@ class TextEditor extends Model
#
# Returns a {Boolean}.
isSoftWrapped: (softWrapped) -> @displayBuffer.isSoftWrapped()
getSoftWrapped: ->
deprecate("Use TextEditor::isSoftWrapped instead")
@displayBuffer.isSoftWrapped()
# Essential: Enable or disable soft wrapping for this editor.
#
@ -2447,17 +2260,11 @@ class TextEditor extends Model
#
# Returns a {Boolean}.
setSoftWrapped: (softWrapped) -> @displayBuffer.setSoftWrapped(softWrapped)
setSoftWrap: (softWrapped) ->
deprecate("Use TextEditor::setSoftWrapped instead")
@setSoftWrapped(softWrapped)
# Essential: Toggle soft wrapping for this editor
#
# Returns a {Boolean}.
toggleSoftWrapped: -> @setSoftWrapped(not @isSoftWrapped())
toggleSoftWrap: ->
deprecate("Use TextEditor::toggleSoftWrapped instead")
@toggleSoftWrapped()
# Public: Gets the column at which column will soft wrap
getSoftWrapColumn: -> @displayBuffer.getSoftWrapColumn()
@ -2582,9 +2389,6 @@ class TextEditor extends Model
# Returns a {ScopeDescriptor}.
scopeDescriptorForBufferPosition: (bufferPosition) ->
@displayBuffer.scopeDescriptorForBufferPosition(bufferPosition)
scopesForBufferPosition: (bufferPosition) ->
deprecate 'Use ::scopeDescriptorForBufferPosition instead. The return value has changed! It now returns a `ScopeDescriptor`'
@scopeDescriptorForBufferPosition(bufferPosition).getScopesArray()
# Extended: Get the range in buffer coordinates of all tokens surrounding the
# cursor that match the given scope selector.
@ -2616,13 +2420,6 @@ class TextEditor extends Model
# {Delegates to: DisplayBuffer.tokenForBufferPosition}
tokenForBufferPosition: (bufferPosition) -> @displayBuffer.tokenForBufferPosition(bufferPosition)
scopesAtCursor: ->
deprecate 'Use editor.getLastCursor().getScopeDescriptor() instead'
@getLastCursor().getScopeDescriptor().getScopesArray()
getCursorScopes: ->
deprecate 'Use editor.getLastCursor().getScopeDescriptor() instead'
@scopesAtCursor()
###
Section: Clipboard Operations
###
@ -2936,7 +2733,7 @@ class TextEditor extends Model
@updateInvisibles()
@subscribeToScopedConfigSettings()
@unfoldAll()
@emit 'grammar-changed'
@emit 'grammar-changed' if includeDeprecatedAPIs
@emitter.emit 'did-change-grammar', @getGrammar()
handleMarkerCreated: (marker) =>
@ -3039,11 +2836,6 @@ class TextEditor extends Model
pixelRectForScreenRange: (screenRange) -> @displayBuffer.pixelRectForScreenRange(screenRange)
# Deprecated: Call {::joinLines} instead.
joinLine: ->
deprecate("Use TextEditor::joinLines() instead")
@joinLines()
###
Section: Utility
###
@ -3052,3 +2844,231 @@ class TextEditor extends Model
"<TextEditor #{@id}>"
logScreenLines: (start, end) -> @displayBuffer.logLines(start, end)
if includeDeprecatedAPIs
TextEditor.delegatesProperties '$lineHeightInPixels', '$defaultCharWidth', '$height', '$width',
'$verticalScrollbarWidth', '$horizontalScrollbarHeight', '$scrollTop', '$scrollLeft',
toProperty: 'displayBuffer'
TextEditor::getViewClass = ->
require './text-editor-view'
TextEditor::joinLine = ->
deprecate("Use TextEditor::joinLines() instead")
@joinLines()
TextEditor::scopesAtCursor = ->
deprecate 'Use editor.getLastCursor().getScopeDescriptor() instead'
@getLastCursor().getScopeDescriptor().getScopesArray()
TextEditor::getCursorScopes = ->
deprecate 'Use editor.getLastCursor().getScopeDescriptor() instead'
@scopesAtCursor()
TextEditor::getUri = ->
deprecate("Use `::getURI` instead")
@getURI()
TextEditor::lineForBufferRow = (bufferRow) ->
deprecate 'Use TextEditor::lineTextForBufferRow(bufferRow) instead'
@lineTextForBufferRow(bufferRow)
TextEditor::lineForScreenRow = (screenRow) ->
deprecate "TextEditor::tokenizedLineForScreenRow(bufferRow) is the new name. But it's private. Try to use TextEditor::lineTextForScreenRow instead"
@tokenizedLineForScreenRow(screenRow)
TextEditor::linesForScreenRows = (start, end) ->
deprecate "Use TextEditor::tokenizedLinesForScreenRows instead"
@tokenizedLinesForScreenRows(start, end)
TextEditor::lineLengthForBufferRow = (row) ->
deprecate "Use editor.lineTextForBufferRow(row).length instead"
@lineTextForBufferRow(row).length
TextEditor::duplicateLine = ->
deprecate("Use TextEditor::duplicateLines() instead")
@duplicateLines()
TextEditor::scopesForBufferPosition = (bufferPosition) ->
deprecate 'Use ::scopeDescriptorForBufferPosition instead. The return value has changed! It now returns a `ScopeDescriptor`'
@scopeDescriptorForBufferPosition(bufferPosition).getScopesArray()
TextEditor::toggleSoftWrap = ->
deprecate("Use TextEditor::toggleSoftWrapped instead")
@toggleSoftWrapped()
TextEditor::setSoftWrap = (softWrapped) ->
deprecate("Use TextEditor::setSoftWrapped instead")
@setSoftWrapped(softWrapped)
TextEditor::backspaceToBeginningOfWord = ->
deprecate("Use TextEditor::deleteToBeginningOfWord() instead")
@deleteToBeginningOfWord()
TextEditor::backspaceToBeginningOfLine = ->
deprecate("Use TextEditor::deleteToBeginningOfLine() instead")
@deleteToBeginningOfLine()
TextEditor::getGutterDecorations = (propertyFilter) ->
deprecate("Use ::getLineNumberDecorations instead")
@getLineNumberDecorations(propertyFilter)
TextEditor::getCursorScreenRow = ->
deprecate('Use `editor.getCursorScreenPosition().row` instead')
@getCursorScreenPosition().row
TextEditor::moveCursorUp = (lineCount) ->
deprecate("Use TextEditor::moveUp() instead")
@moveUp(lineCount)
TextEditor::moveCursorDown = (lineCount) ->
deprecate("Use TextEditor::moveDown() instead")
@moveDown(lineCount)
TextEditor::moveCursorLeft = ->
deprecate("Use TextEditor::moveLeft() instead")
@moveLeft()
TextEditor::moveCursorRight = ->
deprecate("Use TextEditor::moveRight() instead")
@moveRight()
TextEditor::moveCursorToBeginningOfLine = ->
deprecate("Use TextEditor::moveToBeginningOfLine() instead")
@moveToBeginningOfLine()
TextEditor::moveCursorToBeginningOfScreenLine = ->
deprecate("Use TextEditor::moveToBeginningOfScreenLine() instead")
@moveToBeginningOfScreenLine()
TextEditor::moveCursorToFirstCharacterOfLine = ->
deprecate("Use TextEditor::moveToFirstCharacterOfLine() instead")
@moveToFirstCharacterOfLine()
TextEditor::moveCursorToEndOfLine = ->
deprecate("Use TextEditor::moveToEndOfLine() instead")
@moveToEndOfLine()
TextEditor::moveCursorToEndOfScreenLine = ->
deprecate("Use TextEditor::moveToEndOfScreenLine() instead")
@moveToEndOfScreenLine()
TextEditor::moveCursorToBeginningOfWord = ->
deprecate("Use TextEditor::moveToBeginningOfWord() instead")
@moveToBeginningOfWord()
TextEditor::moveCursorToEndOfWord = ->
deprecate("Use TextEditor::moveToEndOfWord() instead")
@moveToEndOfWord()
TextEditor::moveCursorToTop = ->
deprecate("Use TextEditor::moveToTop() instead")
@moveToTop()
TextEditor::moveCursorToBottom = ->
deprecate("Use TextEditor::moveToBottom() instead")
@moveToBottom()
TextEditor::moveCursorToBeginningOfNextWord = ->
deprecate("Use TextEditor::moveToBeginningOfNextWord() instead")
@moveToBeginningOfNextWord()
TextEditor::moveCursorToPreviousWordBoundary = ->
deprecate("Use TextEditor::moveToPreviousWordBoundary() instead")
@moveToPreviousWordBoundary()
TextEditor::moveCursorToNextWordBoundary = ->
deprecate("Use TextEditor::moveToNextWordBoundary() instead")
@moveToNextWordBoundary()
TextEditor::moveCursorToBeginningOfNextParagraph = ->
deprecate("Use TextEditor::moveToBeginningOfNextParagraph() instead")
@moveToBeginningOfNextParagraph()
TextEditor::moveCursorToBeginningOfPreviousParagraph = ->
deprecate("Use TextEditor::moveToBeginningOfPreviousParagraph() instead")
@moveToBeginningOfPreviousParagraph()
TextEditor::getCursor = ->
deprecate("Use TextEditor::getLastCursor() instead")
@getLastCursor()
TextEditor::selectLine = ->
deprecate('Use TextEditor::selectLinesContainingCursors instead')
@selectLinesContainingCursors()
TextEditor::selectWord = ->
deprecate('Use TextEditor::selectWordsContainingCursors instead')
@selectWordsContainingCursors()
TextEditor::getSelection = (index) ->
if index?
deprecate("Use TextEditor::getSelections()[index] instead when getting a specific selection")
@getSelections()[index]
else
deprecate("Use TextEditor::getLastSelection() instead")
@getLastSelection()
TextEditor::getSoftWrapped = ->
deprecate("Use TextEditor::isSoftWrapped instead")
@displayBuffer.isSoftWrapped()
TextEditor::on = (eventName) ->
switch eventName
when 'title-changed'
deprecate("Use TextEditor::onDidChangeTitle instead")
when 'path-changed'
deprecate("Use TextEditor::onDidChangePath instead")
when 'modified-status-changed'
deprecate("Use TextEditor::onDidChangeModified instead")
when 'soft-wrap-changed'
deprecate("Use TextEditor::onDidChangeSoftWrapped instead")
when 'grammar-changed'
deprecate("Use TextEditor::onDidChangeGrammar instead")
when 'character-widths-changed'
deprecate("Use TextEditor::onDidChangeCharacterWidths instead")
when 'contents-modified'
deprecate("Use TextEditor::onDidStopChanging instead")
when 'contents-conflicted'
deprecate("Use TextEditor::onDidConflict instead")
when 'will-insert-text'
deprecate("Use TextEditor::onWillInsertText instead")
when 'did-insert-text'
deprecate("Use TextEditor::onDidInsertText instead")
when 'cursor-added'
deprecate("Use TextEditor::onDidAddCursor instead")
when 'cursor-removed'
deprecate("Use TextEditor::onDidRemoveCursor instead")
when 'cursor-moved'
deprecate("Use TextEditor::onDidChangeCursorPosition instead")
when 'selection-added'
deprecate("Use TextEditor::onDidAddSelection instead")
when 'selection-removed'
deprecate("Use TextEditor::onDidRemoveSelection instead")
when 'selection-screen-range-changed'
deprecate("Use TextEditor::onDidChangeSelectionRange instead")
when 'decoration-added'
deprecate("Use TextEditor::onDidAddDecoration instead")
when 'decoration-removed'
deprecate("Use TextEditor::onDidRemoveDecoration instead")
when 'decoration-updated'
deprecate("Use Decoration::onDidChangeProperties instead. You will get the decoration back from `TextEditor::decorateMarker()`")
when 'decoration-changed'
deprecate("Use Marker::onDidChange instead. e.g. `editor::decorateMarker(...).getMarker().onDidChange()`")
when 'screen-lines-changed'
deprecate("Use TextEditor::onDidChange instead")
when 'scroll-top-changed'
deprecate("Use TextEditor::onDidChangeScrollTop instead")
when 'scroll-left-changed'
deprecate("Use TextEditor::onDidChangeScrollLeft instead")
else
deprecate("TextEditor::on is deprecated. Use documented event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)

View File

@ -1,22 +1,16 @@
path = require 'path'
_ = require 'underscore-plus'
EmitterMixin = require('emissary').Emitter
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
{File} = require 'pathwatcher'
fs = require 'fs-plus'
Q = require 'q'
Grim = require 'grim'
Package = require './package'
# Extended: Handles loading and activating available themes.
#
# An instance of this class is always available as the `atom.themes` global.
module.exports =
class ThemeManager
EmitterMixin.includeInto(this)
constructor: ({@packageManager, @resourcePath, @configDirPath, @safeMode}) ->
@emitter = new Emitter
@styleSheetDisposablesBySourcePath = {}
@ -33,24 +27,24 @@ class ThemeManager
styleElementAdded: (styleElement) ->
{sheet} = styleElement
@sheetsByStyleElement.set(styleElement, sheet)
@emit 'stylesheet-added', sheet
@emit 'stylesheet-added', sheet if Grim.includeDeprecatedAPIs
@emitter.emit 'did-add-stylesheet', sheet
@emit 'stylesheets-changed'
@emit 'stylesheets-changed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-stylesheets'
styleElementRemoved: (styleElement) ->
sheet = @sheetsByStyleElement.get(styleElement)
@emit 'stylesheet-removed', sheet
@emit 'stylesheet-removed', sheet if Grim.includeDeprecatedAPIs
@emitter.emit 'did-remove-stylesheet', sheet
@emit 'stylesheets-changed'
@emit 'stylesheets-changed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-stylesheets'
styleElementUpdated: ({sheet}) ->
@emit 'stylesheet-removed', sheet
@emit 'stylesheet-removed', sheet if Grim.includeDeprecatedAPIs
@emitter.emit 'did-remove-stylesheet', sheet
@emit 'stylesheet-added', sheet
@emit 'stylesheet-added', sheet if Grim.includeDeprecatedAPIs
@emitter.emit 'did-add-stylesheet', sheet
@emit 'stylesheets-changed'
@emit 'stylesheets-changed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-stylesheets'
###
@ -65,65 +59,6 @@ class ThemeManager
@emitter.on 'did-change-active-themes', callback
@emitter.on 'did-reload-all', callback # TODO: Remove once deprecated pre-1.0 APIs are gone
onDidReloadAll: (callback) ->
Grim.deprecate("Use `::onDidChangeActiveThemes` instead.")
@onDidChangeActiveThemes(callback)
# Deprecated: Invoke `callback` when a stylesheet has been added to the dom.
#
# * `callback` {Function}
# * `stylesheet` {StyleSheet} the style node
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidAddStylesheet: (callback) ->
Grim.deprecate("Use atom.styles.onDidAddStyleElement instead")
@emitter.on 'did-add-stylesheet', callback
# Deprecated: Invoke `callback` when a stylesheet has been removed from the dom.
#
# * `callback` {Function}
# * `stylesheet` {StyleSheet} the style node
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidRemoveStylesheet: (callback) ->
Grim.deprecate("Use atom.styles.onDidRemoveStyleElement instead")
@emitter.on 'did-remove-stylesheet', callback
# Deprecated: Invoke `callback` when a stylesheet has been updated.
#
# * `callback` {Function}
# * `stylesheet` {StyleSheet} the style node
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidUpdateStylesheet: (callback) ->
Grim.deprecate("Use atom.styles.onDidUpdateStyleElement instead")
@emitter.on 'did-update-stylesheet', callback
# Deprecated: Invoke `callback` when any stylesheet has been updated, added, or removed.
#
# * `callback` {Function}
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidChangeStylesheets: (callback) ->
Grim.deprecate("Use atom.styles.onDidAdd/RemoveStyleElement instead")
@emitter.on 'did-change-stylesheets', callback
on: (eventName) ->
switch eventName
when 'reloaded'
Grim.deprecate 'Use ThemeManager::onDidChangeActiveThemes instead'
when 'stylesheet-added'
Grim.deprecate 'Use ThemeManager::onDidAddStylesheet instead'
when 'stylesheet-removed'
Grim.deprecate 'Use ThemeManager::onDidRemoveStylesheet instead'
when 'stylesheet-updated'
Grim.deprecate 'Use ThemeManager::onDidUpdateStylesheet instead'
when 'stylesheets-changed'
Grim.deprecate 'Use ThemeManager::onDidChangeStylesheets instead'
else
Grim.deprecate 'ThemeManager::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
###
Section: Accessing Available Themes
###
@ -140,10 +75,6 @@ class ThemeManager
getLoadedThemeNames: ->
theme.name for theme in @getLoadedThemes()
getLoadedNames: ->
Grim.deprecate("Use `::getLoadedThemeNames` instead.")
@getLoadedThemeNames()
# Public: Get an array of all the loaded themes.
getLoadedThemes: ->
pack for pack in @packageManager.getLoadedPackages() when pack.isTheme()
@ -156,10 +87,6 @@ class ThemeManager
getActiveThemeNames: ->
theme.name for theme in @getActiveThemes()
getActiveNames: ->
Grim.deprecate("Use `::getActiveThemeNames` instead.")
@getActiveThemeNames()
# Public: Get an array of all the active themes.
getActiveThemes: ->
pack for pack in @packageManager.getActivePackages() when pack.isTheme()
@ -208,22 +135,10 @@ class ThemeManager
# the first/top theme to override later themes in the stack.
themeNames.reverse()
# Set the list of enabled themes.
#
# * `enabledThemeNames` An {Array} of {String} theme names.
setEnabledThemes: (enabledThemeNames) ->
Grim.deprecate("Use `atom.config.set('core.themes', arrayOfThemeNames)` instead")
atom.config.set('core.themes', enabledThemeNames)
###
Section: Private
###
# Returns the {String} path to the user's stylesheet under ~/.atom
getUserStylesheetPath: ->
Grim.deprecate("Call atom.styles.getUserStyleSheetPath() instead")
atom.styles.getUserStyleSheetPath()
# Resolve and apply the stylesheet specified by the path.
#
# This supports both CSS and Less stylsheets.
@ -366,7 +281,7 @@ class ThemeManager
@loadUserStylesheet()
@reloadBaseStylesheets()
@initialLoadComplete = true
@emit 'reloaded'
@emit 'reloaded' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-active-themes'
deferred.resolve()
@ -410,3 +325,59 @@ class ThemeManager
themePaths.push(path.join(themePath, 'styles'))
themePaths.filter (themePath) -> fs.isDirectorySync(themePath)
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(ThemeManager)
ThemeManager::on = (eventName) ->
switch eventName
when 'reloaded'
Grim.deprecate 'Use ThemeManager::onDidChangeActiveThemes instead'
when 'stylesheet-added'
Grim.deprecate 'Use ThemeManager::onDidAddStylesheet instead'
when 'stylesheet-removed'
Grim.deprecate 'Use ThemeManager::onDidRemoveStylesheet instead'
when 'stylesheet-updated'
Grim.deprecate 'Use ThemeManager::onDidUpdateStylesheet instead'
when 'stylesheets-changed'
Grim.deprecate 'Use ThemeManager::onDidChangeStylesheets instead'
else
Grim.deprecate 'ThemeManager::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
ThemeManager::onDidReloadAll = (callback) ->
Grim.deprecate("Use `::onDidChangeActiveThemes` instead.")
@onDidChangeActiveThemes(callback)
ThemeManager::onDidAddStylesheet = (callback) ->
Grim.deprecate("Use atom.styles.onDidAddStyleElement instead")
@emitter.on 'did-add-stylesheet', callback
ThemeManager::onDidRemoveStylesheet = (callback) ->
Grim.deprecate("Use atom.styles.onDidRemoveStyleElement instead")
@emitter.on 'did-remove-stylesheet', callback
ThemeManager::onDidUpdateStylesheet = (callback) ->
Grim.deprecate("Use atom.styles.onDidUpdateStyleElement instead")
@emitter.on 'did-update-stylesheet', callback
ThemeManager::onDidChangeStylesheets = (callback) ->
Grim.deprecate("Use atom.styles.onDidAdd/RemoveStyleElement instead")
@emitter.on 'did-change-stylesheets', callback
ThemeManager::getUserStylesheetPath = ->
Grim.deprecate("Call atom.styles.getUserStyleSheetPath() instead")
atom.styles.getUserStyleSheetPath()
ThemeManager::getLoadedNames = ->
Grim.deprecate("Use `::getLoadedThemeNames` instead.")
@getLoadedThemeNames()
ThemeManager::getActiveNames = ->
Grim.deprecate("Use `::getActiveThemeNames` instead.")
@getActiveThemeNames()
ThemeManager::setEnabledThemes = (enabledThemeNames) ->
Grim.deprecate("Use `atom.config.set('core.themes', arrayOfThemeNames)` instead")
atom.config.set('core.themes', enabledThemeNames)

View File

@ -1,5 +1,4 @@
_ = require 'underscore-plus'
{deprecate} = require 'grim'
textUtils = require './text-utils'
WhitespaceRegexesByTabLength = {}

View File

@ -1,9 +1,8 @@
_ = require 'underscore-plus'
{Model} = require 'theorist'
EmitterMixin = require('emissary').Emitter
{Emitter} = require 'event-kit'
{CompositeDisposable, Emitter} = require 'event-kit'
{Point, Range} = require 'text-buffer'
Serializable = require 'serializable'
Model = require './model'
TokenizedLine = require './tokenized-line'
Token = require './token'
ScopeDescriptor = require './scope-descriptor'
@ -13,11 +12,10 @@ module.exports =
class TokenizedBuffer extends Model
Serializable.includeInto(this)
@property 'tabLength'
grammar: null
currentGrammarScore: null
buffer: null
tabLength: null
tokenizedLines: null
chunkSize: 50
invalidRows: null
@ -25,15 +23,19 @@ class TokenizedBuffer extends Model
constructor: ({@buffer, @tabLength, @invisibles}) ->
@emitter = new Emitter
@disposables = new CompositeDisposable
@subscribe atom.grammars.onDidAddGrammar(@grammarAddedOrUpdated)
@subscribe atom.grammars.onDidUpdateGrammar(@grammarAddedOrUpdated)
@disposables.add atom.grammars.onDidAddGrammar(@grammarAddedOrUpdated)
@disposables.add atom.grammars.onDidUpdateGrammar(@grammarAddedOrUpdated)
@subscribe @buffer.preemptDidChange (e) => @handleBufferChange(e)
@subscribe @buffer.onDidChangePath (@bufferPath) => @reloadGrammar()
@disposables.add @buffer.preemptDidChange (e) => @handleBufferChange(e)
@disposables.add @buffer.onDidChangePath (@bufferPath) => @reloadGrammar()
@reloadGrammar()
destroyed: ->
@disposables.dispose()
serializeParams: ->
bufferPath: @buffer.getPath()
tabLength: @tabLength
@ -56,19 +58,6 @@ class TokenizedBuffer extends Model
onDidTokenize: (callback) ->
@emitter.on 'did-tokenize', callback
on: (eventName) ->
switch eventName
when 'changed'
Grim.deprecate("Use TokenizedBuffer::onDidChange instead")
when 'grammar-changed'
Grim.deprecate("Use TokenizedBuffer::onDidChangeGrammar instead")
when 'tokenized'
Grim.deprecate("Use TokenizedBuffer::onDidTokenize instead")
else
Grim.deprecate("TokenizedBuffer::on is deprecated. Use event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
grammarAddedOrUpdated: (grammar) =>
if grammar.injectionSelector?
@retokenizeLines() if @hasTokenForSelector(grammar.injectionSelector)
@ -78,11 +67,14 @@ class TokenizedBuffer extends Model
setGrammar: (grammar, score) ->
return if grammar is @grammar
@unsubscribe(@grammar) if @grammar
@grammar = grammar
@rootScopeDescriptor = new ScopeDescriptor(scopes: [@grammar.scopeName])
@currentGrammarScore = score ? grammar.getScore(@buffer.getPath(), @buffer.getText())
@subscribe @grammar.onDidUpdate => @retokenizeLines()
@grammarUpdateDisposable?.dispose()
@grammarUpdateDisposable = @grammar.onDidUpdate => @retokenizeLines()
@disposables.add(@grammarUpdateDisposable)
@configSettings = tabLength: atom.config.get('editor.tabLength', scope: @rootScopeDescriptor)
@ -90,11 +82,11 @@ class TokenizedBuffer extends Model
@grammarTabLengthSubscription = atom.config.onDidChange 'editor.tabLength', scope: @rootScopeDescriptor, ({newValue}) =>
@configSettings.tabLength = newValue
@retokenizeLines()
@subscribe @grammarTabLengthSubscription
@disposables.add(@grammarTabLengthSubscription)
@retokenizeLines()
@emit 'grammar-changed', grammar
@emit 'grammar-changed', grammar if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-grammar', grammar
reloadGrammar: ->
@ -116,7 +108,7 @@ class TokenizedBuffer extends Model
@invalidateRow(0)
@fullyTokenized = false
event = {start: 0, end: lastRow, delta: 0}
@emit 'changed', event
@emit 'changed', event if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', event
setVisible: (@visible) ->
@ -178,7 +170,7 @@ class TokenizedBuffer extends Model
[startRow, endRow] = @updateFoldableStatus(startRow, endRow)
event = {start: startRow, end: endRow, delta: 0}
@emit 'changed', event
@emit 'changed', event if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', event
if @firstInvalidRow()?
@ -188,7 +180,7 @@ class TokenizedBuffer extends Model
markTokenizationComplete: ->
unless @fullyTokenized
@emit 'tokenized'
@emit 'tokenized' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-tokenize'
@fullyTokenized = true
@ -235,7 +227,7 @@ class TokenizedBuffer extends Model
end -= delta
event = { start, end, delta, bufferChange: e }
@emit 'changed', event
@emit 'changed', event if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', event
retokenizeWhitespaceRowsIfIndentLevelChanged: (row, increment) ->
@ -470,3 +462,19 @@ class TokenizedBuffer extends Model
line = @tokenizedLineForRow(row).text
console.log row, line, line.length
return
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
TokenizedBuffer::on = (eventName) ->
switch eventName
when 'changed'
Grim.deprecate("Use TokenizedBuffer::onDidChange instead")
when 'grammar-changed'
Grim.deprecate("Use TokenizedBuffer::onDidChangeGrammar instead")
when 'tokenized'
Grim.deprecate("Use TokenizedBuffer::onDidTokenize instead")
else
Grim.deprecate("TokenizedBuffer::on is deprecated. Use event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)

View File

@ -16,10 +16,10 @@ class WorkspaceElement extends HTMLElement
@initializeContent()
@observeScrollbarStyle()
@observeTextEditorFontConfig()
@createSpacePenShim()
@createSpacePenShim() if Grim.includeDeprecatedAPIs
attachedCallback: ->
callAttachHooks(this)
callAttachHooks(this) if Grim.includeDeprecatedAPIs
@focus()
detachedCallback: ->
@ -82,7 +82,7 @@ class WorkspaceElement extends HTMLElement
@appendChild(@panelContainers.modal)
@__spacePenView.setModel(@model)
@__spacePenView.setModel(@model) if Grim.includeDeprecatedAPIs
this
getModel: -> @model
@ -136,6 +136,9 @@ atom.commands.add 'atom-workspace',
'application:open-folder': -> ipc.send('command', 'application:open-folder')
'application:open-dev': -> ipc.send('command', 'application:open-dev')
'application:open-safe': -> ipc.send('command', 'application:open-safe')
'application:open-api-preview': -> ipc.send('command', 'application:open-api-preview')
'application:open-dev-api-preview': -> ipc.send('command', 'application:open-dev-api-preview')
'application:add-root-folder': -> atom.addRootFolder()
'application:minimize': -> ipc.send('command', 'application:minimize')
'application:zoom': -> ipc.send('command', 'application:zoom')
'application:bring-all-windows-to-front': -> ipc.send('command', 'application:bring-all-windows-to-front')
@ -153,9 +156,9 @@ atom.commands.add 'atom-workspace',
'window:focus-pane-on-left': -> @focusPaneViewOnLeft()
'window:focus-pane-on-right': -> @focusPaneViewOnRight()
'window:save-all': -> @getModel().saveAll()
'window:toggle-invisibles': -> atom.config.toggle("editor.showInvisibles")
'window:toggle-invisibles': -> atom.config.set("editor.showInvisibles", !atom.config.get("editor.showInvisibles"))
'window:log-deprecation-warnings': -> Grim.logDeprecations()
'window:toggle-auto-indent': -> atom.config.toggle("editor.autoIndent")
'window:toggle-auto-indent': -> atom.config.set("editor.autoIndent", !atom.config.get("editor.autoIndent"))
'pane:reopen-closed-item': -> @getModel().reopenItem()
'core:close': -> @getModel().destroyActivePaneItemOrEmptyPane()
'core:save': -> @getModel().saveActivePaneItem()

View File

@ -1,14 +1,14 @@
{deprecate} = require 'grim'
{includeDeprecatedAPIs, deprecate} = require 'grim'
_ = require 'underscore-plus'
path = require 'path'
{join} = path
{Model} = require 'theorist'
Q = require 'q'
Serializable = require 'serializable'
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
Grim = require 'grim'
fs = require 'fs-plus'
StackTraceParser = require 'stacktrace-parser'
Model = require './model'
TextEditor = require './text-editor'
PaneContainer = require './pane-container'
Pane = require './pane'
@ -33,24 +33,14 @@ class Workspace extends Model
atom.deserializers.add(this)
Serializable.includeInto(this)
Object.defineProperty @::, 'activePaneItem',
get: ->
Grim.deprecate "Use ::getActivePaneItem() instead of the ::activePaneItem property"
@getActivePaneItem()
Object.defineProperty @::, 'activePane',
get: ->
Grim.deprecate "Use ::getActivePane() instead of the ::activePane property"
@getActivePane()
@properties
paneContainer: null
fullScreen: false
destroyedItemURIs: -> []
constructor: (params) ->
super
unless Grim.includeDeprecatedAPIs
@paneContainer = params?.paneContainer
@fullScreen = params?.fullScreen ? false
@destroyedItemURIs = params?.destroyedItemURIs ? []
@emitter = new Emitter
@openers = []
@ -122,7 +112,7 @@ class Workspace extends Model
_.uniq(packageNames)
editorAdded: (editor) ->
@emit 'editor-created', editor
@emit 'editor-created', editor if includeDeprecatedAPIs
installShellCommands: ->
require('./command-installer').installShellCommandsInteractively()
@ -342,32 +332,6 @@ class Workspace extends Model
@onDidAddPaneItem ({item, pane, index}) ->
callback({textEditor: item, pane, index}) if item instanceof TextEditor
eachEditor: (callback) ->
deprecate("Use Workspace::observeTextEditors instead")
callback(editor) for editor in @getEditors()
@subscribe this, 'editor-created', (editor) -> callback(editor)
getEditors: ->
deprecate("Use Workspace::getTextEditors instead")
editors = []
for pane in @paneContainer.getPanes()
editors.push(item) for item in pane.getItems() when item instanceof TextEditor
editors
on: (eventName) ->
switch eventName
when 'editor-created'
deprecate("Use Workspace::onDidAddTextEditor or Workspace::observeTextEditors instead.")
when 'uri-opened'
deprecate("Use Workspace::onDidOpen or Workspace::onDidAddPaneItem instead. https://atom.io/docs/api/latest/Workspace#instance-onDidOpen")
else
deprecate("Subscribing via ::on is deprecated. Use documented event subscription methods instead.")
super
###
Section: Opening
###
@ -425,7 +389,7 @@ class Workspace extends Model
# the containing pane. Defaults to `true`.
openSync: (uri='', options={}) ->
# TODO: Remove deprecated changeFocus option
if options.changeFocus?
if includeDeprecatedAPIs and options.changeFocus?
deprecate("The `changeFocus` option has been renamed to `activatePane`")
options.activatePane = options.changeFocus
delete options.changeFocus
@ -446,7 +410,7 @@ class Workspace extends Model
openURIInPane: (uri, pane, options={}) ->
# TODO: Remove deprecated changeFocus option
if options.changeFocus?
if includeDeprecatedAPIs and options.changeFocus?
deprecate("The `changeFocus` option has been renamed to `activatePane`")
options.activatePane = options.changeFocus
delete options.changeFocus
@ -482,7 +446,7 @@ class Workspace extends Model
if options.initialLine? or options.initialColumn?
item.setCursorBufferPosition?([options.initialLine, options.initialColumn])
index = pane.getActiveItemIndex()
@emit "uri-opened"
@emit "uri-opened" if includeDeprecatedAPIs
@emitter.emit 'did-open', {uri, pane, item, index}
item
@ -496,12 +460,6 @@ class Workspace extends Model
else
Q()
# Deprecated
reopenItemSync: ->
deprecate("Use Workspace::reopenItem instead")
if uri = @destroyedItemURIs.pop()
@openSync(uri)
# Public: Register an opener for a uri.
#
# An {TextEditor} will be used if no openers return a value.
@ -519,24 +477,20 @@ class Workspace extends Model
# Returns a {Disposable} on which `.dispose()` can be called to remove the
# opener.
addOpener: (opener) ->
packageName = @getCallingPackageName()
if includeDeprecatedAPIs
packageName = @getCallingPackageName()
wrappedOpener = (uri, options) ->
item = opener(uri, options)
if item? and typeof item.getUri is 'function' and typeof item.getURI isnt 'function'
Grim.deprecate("Pane item with class `#{item.constructor.name}` should implement `::getURI` instead of `::getUri`.", {packageName})
item
wrappedOpener = (uri, options) ->
item = opener(uri, options)
if item? and typeof item.getUri is 'function' and typeof item.getURI isnt 'function'
Grim.deprecate("Pane item with class `#{item.constructor.name}` should implement `::getURI` instead of `::getUri`.", {packageName})
item
@openers.push(wrappedOpener)
new Disposable => _.remove(@openers, wrappedOpener)
registerOpener: (opener) ->
Grim.deprecate("Call Workspace::addOpener instead")
@addOpener(opener)
unregisterOpener: (opener) ->
Grim.deprecate("Call .dispose() on the Disposable returned from ::addOpener instead")
_.remove(@openers, opener)
@openers.push(wrappedOpener)
new Disposable => _.remove(@openers, wrappedOpener)
else
@openers.push(opener)
new Disposable => _.remove(@openers, opener)
getOpeners: ->
@openers
@ -599,11 +553,6 @@ class Workspace extends Model
activeItem = @getActivePaneItem()
activeItem if activeItem instanceof TextEditor
# Deprecated
getActiveEditor: ->
Grim.deprecate "Call ::getActiveTextEditor instead"
@getActivePane()?.getActiveEditor()
# Save all pane items.
saveAll: ->
@paneContainer.saveAll()
@ -667,10 +616,6 @@ class Workspace extends Model
paneForURI: (uri) ->
@paneContainer.paneForURI(uri)
paneForUri: (uri) ->
deprecate("Use ::paneForURI instead.")
@paneForURI(uri)
# Extended: Get the {Pane} containing the given item.
#
# * `item` Item the returned pane contains.
@ -945,3 +890,66 @@ class Workspace extends Model
checkFinished()
deferred.promise
if includeDeprecatedAPIs
Workspace.properties
paneContainer: null
fullScreen: false
destroyedItemURIs: -> []
Object.defineProperty Workspace::, 'activePaneItem',
get: ->
Grim.deprecate "Use ::getActivePaneItem() instead of the ::activePaneItem property"
@getActivePaneItem()
Object.defineProperty Workspace::, 'activePane',
get: ->
Grim.deprecate "Use ::getActivePane() instead of the ::activePane property"
@getActivePane()
Workspace::eachEditor = (callback) ->
deprecate("Use Workspace::observeTextEditors instead")
callback(editor) for editor in @getEditors()
@subscribe this, 'editor-created', (editor) -> callback(editor)
Workspace::getEditors = ->
deprecate("Use Workspace::getTextEditors instead")
editors = []
for pane in @paneContainer.getPanes()
editors.push(item) for item in pane.getItems() when item instanceof TextEditor
editors
Workspace::on = (eventName) ->
switch eventName
when 'editor-created'
deprecate("Use Workspace::onDidAddTextEditor or Workspace::observeTextEditors instead.")
when 'uri-opened'
deprecate("Use Workspace::onDidOpen or Workspace::onDidAddPaneItem instead. https://atom.io/docs/api/latest/Workspace#instance-onDidOpen")
else
deprecate("Subscribing via ::on is deprecated. Use documented event subscription methods instead.")
super
Workspace::reopenItemSync = ->
deprecate("Use Workspace::reopenItem instead")
if uri = @destroyedItemURIs.pop()
@openSync(uri)
Workspace::registerOpener = (opener) ->
Grim.deprecate("Call Workspace::addOpener instead")
@addOpener(opener)
Workspace::unregisterOpener = (opener) ->
Grim.deprecate("Call .dispose() on the Disposable returned from ::addOpener instead")
_.remove(@openers, opener)
Workspace::getActiveEditor = ->
Grim.deprecate "Call ::getActiveTextEditor instead"
@getActivePane()?.getActiveEditor()
Workspace::paneForUri = (uri) ->
deprecate("Use ::paneForURI instead.")
@paneForURI(uri)

View File

@ -34,6 +34,8 @@ window.onload = function() {
ModuleCache.register(loadSettings);
ModuleCache.add(loadSettings.resourcePath);
require('grim').includeDeprecatedAPIs = !loadSettings.apiPreviewMode;
// Start the crash reporter before anything else.
require('crash-reporter').start({
productName: 'Atom',