Merge pull request #1166 from atom/ks-rename-root-view

Rename RootView to WorkspaceView
This commit is contained in:
Kevin Sawicki
2013-11-26 12:28:10 -08:00
30 changed files with 324 additions and 330 deletions

View File

@@ -1,19 +1,19 @@
require './benchmark-helper'
{$, _, RootView} = require 'atom'
{$, _, WorkspaceView} = require 'atom'
TokenizedBuffer = require '../src/tokenized-buffer'
describe "editorView.", ->
editorView = null
beforeEach ->
window.rootViewParentSelector = '#jasmine-content'
window.rootView = new RootView
window.rootView.attachToDom()
atom.workspaceViewParentSelector = '#jasmine-content'
atom.workspaceView = new WorkspaceView
atom.workspaceView.attachToDom()
rootView.width(1024)
rootView.height(768)
rootView.openSync()
editorView = rootView.getActiveView()
atom.workspaceView.width(1024)
atom.workspaceView.height(768)
atom.workspaceView.openSync()
editorView = atom.workspaceView.getActiveView()
afterEach ->
if editorView.pendingDisplayUpdate
@@ -40,7 +40,7 @@ describe "editorView.", ->
describe "300-line-file.", ->
beforeEach ->
rootView.openSync('medium.coffee')
atom.workspaceView.openSync('medium.coffee')
describe "at-begining.", ->
benchmark "insert-delete", ->
@@ -171,11 +171,11 @@ describe "editorView.", ->
describe "9000-line-file.", ->
benchmark "opening.", 5, ->
rootView.openSync('huge.js')
atom.workspaceView.openSync('huge.js')
describe "after-opening.", ->
beforeEach ->
rootView.openSync('huge.js')
atom.workspaceView.openSync('huge.js')
benchmark "moving-to-eof.", 1, ->
editorView.moveCursorToBottom()

View File

@@ -67,11 +67,11 @@ object.
Your package's top-level module should implement the following methods:
- `activate(rootView, state)`: This **required** method is called when your
package is loaded. It is always passed the window's global `rootView`, and is
sometimes passed state data if the window has been reloaded and your module
implements the `serialize` method. Use this to do initialization work when your
package is started (like setting up DOM elements or binding events).
- `activate(state)`: This **required** method is called when your
package is activated. It is passed the state data from the last time the window
was serialized if your module implements the `serialize()` method. Use this to
do initialization work when your package is started (like setting up DOM
elements or binding events).
- `serialize()`: This **optional** method is called when the window is shutting
down, allowing you to return JSON to represent the state of your component. When
@@ -104,7 +104,7 @@ module.exports = require "./lib/my-package"
`my-package/my-package.coffee` might start:
```coffeescript
module.exports =
activate: (rootView, state) -> # ...
activate: (state) -> # ...
deactivate: -> # ...
serialize: -> # ...
```
@@ -206,7 +206,7 @@ specific parts of the interface, like adding a file in the tree-view:
'context-menu':
'.tree-view':
'Add file': 'tree-view:add-file'
'#root-view':
'#workspace-view':
'Inspect Element': 'core:inspect'
```

View File

@@ -8,11 +8,11 @@ view objects inherit from the jQuery prototype, and wrap DOM nodes
View objects are actually jQuery wrappers around DOM fragments, supporting all
the typical jQuery traversal and manipulation methods. In addition, view objects
have methods that are view-specific. For example, you could call both general
and view-specific on the global `rootView` instance:
and view-specific on the global `atom.workspaceView` instance:
```coffeescript
rootView.find('.editor.active') # standard jQuery method
rootView.getActiveEditor() # view-specific method
atom.workspaceView.find('.editor.active') # standard jQuery method
atom.workspaceView.getActiveEditor() # view-specific method
```
If you retrieve a jQuery wrapper for an element associated with a view, use the
@@ -20,7 +20,7 @@ If you retrieve a jQuery wrapper for an element associated with a view, use the
```coffeescript
# this is a plain jQuery object; you can't call view-specific methods
editorElement = rootView.find('.editor.active')
editorElement = atom.workspaceView.find('.editor.active')
# get the view object by calling `.view()` to call view-specific methods
editorView = editorElement.view()
@@ -29,18 +29,18 @@ editorView.setCursorBufferPosition([1, 2])
Refer to the [SpacePen] documentation for more details.
### RootView
### WorkspaceView
The root of Atom's view hierarchy is a global called `rootView`, which is a
singleton instance of the `RootView` view class. The root view fills the entire
The root of Atom's view hierarchy is a global called `atom.workspaceView`, which is a
singleton instance of the `WorkspaceView` view class. The root view fills the entire
window, and contains every other view. If you open Atom's inspector with
`alt-cmd-i`, you can see the internal structure of `RootView`:
`alt-cmd-i`, you can see the internal structure of `WorkspaceView`:
![RootView in the inspector][rootview-inspector]
![WorkspaceView in the inspector][workspaceview-inspector]
#### Panes
The `RootView` contains a `#horizontal` and a `#vertical` axis surrounding
The `WorkspaceView` contains a `#horizontal` and a `#vertical` axis surrounding
`#panes`. Elements in the horizontal axis will tile across the window
horizontally, appearing to have a vertical orientation. Items in the vertical
axis will tile across the window vertically, appearing to have a horizontal
@@ -55,11 +55,11 @@ outlets as follows:
```coffeescript
# place a view to the left of the panes (or use .append() to place it to the right)
rootView.horizontal.prepend(new MyView)
atom.workspaceView.horizontal.prepend(new MyView)
# place a view below the panes (or use .prepend() to place it above)
rootView.vertical.append(new MyOtherView)
atom.workspaceView.vertical.append(new MyOtherView)
```
[spacepen]: http://github.com/nathansobo/space-pen
[rootview-inspector]: https://f.cloud.github.com/assets/1424/1091631/1932c2d6-166b-11e3-8adf-9690fe82d3b8.png
[workspaceView-inspector]: https://f.cloud.github.com/assets/1424/1091631/1932c2d6-166b-11e3-8adf-9690fe82d3b8.png

View File

@@ -44,12 +44,12 @@ you can map to `body` if you want to scope to anywhere in Atom, or just `.editor
for the editor portion.
To bind keybindings to a command, we'll need to do a bit of association in our
CoffeeScript code using the `rootView.command` method. This method takes a command
CoffeeScript code using the `atom.workspaceView.command` method. This method takes a command
name and executes a callback function. Open up _lib/changer-view.coffee_, and
change `rootView.command "changer:toggle"` to look like this:
change `atom.workspaceView.command "changer:toggle"` to look like this:
```coffeescript
rootView.command "changer:magic", => @magic()
atom.workspaceView.command "changer:magic", => @magic()
```
It's common practice to namespace your commands with your package name, separated
@@ -180,7 +180,7 @@ ul.modified-files-list {
We'll add one more line to the end of the `magic` method to make this pane appear:
```coffeescript
rootView.vertical.append(this)
atom.workspaceView.vertical.append(this)
```
If you refresh Atom and hit the key command, you'll see a box appear right underneath
@@ -188,21 +188,21 @@ the editor:
![Changer_Panel_Append]
As you might have guessed, `rootView.vertical.append` tells Atom to append `this`
As you might have guessed, `atom.workspaceView.vertical.append` tells Atom to append `this`
item (_i.e._, whatever is defined by`@content`) _vertically_ to the editor. If
we had called `rootView.horizontal.append`, the pane would be attached to the
we had called `atom.workspaceView.horizontal.append`, the pane would be attached to the
right-hand side of the editor.
Before we populate this panel for real, let's apply some logic to toggle the pane
off and on, just like we did with the tree view. Replace the `rootView.vertical.append`
off and on, just like we did with the tree view. Replace the `atom.workspaceView.vertical.append`
call with this code:
```coffeescript
# toggles the pane
if @hasParent()
rootView.vertical.children().last().remove()
atom.workspaceView.vertical.children().last().remove()
else
rootView.vertical.append(this)
atom.workspaceView.vertical.append(this)
```
There are about a hundred different ways to toggle a pane on and off, and this
@@ -261,13 +261,13 @@ appending it to `modifiedFilesList`:
```coffeescript
# toggles the pane
if @hasParent()
rootView.vertical.children().last().remove()
atom.workspaceView.vertical.children().last().remove()
else
for file in modifiedFiles
stat = fs.lstatSync(file)
mtime = stat.mtime
@modifiedFilesList.append("<li>#{file} - Modified at #{mtime}")
rootView.vertical.append(this)
atom.workspaceView.vertical.append(this)
```
When you toggle the modified files list, your pane is now populated with the
@@ -283,13 +283,13 @@ this demonstration, we'll just clear the `modifiedFilesList` each time it's clos
# toggles the pane
if @hasParent()
@modifiedFilesList.empty() # added this to clear the list on close
rootView.vertical.children().last().remove()
atom.workspaceView.vertical.children().last().remove()
else
for file in modifiedFiles
stat = fs.lstatSync(file)
mtime = stat.mtime
@modifiedFilesList.append("<li>#{file} - Modified at #{mtime}")
rootView.vertical.append(this)
atom.workspaceView.vertical.append(this)
```
## Coloring UI Elements

View File

@@ -21,8 +21,7 @@ unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE
module.exports.$$ = $$
module.exports.$$$ = $$$
module.exports.Editor = require '../src/editor-view'
module.exports.RootView = require '../src/root-view'
module.exports.WorkspaceView = require '../src/root-view'
module.exports.WorkspaceView = require '../src/workspace-view'
module.exports.SelectList = require '../src/select-list'
module.exports.ScrollView = require '../src/scroll-view'
module.exports.Task = require '../src/task'

View File

@@ -64,51 +64,51 @@
"rimraf": "~2.2.2"
},
"packageDependencies": {
"atom-light-ui": "0.8.0",
"atom-light-ui": "0.9.0",
"atom-light-syntax": "0.6.0",
"atom-dark-ui": "0.8.0",
"atom-dark-ui": "0.9.0",
"atom-dark-syntax": "0.6.0",
"base16-tomorrow-dark-theme": "0.6.0",
"solarized-dark-syntax": "0.4.0",
"archive-view": "0.14.0",
"autocomplete": "0.15.0",
"autoflow": "0.9.0",
"autosave": "0.7.0",
"bookmarks": "0.13.0",
"bracket-matcher": "0.12.0",
"command-logger": "0.7.0",
"command-palette": "0.10.0",
"dev-live-reload": "0.17.0",
"editor-stats": "0.7.0",
"archive-view": "0.15.0",
"autocomplete": "0.16.0",
"autoflow": "0.10.0",
"autosave": "0.8.0",
"bookmarks": "0.14.0",
"bracket-matcher": "0.13.0",
"command-logger": "0.8.0",
"command-palette": "0.11.0",
"dev-live-reload": "0.18.0",
"editor-stats": "0.8.0",
"exception-reporting": "0.8.0",
"find-and-replace": "0.49.0",
"fuzzy-finder": "0.25.0",
"gists": "0.11.0",
"git-diff": "0.16.0",
"github-sign-in": "0.11.0",
"go-to-line": "0.10.0",
"grammar-selector": "0.11.0",
"find-and-replace": "0.52.0",
"fuzzy-finder": "0.26.0",
"gists": "0.12.0",
"git-diff": "0.17.0",
"github-sign-in": "0.12.0",
"go-to-line": "0.11.0",
"grammar-selector": "0.12.0",
"image-view": "0.9.0",
"keybinding-resolver": "0.5.0",
"link": "0.9.0",
"markdown-preview": "0.19.0",
"keybinding-resolver": "0.6.0",
"link": "0.10.0",
"markdown-preview": "0.20.0",
"metrics": "0.12.0",
"package-generator": "0.21.0",
"release-notes": "0.12.0",
"settings-view": "0.47.0",
"snippets": "0.15.0",
"spell-check": "0.15.0",
"status-bar": "0.22.0",
"styleguide": "0.15.0",
"symbols-view": "0.24.0",
"tabs": "0.12.0",
"terminal": "0.22.0",
"timecop": "0.10.0",
"to-the-hubs": "0.13.0",
"tree-view": "0.39.0",
"visual-bell": "0.4.0",
"package-generator": "0.22.0",
"release-notes": "0.13.0",
"settings-view": "0.48.0",
"snippets": "0.16.0",
"spell-check": "0.16.0",
"status-bar": "0.23.0",
"styleguide": "0.16.0",
"symbols-view": "0.25.0",
"tabs": "0.13.0",
"terminal": "0.23.0",
"timecop": "0.11.0",
"to-the-hubs": "0.14.0",
"tree-view": "0.40.0",
"visual-bell": "0.5.0",
"whitespace": "0.9.0",
"wrap-guide": "0.6.0",
"wrap-guide": "0.7.0",
"language-c": "0.2.0",
"language-clojure": "0.1.0",
"language-coffee-script": "0.3.0",

View File

@@ -1,11 +1,11 @@
{$, $$, fs, RootView} = require 'atom'
{$, $$, fs, WorkspaceView} = require 'atom'
Exec = require('child_process').exec
path = require 'path'
ThemeManager = require '../src/theme-manager'
describe "the `atom` global", ->
beforeEach ->
atom.rootView = new RootView
atom.workspaceView = new WorkspaceView
describe "package lifecycle methods", ->
describe ".loadPackage(name)", ->
@@ -90,12 +90,12 @@ describe "the `atom` global", ->
it "defers requiring/activating the main module until an activation event bubbles to the root view", ->
expect(pack.requireMainModule).not.toHaveBeenCalled()
expect(mainModule.activate).not.toHaveBeenCalled()
atom.rootView.trigger 'activation-event'
atom.workspaceView.trigger 'activation-event'
expect(mainModule.activate).toHaveBeenCalled()
it "triggers the activation event on all handlers registered during activation", ->
atom.rootView.openSync()
editorView = atom.rootView.getActiveView()
atom.workspaceView.openSync()
editorView = atom.workspaceView.getActiveView()
eventHandler = jasmine.createSpy("activation-event")
editorView.command 'activation-event', eventHandler
editorView.trigger 'activation-event'

View File

@@ -1,4 +1,4 @@
RootView = require '../src/root-view'
WorkspaceView = require '../src/workspace-view'
EditorView = require '../src/editor-view'
{$, $$} = require '../src/space-pen-extensions'
_ = require 'underscore-plus'
@@ -2764,10 +2764,10 @@ describe "EditorView", ->
describe "when the editor view is attached but invisible", ->
describe "when the editor view's text is changed", ->
it "redraws the editor view when it is next shown", ->
atom.rootView = new RootView
atom.rootView.openSync('sample.js')
atom.rootView.attachToDom()
editorView = atom.rootView.getActiveView()
atom.workspaceView = new WorkspaceView
atom.workspaceView.openSync('sample.js')
atom.workspaceView.attachToDom()
editorView = atom.workspaceView.getActiveView()
view = $$ -> @div id: 'view', tabindex: -1, 'View'
editorView.getPane().showItem(view)
@@ -2818,10 +2818,10 @@ describe "EditorView", ->
describe "when the editor view is removed", ->
it "fires a editor:will-be-removed event", ->
atom.rootView = new RootView
atom.rootView.openSync('sample.js')
atom.rootView.attachToDom()
editorView = atom.rootView.getActiveView()
atom.workspaceView = new WorkspaceView
atom.workspaceView.openSync('sample.js')
atom.workspaceView.attachToDom()
editorView = atom.workspaceView.getActiveView()
willBeRemovedHandler = jasmine.createSpy('fileChange')
editorView.on 'editor:will-be-removed', willBeRemovedHandler

View File

@@ -9,5 +9,5 @@ module.exports =
activate: ->
@activateCallCount++
atom.rootView.getActiveView()?.command 'activation-event', =>
atom.workspaceView.getActiveView()?.command 'activation-event', =>
@activationEventCallCount++

View File

@@ -1,5 +1,5 @@
# This package loads async, otherwise it would log errors when it
# is automatically serialized when rootView is deactivatated
# is automatically serialized when workspaceView is deactivatated
'main': 'index.coffee'
'activationEvents': ['activation-event']

View File

@@ -1,7 +1,7 @@
path = require 'path'
Keymap = require '../src/keymap'
{$, $$, RootView} = require 'atom'
{$, $$, WorkspaceView} = require 'atom'
describe "Keymap", ->
fragment = null
@@ -158,12 +158,12 @@ describe "Keymap", ->
expect(bazHandler).toHaveBeenCalled()
describe "when the event's target is the document body", ->
it "triggers the mapped event on the rootView", ->
atom.rootView = new RootView
atom.rootView.attachToDom()
it "triggers the mapped event on the workspaceView", ->
atom.workspaceView = new WorkspaceView
atom.workspaceView.attachToDom()
keymap.bindKeys 'name', 'body', 'x': 'foo'
fooHandler = jasmine.createSpy("fooHandler")
atom.rootView.on 'foo', fooHandler
atom.workspaceView.on 'foo', fooHandler
result = keymap.handleKeyEvent(keydownEvent('x', target: document.body))
expect(result).toBe(false)

View File

@@ -475,20 +475,20 @@ describe "Pane", ->
describe "when it is the last pane", ->
beforeEach ->
expect(container.getPanes().length).toBe 1
atom.rootView = focus: jasmine.createSpy("rootView.focus")
atom.workspaceView = focus: jasmine.createSpy("workspaceView.focus")
describe "when the removed pane is focused", ->
it "calls focus on rootView so we don't lose focus", ->
it "calls focus on workspaceView so we don't lose focus", ->
container.attachToDom()
pane.focus()
pane.remove()
expect(atom.rootView.focus).toHaveBeenCalled()
expect(atom.workspaceView.focus).toHaveBeenCalled()
describe "when the removed pane is not focused", ->
it "does not call focus on root view", ->
expect(pane).not.toMatchSelector ':has(:focus)'
pane.remove()
expect(atom.rootView.focus).not.toHaveBeenCalled()
expect(atom.workspaceView.focus).not.toHaveBeenCalled()
describe ".getNextPane()", ->
it "returns the next pane if one exists, wrapping around from the last pane to the first", ->

View File

@@ -1,52 +1,52 @@
{$, $$, fs, RootView, View} = require 'atom'
{$, $$, fs, WorkspaceView, View} = require 'atom'
Q = require 'q'
path = require 'path'
temp = require 'temp'
Pane = require '../src/pane'
describe "RootView", ->
describe "WorkspaceView", ->
pathToOpen = null
beforeEach ->
atom.project.setPath(atom.project.resolve('dir'))
pathToOpen = atom.project.resolve('a')
atom.rootView = new RootView
atom.rootView.enableKeymap()
atom.rootView.openSync(pathToOpen)
atom.rootView.focus()
atom.workspaceView = new WorkspaceView
atom.workspaceView.enableKeymap()
atom.workspaceView.openSync(pathToOpen)
atom.workspaceView.focus()
describe "@deserialize()", ->
viewState = null
refreshRootViewAndProject = ->
rootViewState = atom.rootView.serialize()
refreshWorkspaceViewAndProject = ->
workspaceViewState = atom.workspaceView.serialize()
atom.project.getState().serializeForPersistence()
project2 = atom.replicate().get('project')
atom.rootView.remove()
atom.workspaceView.remove()
atom.project.destroy()
atom.project = project2
atom.rootView = atom.deserializers.deserialize(rootViewState)
atom.rootView.attachToDom()
atom.workspaceView = atom.deserializers.deserialize(workspaceViewState)
atom.workspaceView.attachToDom()
describe "when the serialized RootView has an unsaved buffer", ->
describe "when the serialized WorkspaceView has an unsaved buffer", ->
it "constructs the view with the same panes", ->
atom.rootView.attachToDom()
atom.rootView.openSync()
editor1 = atom.rootView.getActiveView()
atom.workspaceView.attachToDom()
atom.workspaceView.openSync()
editor1 = atom.workspaceView.getActiveView()
buffer = editor1.getBuffer()
editor1.splitRight()
expect(atom.rootView.getActiveView()).toBe atom.rootView.getEditors()[2]
expect(atom.workspaceView.getActiveView()).toBe atom.workspaceView.getEditors()[2]
refreshRootViewAndProject()
refreshWorkspaceViewAndProject()
expect(atom.rootView.getEditors().length).toBe 2
expect(atom.rootView.getActiveView()).toBe atom.rootView.getEditors()[1]
expect(atom.rootView.title).toBe "untitled - #{atom.project.getPath()}"
expect(atom.workspaceView.getEditors().length).toBe 2
expect(atom.workspaceView.getActiveView()).toBe atom.workspaceView.getEditors()[1]
expect(atom.workspaceView.title).toBe "untitled - #{atom.project.getPath()}"
describe "when there are open editors", ->
it "constructs the view with the same panes", ->
atom.rootView.attachToDom()
pane1 = atom.rootView.getActivePane()
atom.workspaceView.attachToDom()
pane1 = atom.workspaceView.getActivePane()
pane2 = pane1.splitRight()
pane3 = pane2.splitRight()
pane4 = pane2.splitDown()
@@ -57,13 +57,13 @@ describe "RootView", ->
pane4.activeItem.setCursorScreenPosition([0, 2])
pane2.focus()
refreshRootViewAndProject()
refreshWorkspaceViewAndProject()
expect(atom.rootView.getEditors().length).toBe 4
editor1 = atom.rootView.panes.find('.row > .pane .editor:eq(0)').view()
editor3 = atom.rootView.panes.find('.row > .pane .editor:eq(1)').view()
editor2 = atom.rootView.panes.find('.row > .column > .pane .editor:eq(0)').view()
editor4 = atom.rootView.panes.find('.row > .column > .pane .editor:eq(1)').view()
expect(atom.workspaceView.getEditors().length).toBe 4
editor1 = atom.workspaceView.panes.find('.row > .pane .editor:eq(0)').view()
editor3 = atom.workspaceView.panes.find('.row > .pane .editor:eq(1)').view()
editor2 = atom.workspaceView.panes.find('.row > .column > .pane .editor:eq(0)').view()
editor4 = atom.workspaceView.panes.find('.row > .column > .pane .editor:eq(1)').view()
expect(editor1.getPath()).toBe atom.project.resolve('a')
expect(editor2.getPath()).toBe atom.project.resolve('b')
@@ -84,181 +84,181 @@ describe "RootView", ->
expect(editor3.isFocused).toBeFalsy()
expect(editor4.isFocused).toBeFalsy()
expect(atom.rootView.title).toBe "#{path.basename(editor2.getPath())} - #{atom.project.getPath()}"
expect(atom.workspaceView.title).toBe "#{path.basename(editor2.getPath())} - #{atom.project.getPath()}"
describe "where there are no open editors", ->
it "constructs the view with no open editors", ->
atom.rootView.getActivePane().remove()
expect(atom.rootView.getEditors().length).toBe 0
refreshRootViewAndProject()
expect(atom.rootView.getEditors().length).toBe 0
atom.workspaceView.getActivePane().remove()
expect(atom.workspaceView.getEditors().length).toBe 0
refreshWorkspaceViewAndProject()
expect(atom.workspaceView.getEditors().length).toBe 0
describe "focus", ->
beforeEach ->
atom.rootView.attachToDom()
atom.workspaceView.attachToDom()
describe "when there is an active view", ->
it "hands off focus to the active view", ->
editorView = atom.rootView.getActiveView()
editorView = atom.workspaceView.getActiveView()
editorView.isFocused = false
atom.rootView.focus()
atom.workspaceView.focus()
expect(editorView.isFocused).toBeTruthy()
describe "when there is no active view", ->
beforeEach ->
atom.rootView.getActivePane().remove()
expect(atom.rootView.getActiveView()).toBeUndefined()
atom.rootView.attachToDom()
atom.workspaceView.getActivePane().remove()
expect(atom.workspaceView.getActiveView()).toBeUndefined()
atom.workspaceView.attachToDom()
expect(document.activeElement).toBe document.body
describe "when are visible focusable elements (with a -1 tabindex)", ->
it "passes focus to the first focusable element", ->
focusable1 = $$ -> @div "One", id: 'one', tabindex: -1
focusable2 = $$ -> @div "Two", id: 'two', tabindex: -1
atom.rootView.horizontal.append(focusable1, focusable2)
atom.workspaceView.horizontal.append(focusable1, focusable2)
expect(document.activeElement).toBe document.body
atom.rootView.focus()
atom.workspaceView.focus()
expect(document.activeElement).toBe focusable1[0]
describe "when there are no visible focusable elements", ->
it "surrenders focus to the body", ->
focusable = $$ -> @div "One", id: 'one', tabindex: -1
atom.rootView.horizontal.append(focusable)
atom.workspaceView.horizontal.append(focusable)
focusable.hide()
expect(document.activeElement).toBe document.body
atom.rootView.focus()
atom.workspaceView.focus()
expect(document.activeElement).toBe document.body
describe "keymap wiring", ->
commandHandler = null
beforeEach ->
commandHandler = jasmine.createSpy('commandHandler')
atom.rootView.on('foo-command', commandHandler)
atom.workspaceView.on('foo-command', commandHandler)
atom.keymap.bindKeys('name', '*', 'x': 'foo-command')
describe "when a keydown event is triggered in the RootView", ->
describe "when a keydown event is triggered in the WorkspaceView", ->
it "triggers matching keybindings for that event", ->
event = keydownEvent 'x', target: atom.rootView[0]
event = keydownEvent 'x', target: atom.workspaceView[0]
atom.rootView.trigger(event)
atom.workspaceView.trigger(event)
expect(commandHandler).toHaveBeenCalled()
describe "window title", ->
describe "when the project has no path", ->
it "sets the title to 'untitled'", ->
atom.project.setPath(undefined)
expect(atom.rootView.title).toBe 'untitled'
expect(atom.workspaceView.title).toBe 'untitled'
describe "when the project has a path", ->
beforeEach ->
atom.rootView.openSync('b')
atom.workspaceView.openSync('b')
describe "when there is an active pane item", ->
it "sets the title to the pane item's title plus the project path", ->
item = atom.rootView.getActivePaneItem()
expect(atom.rootView.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
item = atom.workspaceView.getActivePaneItem()
expect(atom.workspaceView.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
describe "when the title of the active pane item changes", ->
it "updates the window title based on the item's new title", ->
editor = atom.rootView.getActivePaneItem()
editor = atom.workspaceView.getActivePaneItem()
editor.buffer.setPath(path.join(temp.dir, 'hi'))
expect(atom.rootView.title).toBe "#{editor.getTitle()} - #{atom.project.getPath()}"
expect(atom.workspaceView.title).toBe "#{editor.getTitle()} - #{atom.project.getPath()}"
describe "when the active pane's item changes", ->
it "updates the title to the new item's title plus the project path", ->
atom.rootView.getActivePane().showNextItem()
item = atom.rootView.getActivePaneItem()
expect(atom.rootView.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
atom.workspaceView.getActivePane().showNextItem()
item = atom.workspaceView.getActivePaneItem()
expect(atom.workspaceView.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
describe "when the last pane item is removed", ->
it "updates the title to contain the project's path", ->
atom.rootView.getActivePane().remove()
expect(atom.rootView.getActivePaneItem()).toBeUndefined()
expect(atom.rootView.title).toBe atom.project.getPath()
atom.workspaceView.getActivePane().remove()
expect(atom.workspaceView.getActivePaneItem()).toBeUndefined()
expect(atom.workspaceView.title).toBe atom.project.getPath()
describe "when an inactive pane's item changes", ->
it "does not update the title", ->
pane = atom.rootView.getActivePane()
pane = atom.workspaceView.getActivePane()
pane.splitRight()
initialTitle = atom.rootView.title
initialTitle = atom.workspaceView.title
pane.showNextItem()
expect(atom.rootView.title).toBe initialTitle
expect(atom.workspaceView.title).toBe initialTitle
describe "when the root view is deserialized", ->
it "updates the title to contain the project's path", ->
rootView2 = atom.deserializers.deserialize(atom.rootView.serialize())
item = atom.rootView.getActivePaneItem()
expect(rootView2.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
rootView2.remove()
workspaceView2 = atom.deserializers.deserialize(atom.workspaceView.serialize())
item = atom.workspaceView.getActivePaneItem()
expect(workspaceView2.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
workspaceView2.remove()
describe "font size adjustment", ->
it "increases/decreases font size when increase/decrease-font-size events are triggered", ->
fontSizeBefore = atom.config.get('editor.fontSize')
atom.rootView.trigger 'window:increase-font-size'
atom.workspaceView.trigger 'window:increase-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 1
atom.rootView.trigger 'window:increase-font-size'
atom.workspaceView.trigger 'window:increase-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 2
atom.rootView.trigger 'window:decrease-font-size'
atom.workspaceView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 1
atom.rootView.trigger 'window:decrease-font-size'
atom.workspaceView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore
it "does not allow the font size to be less than 1", ->
atom.config.set("editor.fontSize", 1)
atom.rootView.trigger 'window:decrease-font-size'
atom.workspaceView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe 1
describe ".openSync(filePath, options)", ->
describe "when there is no active pane", ->
beforeEach ->
spyOn(Pane.prototype, 'focus')
atom.rootView.getActivePane().remove()
expect(atom.rootView.getActivePane()).toBeUndefined()
atom.workspaceView.getActivePane().remove()
expect(atom.workspaceView.getActivePane()).toBeUndefined()
describe "when called with no path", ->
it "creates a empty edit session as an item on a new pane, and focuses the pane", ->
editor = atom.rootView.openSync()
expect(atom.rootView.getActivePane().activeItem).toBe editor
editor = atom.workspaceView.openSync()
expect(atom.workspaceView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBeUndefined()
expect(atom.rootView.getActivePane().focus).toHaveBeenCalled()
expect(atom.workspaceView.getActivePane().focus).toHaveBeenCalled()
it "can create multiple empty edit sessions as an item on a new pane", ->
editor = atom.rootView.openSync()
editor2 = atom.rootView.openSync()
expect(atom.rootView.getActivePane().getItems().length).toBe 2
editor = atom.workspaceView.openSync()
editor2 = atom.workspaceView.openSync()
expect(atom.workspaceView.getActivePane().getItems().length).toBe 2
expect(editor).not.toBe editor2
describe "when called with a path", ->
it "creates an edit session for the given path as an item on a new pane, and focuses the pane", ->
editor = atom.rootView.openSync('b')
expect(atom.rootView.getActivePane().activeItem).toBe editor
editor = atom.workspaceView.openSync('b')
expect(atom.workspaceView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
expect(atom.rootView.getActivePane().focus).toHaveBeenCalled()
expect(atom.workspaceView.getActivePane().focus).toHaveBeenCalled()
describe "when the changeFocus option is false", ->
it "does not focus the new pane", ->
editor = atom.rootView.openSync('b', changeFocus: false)
expect(atom.rootView.getActivePane().focus).not.toHaveBeenCalled()
editor = atom.workspaceView.openSync('b', changeFocus: false)
expect(atom.workspaceView.getActivePane().focus).not.toHaveBeenCalled()
describe "when the split option is 'right'", ->
it "creates a new pane and opens the file in said pane", ->
editor = atom.rootView.openSync('b', split: 'right')
expect(atom.rootView.getActivePane().activeItem).toBe editor
editor = atom.workspaceView.openSync('b', split: 'right')
expect(atom.workspaceView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
describe "when there is an active pane", ->
[activePane, initialItemCount] = []
beforeEach ->
activePane = atom.rootView.getActivePane()
activePane = atom.workspaceView.getActivePane()
spyOn(activePane, 'focus')
initialItemCount = activePane.getItems().length
describe "when called with no path", ->
it "opens an edit session with an empty buffer as an item in the active pane and focuses it", ->
editor = atom.rootView.openSync()
editor = atom.workspaceView.openSync()
expect(activePane.getItems().length).toBe initialItemCount + 1
expect(activePane.activeItem).toBe editor
expect(editor.getPath()).toBeUndefined()
@@ -269,11 +269,11 @@ describe "RootView", ->
it "shows the existing edit session in the pane", ->
previousEditSession = activePane.activeItem
editor = atom.rootView.openSync('b')
editor = atom.workspaceView.openSync('b')
expect(activePane.activeItem).toBe editor
expect(editor).not.toBe previousEditSession
editor = atom.rootView.openSync(previousEditSession.getPath())
editor = atom.workspaceView.openSync(previousEditSession.getPath())
expect(editor).toBe previousEditSession
expect(activePane.activeItem).toBe editor
@@ -281,85 +281,85 @@ describe "RootView", ->
describe "when the active pane does not have an edit session item for the path being opened", ->
it "creates a new edit session for the given path in the active editor", ->
editor = atom.rootView.openSync('b')
editor = atom.workspaceView.openSync('b')
expect(activePane.items.length).toBe 2
expect(activePane.activeItem).toBe editor
expect(activePane.focus).toHaveBeenCalled()
describe "when the changeFocus option is false", ->
it "does not focus the active pane", ->
editor = atom.rootView.openSync('b', changeFocus: false)
editor = atom.workspaceView.openSync('b', changeFocus: false)
expect(activePane.focus).not.toHaveBeenCalled()
describe "when the split option is 'right'", ->
it "creates a new pane and opens the file in said pane", ->
pane1 = atom.rootView.getActivePane()
pane1 = atom.workspaceView.getActivePane()
editor = atom.rootView.openSync('b', split: 'right')
pane2 = atom.rootView.getActivePane()
editor = atom.workspaceView.openSync('b', split: 'right')
pane2 = atom.workspaceView.getActivePane()
expect(pane2[0]).not.toBe pane1[0]
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.workspaceView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
editor = atom.rootView.openSync('file1', split: 'right')
pane3 = atom.rootView.getActivePane()
editor = atom.workspaceView.openSync('file1', split: 'right')
pane3 = atom.workspaceView.getActivePane()
expect(pane3[0]).toBe pane2[0]
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/file1')
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.workspaceView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
describe ".openSingletonSync(filePath, options)", ->
describe "when there is an active pane", ->
[pane1] = []
beforeEach ->
spyOn(Pane.prototype, 'focus').andCallFake -> @makeActive()
pane1 = atom.rootView.getActivePane()
pane1 = atom.workspaceView.getActivePane()
it "creates a new pane and reuses the file when already open", ->
atom.rootView.openSingletonSync('b', split: 'right')
pane2 = atom.rootView.getActivePane()
atom.workspaceView.openSingletonSync('b', split: 'right')
pane2 = atom.workspaceView.getActivePane()
expect(pane2[0]).not.toBe pane1[0]
expect(pane1.itemForUri('b')).toBeFalsy()
expect(pane2.itemForUri('b')).not.toBeFalsy()
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.workspaceView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
pane1.focus()
expect(atom.rootView.getActivePane()[0]).toBe pane1[0]
expect(atom.workspaceView.getActivePane()[0]).toBe pane1[0]
atom.rootView.openSingletonSync('b', split: 'right')
pane3 = atom.rootView.getActivePane()
atom.workspaceView.openSingletonSync('b', split: 'right')
pane3 = atom.workspaceView.getActivePane()
expect(pane3[0]).toBe pane2[0]
expect(pane1.itemForUri('b')).toBeFalsy()
expect(pane2.itemForUri('b')).not.toBeFalsy()
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.workspaceView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
it "handles split: left by opening to the left pane when necessary", ->
atom.rootView.openSingletonSync('b', split: 'right')
pane2 = atom.rootView.getActivePane()
atom.workspaceView.openSingletonSync('b', split: 'right')
pane2 = atom.workspaceView.getActivePane()
expect(pane2[0]).not.toBe pane1[0]
atom.rootView.openSingletonSync('file1', split: 'left')
atom.workspaceView.openSingletonSync('file1', split: 'left')
activePane = atom.rootView.getActivePane()
activePane = atom.workspaceView.getActivePane()
expect(activePane[0]).toBe pane1[0]
expect(pane1.itemForUri('file1')).toBeTruthy()
expect(pane2.itemForUri('file1')).toBeFalsy()
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.workspaceView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
pane2.focus()
expect(atom.rootView.getActivePane()[0]).toBe pane2[0]
expect(atom.workspaceView.getActivePane()[0]).toBe pane2[0]
atom.rootView.openSingletonSync('file1', split: 'left')
activePane = atom.rootView.getActivePane()
atom.workspaceView.openSingletonSync('file1', split: 'left')
activePane = atom.workspaceView.getActivePane()
expect(activePane[0]).toBe pane1[0]
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.workspaceView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
it "reuses the file when already open", ->
atom.rootView.openSync('b')
atom.rootView.openSingletonSync('b', split: 'right')
expect(atom.rootView.panes.find('.pane').toArray()).toEqual [pane1[0]]
atom.workspaceView.openSync('b')
atom.workspaceView.openSingletonSync('b', split: 'right')
expect(atom.workspaceView.panes.find('.pane').toArray()).toEqual [pane1[0]]
describe ".open(filePath)", ->
beforeEach ->
@@ -367,60 +367,60 @@ describe "RootView", ->
describe "when there is no active pane", ->
beforeEach ->
atom.rootView.getActivePane().remove()
expect(atom.rootView.getActivePane()).toBeUndefined()
atom.workspaceView.getActivePane().remove()
expect(atom.workspaceView.getActivePane()).toBeUndefined()
describe "when called with no path", ->
it "creates a empty edit session as an item on a new pane, and focuses the pane", ->
editor = null
waitsForPromise ->
atom.rootView.open().then (o) -> editor = o
atom.workspaceView.open().then (o) -> editor = o
runs ->
expect(atom.rootView.getActivePane().activeItem).toBe editor
expect(atom.workspaceView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBeUndefined()
expect(atom.rootView.getActivePane().focus).toHaveBeenCalled()
expect(atom.workspaceView.getActivePane().focus).toHaveBeenCalled()
it "can create multiple empty edit sessions as items on a pane", ->
editor1 = null
editor2 = null
waitsForPromise ->
atom.rootView.open()
atom.workspaceView.open()
.then (o) ->
editor1 = o
atom.rootView.open()
atom.workspaceView.open()
.then (o) ->
editor2 = o
runs ->
expect(atom.rootView.getActivePane().getItems().length).toBe 2
expect(atom.workspaceView.getActivePane().getItems().length).toBe 2
expect(editor1).not.toBe editor2
describe "when called with a path", ->
it "creates an edit session for the given path as an item on a new pane, and focuses the pane", ->
editor = null
waitsForPromise ->
atom.rootView.open('b').then (o) -> editor = o
atom.workspaceView.open('b').then (o) -> editor = o
runs ->
expect(atom.rootView.getActivePane().activeItem).toBe editor
expect(atom.workspaceView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
expect(atom.rootView.getActivePane().focus).toHaveBeenCalled()
expect(atom.workspaceView.getActivePane().focus).toHaveBeenCalled()
describe "when there is an active pane", ->
[activePane] = []
beforeEach ->
activePane = atom.rootView.getActivePane()
activePane = atom.workspaceView.getActivePane()
describe "when called with no path", ->
it "opens an edit session with an empty buffer as an item in the active pane and focuses it", ->
editor = null
waitsForPromise ->
atom.rootView.open().then (o) -> editor = o
atom.workspaceView.open().then (o) -> editor = o
runs ->
expect(activePane.getItems().length).toBe 2
@@ -435,14 +435,14 @@ describe "RootView", ->
editor = null
waitsForPromise ->
atom.rootView.open('b').then (o) -> editor = o
atom.workspaceView.open('b').then (o) -> editor = o
runs ->
expect(activePane.activeItem).toBe editor
expect(editor).not.toBe previousEditSession
waitsForPromise ->
atom.rootView.open(previousEditSession.getPath()).then (o) -> editor = o
atom.workspaceView.open(previousEditSession.getPath()).then (o) -> editor = o
runs ->
expect(editor).toBe previousEditSession
@@ -454,7 +454,7 @@ describe "RootView", ->
editor = null
waitsForPromise ->
atom.rootView.open('b').then (o) -> editor = o
atom.workspaceView.open('b').then (o) -> editor = o
runs ->
expect(activePane.activeItem).toBe editor
@@ -463,9 +463,9 @@ describe "RootView", ->
describe "window:toggle-invisibles event", ->
it "shows/hides invisibles in all open and future editors", ->
atom.rootView.height(200)
atom.rootView.attachToDom()
rightEditor = atom.rootView.getActiveView()
atom.workspaceView.height(200)
atom.workspaceView.attachToDom()
rightEditor = atom.workspaceView.getActiveView()
rightEditor.setText(" \t ")
leftEditor = rightEditor.splitLeft()
expect(rightEditor.find(".line:first").text()).toBe " "
@@ -473,14 +473,14 @@ describe "RootView", ->
withInvisiblesShowing = "#{rightEditor.invisibles.space}#{rightEditor.invisibles.tab} #{rightEditor.invisibles.space}#{rightEditor.invisibles.eol}"
atom.rootView.trigger "window:toggle-invisibles"
atom.workspaceView.trigger "window:toggle-invisibles"
expect(rightEditor.find(".line:first").text()).toBe withInvisiblesShowing
expect(leftEditor.find(".line:first").text()).toBe withInvisiblesShowing
lowerLeftEditor = leftEditor.splitDown()
expect(lowerLeftEditor.find(".line:first").text()).toBe withInvisiblesShowing
atom.rootView.trigger "window:toggle-invisibles"
atom.workspaceView.trigger "window:toggle-invisibles"
expect(rightEditor.find(".line:first").text()).toBe " "
expect(leftEditor.find(".line:first").text()).toBe " "
@@ -489,7 +489,7 @@ describe "RootView", ->
describe ".eachEditor(callback)", ->
beforeEach ->
atom.rootView.attachToDom()
atom.workspaceView.attachToDom()
it "invokes the callback for existing editor", ->
count = 0
@@ -497,9 +497,9 @@ describe "RootView", ->
callback = (editor) ->
callbackEditor = editor
count++
atom.rootView.eachEditor(callback)
atom.workspaceView.eachEditor(callback)
expect(count).toBe 1
expect(callbackEditor).toBe atom.rootView.getActiveView()
expect(callbackEditor).toBe atom.workspaceView.getActiveView()
it "invokes the callback for new editor", ->
count = 0
@@ -508,28 +508,28 @@ describe "RootView", ->
callbackEditor = editor
count++
atom.rootView.eachEditor(callback)
atom.workspaceView.eachEditor(callback)
count = 0
callbackEditor = null
atom.rootView.getActiveView().splitRight()
atom.workspaceView.getActiveView().splitRight()
expect(count).toBe 1
expect(callbackEditor).toBe atom.rootView.getActiveView()
expect(callbackEditor).toBe atom.workspaceView.getActiveView()
it "returns a subscription that can be disabled", ->
count = 0
callback = (editor) -> count++
subscription = atom.rootView.eachEditor(callback)
subscription = atom.workspaceView.eachEditor(callback)
expect(count).toBe 1
atom.rootView.getActiveView().splitRight()
atom.workspaceView.getActiveView().splitRight()
expect(count).toBe 2
subscription.off()
atom.rootView.getActiveView().splitRight()
atom.workspaceView.getActiveView().splitRight()
expect(count).toBe 2
describe ".eachBuffer(callback)", ->
beforeEach ->
atom.rootView.attachToDom()
atom.workspaceView.attachToDom()
it "invokes the callback for existing buffer", ->
count = 0
@@ -538,9 +538,9 @@ describe "RootView", ->
callback = (buffer) ->
callbackBuffer = buffer
count++
atom.rootView.eachBuffer(callback)
atom.workspaceView.eachBuffer(callback)
expect(count).toBe 1
expect(callbackBuffer).toBe atom.rootView.getActiveView().getBuffer()
expect(callbackBuffer).toBe atom.workspaceView.getActiveView().getBuffer()
it "invokes the callback for new buffer", ->
count = 0
@@ -549,9 +549,9 @@ describe "RootView", ->
callbackBuffer = buffer
count++
atom.rootView.eachBuffer(callback)
atom.workspaceView.eachBuffer(callback)
count = 0
callbackBuffer = null
atom.rootView.openSync(require.resolve('./fixtures/sample.txt'))
atom.workspaceView.openSync(require.resolve('./fixtures/sample.txt'))
expect(count).toBe 1
expect(callbackBuffer).toBe atom.rootView.getActiveView().getBuffer()
expect(callbackBuffer).toBe atom.workspaceView.getActiveView().getBuffer()

View File

@@ -4,7 +4,7 @@ atom.restoreDimensions()
require '../vendor/jasmine-jquery'
path = require 'path'
{_, $, File, RootView, fs} = require 'atom'
{_, $, File, WorkspaceView, fs} = require 'atom'
Keymap = require '../src/keymap'
Config = require '../src/config'
{Point} = require 'telepath'
@@ -73,7 +73,7 @@ beforeEach ->
config = new Config({resourcePath, configDirPath: atom.getConfigDirPath()})
spyOn(config, 'load')
spyOn(config, 'save')
config.setDefaults('core', RootView.configDefaults)
config.setDefaults('core', WorkspaceView.configDefaults)
config.setDefaults('editor', EditorView.configDefaults)
config.set "editor.fontFamily", "Courier"
config.set "editor.fontSize", 16
@@ -85,7 +85,7 @@ beforeEach ->
# make editor display updates synchronous
spyOn(EditorView.prototype, 'requestDisplayUpdate').andCallFake -> @updateDisplay()
spyOn(RootView.prototype, 'setTitle').andCallFake (@title) ->
spyOn(WorkspaceView.prototype, 'setTitle').andCallFake (@title) ->
spyOn(window, "setTimeout").andCallFake window.fakeSetTimeout
spyOn(window, "clearTimeout").andCallFake window.fakeClearTimeout
spyOn(File.prototype, "detectResurrectionAfterDelay").andCallFake -> @detectResurrection()
@@ -104,8 +104,8 @@ afterEach ->
atom.packages.deactivatePackages()
atom.menu.template = []
atom.rootView?.remove?()
atom.rootView = null
atom.workspaceView?.remove?()
atom.workspaceView = null
atom.project?.destroy?()
atom.project = null

View File

@@ -1,5 +1,5 @@
path = require 'path'
{$, $$, fs, RootView} = require 'atom'
{$, $$, fs, WorkspaceView} = require 'atom'
ThemeManager = require '../src/theme-manager'
AtomPackage = require '../src/atom-package'
@@ -140,16 +140,16 @@ describe "ThemeManager", ->
describe "base stylesheet loading", ->
beforeEach ->
atom.rootView = new RootView
atom.rootView.append $$ -> @div class: 'editor'
atom.rootView.attachToDom()
atom.workspaceView = new WorkspaceView
atom.workspaceView.append $$ -> @div class: 'editor'
atom.workspaceView.attachToDom()
themeManager.activateThemes()
it "loads the correct values from the theme's ui-variables file", ->
atom.config.set('core.themes', ['theme-with-ui-variables'])
# an override loaded in the base css
expect(atom.rootView.css("background-color")).toBe "rgb(0, 0, 255)"
expect(atom.workspaceView.css("background-color")).toBe "rgb(0, 0, 255)"
# from within the theme itself
expect($(".editor").css("padding-top")).toBe "150px"

View File

@@ -58,46 +58,46 @@ describe "Window", ->
beforeUnloadEvent = $.Event(new Event('beforeunload'))
describe "when pane items are are modified", ->
it "prompts user to save and and calls rootView.confirmClose", ->
spyOn(atom.rootView, 'confirmClose').andCallThrough()
it "prompts user to save and and calls workspaceView.confirmClose", ->
spyOn(atom.workspaceView, 'confirmClose').andCallThrough()
spyOn(atom, "confirm").andReturn(2)
editor = atom.rootView.openSync("sample.js")
editor = atom.workspaceView.openSync("sample.js")
editor.insertText("I look different, I feel different.")
$(window).trigger(beforeUnloadEvent)
expect(atom.rootView.confirmClose).toHaveBeenCalled()
expect(atom.workspaceView.confirmClose).toHaveBeenCalled()
expect(atom.confirm).toHaveBeenCalled()
it "prompts user to save and handler returns true if don't save", ->
spyOn(atom, "confirm").andReturn(2)
editor = atom.rootView.openSync("sample.js")
editor = atom.workspaceView.openSync("sample.js")
editor.insertText("I look different, I feel different.")
$(window).trigger(beforeUnloadEvent)
expect(atom.confirm).toHaveBeenCalled()
it "prompts user to save and handler returns false if dialog is canceled", ->
spyOn(atom, "confirm").andReturn(1)
editor = atom.rootView.openSync("sample.js")
editor = atom.workspaceView.openSync("sample.js")
editor.insertText("I look different, I feel different.")
$(window).trigger(beforeUnloadEvent)
expect(atom.confirm).toHaveBeenCalled()
describe ".unloadEditorWindow()", ->
it "saves the serialized state of the window so it can be deserialized after reload", ->
rootViewState = atom.rootView.serialize()
workspaceViewState = atom.workspaceView.serialize()
syntaxState = atom.syntax.serialize()
atom.unloadEditorWindow()
expect(atom.getWindowState().getObject('rootView')).toEqual rootViewState.toObject()
expect(atom.getWindowState().getObject('workspaceView')).toEqual workspaceViewState.toObject()
expect(atom.getWindowState().getObject('syntax')).toEqual syntaxState
expect(atom.saveWindowState).toHaveBeenCalled()
it "unsubscribes from all buffers", ->
atom.rootView.openSync('sample.js')
buffer = atom.rootView.getActivePaneItem().buffer
pane = atom.rootView.getActivePane()
atom.workspaceView.openSync('sample.js')
buffer = atom.workspaceView.getActivePaneItem().buffer
pane = atom.workspaceView.getActivePane()
pane.splitRight(pane.copyActiveItem())
expect(atom.rootView.find('.editor').length).toBe 2
expect(atom.workspaceView.find('.editor').length).toBe 2
atom.unloadEditorWindow()

View File

@@ -219,11 +219,11 @@ class AtomPackage extends Package
subscribeToActivationEvents: ->
return unless @metadata.activationEvents?
if _.isArray(@metadata.activationEvents)
atom.rootView.command(event, @handleActivationEvent) for event in @metadata.activationEvents
atom.workspaceView.command(event, @handleActivationEvent) for event in @metadata.activationEvents
else if _.isString(@metadata.activationEvents)
atom.rootView.command(@metadata.activationEvents, @handleActivationEvent)
atom.workspaceView.command(@metadata.activationEvents, @handleActivationEvent)
else
atom.rootView.command(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents
atom.workspaceView.command(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents
handleActivationEvent: (event) =>
bubblePathEventHandlers = @disableEventHandlersOnBubblePath(event)
@@ -234,11 +234,11 @@ class AtomPackage extends Package
unsubscribeFromActivationEvents: ->
if _.isArray(@metadata.activationEvents)
atom.rootView.off(event, @handleActivationEvent) for event in @metadata.activationEvents
atom.workspaceView.off(event, @handleActivationEvent) for event in @metadata.activationEvents
else if _.isString(@metadata.activationEvents)
atom.rootView.off(@metadata.activationEvents, @handleActivationEvent)
atom.workspaceView.off(@metadata.activationEvents, @handleActivationEvent)
else
atom.rootView.off(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents
atom.workspaceView.off(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents
disableEventHandlersOnBubblePath: (event) ->
bubblePathEventHandlers = []

View File

@@ -28,7 +28,7 @@ WindowEventHandler = require './window-event-handler'
# * `atom.contextMenu` - A {ContextMenuManager} instance
# * `atom.keymap` - A {Keymap} instance
# * `atom.menu` - A {MenuManager} instance
# * `atom.rootView` - A {RootView} instance
# * `atom.workspaceView` - A {WorkspaceView} instance
# * `atom.packages` - A {PackageManager} instance
# * `atom.pasteboard` - A {Pasteboard} instance
# * `atom.project` - A {Project} instance
@@ -40,14 +40,9 @@ class Atom
# Private:
constructor: ->
@rootViewParentSelector = 'body'
@workspaceViewParentSelector = 'body'
@deserializers = new DeserializerManager()
#TODO Remove once all `atom.rootView` references have been updated
Object.defineProperty this, 'workspaceView',
get: -> @rootView
set: (workspaceView) -> @rootView = workspaceView
# Private: Initialize all the properties in this object.
initialize: ->
@unsubscribe()
@@ -145,14 +140,14 @@ class Atom
@setWindowState('project', @project)
# Private:
deserializeRootView: ->
RootView = require './root-view'
deserializeWorkspaceView: ->
WorkspaceView = require './workspace-view'
state = @getWindowState()
@rootView = @deserializers.deserialize(state.get('rootView'))
unless @rootView?
@rootView = new RootView()
state.set('rootView', @rootView.getState())
$(@rootViewParentSelector).append(@rootView)
@workspaceView = @deserializers.deserialize(state.get('workspaceView'))
unless @workspaceView?
@workspaceView = new WorkspaceView()
state.set('workspaceView', @workspaceView.getState())
$(@workspaceViewParentSelector).append(@workspaceView)
# Private:
deserializePackageStates: ->
@@ -164,7 +159,7 @@ class Atom
deserializeEditorWindow: ->
@deserializePackageStates()
@deserializeProject()
@deserializeRootView()
@deserializeWorkspaceView()
# Private: This method is only called when opening a real application window
startEditorWindow: ->
@@ -176,7 +171,7 @@ class Atom
@windowEventHandler = new WindowEventHandler
@restoreDimensions()
@config.load()
@config.setDefaults('core', require('./root-view').configDefaults)
@config.setDefaults('core', require('./workspace-view').configDefaults)
@config.setDefaults('editor', require('./editor-view').configDefaults)
@keymap.loadBundledKeymaps()
@themes.loadBaseStylesheets()
@@ -196,16 +191,16 @@ class Atom
# Private:
unloadEditorWindow: ->
return if not @project and not @rootView
return if not @project and not @workspaceView
windowState = @getWindowState()
windowState.set('project', @project)
windowState.set('syntax', @syntax.serialize())
windowState.set('rootView', @rootView.serialize())
windowState.set('workspaceView', @workspaceView.serialize())
@packages.deactivatePackages()
windowState.set('packageStates', @packages.packageStates)
@saveWindowState()
@rootView.remove()
@workspaceView.remove()
@project.destroy()
@windowEventHandler?.unsubscribe()
@@ -324,7 +319,7 @@ class Atom
setImmediate =>
@show()
@focus()
@setFullScreen(true) if @rootView.getState().get('fullScreen')
@setFullScreen(true) if @workspaceView.getState().get('fullScreen')
# Public: Close the current window.
close: ->
@@ -448,7 +443,7 @@ class Atom
# Public: Visually and audibly trigger a beep.
beep: ->
shell.beep() if @config.get('core.audioBeep')
@rootView.trigger 'beep'
@workspaceView.trigger 'beep'
# Private:
requireUserInitScript: ->

View File

@@ -14,7 +14,7 @@ class ContextMenuManager
@devModeDefinitions = {}
@activeElement = null
@devModeDefinitions['#root-view'] = [
@devModeDefinitions['#workspace-view'] = [
label: 'Inspect Element'
command: 'application:inspect'
executeAtBuild: (e) ->

View File

@@ -1058,7 +1058,7 @@ class EditorView extends View
remove: (selector, keepData) ->
return super if keepData or @removed
super
atom.rootView?.focus()
atom.workspaceView?.focus()
beforeRemove: ->
@trigger 'editor:will-be-removed'

View File

@@ -22,12 +22,12 @@ TextMateScopeSelector = require('first-mate').ScopeSelector
#
# Almost all extension will interact primiarily with this class as it provides
# access to objects you'll most commonly interact with. To access it you'll
# want to register a callback on {RootView} which will be fired once for every
# want to register a callback on {WorkspaceView} which will be fired once for every
# existing {Editor} as well as any future {Editor}s.
#
# ## Example
# ```coffeescript
# global.rootView.eachEditSession (editor) ->
# global.workspaceView.eachEditSession (editor) ->
# editor.insertText('Hello World')
# ```
#

View File

@@ -141,7 +141,7 @@ class Keymap
handleKeyEvent: (event) ->
element = event.target
element = atom.rootView if element == document.body
element = atom.workspaceView if element == document.body
keystroke = @keystrokeStringForEvent(event, @queuedKeystroke)
keyBindings = @keyBindingsForKeystrokeMatchingElement(keystroke, element)

View File

@@ -2,7 +2,7 @@
Pane = require './pane'
telepath = require 'telepath'
# Private: Manages the list of panes within a {RootView}
# Private: Manages the list of panes within a {WorkspaceView}
module.exports =
class PaneContainer extends View
atom.deserializers.add(this)

View File

@@ -426,7 +426,7 @@ class Pane extends View
# Private:
beforeRemove: ->
if @is(':has(:focus)')
@getContainer().focusNextPane() or atom.rootView?.focus()
@getContainer().focusNextPane() or atom.workspaceView?.focus()
else if @isActive()
@getContainer().makeNextPaneActive()

View File

@@ -171,7 +171,7 @@ class SelectList extends View
if @previouslyFocusedElement?.isOnDom()
@previouslyFocusedElement.focus()
else
atom.rootView.focus()
atom.workspaceView.focus()
# Public:
cancelled: ->

View File

@@ -16,8 +16,8 @@ class WindowEventHandler
@subscribe ipc, 'command', (command, args...) ->
activeElement = document.activeElement
# Use root view if body has focus
if activeElement is document.body and atom.rootView?
activeElement = atom.rootView
if activeElement is document.body and atom.workspaceView?
activeElement = atom.workspaceView
$(activeElement).trigger(command, args...)
@subscribe ipc, 'context-command', (command, args...) ->
@@ -29,10 +29,10 @@ class WindowEventHandler
@subscribe $(window), 'window:open-path', (event, {pathToOpen, initialLine}) ->
unless fs.isDirectorySync(pathToOpen)
atom.rootView?.open(pathToOpen, {initialLine})
atom.workspaceView?.open(pathToOpen, {initialLine})
@subscribe $(window), 'beforeunload', =>
confirmed = atom.rootView?.confirmClose()
confirmed = atom.workspaceView?.confirmClose()
atom.hide() if confirmed and not @reloadRequested and atom.getCurrentWindow().isWebViewFocused()
@reloadRequested = false
confirmed

View File

@@ -37,7 +37,7 @@ Editor = require './editor'
# the front.
#
module.exports =
class RootView extends View
class WorkspaceView extends View
atom.deserializers.add(this, Pane, PaneRow, PaneColumn, EditorView)
@version: 1
@@ -54,14 +54,14 @@ class RootView extends View
# Private:
@content: (state) ->
@div id: 'root-view', tabindex: -1, =>
@div id: 'workspace', tabindex: -1, =>
@div id: 'horizontal', outlet: 'horizontal', =>
@div id: 'vertical', outlet: 'vertical', =>
@div outlet: 'panes'
# Private:
@deserialize: (state) ->
new RootView(state)
new WorkspaceView(state)
# Private:
initialize: (state={}) ->

View File

@@ -3,7 +3,7 @@
@import "octicon-utf-codes";
@import "octicon-mixins";
@import "root-view";
@import "workspace-view";
@import "bootstrap";
@import "buttons";
@import "icons";

View File

@@ -22,6 +22,6 @@
}
</script>
</head>
<body class="workspace" tabindex="-1">
<body tabindex="-1">
</body>
</html>

View File

@@ -21,7 +21,7 @@ h6 {
font-family: @font-family;
}
#root-view {
#workspace {
height: 100%;
overflow: hidden;
position: relative;