Comparar commits
307 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| c8b92526ec | |||
| 92a9c7aef6 | |||
| d51a86e804 | |||
| 278a507653 | |||
| 7422f4378e | |||
| f2ab14656b | |||
| 453abf8b90 | |||
| 7866f0819d | |||
| 921e3c581d | |||
| 58aa87438d | |||
| ad73902382 | |||
| bf63a9715c | |||
| 06c52c6873 | |||
| 9ac27bc2f8 | |||
| 98caaf0d70 | |||
| a102d1e134 | |||
| 6caa86fb04 | |||
| b1e0c8132d | |||
| f3947dd6e0 | |||
| 27dbbabe09 | |||
| 5950110860 | |||
| ab5d71e6b5 | |||
| 1ee2839245 | |||
| a6f31ed791 | |||
| e04b5a74d7 | |||
| 4acf143f45 | |||
| 5ad5ce0841 | |||
| 31d1ca12c1 | |||
| ace3325db8 | |||
| b718114fc4 | |||
| 1df8c77f41 | |||
| 26e867d65e | |||
| 2688761c29 | |||
| b64d9db198 | |||
| bc5b786bb2 | |||
| 13025c17f1 | |||
| 8b4b5230ab | |||
| 7d6d634ceb | |||
| b386b00bc0 | |||
| 2028045254 | |||
| ca60dae630 | |||
| a5605bd408 | |||
| caf6fdd5ac | |||
| 19872959bc | |||
| 299ea18c58 | |||
| 966360e022 | |||
| 70a2be849a | |||
| 1c7843d9b2 | |||
| 5291f1c62c | |||
| c9e7cfc02c | |||
| e93ca3c901 | |||
| 48bd330a5e | |||
| 6240bc1fc9 | |||
| 6ccc60342f | |||
| 03750d0b6c | |||
| 03e31ad918 | |||
| 610c07870a | |||
| 5c37d208f5 | |||
| 88c119f4ad | |||
| d03cfda6c4 | |||
| 8f02b21d08 | |||
| 953f2c61f7 | |||
| 15e95d0d21 | |||
| 391a71fed0 | |||
| 67ed490618 | |||
| c812dfef9b | |||
| 631bca6c89 | |||
| 095c1b74a7 | |||
| 7e408ad268 | |||
| 4945fd7aae | |||
| 0db5549b64 | |||
| 96095f9c30 | |||
| e2b4fcad65 | |||
| 3ea1c80fe7 | |||
| 525b4ac3eb | |||
| 6ffc750e18 | |||
| 66716db4d1 | |||
| 95d03fc5fa | |||
| b816fca75e | |||
| 6f148f681d | |||
| a489358f55 | |||
| 1cd0caeb2d | |||
| 310939338c | |||
| e39d50972d | |||
| 9a5f3ab000 | |||
| 9285f2605f | |||
| b654209adb | |||
| 0c07166a8e | |||
| de36ceb00c | |||
| aa292874ec | |||
| 736b6f37e4 | |||
| 8d9098464c | |||
| eb6ce74a12 | |||
| 33ee1cb0de | |||
| 11a07f41ac | |||
| 5cf97db07c | |||
| f095d38978 | |||
| 218f6ab629 | |||
| 26edd40f14 | |||
| 8241351143 | |||
| 286361bf2b | |||
| 3d5437c1e9 | |||
| 95b9140dcf | |||
| fc82e5ffd6 | |||
| 20521ad487 | |||
| 99f91fac48 | |||
| d4b0b33d86 | |||
| 790c125e0b | |||
| 4afe133f85 | |||
| 763e83584d | |||
| 62a671aae6 | |||
| c0eb5d0ebe | |||
| d1e9ad3ed1 | |||
| 396b53b8dc | |||
| d87d98278e | |||
| 682a4be285 | |||
| 14c68a4280 | |||
| ddfbc6c335 | |||
| 779642b3da | |||
| 705c78bf18 | |||
| 07a21a15a1 | |||
| 287895c78c | |||
| fcf7b6747b | |||
| 1af25ea401 | |||
| aecd689593 | |||
| 8ad8a61aab | |||
| 6a83246838 | |||
| a7fc1c4138 | |||
| c19aee5472 | |||
| e9d49b1df3 | |||
| 5a456c8552 | |||
| 1179ced85c | |||
| 7738472eb8 | |||
| 45274eaad3 | |||
| 24f7638e8b | |||
| 6ec7b7b38d | |||
| 094a7e9a5f | |||
| 97181121c9 | |||
| 3e4c7a8ab7 | |||
| f4b08649a0 | |||
| c1a93395f5 | |||
| 53b538311e | |||
| 19ae78e062 | |||
| 5a93f14199 | |||
| d7dd0f3224 | |||
| 37e6f03346 | |||
| 0aa3cd58c1 | |||
| ac23717f8c | |||
| 491561db4a | |||
| edfd67b093 | |||
| dd63d47c11 | |||
| 067f5ea7e8 | |||
| eb223c4f21 | |||
| f632b6fe79 | |||
| 5bdc8af850 | |||
| b03931371a | |||
| c02755f59a | |||
| e178b25f17 | |||
| 96efb232ee | |||
| 714cbc9f4b | |||
| 64e4053a19 | |||
| a7f1f90c1d | |||
| cacaba936b | |||
| b20589fbb6 | |||
| d3f14d8939 | |||
| 094ba81758 | |||
| 8a40be8345 | |||
| 2d8d330df7 | |||
| fbc9c05096 | |||
| 1eab423a1c | |||
| cfca6ecc86 | |||
| fb96b01f30 | |||
| 625b95a6d9 | |||
| 0fe9dc6aa9 | |||
| 38e6aee46d | |||
| 01f87d9678 | |||
| 93bf9357b0 | |||
| ed42a275ab | |||
| 6998337144 | |||
| 8b92aef3ff | |||
| 66d6af54bf | |||
| 2a06ece3df | |||
| 1c0c8db042 | |||
| 9293ef766b | |||
| a7a9b3707f | |||
| 7e16e42b3f | |||
| 179fb2d274 | |||
| f804006d6c | |||
| 9a9347e3a5 | |||
| e4bcb96dcc | |||
| 8a0992d689 | |||
| db17a6cba4 | |||
| 5449fc2e15 | |||
| 0a84ad5307 | |||
| 485c402661 | |||
| 4591f00a65 | |||
| b635fa0c97 | |||
| 004103d579 | |||
| 2c952fad95 | |||
| adc983e8da | |||
| 7dc9d0c8ce | |||
| 3d3521962c | |||
| 46a1f69ab1 | |||
| 298d3e5fb6 | |||
| 27291980cb | |||
| 64ae4bf6c3 | |||
| 90a71d1171 | |||
| a5b7d15bcc | |||
| be2d49a410 | |||
| 8a9805cc6d | |||
| 196694e352 | |||
| 12683571e3 | |||
| c0991447ff | |||
| f9fcb9f2e2 | |||
| 1daab1b956 | |||
| fc7f922de0 | |||
| 5f1f2cd9be | |||
| dca0576496 | |||
| aa7d8fb382 | |||
| 08f20adc35 | |||
| c5f1165f61 | |||
| 58499aeec7 | |||
| 83c73fc94a | |||
| b28a1aa5c7 | |||
| bcb72394f9 | |||
| efe7baf140 | |||
| 4b07103fcf | |||
| 9d60fd2322 | |||
| 71228a5f45 | |||
| 6b3ba8e332 | |||
| 5da4846fff | |||
| de619a731b | |||
| d2283b0567 | |||
| 2a00acfdaf | |||
| b2025ebad0 | |||
| 0b44cee8db | |||
| 5fed6199ec | |||
| ddc04f2278 | |||
| f64a813fc6 | |||
| 68bc3f6ead | |||
| ffbcddf063 | |||
| b341749d54 | |||
| d2ab75382a | |||
| b125565776 | |||
| 9cec02420c | |||
| 6f82281b8f | |||
| ffda2386c3 | |||
| aefc647155 | |||
| 83455a7f3a | |||
| d8f64c15b8 | |||
| c927e95c2c | |||
| 5b12646a44 | |||
| 68bb43ee7d | |||
| 4048fb978c | |||
| 2d885496a3 | |||
| 64222d3096 | |||
| 2c7bbf8e9f | |||
| a45e9a1e8b | |||
| 3fd5ba9b3c | |||
| eb0e3df720 | |||
| 60a49d9c81 | |||
| 43ccf0a041 | |||
| 1f6764e708 | |||
| 48f714d5fb | |||
| e2813b4dd9 | |||
| 41b3d65e05 | |||
| 1e50985ec7 | |||
| 1d6087fcd3 | |||
| f2e74f216c | |||
| b9950ef2df | |||
| 67f4d51774 | |||
| 1bf4db15b2 | |||
| 28eb03ed29 | |||
| 2843af458b | |||
| 163a7587f9 | |||
| 18f83e90f7 | |||
| 7094701c66 | |||
| d7d23f7fc9 | |||
| bdbc850695 | |||
| 4e0ab92827 | |||
| b662281958 | |||
| 4d2cc86ada | |||
| 19fcc1c441 | |||
| 1f5fa27113 | |||
| 362bd2e61a | |||
| 4cb80d3c7e | |||
| 7f108dab38 | |||
| cec5a83eff | |||
| a7c3c15885 | |||
| 1c16738969 | |||
| b4a456d911 | |||
| c92f805e6e | |||
| 859a4db242 | |||
| 3a94b70270 | |||
| 85d6689344 | |||
| e0726b0354 | |||
| 0abd25ad6f | |||
| 42522686d7 | |||
| 1e9a8b92f2 | |||
| dda2b2e893 | |||
| e04c05ffee | |||
| 8cb0197638 | |||
| 73763d3e41 | |||
| 9d1c3124ee | |||
| 8cf24bc7de | |||
| 509d16b65a | |||
| e8e13ca645 |
+1
-1
@@ -1 +1 @@
|
||||
v0.10.21
|
||||
v0.10.33
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
2.7.6
|
||||
+18
-9
@@ -2,7 +2,7 @@
|
||||
|
||||
Atom is a hackable text editor for the 21st century, built on [atom-shell](http://github.com/atom/atom-shell), and based on everything we love about our favorite editors. We designed it to be deeply customizable, but still approachable using the default configuration.
|
||||
|
||||
Visit [atom.io](https://atom.io) to learn more.
|
||||
Visit [atom.io](https://atom.io) to learn more or visit the [Atom forum](https://discuss.atom.io).
|
||||
|
||||
Visit [issue #3684](https://github.com/atom/atom/issues/3684) to learn more
|
||||
about the Atom 1.0 roadmap.
|
||||
@@ -17,16 +17,25 @@ Atom will automatically update when a new release is available.
|
||||
|
||||
### Windows
|
||||
|
||||
Install the [Atom chocolatey package](https://chocolatey.org/packages/Atom).
|
||||
Download the latest [AtomSetup.exe installer](https://github.com/atom/atom/releases/latest).
|
||||
|
||||
1. Install [chocolatey](https://chocolatey.org).
|
||||
2. Close and reopen your command prompt or PowerShell window.
|
||||
3. Run `cinst Atom`
|
||||
4. In the future run `cup Atom` to upgrade to the latest release.
|
||||
Atom will automatically update when a new release is available.
|
||||
|
||||
You can also download a `.zip` file from the [releases page](https://github.com/atom/atom/releases/latest).
|
||||
The Windows version does not currently automatically update so you will need to
|
||||
manually upgrade to future releases by re-downloading the `.zip` file.
|
||||
You can also download an `atom-windows.zip` file from the [releases page](https://github.com/atom/atom/releases/latest).
|
||||
The `.zip` version will not automatically update.
|
||||
|
||||
#### Uninstalling Chocolatey Version
|
||||
|
||||
The recommended installation of Atom on Windows used to be using [Chocolatey](https://chocolatey.org/packages/Atom/).
|
||||
This is no longer recommended now that the Atom Windows installer & auto-updater
|
||||
exists.
|
||||
|
||||
To switch from Chocolatey to the new installer:
|
||||
* Upgrade to Atom 0.155 or above by running `cup Atom`
|
||||
* Run `cuninst Atom` to uninstall the Chocolatey version of Atom
|
||||
* This will not delete any of your installed packages or Atom config files.
|
||||
* Download the latest [AtomSetup.exe installer](https://github.com/atom/atom/releases/latest).
|
||||
* Double-click the downloaded file to install Atom
|
||||
|
||||
### Debian Linux (Ubuntu)
|
||||
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@
|
||||
"url": "https://github.com/atom/atom.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"atom-package-manager": "0.111.0"
|
||||
"atom-package-manager": "0.113.0"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,12 +45,12 @@ if [ $REDIRECT_STDERR ]; then
|
||||
fi
|
||||
|
||||
if [ $OS == 'Mac' ]; then
|
||||
ATOM_PATH=${ATOM_PATH:-/Applications} # Set ATOM_PATH unless it is already set
|
||||
ATOM_PATH="${ATOM_PATH:-/Applications}" # Set ATOM_PATH unless it is already set
|
||||
ATOM_APP_NAME=Atom.app
|
||||
|
||||
# If ATOM_PATH isn't a executable file, use spotlight to search for Atom
|
||||
if [ ! -x "$ATOM_PATH/$ATOM_APP_NAME" ]; then
|
||||
ATOM_PATH=$(mdfind "kMDItemCFBundleIdentifier == 'com.github.atom'" | grep -v ShipIt | head -1 | xargs dirname)
|
||||
ATOM_PATH="$(mdfind "kMDItemCFBundleIdentifier == 'com.github.atom'" | grep -v ShipIt | head -1 | xargs -0 dirname)"
|
||||
fi
|
||||
|
||||
# Exit if Atom can't be found
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
require '../spec/spec-helper'
|
||||
|
||||
path = require 'path'
|
||||
{$, Point} = require 'atom'
|
||||
{$} = require '../src/space-pen-extensions'
|
||||
{Point} = require 'atom'
|
||||
_ = require 'underscore-plus'
|
||||
fs = require 'fs-plus'
|
||||
Project = require '../src/project'
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
require './benchmark-helper'
|
||||
{$, _, WorkspaceView} = require 'atom'
|
||||
{$} = require '../src/space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
{WorkspaceView} = require 'atom'
|
||||
TokenizedBuffer = require '../src/tokenized-buffer'
|
||||
|
||||
describe "editorView.", ->
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"fs-plus": "2.x",
|
||||
"github-releases": "~0.2.0",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-atom-shell-installer": "^0.10.0",
|
||||
"grunt-atom-shell-installer": "^0.13.0",
|
||||
"grunt-cli": "~0.1.9",
|
||||
"grunt-coffeelint": "git+https://github.com/atom/grunt-coffeelint.git#cfb99aa99811d52687969532bd5a98011ed95bfe",
|
||||
"grunt-contrib-coffee": "~0.9.0",
|
||||
@@ -31,7 +31,7 @@
|
||||
"request": "~2.27.0",
|
||||
"rimraf": "~2.2.2",
|
||||
"runas": "~1.0.1",
|
||||
"tello": "1.0.3",
|
||||
"tello": "1.0.4",
|
||||
"temp": "~0.8.1",
|
||||
"underscore-plus": "1.x",
|
||||
"unzip": "~0.1.9",
|
||||
|
||||
@@ -29,6 +29,10 @@ Ubuntu LTS 12.04 64-bit is the recommended platform.
|
||||
* `sudo pacman -S base-devel git nodejs libgnome-keyring python2`
|
||||
* `export PYTHON=/usr/bin/python2` before building Atom.
|
||||
|
||||
### Slackware
|
||||
|
||||
* `sbopkg -k -i node -i atom`
|
||||
|
||||
## Instructions
|
||||
|
||||
If you have problems with permissions don't forget to prefix with `sudo`
|
||||
@@ -121,6 +125,15 @@ have Node.js installed, or node isn't identified as Node.js on your machine.
|
||||
If it's the latter, entering `sudo ln -s /usr/bin/nodejs /usr/bin/node` into
|
||||
your terminal may fix the issue.
|
||||
|
||||
#### You can also use Alternatives
|
||||
|
||||
On some variants (mostly Debian based distros) it's preferable for you to use
|
||||
Alternatives so that changes to the binary paths can be fixed or altered easily:
|
||||
|
||||
```sh
|
||||
sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 1 --slave /usr/bin/js js /usr/bin/nodejs
|
||||
```
|
||||
|
||||
### AttributeError: 'module' object has no attribute 'script_main'
|
||||
|
||||
If you get following error with a big traceback while building Atom:
|
||||
@@ -137,15 +150,6 @@ On Fedora you would do the following:
|
||||
sudo yum remove gyp
|
||||
```
|
||||
|
||||
#### You can also use Alternatives
|
||||
|
||||
On some variants (mostly Debian based distros) it's preferable for you to use
|
||||
Alternatives so that changes to the binary paths can be fixed or altered easily:
|
||||
|
||||
```sh
|
||||
sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 1 --slave /usr/bin/js js /usr/bin/nodejs
|
||||
```
|
||||
|
||||
### Linux build error reports in atom/atom
|
||||
* Use [this search](https://github.com/atom/atom/search?q=label%3Abuild-error+label%3Alinux&type=Issues)
|
||||
to get a list of reports about build errors on Linux.
|
||||
|
||||
@@ -72,7 +72,7 @@ Writing Asynchronous specs can be tricky at first. Some examples.
|
||||
atom.workspace.open 'c.coffee'
|
||||
|
||||
it "should be opened in an editor", ->
|
||||
expect(atom.workspace.getActiveEditor().getPath()).toContain 'c.coffee'
|
||||
expect(atom.workspace.getActiveTextEditor().getPath()).toContain 'c.coffee'
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE
|
||||
Object.defineProperty module.exports, 'WorkspaceView', get: ->
|
||||
deprecate """
|
||||
Requiring `WorkspaceView` from `atom` is no longer supported.
|
||||
Use `atom.view.getView(atom.workspace)` instead.
|
||||
Use `atom.views.getView(atom.workspace)` instead.
|
||||
"""
|
||||
require '../src/workspace-view'
|
||||
|
||||
@@ -119,8 +119,8 @@ unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE
|
||||
require 'react-atom-fork'
|
||||
|
||||
Object.defineProperty module.exports, 'Reactionary', get: ->
|
||||
deprecate "Please require `reactionary` instead: `Reactionary = require 'reactionary'`. Add `\"reactionary\": \"^0.9\"` to your package dependencies."
|
||||
require 'reactionary'
|
||||
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'`"
|
||||
|
||||
@@ -164,6 +164,9 @@
|
||||
{ label: 'View &Terms of Use', command: 'application:open-terms-of-use' }
|
||||
{ label: 'View &License', command: 'application:open-license' }
|
||||
{ label: 'VERSION', enabled: false }
|
||||
{ label: 'Restart and Install Update', command: 'application:install-update', visible: false}
|
||||
{ label: 'Check for Update', command: 'application:check-for-update', visible: false}
|
||||
{ label: 'Downloading Update', enabled: false, visible: false}
|
||||
{ type: 'separator' }
|
||||
{ label: '&Documentation', command: 'application:open-documentation' }
|
||||
{ label: 'Roadmap', command: 'application:open-roadmap' }
|
||||
|
||||
+63
-60
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "atom",
|
||||
"productName": "Atom",
|
||||
"version": "0.152.0",
|
||||
"version": "0.157.0",
|
||||
"description": "A hackable text editor for the 21st Century.",
|
||||
"main": "./src/browser/main.js",
|
||||
"repository": {
|
||||
@@ -20,14 +20,14 @@
|
||||
"atomShellVersion": "0.19.4",
|
||||
"dependencies": {
|
||||
"async": "0.2.6",
|
||||
"atom-keymap": "^2.2.2",
|
||||
"atom-keymap": "^2.3.0",
|
||||
"bootstrap": "git+https://github.com/atom/bootstrap.git#6af81906189f1747fd6c93479e3d998ebe041372",
|
||||
"clear-cut": "0.4.0",
|
||||
"coffee-script": "1.7.0",
|
||||
"coffeestack": "0.7.0",
|
||||
"delegato": "^1",
|
||||
"emissary": "^1.3.1",
|
||||
"event-kit": "0.7.2",
|
||||
"event-kit": "0.8.1",
|
||||
"first-mate": "^2.2.0",
|
||||
"fs-plus": "^2.3.2",
|
||||
"fstream": "0.1.24",
|
||||
@@ -45,7 +45,7 @@
|
||||
"nslog": "^1.0.1",
|
||||
"oniguruma": "^3.0.4",
|
||||
"optimist": "0.4.0",
|
||||
"pathwatcher": "^2.3.2",
|
||||
"pathwatcher": "^2.3.5",
|
||||
"property-accessors": "^1",
|
||||
"q": "^1.0.1",
|
||||
"random-words": "0.0.1",
|
||||
@@ -58,91 +58,94 @@
|
||||
"season": "^1.0.2",
|
||||
"semver": "2.2.1",
|
||||
"serializable": "^1",
|
||||
"service-hub": "^0.1.0",
|
||||
"space-pen": "3.8.2",
|
||||
"temp": "0.7.0",
|
||||
"text-buffer": "^3.7.2",
|
||||
"text-buffer": "^3.8.2",
|
||||
"theorist": "^1.0.2",
|
||||
"underscore-plus": "^1.6.1",
|
||||
"vm-compatibility-layer": "0.1.0"
|
||||
},
|
||||
"packageDependencies": {
|
||||
"atom-dark-syntax": "0.23.0",
|
||||
"atom-dark-ui": "0.41.0",
|
||||
"atom-dark-ui": "0.42.0",
|
||||
"atom-light-syntax": "0.22.0",
|
||||
"atom-light-ui": "0.35.0",
|
||||
"atom-light-ui": "0.36.0",
|
||||
"base16-tomorrow-dark-theme": "0.22.0",
|
||||
"base16-tomorrow-light-theme": "0.5.0",
|
||||
"solarized-dark-syntax": "0.23.0",
|
||||
"solarized-dark-syntax": "0.26.0",
|
||||
"solarized-light-syntax": "0.13.0",
|
||||
"archive-view": "0.37.0",
|
||||
"autocomplete": "0.33.0",
|
||||
"autoflow": "0.18.0",
|
||||
"autosave": "0.18.0",
|
||||
"background-tips": "0.17.0",
|
||||
"bookmarks": "0.30.0",
|
||||
"bracket-matcher": "0.62.0",
|
||||
"command-palette": "0.28.0",
|
||||
"archive-view": "0.40.0",
|
||||
"autocomplete": "0.34.0",
|
||||
"autoflow": "0.19.0",
|
||||
"autosave": "0.19.0",
|
||||
"background-tips": "0.18.0",
|
||||
"bookmarks": "0.31.0",
|
||||
"bracket-matcher": "0.64.0",
|
||||
"command-palette": "0.30.0",
|
||||
"deprecation-cop": "0.18.0",
|
||||
"dev-live-reload": "0.35.0",
|
||||
"encoding-selector": "0.8.0",
|
||||
"exception-reporting": "0.20.0",
|
||||
"find-and-replace": "0.147.0",
|
||||
"fuzzy-finder": "0.60.0",
|
||||
"git-diff": "0.43.0",
|
||||
"go-to-line": "0.26.0",
|
||||
"encoding-selector": "0.10.0",
|
||||
"exception-reporting": "0.21.0",
|
||||
"find-and-replace": "0.152.0",
|
||||
"fuzzy-finder": "0.62.0",
|
||||
"git-diff": "0.45.0",
|
||||
"go-to-line": "0.27.0",
|
||||
"grammar-selector": "0.37.0",
|
||||
"image-view": "0.42.0",
|
||||
"incompatible-packages": "0.10.0",
|
||||
"keybinding-resolver": "0.20.0",
|
||||
"link": "0.26.0",
|
||||
"markdown-preview": "0.110.0",
|
||||
"image-view": "0.43.0",
|
||||
"incompatible-packages": "0.15.0",
|
||||
"keybinding-resolver": "0.23.0",
|
||||
"link": "0.28.0",
|
||||
"markdown-preview": "0.112.0",
|
||||
"metrics": "0.39.0",
|
||||
"open-on-github": "0.30.0",
|
||||
"package-generator": "0.32.0",
|
||||
"notifications": "0.13.0",
|
||||
"open-on-github": "0.31.0",
|
||||
"package-generator": "0.33.0",
|
||||
"release-notes": "0.36.0",
|
||||
"settings-view": "0.161.0",
|
||||
"snippets": "0.56.0",
|
||||
"snippets": "0.58.0",
|
||||
"spell-check": "0.44.0",
|
||||
"status-bar": "0.47.0",
|
||||
"styleguide": "0.30.0",
|
||||
"symbols-view": "0.68.0",
|
||||
"tabs": "0.56.0",
|
||||
"timecop": "0.23.0",
|
||||
"tree-view": "0.134.0",
|
||||
"update-package-dependencies": "0.6.0",
|
||||
"welcome": "0.19.0",
|
||||
"whitespace": "0.26.0",
|
||||
"wrap-guide": "0.24.0",
|
||||
"language-c": "0.31.0",
|
||||
"language-coffee-script": "0.38.0",
|
||||
"language-css": "0.23.0",
|
||||
"language-gfm": "0.54.0",
|
||||
"status-bar": "0.53.0",
|
||||
"styleguide": "0.34.0",
|
||||
"symbols-view": "0.70.0",
|
||||
"tabs": "0.57.0",
|
||||
"timecop": "0.24.0",
|
||||
"tree-view": "0.137.0",
|
||||
"update-package-dependencies": "0.7.0",
|
||||
"welcome": "0.21.0",
|
||||
"whitespace": "0.27.0",
|
||||
"wrap-guide": "0.26.0",
|
||||
"language-c": "0.33.0",
|
||||
"language-clojure": "0.9.0",
|
||||
"language-coffee-script": "0.38.1",
|
||||
"language-css": "0.23.1",
|
||||
"language-gfm": "0.55.0",
|
||||
"language-git": "0.9.0",
|
||||
"language-go": "0.19.0",
|
||||
"language-html": "0.26.0",
|
||||
"language-hyperlink": "0.12.0",
|
||||
"language-java": "0.11.0",
|
||||
"language-javascript": "0.45.0",
|
||||
"language-json": "0.8.0",
|
||||
"language-less": "0.18.0",
|
||||
"language-go": "0.19.1",
|
||||
"language-html": "0.26.1",
|
||||
"language-hyperlink": "0.12.2",
|
||||
"language-java": "0.13.0",
|
||||
"language-javascript": "0.48.0",
|
||||
"language-json": "0.10.0",
|
||||
"language-less": "0.21.0",
|
||||
"language-make": "0.12.0",
|
||||
"language-mustache": "0.10.0",
|
||||
"language-objective-c": "0.11.0",
|
||||
"language-mustache": "0.11.0",
|
||||
"language-objective-c": "0.12.0",
|
||||
"language-perl": "0.9.0",
|
||||
"language-php": "0.18.0",
|
||||
"language-property-list": "0.7.0",
|
||||
"language-python": "0.24.0",
|
||||
"language-ruby": "0.41.0",
|
||||
"language-python": "0.26.0",
|
||||
"language-ruby": "0.44.0",
|
||||
"language-ruby-on-rails": "0.18.0",
|
||||
"language-sass": "0.26.0",
|
||||
"language-shellscript": "0.10.0",
|
||||
"language-sass": "0.28.0",
|
||||
"language-shellscript": "0.10.1",
|
||||
"language-source": "0.8.0",
|
||||
"language-sql": "0.11.0",
|
||||
"language-text": "0.6.0",
|
||||
"language-todo": "0.13.0",
|
||||
"language-toml": "0.14.0",
|
||||
"language-todo": "0.14.0",
|
||||
"language-toml": "0.14.1",
|
||||
"language-xml": "0.25.0",
|
||||
"language-yaml": "0.20.0"
|
||||
"language-yaml": "0.21.0"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{$} = require 'atom'
|
||||
{$} = require '../src/space-pen-extensions'
|
||||
|
||||
describe '"atom" protocol URL', ->
|
||||
it 'sends the file relative in the package as response', ->
|
||||
|
||||
@@ -38,7 +38,8 @@ module.exports =
|
||||
class AtomReporter extends View
|
||||
@content: ->
|
||||
@div class: 'spec-reporter', =>
|
||||
@div outlet: "suites"
|
||||
@div class: 'padded pull-right', =>
|
||||
@button outlet: 'reloadButton', class: 'btn btn-small reload-button', 'Reload Specs'
|
||||
@div outlet: 'coreArea', class: 'symbol-area', =>
|
||||
@div outlet: 'coreHeader', class: 'symbol-header'
|
||||
@ul outlet: 'coreSummary', class: 'symbol-summary list-unstyled'
|
||||
@@ -80,6 +81,8 @@ class AtomReporter extends View
|
||||
@on 'click', '.stack-trace', ->
|
||||
$(this).toggleClass('expanded')
|
||||
|
||||
@reloadButton.on 'click', -> require('ipc').send('call-window-method', 'restart')
|
||||
|
||||
reportRunnerResults: (runner) ->
|
||||
@updateSpecCounts()
|
||||
@status.addClass('alert-success').removeClass('alert-info') if @failedCount is 0
|
||||
|
||||
+12
-9
@@ -1,4 +1,4 @@
|
||||
{$, $$, WorkspaceView} = require 'atom'
|
||||
{$, $$} = require '../src/space-pen-extensions'
|
||||
Exec = require('child_process').exec
|
||||
path = require 'path'
|
||||
Package = require '../src/package'
|
||||
@@ -30,13 +30,16 @@ describe "the `atom` global", ->
|
||||
version = '36b5518'
|
||||
expect(atom.isReleasedVersion()).toBe false
|
||||
|
||||
describe "window:update-available", ->
|
||||
it "is triggered when the auto-updater sends the update-downloaded event", ->
|
||||
# FIXME: We need to figure out a way minus workspaceView to handle update-available events.
|
||||
atom.workspaceView = atom.views.getView(atom.workspace).__spacePenView
|
||||
describe "when an update becomes available", ->
|
||||
subscription = null
|
||||
|
||||
afterEach ->
|
||||
subscription?.dispose()
|
||||
|
||||
it "invokes onUpdateAvailable listeners", ->
|
||||
updateAvailableHandler = jasmine.createSpy("update-available-handler")
|
||||
atom.workspaceView.on 'window:update-available', updateAvailableHandler
|
||||
subscription = atom.onUpdateAvailable updateAvailableHandler
|
||||
|
||||
autoUpdater = require('remote').require('auto-updater')
|
||||
autoUpdater.emit 'update-downloaded', null, "notes", "version"
|
||||
|
||||
@@ -44,9 +47,9 @@ describe "the `atom` global", ->
|
||||
updateAvailableHandler.callCount > 0
|
||||
|
||||
runs ->
|
||||
[event, version, notes] = updateAvailableHandler.mostRecentCall.args
|
||||
expect(notes).toBe 'notes'
|
||||
expect(version).toBe 'version'
|
||||
{releaseVersion, releaseNotes} = updateAvailableHandler.mostRecentCall.args[0]
|
||||
expect(releaseVersion).toBe 'version'
|
||||
expect(releaseNotes).toBe 'notes'
|
||||
|
||||
describe "loading default config", ->
|
||||
it 'loads the default core config', ->
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
BufferedProcess = require '../src/buffered-process'
|
||||
|
||||
describe "BufferedProcess", ->
|
||||
describe "when a bad command is specified", ->
|
||||
[oldOnError] = []
|
||||
beforeEach ->
|
||||
oldOnError = window.onerror
|
||||
window.onerror = jasmine.createSpy()
|
||||
|
||||
afterEach ->
|
||||
window.onerror = oldOnError
|
||||
|
||||
describe "when there is an error handler specified", ->
|
||||
it "calls the error handler and does not throw an exception", ->
|
||||
process = new BufferedProcess
|
||||
command: 'bad-command-nope'
|
||||
args: ['nothing']
|
||||
options: {}
|
||||
|
||||
errorSpy = jasmine.createSpy().andCallFake (error) -> error.handle()
|
||||
process.onWillThrowError(errorSpy)
|
||||
|
||||
waitsFor -> errorSpy.callCount > 0
|
||||
|
||||
runs ->
|
||||
expect(window.onerror).not.toHaveBeenCalled()
|
||||
expect(errorSpy).toHaveBeenCalled()
|
||||
expect(errorSpy.mostRecentCall.args[0].error.message).toContain 'spawn bad-command-nope ENOENT'
|
||||
|
||||
describe "when there is not an error handler specified", ->
|
||||
it "calls the error handler and does not throw an exception", ->
|
||||
process = new BufferedProcess
|
||||
command: 'bad-command-nope'
|
||||
args: ['nothing']
|
||||
options: {}
|
||||
|
||||
waitsFor -> window.onerror.callCount > 0
|
||||
|
||||
runs ->
|
||||
expect(window.onerror).toHaveBeenCalled()
|
||||
expect(window.onerror.mostRecentCall.args[0]).toContain 'Failed to spawn command `bad-command-nope`'
|
||||
expect(window.onerror.mostRecentCall.args[4].name).toBe 'BufferedProcessError'
|
||||
@@ -128,6 +128,12 @@ describe "Config", ->
|
||||
expect(atom.config.get("foo")).toEqual 'a\\.b': 1, b: 2
|
||||
|
||||
describe ".toggle(keyPath)", ->
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
afterEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
it "negates the boolean value of the current key path value", ->
|
||||
atom.config.set('foo.a', 1)
|
||||
atom.config.toggle('foo.a')
|
||||
@@ -298,6 +304,12 @@ describe "Config", ->
|
||||
expect(observeHandler).toHaveBeenCalledWith atom.config.get("foo.bar.baz")
|
||||
|
||||
describe ".getPositiveInt(keyPath, defaultValue)", ->
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
afterEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
it "returns the proper coerced value", ->
|
||||
atom.config.set('editor.preferredLineLength', 0)
|
||||
expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 1
|
||||
@@ -470,7 +482,7 @@ describe "Config", ->
|
||||
|
||||
it "does not fire the callback once the observe subscription is off'ed", ->
|
||||
observeHandler.reset() # clear the initial call
|
||||
observeSubscription.off()
|
||||
observeSubscription.dispose()
|
||||
atom.config.set('foo.bar.baz', "value 2")
|
||||
expect(observeHandler).not.toHaveBeenCalled()
|
||||
|
||||
@@ -554,11 +566,13 @@ describe "Config", ->
|
||||
describe "when the config file contains invalid cson", ->
|
||||
beforeEach ->
|
||||
spyOn(console, 'error')
|
||||
spyOn(atom.notifications, 'addError')
|
||||
fs.writeFileSync(atom.config.configFilePath, "{{{{{")
|
||||
|
||||
it "logs an error to the console and does not overwrite the config file on a subsequent save", ->
|
||||
atom.config.loadUserConfig()
|
||||
expect(console.error).toHaveBeenCalled()
|
||||
expect(atom.notifications.addError.callCount).toBe 1
|
||||
atom.config.set("hair", "blonde") # trigger a save
|
||||
expect(atom.config.save).not.toHaveBeenCalled()
|
||||
|
||||
@@ -692,7 +706,6 @@ describe "Config", ->
|
||||
expect(atom.config.get(['.source.ruby'], 'foo.bar')).toBe 'baz'
|
||||
expect(atom.config.get(['.source.ruby'], 'foo.scoped')).toBe true
|
||||
|
||||
|
||||
describe "when the config file changes to omit a setting with a default", ->
|
||||
it "resets the setting back to the default", ->
|
||||
fs.writeFileSync(atom.config.configFilePath, "foo: { baz: 'new'}")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{$$} = require 'atom'
|
||||
{$$} = require '../src/space-pen-extensions'
|
||||
|
||||
ContextMenuManager = require '../src/context-menu-manager'
|
||||
|
||||
@@ -151,24 +151,31 @@ describe "ContextMenuManager", ->
|
||||
shouldDisplay = false
|
||||
expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual []
|
||||
|
||||
it "allows items to be specified in the legacy format for now", ->
|
||||
contextMenu.add '.parent':
|
||||
'A': 'a'
|
||||
'Separator 1': '-'
|
||||
'B':
|
||||
'C': 'c'
|
||||
'Separator 2': '-'
|
||||
'D': 'd'
|
||||
describe "when the menus are specified in a legacy format", ->
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
expect(contextMenu.templateForElement(parent)).toEqual [
|
||||
{label: 'A', command: 'a'}
|
||||
{type: 'separator'}
|
||||
{
|
||||
label: 'B'
|
||||
submenu: [
|
||||
{label: 'C', command: 'c'}
|
||||
{type: 'separator'}
|
||||
{label: 'D', command: 'd'}
|
||||
]
|
||||
}
|
||||
]
|
||||
afterEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
it "allows items to be specified in the legacy format for now", ->
|
||||
contextMenu.add '.parent':
|
||||
'A': 'a'
|
||||
'Separator 1': '-'
|
||||
'B':
|
||||
'C': 'c'
|
||||
'Separator 2': '-'
|
||||
'D': 'd'
|
||||
|
||||
expect(contextMenu.templateForElement(parent)).toEqual [
|
||||
{label: 'A', command: 'a'}
|
||||
{type: 'separator'}
|
||||
{
|
||||
label: 'B'
|
||||
submenu: [
|
||||
{label: 'C', command: 'c'}
|
||||
{type: 'separator'}
|
||||
{label: 'D', command: 'd'}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1085,6 +1085,12 @@ describe "DisplayBuffer", ->
|
||||
expect(oldProperties).toEqual decorationProperties
|
||||
expect(newProperties).toEqual type: 'gutter', class: 'two', id: decoration.id
|
||||
|
||||
describe "::getDecorations(properties)", ->
|
||||
it "returns decorations matching the given optional properties", ->
|
||||
expect(displayBuffer.getDecorations()).toEqual [decoration]
|
||||
expect(displayBuffer.getDecorations(class: 'two').length).toEqual 0
|
||||
expect(displayBuffer.getDecorations(class: 'one').length).toEqual 1
|
||||
|
||||
describe "::setScrollTop", ->
|
||||
beforeEach ->
|
||||
displayBuffer.manageScrollPosition = true
|
||||
|
||||
@@ -9,6 +9,6 @@ module.exports =
|
||||
atom.commands.add 'atom-workspace', 'activation-command', =>
|
||||
@activationCommandCallCount++
|
||||
|
||||
editorView = atom.views.getView(atom.workspace.getActiveEditor())?.__spacePenView
|
||||
editorView = atom.views.getView(atom.workspace.getActiveTextEditor())?.__spacePenView
|
||||
editorView?.command 'activation-command', =>
|
||||
@legacyActivationCommandCallCount++
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
]
|
||||
|
||||
'context-menu':
|
||||
'.test-1':
|
||||
'Menu item 1': 'command-1'
|
||||
'.test-1': [
|
||||
{label: 'Menu item 1', command: 'command-1'}
|
||||
]
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
]
|
||||
|
||||
'context-menu':
|
||||
'.test-1':
|
||||
'Menu item 2': 'command-2'
|
||||
'.test-1': [
|
||||
{label: 'Menu item 2', command: 'command-2'}
|
||||
]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
'context-menu':
|
||||
'.test-1':
|
||||
'Menu item 3': 'command-3'
|
||||
'.test-1': [
|
||||
{label: 'Menu item 3', command: 'command-3'}
|
||||
]
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
'.source.omg':
|
||||
'editor':
|
||||
'increaseIndentPattern': '^a'
|
||||
'decreaseIndentPattern': '^z'
|
||||
'commentStart': '/*'
|
||||
'commentEnd': '*/'
|
||||
|
||||
@@ -132,7 +132,7 @@ describe "GitRepository", ->
|
||||
atom.workspace.open(filePath)
|
||||
|
||||
runs ->
|
||||
editor = atom.workspace.getActiveEditor()
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
|
||||
it "displays a confirmation dialog by default", ->
|
||||
spyOn(atom, 'confirm').andCallFake ({buttons}) -> buttons.OK()
|
||||
|
||||
@@ -16,3 +16,32 @@ describe "Notification", ->
|
||||
it "returns the icon specified", ->
|
||||
notification = new Notification('error', 'message!', icon: 'my-icon')
|
||||
expect(notification.getIcon()).toBe 'my-icon'
|
||||
|
||||
describe "dismissing notifications", ->
|
||||
describe "when the notfication is dismissable", ->
|
||||
it "calls a callback when the notification is dismissed", ->
|
||||
dismissedSpy = jasmine.createSpy()
|
||||
notification = new Notification('error', 'message', dismissable: true)
|
||||
notification.onDidDismiss dismissedSpy
|
||||
|
||||
expect(notification.isDismissable()).toBe true
|
||||
expect(notification.isDismissed()).toBe false
|
||||
|
||||
notification.dismiss()
|
||||
|
||||
expect(dismissedSpy).toHaveBeenCalled()
|
||||
expect(notification.isDismissed()).toBe true
|
||||
|
||||
describe "when the notfication is not dismissable", ->
|
||||
it "does nothing when ::dismiss() is called", ->
|
||||
dismissedSpy = jasmine.createSpy()
|
||||
notification = new Notification('error', 'message')
|
||||
notification.onDidDismiss dismissedSpy
|
||||
|
||||
expect(notification.isDismissable()).toBe false
|
||||
expect(notification.isDismissed()).toBe true
|
||||
|
||||
notification.dismiss()
|
||||
|
||||
expect(dismissedSpy).not.toHaveBeenCalled()
|
||||
expect(notification.isDismissed()).toBe true
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{$, $$, WorkspaceView} = require 'atom'
|
||||
Grim = require 'grim'
|
||||
{$, $$} = require '../src/space-pen-extensions'
|
||||
Package = require '../src/package'
|
||||
|
||||
describe "PackageManager", ->
|
||||
workspaceElement = null
|
||||
beforeEach ->
|
||||
workspaceElement = atom.views.getView(atom.workspace)
|
||||
spyOn(Grim, 'deprecate') # suppress deprecation warnings due to comment strings
|
||||
|
||||
describe "::loadPackage(name)", ->
|
||||
it "continues if the package has an invalid package.json", ->
|
||||
@@ -98,15 +100,23 @@ describe "PackageManager", ->
|
||||
expect(atom.config.set('package-with-config-schema.numbers.one', '10')).toBe true
|
||||
expect(atom.config.get('package-with-config-schema.numbers.one')).toBe 10
|
||||
|
||||
it "still assigns configDefaults from the module though deprecated", ->
|
||||
expect(atom.config.get('package-with-config-defaults.numbers.one')).toBeUndefined()
|
||||
describe "when a package has configDefaults", ->
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('package-with-config-defaults')
|
||||
afterEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
runs ->
|
||||
expect(atom.config.get('package-with-config-defaults.numbers.one')).toBe 1
|
||||
expect(atom.config.get('package-with-config-defaults.numbers.two')).toBe 2
|
||||
it "still assigns configDefaults from the module though deprecated", ->
|
||||
|
||||
expect(atom.config.get('package-with-config-defaults.numbers.one')).toBeUndefined()
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('package-with-config-defaults')
|
||||
|
||||
runs ->
|
||||
expect(atom.config.get('package-with-config-defaults.numbers.one')).toBe 1
|
||||
expect(atom.config.get('package-with-config-defaults.numbers.two')).toBe 2
|
||||
|
||||
describe "when the package metadata includes `activationCommands`", ->
|
||||
[mainModule, promise, workspaceCommandListener] = []
|
||||
@@ -136,7 +146,7 @@ describe "PackageManager", ->
|
||||
atom.workspace.open()
|
||||
|
||||
runs ->
|
||||
editorView = atom.views.getView(atom.workspace.getActiveEditor()).__spacePenView
|
||||
editorView = atom.views.getView(atom.workspace.getActiveTextEditor()).__spacePenView
|
||||
legacyCommandListener = jasmine.createSpy("legacyCommandListener")
|
||||
editorView.command 'activation-command', legacyCommandListener
|
||||
editorCommandListener = jasmine.createSpy("editorCommandListener")
|
||||
@@ -359,7 +369,31 @@ describe "PackageManager", ->
|
||||
atom.packages.activatePackage("package-with-scoped-properties")
|
||||
|
||||
runs ->
|
||||
expect(atom.config.get ['.source.omg'], 'editor.increaseIndentPattern').toBe '^a'
|
||||
expect(atom.config.get ['.source.omg'], 'editor.indent.increasePattern').toBe '^a'
|
||||
|
||||
it "combines 'editor.commentStart' and 'editor.commentEnd' strings under the 'editor.comment' key path", ->
|
||||
if atom.packages.isPackageLoaded("package-with-scoped-properties")
|
||||
atom.packages.unloadPackage("package-with-scoped-properties")
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage("package-with-scoped-properties")
|
||||
|
||||
runs ->
|
||||
expect(atom.config.get ['.source.omg'], 'editor.comment.start').toBe '/*'
|
||||
expect(atom.config.get ['.source.omg'], 'editor.comment.end').toBe '*/'
|
||||
expect(Grim.deprecate).toHaveBeenCalled()
|
||||
|
||||
it "combines 'editor.increaseIndentPattern' and 'editor.decreaseIndentPattern' strings under the 'editor.indent' key path", ->
|
||||
if atom.packages.isPackageLoaded("package-with-scoped-properties")
|
||||
atom.packages.unloadPackage("package-with-scoped-properties")
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage("package-with-scoped-properties")
|
||||
|
||||
runs ->
|
||||
expect(atom.config.get ['.source.omg'], 'editor.indent.increasePattern').toBe '^a'
|
||||
expect(atom.config.get ['.source.omg'], 'editor.indent.decreasePattern').toBe '^z'
|
||||
expect(Grim.deprecate).toHaveBeenCalled()
|
||||
|
||||
describe "converted textmate packages", ->
|
||||
it "loads the package's grammars", ->
|
||||
@@ -378,7 +412,7 @@ describe "PackageManager", ->
|
||||
atom.packages.activatePackage('language-ruby')
|
||||
|
||||
runs ->
|
||||
expect(atom.config.get(['.source.ruby'], 'editor.commentStart')).toBe '# '
|
||||
expect(atom.config.get(['.source.ruby'], 'editor.comment.start')).toBe '# '
|
||||
|
||||
describe "::deactivatePackage(id)", ->
|
||||
afterEach ->
|
||||
@@ -485,9 +519,9 @@ describe "PackageManager", ->
|
||||
atom.packages.activatePackage("package-with-scoped-properties")
|
||||
|
||||
runs ->
|
||||
expect(atom.config.get ['.source.omg'], 'editor.increaseIndentPattern').toBe '^a'
|
||||
expect(atom.config.get ['.source.omg'], 'editor.indent.increasePattern').toBe '^a'
|
||||
atom.packages.deactivatePackage("package-with-scoped-properties")
|
||||
expect(atom.config.get ['.source.omg'], 'editor.increaseIndentPattern').toBeUndefined()
|
||||
expect(atom.config.get ['.source.omg'], 'editor.indent.increasePattern').toBeUndefined()
|
||||
|
||||
describe "textmate packages", ->
|
||||
it "removes the package's grammars", ->
|
||||
@@ -514,6 +548,7 @@ describe "PackageManager", ->
|
||||
themeActivator = null
|
||||
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
spyOn(console, 'warn')
|
||||
atom.packages.loadPackages()
|
||||
|
||||
@@ -529,6 +564,7 @@ describe "PackageManager", ->
|
||||
|
||||
GrammarRegistry = require '../src/grammar-registry'
|
||||
atom.grammars = window.syntax = new GrammarRegistry()
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
it "activates all the packages, and none of the themes", ->
|
||||
atom.packages.activate()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{$} = require 'atom'
|
||||
{$} = require '../src/space-pen-extensions'
|
||||
path = require 'path'
|
||||
Package = require '../src/package'
|
||||
ThemePackage = require '../src/theme-package'
|
||||
|
||||
@@ -148,3 +148,57 @@ describe "PaneContainer", ->
|
||||
saved = container.confirmClose()
|
||||
expect(saved).toBeFalsy()
|
||||
expect(atom.confirm).toHaveBeenCalled()
|
||||
|
||||
describe "::onDidAddPane(callback)", ->
|
||||
it "invokes the given callback when panes are added", ->
|
||||
container = new PaneContainer
|
||||
events = []
|
||||
container.onDidAddPane (event) -> events.push(event)
|
||||
|
||||
pane1 = container.getActivePane()
|
||||
pane2 = pane1.splitRight()
|
||||
pane3 = pane2.splitDown()
|
||||
|
||||
expect(events).toEqual [{pane: pane2}, {pane: pane3}]
|
||||
|
||||
describe "::onDidDestroyPane(callback)", ->
|
||||
it "invokes the given callback when panes are destroyed", ->
|
||||
container = new PaneContainer
|
||||
events = []
|
||||
container.onDidDestroyPane (event) -> events.push(event)
|
||||
|
||||
pane1 = container.getActivePane()
|
||||
pane2 = pane1.splitRight()
|
||||
pane3 = pane2.splitDown()
|
||||
|
||||
pane2.destroy()
|
||||
pane3.destroy()
|
||||
|
||||
expect(events).toEqual [{pane: pane2}, {pane: pane3}]
|
||||
|
||||
describe "::onWillDestroyPaneItem() and ::onDidDestroyPaneItem", ->
|
||||
it "invokes the given callbacks when an item will be destroyed on any pane", ->
|
||||
container = new PaneContainer
|
||||
pane1 = container.getRoot()
|
||||
item1 = new Object
|
||||
item2 = new Object
|
||||
item3 = new Object
|
||||
|
||||
pane1.addItem(item1)
|
||||
events = []
|
||||
container.onWillDestroyPaneItem (event) -> events.push(['will', event])
|
||||
container.onDidDestroyPaneItem (event) -> events.push(['did', event])
|
||||
pane2 = pane1.splitRight(items: [item2, item3])
|
||||
|
||||
pane1.destroyItem(item1)
|
||||
pane2.destroyItem(item3)
|
||||
pane2.destroyItem(item2)
|
||||
|
||||
expect(events).toEqual [
|
||||
['will', {item: item1, pane: pane1, index: 0}]
|
||||
['did', {item: item1, pane: pane1, index: 0}]
|
||||
['will', {item: item3, pane: pane2, index: 1}]
|
||||
['did', {item: item3, pane: pane2, index: 1}]
|
||||
['will', {item: item2, pane: pane2, index: 0}]
|
||||
['did', {item: item2, pane: pane2, index: 0}]
|
||||
]
|
||||
|
||||
@@ -3,7 +3,8 @@ temp = require 'temp'
|
||||
PaneContainer = require '../src/pane-container'
|
||||
PaneContainerView = require '../src/pane-container-view'
|
||||
PaneView = require '../src/pane-view'
|
||||
{$, View, $$} = require 'atom'
|
||||
{Disposable} = require 'event-kit'
|
||||
{$, View, $$} = require '../src/space-pen-extensions'
|
||||
|
||||
describe "PaneContainerView", ->
|
||||
[TestView, container, pane1, pane2, pane3, deserializerDisposable] = []
|
||||
@@ -18,6 +19,8 @@ describe "PaneContainerView", ->
|
||||
getUri: -> path.join(temp.dir, @name)
|
||||
save: -> @saved = true
|
||||
isEqual: (other) -> @name is other?.name
|
||||
onDidChangeTitle: -> new Disposable(->)
|
||||
onDidChangeModified: -> new Disposable(->)
|
||||
|
||||
container = atom.views.getView(atom.workspace.paneContainer).__spacePenView
|
||||
pane1 = container.getRoot()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
PaneContainer = require '../src/pane-container'
|
||||
PaneView = require '../src/pane-view'
|
||||
fs = require 'fs-plus'
|
||||
{Emitter} = require 'event-kit'
|
||||
{$, View} = require 'atom'
|
||||
{Emitter, Disposable} = require 'event-kit'
|
||||
{$, View} = require '../src/space-pen-extensions'
|
||||
path = require 'path'
|
||||
temp = require 'temp'
|
||||
|
||||
@@ -21,8 +21,11 @@ describe "PaneView", ->
|
||||
@emitter.emit 'did-change-title', 'title'
|
||||
onDidChangeTitle: (callback) ->
|
||||
@emitter.on 'did-change-title', callback
|
||||
onDidChangeModified: -> new Disposable(->)
|
||||
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
deserializerDisposable = atom.deserializers.add(TestView)
|
||||
container = atom.views.getView(new PaneContainer).__spacePenView
|
||||
containerModel = container.model
|
||||
@@ -41,6 +44,7 @@ describe "PaneView", ->
|
||||
|
||||
afterEach ->
|
||||
deserializerDisposable.dispose()
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
describe "when the active pane item changes", ->
|
||||
it "hides all item views except the active one", ->
|
||||
@@ -155,14 +159,19 @@ describe "PaneView", ->
|
||||
expect(view1.is(':visible')).toBe true
|
||||
|
||||
describe "when the title of the active item changes", ->
|
||||
describe 'when there is no onDidChangeTitle method', ->
|
||||
describe 'when there is no onDidChangeTitle method (deprecated)', ->
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
view1.onDidChangeTitle = null
|
||||
view2.onDidChangeTitle = null
|
||||
|
||||
pane.activateItem(view2)
|
||||
pane.activateItem(view1)
|
||||
|
||||
afterEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
it "emits pane:active-item-title-changed", ->
|
||||
activeItemTitleChangedHandler = jasmine.createSpy("activeItemTitleChangedHandler")
|
||||
pane.on 'pane:active-item-title-changed', activeItemTitleChangedHandler
|
||||
@@ -220,7 +229,7 @@ describe "PaneView", ->
|
||||
|
||||
beforeEach ->
|
||||
pane2Model = paneModel.splitRight() # Can't destroy the last pane, so we add another
|
||||
pane2 = containerModel.getView(pane2Model).__spacePenView
|
||||
pane2 = atom.views.getView(pane2Model).__spacePenView
|
||||
|
||||
it "triggers a 'pane:removed' event with the pane", ->
|
||||
removedHandler = jasmine.createSpy("removedHandler")
|
||||
@@ -253,7 +262,7 @@ describe "PaneView", ->
|
||||
|
||||
beforeEach ->
|
||||
pane2Model = paneModel.splitRight(items: [pane.copyActiveItem()])
|
||||
pane2 = containerModel.getView(pane2Model).__spacePenView
|
||||
pane2 = atom.views.getView(pane2Model).__spacePenView
|
||||
expect(pane2Model.isActive()).toBe true
|
||||
|
||||
it "adds or removes the .active class as appropriate", ->
|
||||
@@ -300,8 +309,8 @@ describe "PaneView", ->
|
||||
pane2Model = pane1Model.splitRight(items: [pane1Model.copyActiveItem()])
|
||||
pane3Model = pane2Model.splitDown(items: [pane2Model.copyActiveItem()])
|
||||
pane2 = pane2Model._view
|
||||
pane2 = containerModel.getView(pane2Model).__spacePenView
|
||||
pane3 = containerModel.getView(pane3Model).__spacePenView
|
||||
pane2 = atom.views.getView(pane2Model).__spacePenView
|
||||
pane3 = atom.views.getView(pane3Model).__spacePenView
|
||||
|
||||
expect(container.find('> atom-pane-axis.horizontal > atom-pane').toArray()).toEqual [pane1[0]]
|
||||
expect(container.find('> atom-pane-axis.horizontal > atom-pane-axis.vertical > atom-pane').toArray()).toEqual [pane2[0], pane3[0]]
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
ViewRegistry = require '../src/view-registry'
|
||||
Panel = require '../src/panel'
|
||||
PanelElement = require '../src/panel-element'
|
||||
PanelContainer = require '../src/panel-container'
|
||||
PanelContainerElement = require '../src/panel-container-element'
|
||||
|
||||
describe "PanelContainerElement", ->
|
||||
[jasmineContent, element, container, viewRegistry] = []
|
||||
[jasmineContent, element, container] = []
|
||||
|
||||
class TestPanelContainerItem
|
||||
constructior: ->
|
||||
@@ -13,25 +12,23 @@ describe "PanelContainerElement", ->
|
||||
class TestPanelContainerItemElement extends HTMLElement
|
||||
createdCallback: ->
|
||||
@classList.add('test-root')
|
||||
setModel: (@model) ->
|
||||
initialize: (@model) ->
|
||||
this
|
||||
|
||||
TestPanelContainerItemElement = document.registerElement 'atom-test-container-item-element', prototype: TestPanelContainerItemElement.prototype
|
||||
|
||||
beforeEach ->
|
||||
jasmineContent = document.body.querySelector('#jasmine-content')
|
||||
|
||||
viewRegistry = new ViewRegistry
|
||||
viewRegistry.addViewProvider
|
||||
modelConstructor: Panel
|
||||
viewConstructor: PanelElement
|
||||
viewRegistry.addViewProvider
|
||||
modelConstructor: PanelContainer
|
||||
viewConstructor: PanelContainerElement
|
||||
viewRegistry.addViewProvider
|
||||
modelConstructor: TestPanelContainerItem
|
||||
viewConstructor: TestPanelContainerItemElement
|
||||
atom.views.addViewProvider Panel, (model) ->
|
||||
new PanelElement().initialize(model)
|
||||
atom.views.addViewProvider PanelContainer, (model) ->
|
||||
new PaneContainerElement().initialize(model)
|
||||
atom.views.addViewProvider TestPanelContainerItem, (model) ->
|
||||
new TestPanelContainerItemElement().initialize(model)
|
||||
|
||||
container = new PanelContainer({viewRegistry, location: 'left'})
|
||||
element = container.getView()
|
||||
container = new PanelContainer({location: 'left'})
|
||||
element = atom.views.getView(container)
|
||||
jasmineContent.appendChild(element)
|
||||
|
||||
it 'has a location class with value from the model', ->
|
||||
@@ -43,23 +40,38 @@ describe "PanelContainerElement", ->
|
||||
expect(element.parentNode).not.toBe jasmineContent
|
||||
|
||||
describe "adding and removing panels", ->
|
||||
it "allows panels to be inserted at any position", ->
|
||||
panel1 = new Panel({item: new TestPanelContainerItem(), priority: 10})
|
||||
panel2 = new Panel({item: new TestPanelContainerItem(), priority: 5})
|
||||
panel3 = new Panel({item: new TestPanelContainerItem(), priority: 8})
|
||||
|
||||
container.addPanel(panel1)
|
||||
container.addPanel(panel2)
|
||||
container.addPanel(panel3)
|
||||
|
||||
expect(element.childNodes[2].getModel()).toBe(panel1)
|
||||
expect(element.childNodes[1].getModel()).toBe(panel3)
|
||||
expect(element.childNodes[0].getModel()).toBe(panel2)
|
||||
|
||||
describe "when the container is at the left location", ->
|
||||
it "adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", ->
|
||||
expect(element.childNodes.length).toBe 0
|
||||
|
||||
panel1 = new Panel({viewRegistry, item: new TestPanelContainerItem()})
|
||||
panel1 = new Panel({item: new TestPanelContainerItem()})
|
||||
container.addPanel(panel1)
|
||||
expect(element.childNodes.length).toBe 1
|
||||
expect(element.childNodes[0]).toHaveClass 'left'
|
||||
expect(element.childNodes[0]).toHaveClass 'tool-panel' # legacy selector support
|
||||
expect(element.childNodes[0]).toHaveClass 'panel-left' # legacy selector support
|
||||
|
||||
expect(element.childNodes[0].tagName).toBe 'ATOM-PANEL'
|
||||
|
||||
panel2 = new Panel({viewRegistry, item: new TestPanelContainerItem()})
|
||||
panel2 = new Panel({item: new TestPanelContainerItem()})
|
||||
container.addPanel(panel2)
|
||||
expect(element.childNodes.length).toBe 2
|
||||
|
||||
expect(panel1.getView().style.display).not.toBe 'none'
|
||||
expect(panel2.getView().style.display).not.toBe 'none'
|
||||
expect(atom.views.getView(panel1).style.display).not.toBe 'none'
|
||||
expect(atom.views.getView(panel2).style.display).not.toBe 'none'
|
||||
|
||||
panel1.destroy()
|
||||
expect(element.childNodes.length).toBe 1
|
||||
@@ -69,24 +81,26 @@ describe "PanelContainerElement", ->
|
||||
|
||||
describe "when the container is at the bottom location", ->
|
||||
beforeEach ->
|
||||
container = new PanelContainer({viewRegistry, location: 'bottom'})
|
||||
element = container.getView()
|
||||
container = new PanelContainer({location: 'bottom'})
|
||||
element = atom.views.getView(container)
|
||||
jasmineContent.appendChild(element)
|
||||
|
||||
it "adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", ->
|
||||
expect(element.childNodes.length).toBe 0
|
||||
|
||||
panel1 = new Panel({viewRegistry, item: new TestPanelContainerItem(), className: 'one'})
|
||||
panel1 = new Panel({item: new TestPanelContainerItem(), className: 'one'})
|
||||
container.addPanel(panel1)
|
||||
expect(element.childNodes.length).toBe 1
|
||||
expect(element.childNodes[0]).toHaveClass 'bottom'
|
||||
expect(element.childNodes[0]).toHaveClass 'tool-panel' # legacy selector support
|
||||
expect(element.childNodes[0]).toHaveClass 'panel-bottom' # legacy selector support
|
||||
expect(element.childNodes[0].tagName).toBe 'ATOM-PANEL'
|
||||
expect(panel1.getView()).toHaveClass 'one'
|
||||
expect(atom.views.getView(panel1)).toHaveClass 'one'
|
||||
|
||||
panel2 = new Panel({viewRegistry, item: new TestPanelContainerItem(), className: 'two'})
|
||||
panel2 = new Panel({item: new TestPanelContainerItem(), className: 'two'})
|
||||
container.addPanel(panel2)
|
||||
expect(element.childNodes.length).toBe 2
|
||||
expect(panel2.getView()).toHaveClass 'two'
|
||||
expect(atom.views.getView(panel2)).toHaveClass 'two'
|
||||
|
||||
panel1.destroy()
|
||||
expect(element.childNodes.length).toBe 1
|
||||
@@ -96,23 +110,34 @@ describe "PanelContainerElement", ->
|
||||
|
||||
describe "when the container is modal", ->
|
||||
beforeEach ->
|
||||
container = new PanelContainer({viewRegistry, location: 'modal'})
|
||||
element = container.getView()
|
||||
container = new PanelContainer({location: 'modal'})
|
||||
element = atom.views.getView(container)
|
||||
jasmineContent.appendChild(element)
|
||||
|
||||
it "allows only one panel to be visible at a time", ->
|
||||
panel1 = new Panel({viewRegistry, item: new TestPanelContainerItem()})
|
||||
panel1 = new Panel({item: new TestPanelContainerItem()})
|
||||
container.addPanel(panel1)
|
||||
|
||||
expect(panel1.getView().style.display).not.toBe 'none'
|
||||
expect(atom.views.getView(panel1).style.display).not.toBe 'none'
|
||||
|
||||
panel2 = new Panel({viewRegistry, item: new TestPanelContainerItem()})
|
||||
panel2 = new Panel({item: new TestPanelContainerItem()})
|
||||
container.addPanel(panel2)
|
||||
|
||||
expect(panel1.getView().style.display).toBe 'none'
|
||||
expect(panel2.getView().style.display).not.toBe 'none'
|
||||
expect(atom.views.getView(panel1).style.display).toBe 'none'
|
||||
expect(atom.views.getView(panel2).style.display).not.toBe 'none'
|
||||
|
||||
panel1.show()
|
||||
|
||||
expect(panel1.getView().style.display).not.toBe 'none'
|
||||
expect(panel2.getView().style.display).toBe 'none'
|
||||
expect(atom.views.getView(panel1).style.display).not.toBe 'none'
|
||||
expect(atom.views.getView(panel2).style.display).toBe 'none'
|
||||
|
||||
it "adds the 'modal' class to panels", ->
|
||||
panel1 = new Panel({item: new TestPanelContainerItem()})
|
||||
container.addPanel(panel1)
|
||||
|
||||
expect(atom.views.getView(panel1)).toHaveClass 'modal'
|
||||
|
||||
# legacy selector support
|
||||
expect(atom.views.getView(panel1)).not.toHaveClass 'tool-panel'
|
||||
expect(atom.views.getView(panel1)).toHaveClass 'overlay'
|
||||
expect(atom.views.getView(panel1)).toHaveClass 'from-top'
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
ViewRegistry = require '../src/view-registry'
|
||||
Panel = require '../src/panel'
|
||||
PanelContainer = require '../src/panel-container'
|
||||
|
||||
describe "PanelContainer", ->
|
||||
[container, viewRegistry] = []
|
||||
[container] = []
|
||||
|
||||
class TestPanelItem
|
||||
constructior: ->
|
||||
|
||||
beforeEach ->
|
||||
viewRegistry = new ViewRegistry
|
||||
container = new PanelContainer({viewRegistry})
|
||||
container = new PanelContainer
|
||||
|
||||
describe "::addPanel(panel)", ->
|
||||
it 'emits an onDidAddPanel event with the index the panel was inserted at', ->
|
||||
@@ -46,7 +44,7 @@ describe "PanelContainer", ->
|
||||
[initialPanel] = []
|
||||
beforeEach ->
|
||||
# 'left' logic is the same as 'top'
|
||||
container = new PanelContainer({viewRegistry, location: 'left'})
|
||||
container = new PanelContainer({location: 'left'})
|
||||
initialPanel = new Panel(item: new TestPanelItem())
|
||||
container.addPanel(initialPanel)
|
||||
|
||||
@@ -75,7 +73,7 @@ describe "PanelContainer", ->
|
||||
[initialPanel] = []
|
||||
beforeEach ->
|
||||
# 'bottom' logic is the same as 'right'
|
||||
container = new PanelContainer({viewRegistry, location: 'right'})
|
||||
container = new PanelContainer({location: 'right'})
|
||||
initialPanel = new Panel(item: new TestPanelItem())
|
||||
container.addPanel(initialPanel)
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
ViewRegistry = require '../src/view-registry'
|
||||
Panel = require '../src/panel'
|
||||
PanelElement = require '../src/panel-element'
|
||||
|
||||
describe "PanelElement", ->
|
||||
[jasmineContent, element, panel, viewRegistry] = []
|
||||
[jasmineContent, element, panel] = []
|
||||
|
||||
class TestPanelItem
|
||||
constructior: ->
|
||||
@@ -11,23 +10,22 @@ describe "PanelElement", ->
|
||||
class TestPanelItemElement extends HTMLElement
|
||||
createdCallback: ->
|
||||
@classList.add('test-root')
|
||||
setModel: (@model) ->
|
||||
initialize: (@model) ->
|
||||
this
|
||||
|
||||
TestPanelItemElement = document.registerElement 'atom-test-item-element', prototype: TestPanelItemElement.prototype
|
||||
|
||||
beforeEach ->
|
||||
jasmineContent = document.body.querySelector('#jasmine-content')
|
||||
|
||||
viewRegistry = new ViewRegistry
|
||||
viewRegistry.addViewProvider
|
||||
modelConstructor: Panel
|
||||
viewConstructor: PanelElement
|
||||
viewRegistry.addViewProvider
|
||||
modelConstructor: TestPanelItem
|
||||
viewConstructor: TestPanelItemElement
|
||||
atom.views.addViewProvider Panel, (model) ->
|
||||
new PanelElement().initialize(model)
|
||||
atom.views.addViewProvider TestPanelItem, (model) ->
|
||||
new TestPanelItemElement().initialize(model)
|
||||
|
||||
it 'removes the element when the panel is destroyed', ->
|
||||
panel = new Panel({viewRegistry, item: new TestPanelItem})
|
||||
element = panel.getView()
|
||||
panel = new Panel({item: new TestPanelItem})
|
||||
element = atom.views.getView(panel)
|
||||
jasmineContent.appendChild(element)
|
||||
|
||||
expect(element.parentNode).toBe jasmineContent
|
||||
@@ -36,15 +34,15 @@ describe "PanelElement", ->
|
||||
|
||||
describe "changing panel visibility", ->
|
||||
it 'initially renders panel created with visibile: false', ->
|
||||
panel = new Panel({viewRegistry, visible: false, item: new TestPanelItem})
|
||||
element = panel.getView()
|
||||
panel = new Panel({visible: false, item: new TestPanelItem})
|
||||
element = atom.views.getView(panel)
|
||||
jasmineContent.appendChild(element)
|
||||
|
||||
expect(element.style.display).toBe 'none'
|
||||
|
||||
it 'hides and shows the panel element when Panel::hide() and Panel::show() are called', ->
|
||||
panel = new Panel({viewRegistry, item: new TestPanelItem})
|
||||
element = panel.getView()
|
||||
panel = new Panel({item: new TestPanelItem})
|
||||
element = atom.views.getView(panel)
|
||||
jasmineContent.appendChild(element)
|
||||
|
||||
expect(element.style.display).not.toBe 'none'
|
||||
@@ -57,8 +55,8 @@ describe "PanelElement", ->
|
||||
|
||||
describe "when a class name is specified", ->
|
||||
it 'initially renders panel created with visibile: false', ->
|
||||
panel = new Panel({viewRegistry, className: 'some classes', item: new TestPanelItem})
|
||||
element = panel.getView()
|
||||
panel = new Panel({className: 'some classes', item: new TestPanelItem})
|
||||
element = atom.views.getView(panel)
|
||||
jasmineContent.appendChild(element)
|
||||
|
||||
expect(element).toHaveClass 'some'
|
||||
|
||||
@@ -21,3 +21,7 @@ describe "Panel", ->
|
||||
panel.show()
|
||||
expect(panel.isVisible()).toBe true
|
||||
expect(spy).toHaveBeenCalledWith(true)
|
||||
|
||||
panel.destroy()
|
||||
expect(panel.isVisible()).toBe false
|
||||
expect(spy).toHaveBeenCalledWith(false)
|
||||
|
||||
@@ -170,30 +170,30 @@ describe "Project", ->
|
||||
absolutePath = fs.absolute(__dirname)
|
||||
expect(atom.project.resolve(absolutePath)).toBe absolutePath
|
||||
|
||||
describe ".setPath(path)", ->
|
||||
describe ".setPaths(path)", ->
|
||||
describe "when path is a file", ->
|
||||
it "sets its path to the files parent directory and updates the root directory", ->
|
||||
atom.project.setPaths([require.resolve('./fixtures/dir/a')])
|
||||
expect(atom.project.getPaths()[0]).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
|
||||
expect(atom.project.getRootDirectory().path).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
|
||||
expect(atom.project.getDirectories()[0].path).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
|
||||
|
||||
describe "when path is a directory", ->
|
||||
it "sets its path to the directory and updates the root directory", ->
|
||||
directory = fs.absolute(path.join(__dirname, 'fixtures', 'dir', 'a-dir'))
|
||||
atom.project.setPaths([directory])
|
||||
expect(atom.project.getPaths()[0]).toEqual directory
|
||||
expect(atom.project.getRootDirectory().path).toEqual directory
|
||||
expect(atom.project.getDirectories()[0].path).toEqual directory
|
||||
|
||||
describe "when path is null", ->
|
||||
it "sets its path and root directory to null", ->
|
||||
atom.project.setPaths([])
|
||||
expect(atom.project.getPaths()[0]?).toBeFalsy()
|
||||
expect(atom.project.getRootDirectory()?).toBeFalsy()
|
||||
expect(atom.project.getDirectories()[0]?).toBeFalsy()
|
||||
|
||||
it "normalizes the path to remove consecutive slashes, ., and .. segments", ->
|
||||
atom.project.setPaths(["#{require.resolve('./fixtures/dir/a')}#{path.sep}b#{path.sep}#{path.sep}.."])
|
||||
expect(atom.project.getPaths()[0]).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
|
||||
expect(atom.project.getRootDirectory().path).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
|
||||
expect(atom.project.getDirectories()[0].path).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
|
||||
|
||||
describe ".replace()", ->
|
||||
[filePath, commentFilePath, sampleContent, sampleCommentContent] = []
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
SelectListView = require '../src/select-list-view'
|
||||
{$, $$} = require 'atom'
|
||||
{$, $$} = require '../src/space-pen-extensions'
|
||||
|
||||
describe "SelectListView", ->
|
||||
[selectList, items, list, filterEditorView] = []
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{View, $, $$} = require 'atom'
|
||||
{View, $, $$} = require '../src/space-pen-extensions'
|
||||
|
||||
describe "SpacePen extensions", ->
|
||||
class TestView extends View
|
||||
|
||||
@@ -9,12 +9,17 @@ _ = require 'underscore-plus'
|
||||
fs = require 'fs-plus'
|
||||
Grim = require 'grim'
|
||||
KeymapManager = require '../src/keymap-extensions'
|
||||
{$, WorkspaceView, Workspace} = require 'atom'
|
||||
|
||||
# FIXME: Remove jquery from this
|
||||
{$} = require '../src/space-pen-extensions'
|
||||
|
||||
Config = require '../src/config'
|
||||
{Point} = require 'text-buffer'
|
||||
Project = require '../src/project'
|
||||
Workspace = require '../src/workspace'
|
||||
TextEditor = require '../src/text-editor'
|
||||
TextEditorView = require '../src/text-editor-view'
|
||||
TextEditorElement = require '../src/text-editor-element'
|
||||
TokenizedBuffer = require '../src/tokenized-buffer'
|
||||
TextEditorComponent = require '../src/text-editor-component'
|
||||
pathwatcher = require 'pathwatcher'
|
||||
@@ -76,6 +81,8 @@ beforeEach ->
|
||||
atom.commands.restoreSnapshot(commandsToRestore)
|
||||
atom.styles.restoreSnapshot(styleElementsToRestore)
|
||||
|
||||
atom.workspaceViewParentSelector = '#jasmine-content'
|
||||
|
||||
window.resetTimeouts()
|
||||
atom.packages.packageStates = {}
|
||||
|
||||
@@ -111,8 +118,7 @@ beforeEach ->
|
||||
config.save.reset()
|
||||
|
||||
# make editor display updates synchronous
|
||||
spyOn(TextEditorView.prototype, 'requestDisplayUpdate').andCallFake -> @updateDisplay()
|
||||
TextEditorComponent.performSyncUpdates = true
|
||||
TextEditorElement::setUpdatedSynchronously(true)
|
||||
|
||||
spyOn(atom, "setRepresentedFilename")
|
||||
spyOn(window, "setTimeout").andCallFake window.fakeSetTimeout
|
||||
@@ -196,6 +202,13 @@ jasmine.attachToDOM = (element) ->
|
||||
jasmineContent = document.querySelector('#jasmine-content')
|
||||
jasmineContent.appendChild(element) unless jasmineContent.contains(element)
|
||||
|
||||
deprecationsSnapshot = null
|
||||
jasmine.snapshotDeprecations = ->
|
||||
deprecationsSnapshot = Grim.getDeprecations() # suppress deprecations!!
|
||||
|
||||
jasmine.restoreDeprecationsSnapshot = ->
|
||||
Grim.grimDeprecations = deprecationsSnapshot
|
||||
|
||||
addCustomMatchers = (spec) ->
|
||||
spec.addMatchers
|
||||
toBeInstanceOf: (expected) ->
|
||||
|
||||
@@ -105,3 +105,8 @@ describe "StylesElement", ->
|
||||
|
||||
document.querySelector('#jasmine-content').appendChild(element)
|
||||
expect(element.firstChild.sheet.cssRules[0].selectorText).toBe ':host'
|
||||
|
||||
it "does not throw exceptions on rules with no selectors", ->
|
||||
atom.styles.addStyleSheet """
|
||||
@media screen {font-size: 10px;}
|
||||
""", context: 'atom-text-editor'
|
||||
|
||||
@@ -105,30 +105,3 @@ describe "the `syntax` global", ->
|
||||
grammar = atom.grammars.selectGrammar('foo.js')
|
||||
atom.grammars.removeGrammar(grammar)
|
||||
expect(atom.grammars.selectGrammar('foo.js').name).not.toBe grammar.name
|
||||
|
||||
describe ".getProperty(scopeDescriptor)", ->
|
||||
it "returns the property with the most specific scope selector", ->
|
||||
atom.grammars.addProperties(".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42)
|
||||
atom.grammars.addProperties(".source .string.quoted.double", foo: bar: baz: 22)
|
||||
atom.grammars.addProperties(".source", foo: bar: baz: 11)
|
||||
|
||||
expect(atom.grammars.getProperty([".source.coffee", ".string.quoted.double.coffee"], "foo.bar.baz")).toBe 42
|
||||
expect(atom.grammars.getProperty([".source.js", ".string.quoted.double.js"], "foo.bar.baz")).toBe 22
|
||||
expect(atom.grammars.getProperty([".source.js", ".variable.assignment.js"], "foo.bar.baz")).toBe 11
|
||||
expect(atom.grammars.getProperty([".text"], "foo.bar.baz")).toBeUndefined()
|
||||
|
||||
it "favors the most recently added properties in the event of a specificity tie", ->
|
||||
atom.grammars.addProperties(".source.coffee .string.quoted.single", foo: bar: baz: 42)
|
||||
atom.grammars.addProperties(".source.coffee .string.quoted.double", foo: bar: baz: 22)
|
||||
|
||||
expect(atom.grammars.getProperty([".source.coffee", ".string.quoted.single"], "foo.bar.baz")).toBe 42
|
||||
expect(atom.grammars.getProperty([".source.coffee", ".string.quoted.single.double"], "foo.bar.baz")).toBe 22
|
||||
|
||||
describe ".removeProperties(name)", ->
|
||||
it "allows properties to be removed by name", ->
|
||||
atom.grammars.addProperties("a", ".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42)
|
||||
atom.grammars.addProperties("b", ".source .string.quoted.double", foo: bar: baz: 22)
|
||||
|
||||
atom.grammars.removeProperties("b")
|
||||
expect(atom.grammars.getProperty([".source.js", ".string.quoted.double.js"], "foo.bar.baz")).toBeUndefined()
|
||||
expect(atom.grammars.getProperty([".source.coffee", ".string.quoted.double.coffee"], "foo.bar.baz")).toBe 42
|
||||
|
||||
@@ -37,9 +37,9 @@ describe "TextEditorComponent", ->
|
||||
wrapperView = new TextEditorView(editor, {lineOverdrawMargin})
|
||||
wrapperView.attachToDom()
|
||||
wrapperNode = wrapperView.element
|
||||
wrapperNode.setUpdatedSynchronously(false)
|
||||
|
||||
{component} = wrapperView
|
||||
component.performSyncUpdates = false
|
||||
component.setFontFamily('monospace')
|
||||
component.setLineHeight(1.3)
|
||||
component.setFontSize(20)
|
||||
@@ -302,7 +302,7 @@ describe "TextEditorComponent", ->
|
||||
|
||||
it "interleaves invisible line-ending characters with indent guides on empty lines", ->
|
||||
component.setShowIndentGuide(true)
|
||||
editor.setTextInBufferRange([[10, 0], [11, 0]], "\r\n", false)
|
||||
editor.setTextInBufferRange([[10, 0], [11, 0]], "\r\n", normalizeLineEndings: false)
|
||||
nextAnimationFrame()
|
||||
expect(component.lineNodeForScreenRow(10).innerHTML).toBe '<span class="indent-guide"><span class="invisible-character">C</span><span class="invisible-character">E</span></span>'
|
||||
|
||||
@@ -1247,7 +1247,7 @@ describe "TextEditorComponent", ->
|
||||
expect(overlay.style.top).toBe position.top + editor.getLineHeightInPixels() + 'px'
|
||||
|
||||
describe "when the marker is not empty", ->
|
||||
it "renders at the head of the marker", ->
|
||||
it "renders at the head of the marker by default", ->
|
||||
marker = editor.displayBuffer.markBufferRange([[2, 5], [2, 10]], invalidate: 'never')
|
||||
decoration = editor.decorateMarker(marker, {type: 'overlay', item})
|
||||
nextAnimationFrame()
|
||||
@@ -1269,6 +1269,17 @@ describe "TextEditorComponent", ->
|
||||
expect(overlay.style.left).toBe position.left + 'px'
|
||||
expect(overlay.style.top).toBe position.top + editor.getLineHeightInPixels() + 'px'
|
||||
|
||||
it "renders at the tail of the marker when the 'position' option is 'tail'", ->
|
||||
marker = editor.displayBuffer.markBufferRange([[2, 5], [2, 10]], invalidate: 'never')
|
||||
decoration = editor.decorateMarker(marker, {type: 'overlay', position: 'tail', item})
|
||||
nextAnimationFrame()
|
||||
|
||||
position = editor.pixelPositionForBufferPosition([2, 5])
|
||||
|
||||
overlay = component.getTopmostDOMNode().querySelector('atom-overlay')
|
||||
expect(overlay.style.left).toBe position.left + 'px'
|
||||
expect(overlay.style.top).toBe position.top + editor.getLineHeightInPixels() + 'px'
|
||||
|
||||
describe "positioning the overlay when near the edge of the editor", ->
|
||||
[itemWidth, itemHeight] = []
|
||||
beforeEach ->
|
||||
@@ -1897,7 +1908,8 @@ describe "TextEditorComponent", ->
|
||||
}
|
||||
""", context: 'atom-text-editor'
|
||||
|
||||
nextAnimationFrame()
|
||||
nextAnimationFrame() # handle stylesheet change event
|
||||
nextAnimationFrame() # perform requested update
|
||||
|
||||
scrollbarCornerNode = componentNode.querySelector('.scrollbar-corner')
|
||||
expect(verticalScrollbarNode.offsetWidth).toBe 8
|
||||
|
||||
@@ -20,6 +20,11 @@ describe "TextEditorElement", ->
|
||||
element = jasmineContent.firstChild
|
||||
expect(element.getModel().getPlaceholderText()).toBe 'testing'
|
||||
|
||||
it "honors the text content", ->
|
||||
jasmineContent.innerHTML = "<atom-text-editor>testing</atom-text-editor>"
|
||||
element = jasmineContent.firstChild
|
||||
expect(element.getModel().getText()).toBe 'testing'
|
||||
|
||||
describe "when the model is assigned", ->
|
||||
it "adds the 'mini' attribute if .isMini() returns true on the model", ->
|
||||
element = new TextEditorElement
|
||||
@@ -98,3 +103,55 @@ describe "TextEditorElement", ->
|
||||
verticalScrollbarNode = element.querySelector(".vertical-scrollbar")
|
||||
scrollbarWidth = verticalScrollbarNode.offsetWidth - verticalScrollbarNode.clientWidth
|
||||
expect(scrollbarWidth).toEqual(8)
|
||||
|
||||
describe "::onDidAttach and ::onDidDetach", ->
|
||||
it "invokes callbacks when the element is attached and detached", ->
|
||||
element = new TextEditorElement
|
||||
|
||||
attachedCallback = jasmine.createSpy("attachedCallback")
|
||||
detachedCallback = jasmine.createSpy("detachedCallback")
|
||||
|
||||
element.onDidAttach(attachedCallback)
|
||||
element.onDidDetach(detachedCallback)
|
||||
|
||||
jasmine.attachToDOM(element)
|
||||
|
||||
expect(attachedCallback).toHaveBeenCalled()
|
||||
expect(detachedCallback).not.toHaveBeenCalled()
|
||||
|
||||
attachedCallback.reset()
|
||||
element.remove()
|
||||
|
||||
expect(attachedCallback).not.toHaveBeenCalled()
|
||||
expect(detachedCallback).toHaveBeenCalled()
|
||||
|
||||
describe "::setUpdatedSynchronously", ->
|
||||
it "controls whether the text editor is updated synchronously", ->
|
||||
spyOn(window, 'requestAnimationFrame').andCallFake (fn) -> fn()
|
||||
|
||||
element = new TextEditorElement
|
||||
jasmine.attachToDOM(element)
|
||||
|
||||
element.setUpdatedSynchronously(false)
|
||||
expect(element.isUpdatedSynchronously()).toBe false
|
||||
|
||||
element.getModel().setText("hello")
|
||||
expect(window.requestAnimationFrame).toHaveBeenCalled()
|
||||
|
||||
expect(element.shadowRoot.textContent).toContain "hello"
|
||||
|
||||
window.requestAnimationFrame.reset()
|
||||
element.setUpdatedSynchronously(true)
|
||||
element.getModel().setText("goodbye")
|
||||
expect(window.requestAnimationFrame).not.toHaveBeenCalled()
|
||||
expect(element.shadowRoot.textContent).toContain "goodbye"
|
||||
|
||||
describe "::getDefaultCharacterWidth", ->
|
||||
it "returns null before the element is attached", ->
|
||||
element = new TextEditorElement
|
||||
expect(element.getDefaultCharacterWidth()).toBeNull()
|
||||
|
||||
it "returns the width of a character in the root scope", ->
|
||||
element = new TextEditorElement
|
||||
jasmine.attachToDOM(element)
|
||||
expect(element.getDefaultCharacterWidth()).toBeGreaterThan(0)
|
||||
|
||||
@@ -192,12 +192,18 @@ describe "TextEditor", ->
|
||||
expect(editor.getCursorBufferPosition()).toEqual [1, 1]
|
||||
|
||||
it "emits an event with the old position, new position, and the cursor that moved", ->
|
||||
editor.onDidChangeCursorPosition positionChangedHandler = jasmine.createSpy()
|
||||
cursorCallback = jasmine.createSpy('cursor-changed-position')
|
||||
editorCallback = jasmine.createSpy('editor-changed-cursor-position')
|
||||
|
||||
editor.getLastCursor().onDidChangePosition(cursorCallback)
|
||||
editor.onDidChangeCursorPosition(editorCallback)
|
||||
|
||||
editor.setCursorBufferPosition([2, 4])
|
||||
|
||||
expect(positionChangedHandler).toHaveBeenCalled()
|
||||
eventObject = positionChangedHandler.mostRecentCall.args[0]
|
||||
expect(editorCallback).toHaveBeenCalled()
|
||||
expect(cursorCallback).toHaveBeenCalled()
|
||||
eventObject = editorCallback.mostRecentCall.args[0]
|
||||
expect(cursorCallback.mostRecentCall.args[0]).toEqual(eventObject)
|
||||
|
||||
expect(eventObject.oldBufferPosition).toEqual [0, 0]
|
||||
expect(eventObject.oldScreenPosition).toEqual [0, 0]
|
||||
@@ -616,7 +622,7 @@ describe "TextEditor", ->
|
||||
describe "when invisible characters are enabled with hard tabs", ->
|
||||
it "moves to the first character of the current line without being confused by the invisible characters", ->
|
||||
atom.config.set('editor.showInvisibles', true)
|
||||
buffer.setTextInRange([[1, 0], [1, Infinity]], '\t\t\ta', false)
|
||||
buffer.setTextInRange([[1, 0], [1, Infinity]], '\t\t\ta', normalizeLineEndings: false)
|
||||
|
||||
editor.setCursorScreenPosition [1,7]
|
||||
editor.moveToFirstCharacterOfLine()
|
||||
@@ -3014,18 +3020,16 @@ describe "TextEditor", ->
|
||||
expect(editor.isFoldedAtBufferRow(1)).toBeFalsy()
|
||||
expect(editor.isFoldedAtBufferRow(2)).toBeTruthy()
|
||||
|
||||
describe "begin/commitTransaction()", ->
|
||||
describe "::transact", ->
|
||||
it "restores the selection when the transaction is undone/redone", ->
|
||||
buffer.setText('1234')
|
||||
editor.setSelectedBufferRange([[0, 1], [0, 3]])
|
||||
editor.beginTransaction()
|
||||
|
||||
editor.delete()
|
||||
editor.moveToEndOfLine()
|
||||
editor.insertText('5')
|
||||
expect(buffer.getText()).toBe '145'
|
||||
|
||||
editor.commitTransaction()
|
||||
editor.transact ->
|
||||
editor.delete()
|
||||
editor.moveToEndOfLine()
|
||||
editor.insertText('5')
|
||||
expect(buffer.getText()).toBe '145'
|
||||
|
||||
editor.undo()
|
||||
expect(buffer.getText()).toBe '1234'
|
||||
@@ -3400,7 +3404,6 @@ describe "TextEditor", ->
|
||||
expect(editor.getCursorBufferPosition()).toEqual([7, 2])
|
||||
|
||||
editor.insertNewline()
|
||||
editor.logScreenLines()
|
||||
expect(editor.lineTextForBufferRow(8)).toBe(" ")
|
||||
|
||||
it "does not indent the line preceding the newline", ->
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
path = require 'path'
|
||||
|
||||
{$, $$, WorkspaceView} = require 'atom'
|
||||
{$, $$} = require '../src/space-pen-extensions'
|
||||
fs = require 'fs-plus'
|
||||
temp = require 'temp'
|
||||
|
||||
@@ -20,8 +20,12 @@ describe "ThemeManager", ->
|
||||
|
||||
describe "theme getters and setters", ->
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
atom.packages.loadPackages()
|
||||
|
||||
afterEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
it 'getLoadedThemes get all the loaded themes', ->
|
||||
themes = themeManager.getLoadedThemes()
|
||||
expect(themes.length).toBeGreaterThan(2)
|
||||
@@ -130,15 +134,24 @@ describe "ThemeManager", ->
|
||||
expect(-> atom.packages.activatePackage('a-theme-that-will-not-be-found')).toThrow()
|
||||
|
||||
describe "::requireStylesheet(path)", ->
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
afterEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
it "synchronously loads css at the given path and installs a style tag for it in the head", ->
|
||||
atom.styles.onDidAddStyleElement styleElementAddedHandler = jasmine.createSpy("styleElementAddedHandler")
|
||||
themeManager.onDidChangeStylesheets stylesheetsChangedHandler = jasmine.createSpy("stylesheetsChangedHandler")
|
||||
themeManager.onDidAddStylesheet stylesheetAddedHandler = jasmine.createSpy("stylesheetAddedHandler")
|
||||
|
||||
cssPath = atom.project.resolve('css.css')
|
||||
lengthBefore = $('head style').length
|
||||
|
||||
themeManager.requireStylesheet(cssPath)
|
||||
expect($('head style').length).toBe lengthBefore + 1
|
||||
|
||||
expect(styleElementAddedHandler).toHaveBeenCalled()
|
||||
expect(stylesheetAddedHandler).toHaveBeenCalled()
|
||||
expect(stylesheetsChangedHandler).toHaveBeenCalled()
|
||||
|
||||
@@ -148,8 +161,10 @@ describe "ThemeManager", ->
|
||||
expect(element[0].sheet).toBe stylesheetAddedHandler.argsForCall[0][0]
|
||||
|
||||
# doesn't append twice
|
||||
styleElementAddedHandler.reset()
|
||||
themeManager.requireStylesheet(cssPath)
|
||||
expect($('head style').length).toBe lengthBefore + 1
|
||||
expect(styleElementAddedHandler).not.toHaveBeenCalled()
|
||||
|
||||
$('head style[id*="css.css"]').remove()
|
||||
|
||||
@@ -192,6 +207,7 @@ describe "ThemeManager", ->
|
||||
disposable = themeManager.requireStylesheet(cssPath)
|
||||
expect($(document.body).css('font-weight')).toBe("bold")
|
||||
|
||||
atom.styles.onDidRemoveStyleElement styleElementRemovedHandler = jasmine.createSpy("styleElementRemovedHandler")
|
||||
themeManager.onDidRemoveStylesheet stylesheetRemovedHandler = jasmine.createSpy("stylesheetRemovedHandler")
|
||||
themeManager.onDidChangeStylesheets stylesheetsChangedHandler = jasmine.createSpy("stylesheetsChangedHandler")
|
||||
|
||||
@@ -199,6 +215,7 @@ describe "ThemeManager", ->
|
||||
|
||||
expect($(document.body).css('font-weight')).not.toBe("bold")
|
||||
|
||||
expect(styleElementRemovedHandler).toHaveBeenCalled()
|
||||
expect(stylesheetRemovedHandler).toHaveBeenCalled()
|
||||
stylesheet = stylesheetRemovedHandler.argsForCall[0][0]
|
||||
expect(stylesheet instanceof CSSStyleSheet).toBe true
|
||||
@@ -209,6 +226,8 @@ describe "ThemeManager", ->
|
||||
describe "base stylesheet loading", ->
|
||||
workspaceElement = null
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
workspaceElement = atom.views.getView(atom.workspace)
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
workspaceElement.appendChild document.createElement('atom-text-editor')
|
||||
@@ -216,6 +235,9 @@ describe "ThemeManager", ->
|
||||
waitsForPromise ->
|
||||
themeManager.activateThemes()
|
||||
|
||||
beforeEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
it "loads the correct values from the theme's ui-variables file", ->
|
||||
themeManager.onDidReloadAll reloadHandler = jasmine.createSpy()
|
||||
atom.config.set('core.themes', ['theme-with-ui-variables', 'theme-with-syntax-variables'])
|
||||
@@ -265,7 +287,14 @@ describe "ThemeManager", ->
|
||||
expect(workspaceElement).not.toHaveClass 'theme-atom-dark-syntax'
|
||||
|
||||
describe "when the user stylesheet changes", ->
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
afterEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
it "reloads it", ->
|
||||
[styleElementAddedHandler, styleElementRemovedHandler] = []
|
||||
[stylesheetRemovedHandler, stylesheetAddedHandler, stylesheetsChangedHandler] = []
|
||||
userStylesheetPath = path.join(temp.mkdirSync("atom"), 'styles.less')
|
||||
fs.writeFileSync(userStylesheetPath, 'body {border-style: dotted !important;}')
|
||||
@@ -275,6 +304,9 @@ describe "ThemeManager", ->
|
||||
themeManager.activateThemes()
|
||||
|
||||
runs ->
|
||||
atom.styles.onDidRemoveStyleElement styleElementRemovedHandler = jasmine.createSpy("styleElementRemovedHandler")
|
||||
atom.styles.onDidAddStyleElement styleElementAddedHandler = jasmine.createSpy("styleElementAddedHandler")
|
||||
|
||||
themeManager.onDidChangeStylesheets stylesheetsChangedHandler = jasmine.createSpy("stylesheetsChangedHandler")
|
||||
themeManager.onDidRemoveStylesheet stylesheetRemovedHandler = jasmine.createSpy("stylesheetRemovedHandler")
|
||||
themeManager.onDidAddStylesheet stylesheetAddedHandler = jasmine.createSpy("stylesheetAddedHandler")
|
||||
@@ -289,14 +321,19 @@ describe "ThemeManager", ->
|
||||
runs ->
|
||||
expect($(document.body).css('border-style')).toBe 'dashed'
|
||||
|
||||
expect(styleElementRemovedHandler).toHaveBeenCalled()
|
||||
expect(styleElementRemovedHandler.argsForCall[0][0].textContent).toContain 'dotted'
|
||||
expect(stylesheetRemovedHandler).toHaveBeenCalled()
|
||||
expect(stylesheetRemovedHandler.argsForCall[0][0].cssRules[0].style.border).toBe 'dotted'
|
||||
|
||||
expect(styleElementAddedHandler).toHaveBeenCalled()
|
||||
expect(styleElementAddedHandler.argsForCall[0][0].textContent).toContain 'dashed'
|
||||
expect(stylesheetAddedHandler).toHaveBeenCalled()
|
||||
expect(stylesheetAddedHandler.argsForCall[0][0].cssRules[0].style.border).toBe 'dashed'
|
||||
|
||||
expect(stylesheetsChangedHandler).toHaveBeenCalled()
|
||||
|
||||
styleElementRemovedHandler.reset()
|
||||
stylesheetRemovedHandler.reset()
|
||||
stylesheetsChangedHandler.reset()
|
||||
fs.removeSync(userStylesheetPath)
|
||||
@@ -305,6 +342,8 @@ describe "ThemeManager", ->
|
||||
themeManager.loadUserStylesheet.callCount is 2
|
||||
|
||||
runs ->
|
||||
expect(styleElementRemovedHandler).toHaveBeenCalled()
|
||||
expect(styleElementRemovedHandler.argsForCall[0][0].textContent).toContain 'dashed'
|
||||
expect(stylesheetRemovedHandler).toHaveBeenCalled()
|
||||
expect(stylesheetRemovedHandler.argsForCall[0][0].cssRules[0].style.border).toBe 'dashed'
|
||||
expect($(document.body).css('border-style')).toBe 'none'
|
||||
|
||||
@@ -59,6 +59,13 @@ describe "TooltipManager", ->
|
||||
tooltipElement = document.body.querySelector(".tooltip")
|
||||
expect(tooltipElement).toHaveText "⌃X ⌃Y"
|
||||
|
||||
it "does not display the keybinding if there is nothing mapped to the specified keyBindingCommand", ->
|
||||
manager.add element, title: 'A Title', keyBindingCommand: 'test-command', keyBindingTarget: element
|
||||
|
||||
hover element, ->
|
||||
tooltipElement = document.body.querySelector(".tooltip")
|
||||
expect(tooltipElement.textContent).toBe "A Title"
|
||||
|
||||
describe "when .dispose() is called on the returned disposable", ->
|
||||
it "no longer displays the tooltip on hover", ->
|
||||
disposable = manager.add element, title: "Title"
|
||||
|
||||
@@ -25,47 +25,27 @@ describe "ViewRegistry", ->
|
||||
|
||||
describe "when passed a model object", ->
|
||||
describe "when a view provider is registered matching the object's constructor", ->
|
||||
describe "when the provider has a viewConstructor property", ->
|
||||
it "constructs a view element and assigns the model on it", ->
|
||||
class TestModel
|
||||
it "constructs a view element and assigns the model on it", ->
|
||||
class TestModel
|
||||
|
||||
class TestModelSubclass extends TestModel
|
||||
class TestModelSubclass extends TestModel
|
||||
|
||||
class TestView
|
||||
setModel: (@model) ->
|
||||
class TestView
|
||||
initialize: (@model) -> this
|
||||
|
||||
model = new TestModel
|
||||
model = new TestModel
|
||||
|
||||
registry.addViewProvider
|
||||
modelConstructor: TestModel
|
||||
viewConstructor: TestView
|
||||
registry.addViewProvider TestModel, (model) ->
|
||||
new TestView().initialize(model)
|
||||
|
||||
view = registry.getView(model)
|
||||
expect(view instanceof TestView).toBe true
|
||||
expect(view.model).toBe model
|
||||
view = registry.getView(model)
|
||||
expect(view instanceof TestView).toBe true
|
||||
expect(view.model).toBe model
|
||||
|
||||
subclassModel = new TestModelSubclass
|
||||
view2 = registry.getView(subclassModel)
|
||||
expect(view2 instanceof TestView).toBe true
|
||||
expect(view2.model).toBe subclassModel
|
||||
|
||||
describe "when the provider has a createView method", ->
|
||||
it "constructs a view element by calling the createView method with the model", ->
|
||||
class TestModel
|
||||
class TestView
|
||||
setModel: (@model) ->
|
||||
|
||||
registry.addViewProvider
|
||||
modelConstructor: TestModel
|
||||
createView: (model) ->
|
||||
view = new TestView
|
||||
view.setModel(model)
|
||||
view
|
||||
|
||||
model = new TestModel
|
||||
view = registry.getView(model)
|
||||
expect(view instanceof TestView).toBe true
|
||||
expect(view.model).toBe model
|
||||
subclassModel = new TestModelSubclass
|
||||
view2 = registry.getView(subclassModel)
|
||||
expect(view2 instanceof TestView).toBe true
|
||||
expect(view2.model).toBe subclassModel
|
||||
|
||||
describe "when no view provider is registered for the object's constructor", ->
|
||||
describe "when the object has a .getViewClass() method", ->
|
||||
@@ -97,10 +77,10 @@ describe "ViewRegistry", ->
|
||||
it "returns a disposable that can be used to remove the provider", ->
|
||||
class TestModel
|
||||
class TestView
|
||||
setModel: (@model) ->
|
||||
disposable = registry.addViewProvider
|
||||
modelConstructor: TestModel
|
||||
viewConstructor: TestView
|
||||
initialize: (@model) -> this
|
||||
|
||||
disposable = registry.addViewProvider TestModel, (model) ->
|
||||
new TestView().initialize(model)
|
||||
|
||||
expect(registry.getView(new TestModel) instanceof TestView).toBe true
|
||||
disposable.dispose()
|
||||
|
||||
+10
-13
@@ -1,4 +1,4 @@
|
||||
{$, $$} = require 'atom'
|
||||
{$, $$} = require '../src/space-pen-extensions'
|
||||
path = require 'path'
|
||||
TextEditor = require '../src/text-editor'
|
||||
WindowEventHandler = require '../src/window-event-handler'
|
||||
@@ -128,17 +128,15 @@ describe "Window", ->
|
||||
setData: (key, value) -> @data[key] = value
|
||||
getData: (key) -> @data[key]
|
||||
|
||||
event = $.Event(type)
|
||||
event.originalEvent = { dataTransfer }
|
||||
event.preventDefault = ->
|
||||
event.stopPropagation = ->
|
||||
event = new CustomEvent("drop")
|
||||
event.dataTransfer = dataTransfer
|
||||
event
|
||||
|
||||
describe "when a file is dragged to window", ->
|
||||
it "opens it", ->
|
||||
spyOn(atom, "open")
|
||||
event = buildDragEvent("drop", [ {path: "/fake1"}, {path: "/fake2"} ])
|
||||
$(document).trigger(event)
|
||||
document.dispatchEvent(event)
|
||||
expect(atom.open.callCount).toBe 1
|
||||
expect(atom.open.argsForCall[0][0]).toEqual pathsToOpen: ['/fake1', '/fake2']
|
||||
|
||||
@@ -146,7 +144,7 @@ describe "Window", ->
|
||||
it "does nothing", ->
|
||||
spyOn(atom, "open")
|
||||
event = buildDragEvent("drop", [])
|
||||
$(document).trigger(event)
|
||||
document.dispatchEvent(event)
|
||||
expect(atom.open).not.toHaveBeenCalled()
|
||||
|
||||
describe "when a link is clicked", ->
|
||||
@@ -259,24 +257,23 @@ describe "Window", ->
|
||||
|
||||
describe "when the opened path exists", ->
|
||||
it "sets the project path to the opened path", ->
|
||||
$(window).trigger('window:open-path', [{pathToOpen: __filename}])
|
||||
|
||||
atom.getCurrentWindow().send 'message', 'open-path', pathToOpen: __filename
|
||||
expect(atom.project.getPaths()[0]).toBe __dirname
|
||||
|
||||
describe "when the opened path does not exist but its parent directory does", ->
|
||||
it "sets the project path to the opened path's parent directory", ->
|
||||
$(window).trigger('window:open-path', [{pathToOpen: path.join(__dirname, 'this-path-does-not-exist.txt')}])
|
||||
|
||||
pathToOpen = path.join(__dirname, 'this-path-does-not-exist.txt')
|
||||
atom.getCurrentWindow().send 'message', 'open-path', {pathToOpen}
|
||||
expect(atom.project.getPaths()[0]).toBe __dirname
|
||||
|
||||
describe "when the opened path is a file", ->
|
||||
it "opens it in the workspace", ->
|
||||
$(window).trigger('window:open-path', [{pathToOpen: __filename}])
|
||||
atom.getCurrentWindow().send 'message', 'open-path', pathToOpen: __filename
|
||||
|
||||
expect(atom.workspace.open.mostRecentCall.args[0]).toBe __filename
|
||||
|
||||
describe "when the opened path is a directory", ->
|
||||
it "does not open it in the workspace", ->
|
||||
$(window).trigger('window:open-path', [{pathToOpen: __dirname}])
|
||||
atom.getCurrentWindow().send 'message', 'open-path', pathToOpen: __dirname
|
||||
|
||||
expect(atom.workspace.open.callCount).toBe 0
|
||||
|
||||
@@ -356,7 +356,7 @@ describe "Workspace", ->
|
||||
atom.workspace.open('sample.coffee')
|
||||
|
||||
runs ->
|
||||
atom.workspace.getActiveEditor().setText """
|
||||
atom.workspace.getActiveTextEditor().setText """
|
||||
i = /test/; #FIXME
|
||||
"""
|
||||
|
||||
@@ -375,7 +375,7 @@ describe "Workspace", ->
|
||||
describe "document.title", ->
|
||||
describe "when the project has no path", ->
|
||||
it "sets the title to 'untitled'", ->
|
||||
atom.project.setPath(undefined)
|
||||
atom.project.setPaths([])
|
||||
expect(document.title).toBe 'untitled - Atom'
|
||||
|
||||
describe "when the project has a path", ->
|
||||
@@ -458,46 +458,98 @@ describe "Workspace", ->
|
||||
expect(atom.setDocumentEdited).toHaveBeenCalledWith(false)
|
||||
|
||||
describe "adding panels", ->
|
||||
class TestPanel
|
||||
constructior: ->
|
||||
class TestItem
|
||||
|
||||
class TestItemElement extends HTMLElement
|
||||
constructor: ->
|
||||
initialize: (@model) -> this
|
||||
getModel: -> @model
|
||||
|
||||
beforeEach ->
|
||||
atom.views.addViewProvider TestItem, (model) ->
|
||||
new TestItemElement().initialize(model)
|
||||
|
||||
describe '::addLeftPanel(model)', ->
|
||||
it 'adds a panel to the correct panel container', ->
|
||||
expect(atom.workspace.getLeftPanels().length).toBe(0)
|
||||
atom.workspace.panelContainers.left.onDidAddPanel addPanelSpy = jasmine.createSpy()
|
||||
panel = atom.workspace.addLeftPanel(item: new TestPanel())
|
||||
|
||||
model = new TestItem
|
||||
panel = atom.workspace.addLeftPanel(item: model)
|
||||
|
||||
expect(panel).toBeDefined()
|
||||
expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0})
|
||||
|
||||
itemView = atom.views.getView(atom.workspace.getLeftPanels()[0].getItem())
|
||||
expect(itemView instanceof TestItemElement).toBe(true)
|
||||
expect(itemView.getModel()).toBe(model)
|
||||
|
||||
describe '::addRightPanel(model)', ->
|
||||
it 'adds a panel to the correct panel container', ->
|
||||
expect(atom.workspace.getRightPanels().length).toBe(0)
|
||||
atom.workspace.panelContainers.right.onDidAddPanel addPanelSpy = jasmine.createSpy()
|
||||
panel = atom.workspace.addRightPanel(item: new TestPanel())
|
||||
|
||||
model = new TestItem
|
||||
panel = atom.workspace.addRightPanel(item: model)
|
||||
|
||||
expect(panel).toBeDefined()
|
||||
expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0})
|
||||
|
||||
itemView = atom.views.getView(atom.workspace.getRightPanels()[0].getItem())
|
||||
expect(itemView instanceof TestItemElement).toBe(true)
|
||||
expect(itemView.getModel()).toBe(model)
|
||||
|
||||
describe '::addTopPanel(model)', ->
|
||||
it 'adds a panel to the correct panel container', ->
|
||||
expect(atom.workspace.getTopPanels().length).toBe(0)
|
||||
atom.workspace.panelContainers.top.onDidAddPanel addPanelSpy = jasmine.createSpy()
|
||||
panel = atom.workspace.addTopPanel(item: new TestPanel())
|
||||
|
||||
model = new TestItem
|
||||
panel = atom.workspace.addTopPanel(item: model)
|
||||
|
||||
expect(panel).toBeDefined()
|
||||
expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0})
|
||||
|
||||
itemView = atom.views.getView(atom.workspace.getTopPanels()[0].getItem())
|
||||
expect(itemView instanceof TestItemElement).toBe(true)
|
||||
expect(itemView.getModel()).toBe(model)
|
||||
|
||||
describe '::addBottomPanel(model)', ->
|
||||
it 'adds a panel to the correct panel container', ->
|
||||
expect(atom.workspace.getBottomPanels().length).toBe(0)
|
||||
atom.workspace.panelContainers.bottom.onDidAddPanel addPanelSpy = jasmine.createSpy()
|
||||
panel = atom.workspace.addBottomPanel(item: new TestPanel())
|
||||
|
||||
model = new TestItem
|
||||
panel = atom.workspace.addBottomPanel(item: model)
|
||||
|
||||
expect(panel).toBeDefined()
|
||||
expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0})
|
||||
|
||||
itemView = atom.views.getView(atom.workspace.getBottomPanels()[0].getItem())
|
||||
expect(itemView instanceof TestItemElement).toBe(true)
|
||||
expect(itemView.getModel()).toBe(model)
|
||||
|
||||
describe '::addModalPanel(model)', ->
|
||||
it 'adds a panel to the correct panel container', ->
|
||||
expect(atom.workspace.getModalPanels().length).toBe(0)
|
||||
atom.workspace.panelContainers.modal.onDidAddPanel addPanelSpy = jasmine.createSpy()
|
||||
panel = atom.workspace.addModalPanel(item: new TestPanel())
|
||||
|
||||
model = new TestItem
|
||||
panel = atom.workspace.addModalPanel(item: model)
|
||||
|
||||
expect(panel).toBeDefined()
|
||||
expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0})
|
||||
expect(panel.getClassName()).toBe 'overlay from-top' # the default
|
||||
|
||||
itemView = atom.views.getView(atom.workspace.getModalPanels()[0].getItem())
|
||||
expect(itemView instanceof TestItemElement).toBe(true)
|
||||
expect(itemView.getModel()).toBe(model)
|
||||
|
||||
describe "::panelForItem(item)", ->
|
||||
it "returns the panel associated with the item", ->
|
||||
item = new TestItem
|
||||
panel = atom.workspace.addLeftPanel(item: item)
|
||||
|
||||
itemWithNoPanel = new TestItem
|
||||
|
||||
expect(atom.workspace.panelForItem(item)).toBe panel
|
||||
expect(atom.workspace.panelForItem(itemWithNoPanel)).toBe null
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{$, $$, WorkspaceView, View} = require 'atom'
|
||||
{$, $$, View} = require '../src/space-pen-extensions'
|
||||
Q = require 'q'
|
||||
path = require 'path'
|
||||
temp = require 'temp'
|
||||
@@ -10,6 +10,8 @@ describe "WorkspaceView", ->
|
||||
pathToOpen = null
|
||||
|
||||
beforeEach ->
|
||||
jasmine.snapshotDeprecations()
|
||||
|
||||
atom.project.setPaths([atom.project.resolve('dir')])
|
||||
pathToOpen = atom.project.resolve('a')
|
||||
atom.workspace = new Workspace
|
||||
@@ -20,6 +22,9 @@ describe "WorkspaceView", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(pathToOpen)
|
||||
|
||||
afterEach ->
|
||||
jasmine.restoreDeprecationsSnapshot()
|
||||
|
||||
describe "@deserialize()", ->
|
||||
viewState = null
|
||||
|
||||
|
||||
+21
-2
@@ -5,13 +5,13 @@ path = require 'path'
|
||||
remote = require 'remote'
|
||||
screen = require 'screen'
|
||||
shell = require 'shell'
|
||||
{deprecate} = require 'grim'
|
||||
|
||||
_ = require 'underscore-plus'
|
||||
{deprecate} = require 'grim'
|
||||
{Emitter} = require 'event-kit'
|
||||
{Model} = require 'theorist'
|
||||
fs = require 'fs-plus'
|
||||
{convertStackTrace, convertLine} = require 'coffeestack'
|
||||
|
||||
{$} = require './space-pen-extensions'
|
||||
WindowEventHandler = require './window-event-handler'
|
||||
@@ -134,6 +134,9 @@ class Atom extends Model
|
||||
# Public: A {Clipboard} instance
|
||||
clipboard: null
|
||||
|
||||
# A {ServiceHub} instance
|
||||
services: null
|
||||
|
||||
# Public: A {ContextMenuManager} instance
|
||||
contextMenu: null
|
||||
|
||||
@@ -196,9 +199,16 @@ class Atom extends Model
|
||||
unless @inDevMode() or @inSpecMode()
|
||||
require('grim').deprecate = ->
|
||||
|
||||
sourceMapCache = {}
|
||||
|
||||
window.onerror = =>
|
||||
@lastUncaughtError = Array::slice.call(arguments)
|
||||
[message, url, line, column, originalError] = @lastUncaughtError
|
||||
|
||||
convertedLine = convertLine(url, line, column, sourceMapCache)
|
||||
{line, column} = convertedLine if convertedLine?
|
||||
originalError.stack = convertStackTrace(originalError.stack, sourceMapCache) if originalError
|
||||
|
||||
eventObject = {message, url, line, column, originalError}
|
||||
|
||||
openDevTools = true
|
||||
@@ -226,6 +236,7 @@ class Atom extends Model
|
||||
NotificationManager = require './notification-manager'
|
||||
PackageManager = require './package-manager'
|
||||
Clipboard = require './clipboard'
|
||||
ServiceHub = require './service-hub'
|
||||
GrammarRegistry = require './grammar-registry'
|
||||
ThemeManager = require './theme-manager'
|
||||
StyleManager = require './style-manager'
|
||||
@@ -249,6 +260,7 @@ class Atom extends Model
|
||||
@config = new Config({configDirPath, resourcePath})
|
||||
@keymaps = new KeymapManager({configDirPath, resourcePath})
|
||||
@keymap = @keymaps # Deprecated
|
||||
@keymaps.subscribeToFileReadFailure()
|
||||
@tooltips = new TooltipManager
|
||||
@notifications = new NotificationManager
|
||||
@commands = new CommandRegistry
|
||||
@@ -260,6 +272,7 @@ class Atom extends Model
|
||||
@contextMenu = new ContextMenuManager({resourcePath, devMode})
|
||||
@menu = new MenuManager({resourcePath})
|
||||
@clipboard = new Clipboard()
|
||||
@services = new ServiceHub
|
||||
|
||||
@grammars = @deserializers.deserialize(@state.grammars ? @state.syntax) ? new GrammarRegistry()
|
||||
|
||||
@@ -603,7 +616,7 @@ class Atom extends Model
|
||||
# Essential: Visually and audibly trigger a beep.
|
||||
beep: ->
|
||||
shell.beep() if @config.get('core.audioBeep')
|
||||
@__workspaceView.trigger 'beep'
|
||||
@__workspaceView?.trigger 'beep'
|
||||
@emitter.emit 'did-beep'
|
||||
|
||||
# Essential: A flexible way to open a dialog akin to an alert dialog.
|
||||
@@ -782,6 +795,12 @@ class Atom extends Model
|
||||
else
|
||||
window[key] = value
|
||||
|
||||
onUpdateAvailable: (callback) ->
|
||||
@emitter.on 'update-available', callback
|
||||
|
||||
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")
|
||||
|
||||
@@ -58,7 +58,7 @@ class AtomWindow
|
||||
@browserWindow.loadUrl @getUrl(loadSettings)
|
||||
@browserWindow.focusOnWebView() if @isSpec
|
||||
|
||||
@openPath(pathToOpen, initialLine, initialColumn)
|
||||
@openPath(pathToOpen, initialLine, initialColumn) unless @isSpecWindow()
|
||||
|
||||
getUrl: (loadSettingsObj) ->
|
||||
# Ignore the windowState when passing loadSettings via URL, since it could
|
||||
@@ -143,10 +143,13 @@ class AtomWindow
|
||||
openPath: (pathToOpen, initialLine, initialColumn) ->
|
||||
if @loaded
|
||||
@focus()
|
||||
@sendCommand('window:open-path', {pathToOpen, initialLine, initialColumn})
|
||||
@sendMessage 'open-path', {pathToOpen, initialLine, initialColumn}
|
||||
else
|
||||
@browserWindow.once 'window:loaded', => @openPath(pathToOpen, initialLine, initialColumn)
|
||||
|
||||
sendMessage: (message, detail) ->
|
||||
@browserWindow.webContents.send 'message', message, detail
|
||||
|
||||
sendCommand: (command, args...) ->
|
||||
if @isSpecWindow()
|
||||
unless global.atomApplication.sendCommandToFirstResponder(command)
|
||||
@@ -154,7 +157,6 @@ class AtomWindow
|
||||
when 'window:reload' then @reload()
|
||||
when 'window:toggle-dev-tools' then @toggleDevTools()
|
||||
when 'window:close' then @close()
|
||||
when 'window:update-available' then @sendCommandToBrowserWindow(command, args...) # For spec testing
|
||||
else if @isWebViewFocused()
|
||||
@sendCommandToBrowserWindow(command, args...)
|
||||
else
|
||||
|
||||
@@ -7,6 +7,7 @@ CheckingState = 'checking'
|
||||
DownladingState = 'downloading'
|
||||
UpdateAvailableState = 'update-available'
|
||||
NoUpdateAvailableState = 'no-update-available'
|
||||
UnsupportedState = 'unsupported'
|
||||
ErrorState = 'error'
|
||||
|
||||
module.exports =
|
||||
@@ -53,10 +54,16 @@ class AutoUpdateManager
|
||||
unless /\w{7}/.test(@version)
|
||||
@check(hidePopups: true)
|
||||
|
||||
switch process.platform
|
||||
when 'win32'
|
||||
@setState(UnsupportedState) unless autoUpdater.supportsUpdates()
|
||||
when 'linux'
|
||||
@setState(UnsupportedState)
|
||||
|
||||
emitUpdateAvailableEvent: (windows...) ->
|
||||
return unless @releaseVersion? and @releaseNotes
|
||||
for atomWindow in windows
|
||||
atomWindow.sendCommand('window:update-available', [@releaseVersion, @releaseNotes])
|
||||
atomWindow.sendMessage('update-available', {@releaseVersion, @releaseNotes})
|
||||
|
||||
setState: (state) ->
|
||||
return if @state is state
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{EventEmitter} = require 'events'
|
||||
_ = require 'underscore-plus'
|
||||
shellAutoUpdater = require 'auto-updater'
|
||||
SquirrelUpdate = require './squirrel-update'
|
||||
|
||||
class AutoUpdater
|
||||
@@ -9,15 +8,10 @@ class AutoUpdater
|
||||
setFeedUrl: (@updateUrl) ->
|
||||
|
||||
quitAndInstall: ->
|
||||
unless SquirrelUpdate.existsSync()
|
||||
shellAutoUpdater.quitAndInstall()
|
||||
return
|
||||
|
||||
@installUpdate (error) ->
|
||||
return if error?
|
||||
|
||||
SquirrelUpdate.spawn ['--processStart', 'atom.exe'], ->
|
||||
shellAutoUpdater.quitAndInstall()
|
||||
if SquirrelUpdate.existsSync()
|
||||
SquirrelUpdate.restartAtom()
|
||||
else
|
||||
require('auto-updater').quitAndInstall()
|
||||
|
||||
downloadUpdate: (callback) ->
|
||||
SquirrelUpdate.spawn ['--download', @updateUrl], (error, stdout) ->
|
||||
@@ -36,6 +30,9 @@ class AutoUpdater
|
||||
installUpdate: (callback) ->
|
||||
SquirrelUpdate.spawn(['--update', @updateUrl], callback)
|
||||
|
||||
supportsUpdates: ->
|
||||
SquirrelUpdate.existsSync()
|
||||
|
||||
checkForUpdates: ->
|
||||
throw new Error('Update URL is not set') unless @updateUrl
|
||||
|
||||
@@ -47,7 +44,6 @@ class AutoUpdater
|
||||
|
||||
@downloadUpdate (error, update) =>
|
||||
if error?
|
||||
console.log "Failed to download: #{error.message} - #{error.code} - #{error.stdout}"
|
||||
@emit 'update-not-available'
|
||||
return
|
||||
|
||||
@@ -57,12 +53,9 @@ class AutoUpdater
|
||||
|
||||
@installUpdate (error) =>
|
||||
if error?
|
||||
console.log "Failed to update: #{error.message} - #{error.code} - #{error.stdout}"
|
||||
@emit 'update-not-available'
|
||||
return
|
||||
|
||||
console.log "Updated to #{update.version}"
|
||||
|
||||
@emit 'update-available'
|
||||
@emit 'update-downloaded', {}, update.releaseNotes, update.version, new Date(), 'https://atom.io', => @quitAndInstall()
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class ContextMenu
|
||||
menu.popup(@atomWindow.browserWindow)
|
||||
|
||||
# It's necessary to build the event handlers in this process, otherwise
|
||||
# closures are drug across processes and failed to be garbage collected
|
||||
# closures are dragged across processes and failed to be garbage collected
|
||||
# appropriately.
|
||||
createClickHandlers: (template) ->
|
||||
for item in template
|
||||
|
||||
@@ -36,7 +36,7 @@ spawn = (command, args, callback) ->
|
||||
error ?= new Error("Command failed: #{signal ? code}") if code isnt 0
|
||||
error?.code ?= code
|
||||
error?.stdout ?= stdout
|
||||
callback(error, stdout)
|
||||
callback?(error, stdout)
|
||||
|
||||
# Spawn reg.exe and callback when it completes
|
||||
spawnReg = (args, callback) ->
|
||||
@@ -159,7 +159,6 @@ removeCommandsFromPath = (callback) ->
|
||||
else
|
||||
callback()
|
||||
|
||||
|
||||
# Create a desktop and start menu shortcut by using the command line API
|
||||
# provided by Squirrel's Update.exe
|
||||
createShortcut = (callback) ->
|
||||
@@ -176,6 +175,11 @@ exports.spawn = spawnUpdate
|
||||
exports.existsSync = ->
|
||||
fs.existsSync(updateDotExe)
|
||||
|
||||
# Restart Atom using the version pointed to by the atom.cmd shim
|
||||
exports.restartAtom = ->
|
||||
app.once 'will-quit', -> spawn(path.join(binFolder, 'atom.cmd'))
|
||||
app.quit()
|
||||
|
||||
# Handle squirrel events denoted by --squirrel-* command line arguments.
|
||||
exports.handleStartupEvent = ->
|
||||
switch process.argv[1]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
_ = require 'underscore-plus'
|
||||
ChildProcess = require 'child_process'
|
||||
{Emitter} = require 'event-kit'
|
||||
|
||||
# Extended: A wrapper which provides standard error/output line buffering for
|
||||
# Node's ChildProcess.
|
||||
@@ -17,6 +18,10 @@ ChildProcess = require 'child_process'
|
||||
# ```
|
||||
module.exports =
|
||||
class BufferedProcess
|
||||
###
|
||||
Section: Construction
|
||||
###
|
||||
|
||||
# Public: Runs the given command by spawning a new child process.
|
||||
#
|
||||
# * `options` An {Object} with the following keys:
|
||||
@@ -39,6 +44,7 @@ class BufferedProcess
|
||||
# * `exit` The callback {Function} which receives a single argument
|
||||
# containing the exit status (optional).
|
||||
constructor: ({command, args, options, stdout, stderr, exit}={}) ->
|
||||
@emitter = new Emitter
|
||||
options ?= {}
|
||||
# Related to joyent/node#2318
|
||||
if process.platform is "win32"
|
||||
@@ -94,6 +100,41 @@ class BufferedProcess
|
||||
processExited = true
|
||||
triggerExitCallback()
|
||||
|
||||
@process.on 'error', (error) =>
|
||||
handled = false
|
||||
handle = -> handled = true
|
||||
|
||||
@emitter.emit 'will-throw-error', {error, handle}
|
||||
|
||||
if error.code is 'ENOENT' and error.syscall.indexOf('spawn') is 0
|
||||
error = new Error("Failed to spawn command `#{command}`. Make sure `#{command}` is installed and on your PATH", error.path)
|
||||
error.name = 'BufferedProcessError'
|
||||
|
||||
throw error unless handled
|
||||
|
||||
###
|
||||
Section: Event Subscription
|
||||
###
|
||||
|
||||
# Public: Will call your callback when an error will be raised by the process.
|
||||
# Usually this is due to the command not being available or not on the PATH.
|
||||
# You can call `handle()` on the object passed to your callback to indicate
|
||||
# that you have handled this error.
|
||||
#
|
||||
# * `callback` {Function} callback
|
||||
# * `errorObject` {Object}
|
||||
# * `error` {Object} the error object
|
||||
# * `handle` {Function} call this to indicate you have handled the error.
|
||||
# The error will not be thrown if this function is called.
|
||||
#
|
||||
# Returns a {Disposable}
|
||||
onWillThrowError: (callback) ->
|
||||
@emitter.on 'will-throw-error', callback
|
||||
|
||||
###
|
||||
Section: Helper Methods
|
||||
###
|
||||
|
||||
# Helper method to pass data line by line.
|
||||
#
|
||||
# * `stream` The Stream to read from.
|
||||
|
||||
@@ -54,9 +54,10 @@ class CommandRegistry
|
||||
#
|
||||
# ## Arguments: Registering One Command
|
||||
#
|
||||
# * `selector` A {String} containing a CSS selector matching elements on which
|
||||
# you want to handle the commands. The `,` combinator is not currently
|
||||
# supported.
|
||||
# * `target` A {String} containing a CSS selector or a DOM element. If you
|
||||
# pass a selector, the command will be globally associated with all matching
|
||||
# elements. The `,` combinator is not currently supported. If you pass a
|
||||
# DOM element, the command will be associated with just that element.
|
||||
# * `commandName` A {String} containing the name of a command you want to
|
||||
# handle such as `user:insert-date`.
|
||||
# * `callback` A {Function} to call when the given command is invoked on an
|
||||
@@ -67,9 +68,11 @@ class CommandRegistry
|
||||
#
|
||||
# ## Arguments: Registering Multiple Commands
|
||||
#
|
||||
# * `selector` A {String} containing a CSS selector matching elements on which
|
||||
# you want to handle the commands. The `,` combinator is not currently
|
||||
# supported.
|
||||
# * `target` A {String} containing a CSS selector or a DOM element. If you
|
||||
# pass a selector, the commands will be globally associated with all
|
||||
# matching elements. The `,` combinator is not currently supported.
|
||||
# If you pass a DOM element, the command will be associated with just that
|
||||
# element.
|
||||
# * `commands` An {Object} mapping command names like `user:insert-date` to
|
||||
# listener {Function}s.
|
||||
#
|
||||
|
||||
@@ -81,14 +81,20 @@ module.exports =
|
||||
type: 'object'
|
||||
properties:
|
||||
# These settings are used in scoped fashion only. No defaults.
|
||||
commentStart:
|
||||
type: ['string', 'null']
|
||||
commentEnd:
|
||||
type: ['string', 'null']
|
||||
increaseIndentPattern:
|
||||
type: ['string', 'null']
|
||||
decreaseIndentPattern:
|
||||
type: ['string', 'null']
|
||||
comment:
|
||||
type: 'object'
|
||||
properties:
|
||||
start:
|
||||
type: ['string', 'null']
|
||||
end:
|
||||
type: ['string', 'null']
|
||||
indent:
|
||||
type: 'object'
|
||||
properties:
|
||||
increasePattern:
|
||||
type: ['string', 'null']
|
||||
decreasePattern:
|
||||
type: ['string', 'null']
|
||||
foldEndPattern:
|
||||
type: ['string', 'null']
|
||||
|
||||
@@ -149,7 +155,7 @@ module.exports =
|
||||
default: false
|
||||
undoGroupingInterval:
|
||||
type: 'integer'
|
||||
default: 500
|
||||
default: 300
|
||||
minimum: 0
|
||||
description: 'Time interval in milliseconds within which operations will be grouped together in the undo history'
|
||||
useHardwareAcceleration:
|
||||
|
||||
+12
-4
@@ -526,6 +526,9 @@ class Config
|
||||
|
||||
# Extended: Restore the global setting at `keyPath` to its default value.
|
||||
#
|
||||
# * `scopeSelector` (optional) {String}. eg. '.source.ruby'
|
||||
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
||||
# for more information.
|
||||
# * `keyPath` The {String} name of the key.
|
||||
#
|
||||
# Returns the new value.
|
||||
@@ -721,21 +724,26 @@ class Config
|
||||
@configFileHasErrors = false
|
||||
catch error
|
||||
@configFileHasErrors = true
|
||||
console.error "Failed to load user config '#{@configFilePath}'", error.message
|
||||
console.error error.stack
|
||||
@notifyFailure('Failed to load config.cson', error)
|
||||
|
||||
observeUserConfig: ->
|
||||
try
|
||||
@watchSubscription ?= pathWatcher.watch @configFilePath, (eventType) =>
|
||||
@loadUserConfig() if eventType is 'change' and @watchSubscription?
|
||||
catch error
|
||||
console.error "Failed to watch user config '#{@configFilePath}'", error.message
|
||||
console.error error.stack
|
||||
@notifyFailure('Failed to watch user config', error)
|
||||
|
||||
unobserveUserConfig: ->
|
||||
@watchSubscription?.close()
|
||||
@watchSubscription = null
|
||||
|
||||
notifyFailure: (errorMessage, error) ->
|
||||
message = "#{errorMessage}"
|
||||
detail = error.stack
|
||||
atom.notifications.addError(message, {detail, dismissable: true})
|
||||
console.error message
|
||||
console.error detail
|
||||
|
||||
save: ->
|
||||
allSettings = global: @settings
|
||||
allSettings = _.extend allSettings, @scopedSettingsStore.propertiesForSource('user-config')
|
||||
|
||||
+5
-5
@@ -45,7 +45,7 @@ class Cursor extends Model
|
||||
cursor: this
|
||||
|
||||
@emit 'moved', movedEvent
|
||||
@emitter.emit 'did-change-position'
|
||||
@emitter.emit 'did-change-position', movedEvent
|
||||
@editor.cursorMoved(movedEvent)
|
||||
@marker.onDidDestroy =>
|
||||
@destroyed = true
|
||||
@@ -476,7 +476,7 @@ class Cursor extends Model
|
||||
endOfWordPosition or currentBufferPosition
|
||||
|
||||
getMoveNextWordBoundaryBufferPosition: (options) ->
|
||||
deprecate 'Use `::getNextWordBoundaryBufferPosition(options)` instead'
|
||||
Grim.deprecate 'Use `::getNextWordBoundaryBufferPosition(options)` instead'
|
||||
@getNextWordBoundaryBufferPosition(options)
|
||||
|
||||
# Public: Retrieves the buffer position of where the current word starts.
|
||||
@@ -665,7 +665,7 @@ class Cursor extends Model
|
||||
autoscroll: (options) ->
|
||||
@editor.scrollToScreenRange(@getScreenRange(), options)
|
||||
|
||||
getBeginningOfNextParagraphBufferPosition: (editor) ->
|
||||
getBeginningOfNextParagraphBufferPosition: ->
|
||||
start = @getBufferPosition()
|
||||
eof = @editor.getEofBufferPosition()
|
||||
scanRange = [start, eof]
|
||||
@@ -679,8 +679,8 @@ class Cursor extends Model
|
||||
stop()
|
||||
@editor.screenPositionForBufferPosition(position)
|
||||
|
||||
getBeginningOfPreviousParagraphBufferPosition: (editor) ->
|
||||
start = @editor.getCursorBufferPosition()
|
||||
getBeginningOfPreviousParagraphBufferPosition: ->
|
||||
start = @getBufferPosition()
|
||||
|
||||
{row, column} = start
|
||||
scanRange = [[row-1, column], [0,0]]
|
||||
|
||||
@@ -883,12 +883,29 @@ class DisplayBuffer extends Model
|
||||
decorationForId: (id) ->
|
||||
@decorationsById[id]
|
||||
|
||||
getDecorations: ->
|
||||
getDecorations: (propertyFilter) ->
|
||||
allDecorations = []
|
||||
for markerId, decorations of @decorationsByMarkerId
|
||||
allDecorations = allDecorations.concat(decorations) if decorations?
|
||||
if propertyFilter?
|
||||
allDecorations = allDecorations.filter (decoration) ->
|
||||
for key, value of propertyFilter
|
||||
return false unless decoration.properties[key] is value
|
||||
true
|
||||
allDecorations
|
||||
|
||||
getLineDecorations: (propertyFilter) ->
|
||||
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('line')
|
||||
|
||||
getGutterDecorations: (propertyFilter) ->
|
||||
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('gutter')
|
||||
|
||||
getHighlightDecorations: (propertyFilter) ->
|
||||
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('highlight')
|
||||
|
||||
getOverlayDecorations: (propertyFilter) ->
|
||||
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('overlay')
|
||||
|
||||
decorationsForScreenRowRange: (startScreenRow, endScreenRow) ->
|
||||
decorationsByMarkerId = {}
|
||||
for marker in @findMarkers(intersectsScreenRowRange: [startScreenRow, endScreenRow])
|
||||
|
||||
@@ -23,6 +23,10 @@ KeymapManager::loadUserKeymap = ->
|
||||
if fs.isFileSync(userKeymapPath)
|
||||
@loadKeymap(userKeymapPath, watch: true, suppressErrors: true)
|
||||
|
||||
KeymapManager::subscribeToFileReadFailure = ->
|
||||
this.onDidFailToReadFile (error) ->
|
||||
atom.notifications.addError('Failed to load keymap.cson', {detail: error.stack, dismissable: true})
|
||||
|
||||
# This enables command handlers registered via jQuery to call
|
||||
# `.abortKeyBinding()` on the `jQuery.Event` object passed to the handler.
|
||||
jQuery.Event::abortKeyBinding = ->
|
||||
|
||||
+23
-15
@@ -30,13 +30,15 @@ class LanguageMode
|
||||
# Returns an {Array} of the commented {Ranges}.
|
||||
toggleLineCommentsForBufferRows: (start, end) ->
|
||||
scopeDescriptor = @editor.scopeDescriptorForBufferPosition([start, 0])
|
||||
properties = atom.config.settingsForScopeDescriptor(scopeDescriptor, 'editor.commentStart')[0]
|
||||
return unless properties
|
||||
|
||||
commentStartString = _.valueForKeyPath(properties, 'editor.commentStart')
|
||||
commentEndString = _.valueForKeyPath(properties, 'editor.commentEnd')
|
||||
commentStrings = atom.config.get(scopeDescriptor, 'editor.comment')
|
||||
|
||||
return unless commentStartString
|
||||
return unless commentStrings?
|
||||
|
||||
commentStartString = commentStrings.start
|
||||
commentEndString = commentStrings.end
|
||||
|
||||
return unless commentStartString?
|
||||
|
||||
buffer = @editor.buffer
|
||||
commentStartRegexString = _.escapeRegExp(commentStartString).replace(/(\s+)$/, '(?:$1)?')
|
||||
@@ -247,7 +249,14 @@ class LanguageMode
|
||||
suggestedIndentForBufferRow: (bufferRow, options) ->
|
||||
currentIndentLevel = @editor.indentationForBufferRow(bufferRow)
|
||||
scopeDescriptor = @editor.scopeDescriptorForBufferPosition([bufferRow, 0])
|
||||
return currentIndentLevel unless increaseIndentRegex = @increaseIndentRegexForScopeDescriptor(scopeDescriptor)
|
||||
|
||||
indentPatterns = atom.config.get(scopeDescriptor, 'editor.indent')
|
||||
if indentPatterns?.increasePattern?
|
||||
increaseIndentRegex = new OnigRegExp(indentPatterns.increasePattern)
|
||||
if indentPatterns?.decreasePattern?
|
||||
decreaseIndentRegex = new OnigRegExp(indentPatterns.decreasePattern)
|
||||
|
||||
return currentIndentLevel unless increaseIndentRegex?
|
||||
|
||||
currentLine = @buffer.lineForRow(bufferRow)
|
||||
if options?.skipBlankLines ? true
|
||||
@@ -261,7 +270,7 @@ class LanguageMode
|
||||
desiredIndentLevel = @editor.indentationForBufferRow(precedingRow)
|
||||
desiredIndentLevel += 1 if increaseIndentRegex.testSync(precedingLine) and not @editor.isBufferRowCommented(precedingRow)
|
||||
|
||||
return desiredIndentLevel unless decreaseIndentRegex = @decreaseIndentRegexForScopeDescriptor(scopeDescriptor)
|
||||
return desiredIndentLevel unless decreaseIndentRegex?
|
||||
desiredIndentLevel -= 1 if decreaseIndentRegex.testSync(currentLine)
|
||||
|
||||
Math.max(desiredIndentLevel, 0)
|
||||
@@ -297,8 +306,13 @@ class LanguageMode
|
||||
# bufferRow - The row {Number}
|
||||
autoDecreaseIndentForBufferRow: (bufferRow) ->
|
||||
scopeDescriptor = @editor.scopeDescriptorForBufferPosition([bufferRow, 0])
|
||||
increaseIndentRegex = @increaseIndentRegexForScopeDescriptor(scopeDescriptor)
|
||||
decreaseIndentRegex = @decreaseIndentRegexForScopeDescriptor(scopeDescriptor)
|
||||
|
||||
indentPatterns = atom.config.get(scopeDescriptor, 'editor.indent')
|
||||
if indentPatterns?.increasePattern?
|
||||
increaseIndentRegex = new OnigRegExp(indentPatterns.increasePattern)
|
||||
if indentPatterns?.decreasePattern?
|
||||
decreaseIndentRegex = new OnigRegExp(indentPatterns.decreasePattern)
|
||||
|
||||
return unless increaseIndentRegex and decreaseIndentRegex
|
||||
|
||||
line = @buffer.lineForRow(bufferRow)
|
||||
@@ -319,11 +333,5 @@ class LanguageMode
|
||||
if pattern = atom.config.get(scopeDescriptor, property)
|
||||
new OnigRegExp(pattern)
|
||||
|
||||
increaseIndentRegexForScopeDescriptor: (scopeDescriptor) ->
|
||||
@getRegexForProperty(scopeDescriptor, 'editor.increaseIndentPattern')
|
||||
|
||||
decreaseIndentRegexForScopeDescriptor: (scopeDescriptor) ->
|
||||
@getRegexForProperty(scopeDescriptor, 'editor.decreaseIndentPattern')
|
||||
|
||||
foldEndRegexForScopeDescriptor: (scopeDescriptor) ->
|
||||
@getRegexForProperty(scopeDescriptor, 'editor.foldEndPattern')
|
||||
|
||||
@@ -42,3 +42,9 @@ class NotificationManager
|
||||
@notifications.push(notification)
|
||||
@emitter.emit('did-add-notification', notification)
|
||||
notification
|
||||
|
||||
###
|
||||
Section: Getting Notifications
|
||||
###
|
||||
|
||||
getNotifications: -> @notifications
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
{Emitter} = require 'event-kit'
|
||||
|
||||
# Experimental: This will likely change, do not use.
|
||||
module.exports =
|
||||
class Notification
|
||||
constructor: (@type, @message, @options={}) ->
|
||||
@emitter = new Emitter
|
||||
@timestamp = new Date()
|
||||
@dismissed = true
|
||||
@dismissed = false if @isDismissable()
|
||||
|
||||
onDidDismiss: (callback) ->
|
||||
@emitter.on 'did-dismiss', callback
|
||||
|
||||
getOptions: -> @options
|
||||
|
||||
@@ -13,10 +20,21 @@ class Notification
|
||||
|
||||
getTimestamp: -> @timestamp
|
||||
|
||||
getDetail: -> @optons.detail
|
||||
getDetail: -> @options.detail
|
||||
|
||||
isClosable: ->
|
||||
!!@options.closable
|
||||
isEqual: (other) ->
|
||||
@getMessage() == other.getMessage() \
|
||||
and @getType() == other.getType() \
|
||||
and @getDetail() == other.getDetail()
|
||||
|
||||
dismiss: ->
|
||||
return unless @isDismissable() and not @isDismissed()
|
||||
@dismissed = true
|
||||
@emitter.emit 'did-dismiss'
|
||||
|
||||
isDismissed: -> @dismissed
|
||||
|
||||
isDismissable: -> !!@options.dismissable
|
||||
|
||||
getIcon: ->
|
||||
return @options.icon if @options.icon?
|
||||
|
||||
@@ -7,9 +7,12 @@ class OverlayManager
|
||||
{editor, overlayDecorations, lineHeightInPixels} = props
|
||||
|
||||
existingDecorations = null
|
||||
for markerId, {isMarkerReversed, headPixelPosition, decorations} of overlayDecorations
|
||||
for markerId, {headPixelPosition, tailPixelPosition, decorations} of overlayDecorations
|
||||
for decoration in decorations
|
||||
@renderOverlay(editor, decoration, headPixelPosition, lineHeightInPixels)
|
||||
pixelPosition =
|
||||
if decoration.position is 'tail' then tailPixelPosition else headPixelPosition
|
||||
|
||||
@renderOverlay(editor, decoration, pixelPosition, lineHeightInPixels)
|
||||
|
||||
existingDecorations ?= {}
|
||||
existingDecorations[decoration.id] = true
|
||||
|
||||
+11
-1
@@ -338,7 +338,7 @@ class Package
|
||||
reloadStylesheets: ->
|
||||
oldSheets = _.clone(@stylesheets)
|
||||
@loadStylesheets()
|
||||
@stylesheetDisposables.dispose()
|
||||
@stylesheetDisposables?.dispose()
|
||||
@stylesheetDisposables = new CompositeDisposable
|
||||
@stylesheetsActivated = false
|
||||
@activateStylesheets()
|
||||
@@ -408,6 +408,16 @@ class Package
|
||||
@activationCommands[selector].push(commands...)
|
||||
|
||||
if @metadata.activationEvents?
|
||||
deprecate """
|
||||
Use `activationCommands` instead of `activationEvents` in your package.json
|
||||
Commands should be grouped by selector as follows:
|
||||
```json
|
||||
"activationCommands": {
|
||||
"atom-workspace": ["foo:bar", "foo:baz"],
|
||||
"atom-text-editor": ["foo:quux"]
|
||||
}
|
||||
```
|
||||
"""
|
||||
if _.isArray(@metadata.activationEvents)
|
||||
for eventName in @metadata.activationEvents
|
||||
@activationCommands['atom-workspace'] ?= []
|
||||
|
||||
@@ -8,7 +8,7 @@ class PaneAxisElement extends HTMLElement
|
||||
detachedCallback: ->
|
||||
@subscriptions.dispose()
|
||||
|
||||
setModel: (@model) ->
|
||||
initialize: (@model) ->
|
||||
@subscriptions.add @model.onDidAddChild(@childAdded.bind(this))
|
||||
@subscriptions.add @model.onDidRemoveChild(@childRemoved.bind(this))
|
||||
@subscriptions.add @model.onDidReplaceChild(@childReplaced.bind(this))
|
||||
@@ -20,14 +20,15 @@ class PaneAxisElement extends HTMLElement
|
||||
@classList.add('horizontal', 'pane-row')
|
||||
when 'vertical'
|
||||
@classList.add('vertical', 'pane-column')
|
||||
this
|
||||
|
||||
childAdded: ({child, index}) ->
|
||||
view = @model.getView(child)
|
||||
view = atom.views.getView(child)
|
||||
@insertBefore(view, @children[index])
|
||||
callAttachHooks(view) # for backward compatibility with SpacePen views
|
||||
|
||||
childRemoved: ({child}) ->
|
||||
view = @model.getView(child)
|
||||
view = atom.views.getView(child)
|
||||
view.remove()
|
||||
|
||||
childReplaced: ({index, oldChild, newChild}) ->
|
||||
|
||||
@@ -39,9 +39,6 @@ class PaneAxis extends Model
|
||||
|
||||
getOrientation: -> @orientation
|
||||
|
||||
getView: (object) ->
|
||||
@container.getView(object)
|
||||
|
||||
getChildren: -> @children.slice()
|
||||
|
||||
getPanes: ->
|
||||
|
||||
@@ -11,15 +11,16 @@ class PaneContainerElement extends HTMLElement
|
||||
PaneContainerView ?= require './pane-container-view'
|
||||
@__spacePenView = new PaneContainerView(this)
|
||||
|
||||
setModel: (@model) ->
|
||||
initialize: (@model) ->
|
||||
@subscriptions.add @model.observeRoot(@rootChanged.bind(this))
|
||||
@__spacePenView.setModel(@model)
|
||||
this
|
||||
|
||||
rootChanged: (root) ->
|
||||
focusedElement = document.activeElement if @hasFocus()
|
||||
@firstChild?.remove()
|
||||
if root?
|
||||
view = @model.getView(root)
|
||||
view = atom.views.getView(root)
|
||||
@appendChild(view)
|
||||
callAttachHooks(view)
|
||||
focusedElement?.focus()
|
||||
@@ -45,7 +46,7 @@ class PaneContainerElement extends HTMLElement
|
||||
y = pointB.y - pointA.y
|
||||
Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
|
||||
|
||||
paneView = @model.getView(@model.getActivePane())
|
||||
paneView = atom.views.getView(@model.getActivePane())
|
||||
box = @boundingBoxForPaneView(paneView)
|
||||
|
||||
paneViews = _.toArray(@querySelectorAll('atom-pane'))
|
||||
|
||||
@@ -23,7 +23,7 @@ class PaneContainerView extends View
|
||||
@subscriptions.add @model.onDidChangeActivePaneItem(@onActivePaneItemChanged)
|
||||
|
||||
getRoot: ->
|
||||
view = @model.getView(@model.getRoot())
|
||||
view = atom.views.getView(@model.getRoot())
|
||||
view.__spacePenView ? view
|
||||
|
||||
onActivePaneItemChanged: (activeItem) =>
|
||||
@@ -55,7 +55,7 @@ class PaneContainerView extends View
|
||||
@getActivePaneView()
|
||||
|
||||
getActivePaneView: ->
|
||||
@model.getView(@model.getActivePane()).__spacePenView
|
||||
atom.views.getView(@model.getActivePane()).__spacePenView
|
||||
|
||||
getActivePaneItem: ->
|
||||
@model.getActivePaneItem()
|
||||
@@ -64,7 +64,7 @@ class PaneContainerView extends View
|
||||
@getActivePaneView()?.activeView
|
||||
|
||||
paneForUri: (uri) ->
|
||||
@model.getView(@model.paneForUri(uri)).__spacePenView
|
||||
atom.views.getView(@model.paneForUri(uri)).__spacePenView
|
||||
|
||||
focusNextPaneView: ->
|
||||
@model.activateNextPane()
|
||||
|
||||
+24
-24
@@ -9,7 +9,6 @@ PaneAxisElement = require './pane-axis-element'
|
||||
PaneAxis = require './pane-axis'
|
||||
TextEditor = require './text-editor'
|
||||
TextEditorElement = require './text-editor-element'
|
||||
ViewRegistry = require './view-registry'
|
||||
ItemRegistry = require './item-registry'
|
||||
|
||||
module.exports =
|
||||
@@ -36,7 +35,6 @@ class PaneContainer extends Model
|
||||
@subscriptions = new CompositeDisposable
|
||||
|
||||
@itemRegistry = new ItemRegistry
|
||||
@viewRegistry = params?.viewRegistry ? new ViewRegistry
|
||||
@registerViewProviders()
|
||||
|
||||
@setRoot(params?.root ? new Pane)
|
||||
@@ -58,24 +56,14 @@ class PaneContainer extends Model
|
||||
activePaneId: @activePane.id
|
||||
|
||||
registerViewProviders: ->
|
||||
@viewRegistry.addViewProvider
|
||||
modelConstructor: PaneContainer
|
||||
viewConstructor: PaneContainerElement
|
||||
|
||||
@viewRegistry.addViewProvider
|
||||
modelConstructor: PaneAxis
|
||||
viewConstructor: PaneAxisElement
|
||||
|
||||
@viewRegistry.addViewProvider
|
||||
modelConstructor: Pane
|
||||
viewConstructor: PaneElement
|
||||
|
||||
@viewRegistry.addViewProvider
|
||||
modelConstructor: TextEditor
|
||||
viewConstructor: TextEditorElement
|
||||
|
||||
getView: (object) ->
|
||||
@viewRegistry.getView(object)
|
||||
atom.views.addViewProvider PaneContainer, (model) ->
|
||||
new PaneContainerElement().initialize(model)
|
||||
atom.views.addViewProvider PaneAxis, (model) ->
|
||||
new PaneAxisElement().initialize(model)
|
||||
atom.views.addViewProvider Pane, (model) ->
|
||||
new PaneElement().initialize(model)
|
||||
atom.views.addViewProvider TextEditor, (model) ->
|
||||
new TextEditorElement().initialize(model)
|
||||
|
||||
onDidChangeRoot: (fn) ->
|
||||
@emitter.on 'did-change-root', fn
|
||||
@@ -91,6 +79,9 @@ class PaneContainer extends Model
|
||||
fn(pane) for pane in @getPanes()
|
||||
@onDidAddPane ({pane}) -> fn(pane)
|
||||
|
||||
onDidDestroyPane: (fn) ->
|
||||
@emitter.on 'did-destroy-pane', fn
|
||||
|
||||
onDidChangeActivePane: (fn) ->
|
||||
@emitter.on 'did-change-active-pane', fn
|
||||
|
||||
@@ -112,6 +103,9 @@ class PaneContainer extends Model
|
||||
fn(@getActivePaneItem())
|
||||
@onDidChangeActivePaneItem(fn)
|
||||
|
||||
onWillDestroyPaneItem: (fn) ->
|
||||
@emitter.on 'will-destroy-pane-item', fn
|
||||
|
||||
onDidDestroyPaneItem: (fn) ->
|
||||
@emitter.on 'did-destroy-pane-item', fn
|
||||
|
||||
@@ -193,11 +187,17 @@ class PaneContainer extends Model
|
||||
destroyEmptyPanes: ->
|
||||
pane.destroy() for pane in @getPanes() when pane.items.length is 0
|
||||
|
||||
paneItemDestroyed: (item) ->
|
||||
@emitter.emit 'did-destroy-pane-item', item
|
||||
willDestroyPaneItem: (event) ->
|
||||
@emitter.emit 'will-destroy-pane-item', event
|
||||
|
||||
didAddPane: (pane) ->
|
||||
@emitter.emit 'did-add-pane', pane
|
||||
didDestroyPaneItem: (event) ->
|
||||
@emitter.emit 'did-destroy-pane-item', event
|
||||
|
||||
didAddPane: (event) ->
|
||||
@emitter.emit 'did-add-pane', event
|
||||
|
||||
didDestroyPane: (event) ->
|
||||
@emitter.emit 'did-destroy-pane', event
|
||||
|
||||
# Called by Model superclass when destroyed
|
||||
destroyed: ->
|
||||
|
||||
@@ -43,18 +43,19 @@ class PaneElement extends HTMLElement
|
||||
createSpacePenShim: ->
|
||||
@__spacePenView = new PaneView(this)
|
||||
|
||||
getModel: -> @model
|
||||
|
||||
setModel: (@model) ->
|
||||
initialize: (@model) ->
|
||||
@subscriptions.add @model.onDidActivate(@activated.bind(this))
|
||||
@subscriptions.add @model.observeActive(@activeStatusChanged.bind(this))
|
||||
@subscriptions.add @model.observeActiveItem(@activeItemChanged.bind(this))
|
||||
@subscriptions.add @model.onDidRemoveItem(@itemRemoved.bind(this))
|
||||
@subscriptions.add @model.onDidDestroy(@paneDestroyed.bind(this))
|
||||
@__spacePenView.setModel(@model)
|
||||
this
|
||||
|
||||
getModel: -> @model
|
||||
|
||||
activated: ->
|
||||
@focus() unless @hasFocus()
|
||||
@focus()
|
||||
|
||||
activeStatusChanged: (active) ->
|
||||
if active
|
||||
@@ -66,7 +67,7 @@ class PaneElement extends HTMLElement
|
||||
return unless item?
|
||||
|
||||
hasFocus = @hasFocus()
|
||||
itemView = @model.getView(item)
|
||||
itemView = atom.views.getView(item)
|
||||
|
||||
unless @itemViews.contains(itemView)
|
||||
@itemViews.appendChild(itemView)
|
||||
@@ -94,14 +95,14 @@ class PaneElement extends HTMLElement
|
||||
itemView.style.display = 'none'
|
||||
|
||||
itemRemoved: ({item, index, destroyed}) ->
|
||||
if viewToRemove = @model.getView(item)
|
||||
if viewToRemove = atom.views.getView(item)
|
||||
callRemoveHooks(viewToRemove) if destroyed
|
||||
viewToRemove.remove()
|
||||
|
||||
paneDestroyed: ->
|
||||
@subscriptions.dispose()
|
||||
|
||||
getActiveView: -> @model.getView(@model.getActiveItem())
|
||||
getActiveView: -> atom.views.getView(@model.getActiveItem())
|
||||
|
||||
hasFocus: ->
|
||||
this is document.activeElement or @contains(document.activeElement)
|
||||
|
||||
@@ -153,15 +153,15 @@ class PaneView extends View
|
||||
activeItemModifiedChanged: =>
|
||||
@trigger 'pane:active-item-modified-status-changed'
|
||||
|
||||
@::accessor 'activeView', -> @model.getView(@activeItem)?.__spacePenView
|
||||
@::accessor 'activeView', -> atom.views.getView(@activeItem)?.__spacePenView
|
||||
|
||||
splitLeft: (items...) -> @model.getView(@model.splitLeft({items})).__spacePenView
|
||||
splitLeft: (items...) -> atom.views.getView(@model.splitLeft({items})).__spacePenView
|
||||
|
||||
splitRight: (items...) -> @model.getView(@model.splitRight({items})).__spacePenView
|
||||
splitRight: (items...) -> atom.views.getView(@model.splitRight({items})).__spacePenView
|
||||
|
||||
splitUp: (items...) -> @model.getView(@model.splitUp({items})).__spacePenView
|
||||
splitUp: (items...) -> atom.views.getView(@model.splitUp({items})).__spacePenView
|
||||
|
||||
splitDown: (items...) -> @model.getView(@model.splitDown({items})).__spacePenView
|
||||
splitDown: (items...) -> atom.views.getView(@model.splitDown({items})).__spacePenView
|
||||
|
||||
getContainer: -> @closest('atom-pane-container').view()
|
||||
|
||||
|
||||
+5
-4
@@ -53,9 +53,6 @@ class Pane extends Model
|
||||
params.activeItem = find params.items, (item) -> item.getUri?() is activeItemUri
|
||||
params
|
||||
|
||||
getView: (object) ->
|
||||
@container.getView(object)
|
||||
|
||||
getParent: -> @parent
|
||||
|
||||
setParent: (@parent) -> @parent
|
||||
@@ -371,7 +368,7 @@ class Pane extends Model
|
||||
@items.splice(index, 1)
|
||||
@emit 'item-removed', item, index, destroyed
|
||||
@emitter.emit 'did-remove-item', {item, index, destroyed}
|
||||
@container?.paneItemDestroyed(item) if destroyed
|
||||
@container?.didDestroyPaneItem({item, index, pane: this}) if destroyed
|
||||
@destroy() if @items.length is 0 and atom.config.get('core.destroyEmptyPanes')
|
||||
|
||||
# Public: Move the given item to the given index.
|
||||
@@ -405,11 +402,14 @@ class Pane extends Model
|
||||
# If the item is active, the next item will be activated. If the item is the
|
||||
# last item, the pane will be destroyed if the `core.destroyEmptyPanes` config
|
||||
# setting is `true`.
|
||||
#
|
||||
# * `item` Item to destroy
|
||||
destroyItem: (item) ->
|
||||
index = @items.indexOf(item)
|
||||
if index isnt -1
|
||||
@emit 'before-item-destroyed', item
|
||||
@emitter.emit 'will-destroy-item', {item, index}
|
||||
@container?.willDestroyPaneItem({item, index, pane: this})
|
||||
if @promptToSaveItem(item)
|
||||
@removeItem(item, true)
|
||||
item.destroy?()
|
||||
@@ -536,6 +536,7 @@ class Pane extends Model
|
||||
@emitter.emit 'did-destroy'
|
||||
@emitter.dispose()
|
||||
item.destroy?() for item in @items.slice()
|
||||
@container?.didDestroyPane(pane: this)
|
||||
|
||||
###
|
||||
Section: Splitting
|
||||
|
||||
@@ -4,21 +4,27 @@ class PanelContainerElement extends HTMLElement
|
||||
createdCallback: ->
|
||||
@subscriptions = new CompositeDisposable
|
||||
|
||||
getModel: -> @model
|
||||
|
||||
setModel: (@model) ->
|
||||
initialize: (@model) ->
|
||||
@subscriptions.add @model.onDidAddPanel(@panelAdded.bind(this))
|
||||
@subscriptions.add @model.onDidRemovePanel(@panelRemoved.bind(this))
|
||||
@subscriptions.add @model.onDidDestroy(@destroyed.bind(this))
|
||||
@classList.add(@model.getLocation())
|
||||
this
|
||||
|
||||
getModel: -> @model
|
||||
|
||||
panelAdded: ({panel, index}) ->
|
||||
panelElement = panel.getView()
|
||||
panelElement = atom.views.getView(panel)
|
||||
panelElement.classList.add(@model.getLocation())
|
||||
if @model.isModal()
|
||||
panelElement.classList.add("overlay", "from-top")
|
||||
else
|
||||
panelElement.classList.add("tool-panel", "panel-#{@model.getLocation()}")
|
||||
|
||||
if index >= @childNodes.length
|
||||
@appendChild(panelElement)
|
||||
else
|
||||
referenceItem = @childNodes[index + 1]
|
||||
referenceItem = @childNodes[index]
|
||||
@insertBefore(panelElement, referenceItem)
|
||||
|
||||
if @model.isModal()
|
||||
@@ -27,7 +33,7 @@ class PanelContainerElement extends HTMLElement
|
||||
@hideAllPanelsExcept(panel) if visible
|
||||
|
||||
panelRemoved: ({panel, index}) ->
|
||||
@removeChild(panel.getView())
|
||||
@removeChild(atom.views.getView(panel))
|
||||
|
||||
destroyed: ->
|
||||
@subscriptions.dispose()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
module.exports =
|
||||
class PanelContainer
|
||||
constructor: ({@viewRegistry, @location}) ->
|
||||
constructor: ({@location}={}) ->
|
||||
@emitter = new Emitter
|
||||
@subscriptions = new CompositeDisposable
|
||||
@panels = []
|
||||
@@ -30,8 +30,6 @@ class PanelContainer
|
||||
Section: Panels
|
||||
###
|
||||
|
||||
getView: -> @viewRegistry.getView(this)
|
||||
|
||||
getLocation: -> @location
|
||||
|
||||
isModal: -> @location is 'modal'
|
||||
@@ -50,6 +48,11 @@ class PanelContainer
|
||||
@emitter.emit 'did-add-panel', {panel, index}
|
||||
panel
|
||||
|
||||
panelForItem: (item) ->
|
||||
for panel in @panels
|
||||
return panel if panel.getItem() is item
|
||||
null
|
||||
|
||||
panelDestroyed: (panel) ->
|
||||
index = @panels.indexOf(panel)
|
||||
if index > -1
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
{CompositeDisposable} = require 'event-kit'
|
||||
{callAttachHooks} = require './space-pen-extensions'
|
||||
Panel = require './panel'
|
||||
|
||||
class PanelElement extends HTMLElement
|
||||
createdCallback: ->
|
||||
@subscriptions = new CompositeDisposable
|
||||
|
||||
getModel: -> @model
|
||||
|
||||
setModel: (@model) ->
|
||||
view = @model.getItemView()
|
||||
@appendChild(view)
|
||||
callAttachHooks(view) # for backward compatibility with SpacePen views
|
||||
initialize: (@model) ->
|
||||
@appendChild(@getItemView())
|
||||
|
||||
@classList.add(@model.getClassName().split(' ')...) if @model.getClassName()?
|
||||
@subscriptions.add @model.onDidChangeVisible(@visibleChanged.bind(this))
|
||||
@subscriptions.add @model.onDidDestroy(@destroyed.bind(this))
|
||||
this
|
||||
|
||||
getModel: ->
|
||||
@model ?= new Panel
|
||||
|
||||
getItemView: ->
|
||||
atom.views.getView(@getModel().getItem())
|
||||
|
||||
attachedCallback: ->
|
||||
@visibleChanged(@model.isVisible())
|
||||
callAttachHooks(@getItemView()) # for backward compatibility with SpacePen views
|
||||
@visibleChanged(@getModel().isVisible())
|
||||
|
||||
visibleChanged: (visible) ->
|
||||
if visible
|
||||
|
||||
+4
-10
@@ -14,13 +14,14 @@ class Panel
|
||||
Section: Construction and Destruction
|
||||
###
|
||||
|
||||
constructor: ({@viewRegistry, @item, @visible, @priority, @className}) ->
|
||||
constructor: ({@item, @visible, @priority, @className}={}) ->
|
||||
@emitter = new Emitter
|
||||
@visible ?= true
|
||||
@priority ?= 100
|
||||
|
||||
# Public: Destroy and remove this panel from the UI.
|
||||
destroy: ->
|
||||
@hide()
|
||||
@emitter.emit 'did-destroy', this
|
||||
@emitter.dispose()
|
||||
|
||||
@@ -50,15 +51,8 @@ class Panel
|
||||
Section: Panel Details
|
||||
###
|
||||
|
||||
# Public: Gets this panel model's view DOM node.
|
||||
#
|
||||
# Returns an `<atom-panel>` {Element}
|
||||
getView: -> @viewRegistry.getView(this)
|
||||
|
||||
# Public: Gets your panel contents view.
|
||||
#
|
||||
# Returns an {Element} or jQuery element, depeneding on how you created the panel.
|
||||
getItemView: -> @viewRegistry.getView(@item)
|
||||
# Public: Returns the panel's item.
|
||||
getItem: -> @item
|
||||
|
||||
# Public: Returns a {Number} indicating this panel's priority.
|
||||
getPriority: -> @priority
|
||||
|
||||
@@ -64,7 +64,7 @@ class Project extends Model
|
||||
###
|
||||
|
||||
serializeParams: ->
|
||||
path: @path
|
||||
paths: @getPaths()
|
||||
buffers: _.compact(@buffers.map (buffer) -> buffer.serialize() if buffer.isRetained())
|
||||
|
||||
deserializeParams: (params) ->
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
Grim = require 'grim'
|
||||
CSON = require 'season'
|
||||
{CompositeDisposable} = require 'event-kit'
|
||||
|
||||
@@ -11,6 +12,31 @@ class ScopedProperties
|
||||
callback(null, new ScopedProperties(scopedPropertiesPath, scopedProperties))
|
||||
|
||||
constructor: (@path, @scopedProperties) ->
|
||||
for selector, properties of @scopedProperties
|
||||
if properties.editor?.commentStart?
|
||||
properties.editor.comment ?= {}
|
||||
properties.editor.comment.start ?= properties.editor.commentStart
|
||||
delete properties.editor.commentStart
|
||||
Grim.deprecate("The 'editor.commentStart' setting has been moved to 'editor.comment.start'. Please update `#{@path}`.")
|
||||
|
||||
if properties.editor?.commentEnd?
|
||||
properties.editor.comment ?= {}
|
||||
properties.editor.comment.end ?= properties.editor.commentEnd
|
||||
delete properties.editor.commentEnd
|
||||
Grim.deprecate("The 'editor.commentEnd' setting has been moved to 'editor.comment.end'. Please update `#{@path}`.")
|
||||
|
||||
if properties.editor?.increaseIndentPattern?
|
||||
properties.editor.indent ?= {}
|
||||
properties.editor.indent.increasePattern ?= properties.editor.increaseIndentPattern
|
||||
delete properties.editor.increaseIndentPattern
|
||||
Grim.deprecate("The 'editor.increaseIndentPattern' setting has been moved to 'editor.indent.increasePattern'. Please update `#{@path}`.")
|
||||
|
||||
if properties.editor?.decreaseIndentPattern?
|
||||
properties.editor.indent ?= {}
|
||||
properties.editor.indent.decreasePattern ?= properties.editor.decreaseIndentPattern
|
||||
delete properties.editor.decreaseIndentPattern
|
||||
Grim.deprecate("The 'editor.decreaseIndentPattern' setting has been moved to 'editor.indent.decreasePattern'. Please update `#{@path}`.")
|
||||
|
||||
@propertyDisposable = new CompositeDisposable
|
||||
|
||||
activate: ->
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
_ServiceHub = require('service-hub')
|
||||
|
||||
# Experimental: This class facilitates communication between Atom packages
|
||||
# through semantically-versioned services. If you want your package to provide
|
||||
# an API for other packages to interact with, provide or consume a service via
|
||||
# the global instance of this class available as `atom.services`.
|
||||
#
|
||||
# If you're providing an API for other packages, the most straightforward is to
|
||||
# `provide` a module namespaced under your package's name as follows.
|
||||
#
|
||||
# ```coffee
|
||||
# atom.services.provide "status-bar", "1.0.0",
|
||||
# addRightItem: (item) -> # ...
|
||||
# addLeftItem: (item) -> # ...
|
||||
# ```
|
||||
#
|
||||
# Then other packages can interact with your package by consuming the provided
|
||||
# service. Note that a service consumer can provide an npm-style version range
|
||||
# string to express the required API version of the consumed service. The
|
||||
# callback will be invoked with the service immediately or when the service
|
||||
# becomes available. If multiple services match the provided key-path and
|
||||
# version range, the callback will be invoked multiple times.
|
||||
#
|
||||
# ```coffee
|
||||
# atom.services.consume "status-bar", "^1.0.0", (statusBar) ->
|
||||
# statusBar.addLeftItem(new GrammarChanger)
|
||||
# ```
|
||||
#
|
||||
# You can also provide multiple services end-points under the same namespace by
|
||||
# passing a dot-separated key path. In this example, we also provide a global
|
||||
# reference to the status bar's DOM element so other packages can modify it
|
||||
# directly. Doing this via `atom.services` is superior to querying from the DOM
|
||||
# manually because you can use semantic versioning to indicate when the DOM
|
||||
# structure changes in a breaking way.
|
||||
#
|
||||
# ```coffee
|
||||
# atom.services.provide "status-bar.view", "1.0.0", statusBarElement
|
||||
# ```
|
||||
#
|
||||
# By convention, every package owns its package name in the services namespace.
|
||||
# Your package can provide a service under another package's namespace, but you
|
||||
# should always conform to that package's API. If you want to make additions to
|
||||
# the API, add them under your own namespace.
|
||||
#
|
||||
# When upgrading your package's API, consider retaining previous versions with
|
||||
# shims if at all possible to minimize breakage and to give the ecosystem time
|
||||
# to catch up with your changes.
|
||||
#
|
||||
# You can also apply an inverted pattern, where your package consumes services
|
||||
# under its own namespace. In this pattern, you would define a contract for
|
||||
# services that other packages provide and your package consumes. For example,
|
||||
# say we were adding the ability to add custom completion providers to
|
||||
# autocomplete:
|
||||
#
|
||||
# ```coffee
|
||||
# atom.services.consume "autocomplete", "1.0.0", (provider) ->
|
||||
# addCompletionProvider(provider)
|
||||
# ```
|
||||
#
|
||||
# In this use case, you would want to consume a specific version number rather
|
||||
# than a range. You could consume multiple version numbers to provide backward
|
||||
# compatibility.
|
||||
module.exports =
|
||||
class ServiceHub extends _ServiceHub
|
||||
# Experimental: Provide a service by invoking the callback of all current and
|
||||
# future consumers matching the given key path and version range.
|
||||
#
|
||||
# * `keyPath` A {String} of `.` separated keys indicating the services's
|
||||
# location in the namespace of all services.
|
||||
# * `version` A {String} containing a [semantic version](http://semver.org/)
|
||||
# for the service's API.
|
||||
# * `service` An object exposing the service API.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to remove the
|
||||
# provided service.
|
||||
provide: (keyPath, version, service) ->
|
||||
super
|
||||
|
||||
# Experimental: Consume a service by invoking the given callback for all
|
||||
# current and future provided services matching the given key path and version
|
||||
# range.
|
||||
#
|
||||
# * `keyPath` A {String} of `.` separated keys indicating the services's
|
||||
# location in the namespace of all services.
|
||||
# * `versionRange` A {String} containing a [semantic version range](https://www.npmjs.org/doc/misc/semver.html)
|
||||
# that any provided services for the given key path must satisfy.
|
||||
# * `callback` A {Function} to be called with current and future matching
|
||||
# service objects.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to remove the
|
||||
# consumer.
|
||||
consume: (keyPath, versionRange, callback) ->
|
||||
super
|
||||
@@ -12,7 +12,7 @@ jQuery.cleanData = (elements) ->
|
||||
|
||||
SpacePenCallRemoveHooks = SpacePen.callRemoveHooks
|
||||
SpacePen.callRemoveHooks = (element) ->
|
||||
view.unsubscribe() for view in SpacePen.viewsForElement(element)
|
||||
view.unsubscribe?() for view in SpacePen.viewsForElement(element)
|
||||
SpacePenCallRemoveHooks(element)
|
||||
|
||||
NativeEventNames = new Set
|
||||
|
||||
@@ -92,6 +92,7 @@ class StylesElement extends HTMLElement
|
||||
upgradedSelectors = []
|
||||
|
||||
for rule in styleElement.sheet.cssRules
|
||||
continue unless rule.selectorText?
|
||||
continue if /\:host/.test(rule.selectorText)
|
||||
|
||||
inputSelector = rule.selectorText
|
||||
|
||||
@@ -20,9 +20,6 @@ TextEditorComponent = React.createClass
|
||||
displayName: 'TextEditorComponent'
|
||||
mixins: [SubscriberMixin]
|
||||
|
||||
statics:
|
||||
performSyncUpdates: false
|
||||
|
||||
visible: false
|
||||
autoHeight: false
|
||||
backgroundColor: null
|
||||
@@ -242,7 +239,7 @@ TextEditorComponent = React.createClass
|
||||
@updateRequestedWhilePaused = true
|
||||
return
|
||||
|
||||
if @performSyncUpdates ? TextEditorComponent.performSyncUpdates
|
||||
if @props.hostElement.isUpdatedSynchronously()
|
||||
@forceUpdate()
|
||||
else unless @updateRequested
|
||||
@updateRequested = true
|
||||
@@ -363,14 +360,16 @@ TextEditorComponent = React.createClass
|
||||
filteredDecorations = {}
|
||||
for markerId, decorations of decorationsByMarkerId
|
||||
marker = editor.getMarker(markerId)
|
||||
headBufferPosition = marker.getHeadBufferPosition()
|
||||
headScreenPosition = marker.getHeadScreenPosition()
|
||||
tailScreenPosition = marker.getTailScreenPosition()
|
||||
if marker.isValid()
|
||||
for decoration in decorations
|
||||
if decoration.isType('overlay')
|
||||
decorationParams = decoration.getProperties()
|
||||
filteredDecorations[markerId] ?=
|
||||
id: markerId
|
||||
headPixelPosition: editor.pixelPositionForScreenPosition(headBufferPosition)
|
||||
headPixelPosition: editor.pixelPositionForScreenPosition(headScreenPosition)
|
||||
tailPixelPosition: editor.pixelPositionForScreenPosition(tailScreenPosition)
|
||||
decorations: []
|
||||
filteredDecorations[markerId].decorations.push decorationParams
|
||||
filteredDecorations
|
||||
@@ -665,8 +664,13 @@ TextEditorComponent = React.createClass
|
||||
onStylesheetsChanged: (styleElement) ->
|
||||
return unless @performedInitialMeasurement
|
||||
return unless atom.themes.isInitialLoadComplete()
|
||||
@refreshScrollbars() if not styleElement.sheet? or @containsScrollbarSelector(styleElement.sheet)
|
||||
@handleStylingChange()
|
||||
|
||||
# This delay prevents the styling from going haywire when stylesheets are
|
||||
# reloaded in dev mode. It seems like a workaround for a browser bug, but
|
||||
# not totally sure.
|
||||
requestAnimationFrame =>
|
||||
@refreshScrollbars() if not styleElement.sheet? or @containsScrollbarSelector(styleElement.sheet)
|
||||
@handleStylingChange()
|
||||
|
||||
onAllThemesLoaded: ->
|
||||
@refreshScrollbars()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{Emitter} = require 'event-kit'
|
||||
{View, $, callRemoveHooks} = require 'space-pen'
|
||||
React = require 'react-atom-fork'
|
||||
Path = require 'path'
|
||||
@@ -13,11 +14,12 @@ class TextEditorElement extends HTMLElement
|
||||
model: null
|
||||
componentDescriptor: null
|
||||
component: null
|
||||
attached: false
|
||||
lineOverdrawMargin: null
|
||||
focusOnAttach: false
|
||||
|
||||
createdCallback: ->
|
||||
@subscriptions =
|
||||
@emitter = new Emitter
|
||||
@initializeContent()
|
||||
@createSpacePenShim()
|
||||
@addEventListener 'focus', @focused.bind(this)
|
||||
@@ -62,6 +64,14 @@ class TextEditorElement extends HTMLElement
|
||||
@mountComponent() unless @component?.isMounted()
|
||||
@component.checkForVisibilityChange()
|
||||
@focus() if @focusOnAttach
|
||||
@emitter.emit("did-attach")
|
||||
|
||||
detachedCallback: ->
|
||||
@emitter.emit("did-detach")
|
||||
|
||||
initialize: (model) ->
|
||||
@setModel(model)
|
||||
this
|
||||
|
||||
setModel: (model) ->
|
||||
throw new Error("Model already assigned on TextEditorElement") if @model?
|
||||
@@ -71,8 +81,8 @@ class TextEditorElement extends HTMLElement
|
||||
@mountComponent()
|
||||
@addGrammarScopeAttribute()
|
||||
@addMiniAttributeIfNeeded()
|
||||
@model.onDidChangeGrammar => @addGrammarScopeAttribute()
|
||||
@addEncodingAttribute()
|
||||
@model.onDidChangeGrammar => @addGrammarScopeAttribute()
|
||||
@model.onDidChangeEncoding => @addEncodingAttribute()
|
||||
@model.onDidDestroy => @unmountComponent()
|
||||
@__spacePenView.setModel(@model)
|
||||
@@ -83,7 +93,7 @@ class TextEditorElement extends HTMLElement
|
||||
|
||||
buildModel: ->
|
||||
@setModel(new TextEditor(
|
||||
buffer: new TextBuffer
|
||||
buffer: new TextBuffer(@textContent)
|
||||
softWrapped: false
|
||||
tabLength: 2
|
||||
softTabs: true
|
||||
@@ -153,6 +163,28 @@ class TextEditorElement extends HTMLElement
|
||||
hasFocus: ->
|
||||
this is document.activeElement or @contains(document.activeElement)
|
||||
|
||||
setUpdatedSynchronously: (@updatedSynchronously) -> @updatedSynchronously
|
||||
|
||||
isUpdatedSynchronously: -> @updatedSynchronously
|
||||
|
||||
# Extended: get the width of a character of text displayed in this element.
|
||||
#
|
||||
# Returns a {Number} of pixels.
|
||||
getDefaultCharacterWidth: ->
|
||||
@getModel().getDefaultCharWidth()
|
||||
|
||||
# Extended: call the given `callback` when the editor is attached to the DOM.
|
||||
#
|
||||
# * `callback` {Function}
|
||||
onDidAttach: (callback) ->
|
||||
@emitter.on("did-attach", callback)
|
||||
|
||||
# Extended: call the given `callback` when the editor is detached from the DOM.
|
||||
#
|
||||
# * `callback` {Function}
|
||||
onDidDetach: (callback) ->
|
||||
@emitter.on("did-detach", callback)
|
||||
|
||||
stopEventPropagation = (commandListeners) ->
|
||||
newCommandListeners = {}
|
||||
for commandName, commandListener of commandListeners
|
||||
@@ -176,28 +208,14 @@ stopEventPropagationAndGroupUndo = (commandListeners) ->
|
||||
atom.commands.add 'atom-text-editor', stopEventPropagation(
|
||||
'core:undo': -> @undo()
|
||||
'core:redo': -> @redo()
|
||||
)
|
||||
|
||||
atom.commands.add 'atom-text-editor', stopEventPropagationAndGroupUndo(
|
||||
'core:move-left': -> @moveLeft()
|
||||
'core:move-right': -> @moveRight()
|
||||
'core:select-left': -> @selectLeft()
|
||||
'core:select-right': -> @selectRight()
|
||||
'core:select-all': -> @selectAll()
|
||||
'core:backspace': -> @backspace()
|
||||
'core:delete': -> @delete()
|
||||
'core:cut': -> @cutSelectedText()
|
||||
'core:copy': -> @copySelectedText()
|
||||
'core:paste': -> @pasteText()
|
||||
'editor:move-to-previous-word': -> @moveToPreviousWord()
|
||||
'editor:select-word': -> @selectWordsContainingCursors()
|
||||
'editor:consolidate-selections': (event) -> event.abortKeyBinding() unless @consolidateSelections()
|
||||
'editor:delete-to-beginning-of-word': -> @deleteToBeginningOfWord()
|
||||
'editor:delete-to-beginning-of-line': -> @deleteToBeginningOfLine()
|
||||
'editor:delete-to-end-of-line': -> @deleteToEndOfLine()
|
||||
'editor:delete-to-end-of-word': -> @deleteToEndOfWord()
|
||||
'editor:delete-line': -> @deleteLine()
|
||||
'editor:cut-to-end-of-line': -> @cutToEndOfLine()
|
||||
'editor:move-to-beginning-of-next-paragraph': -> @moveToBeginningOfNextParagraph()
|
||||
'editor:move-to-beginning-of-previous-paragraph': -> @moveToBeginningOfPreviousParagraph()
|
||||
'editor:move-to-beginning-of-screen-line': -> @moveToBeginningOfScreenLine()
|
||||
@@ -221,12 +239,26 @@ atom.commands.add 'atom-text-editor', stopEventPropagationAndGroupUndo(
|
||||
'editor:select-to-previous-word-boundary': -> @selectToPreviousWordBoundary()
|
||||
'editor:select-to-first-character-of-line': -> @selectToFirstCharacterOfLine()
|
||||
'editor:select-line': -> @selectLinesContainingCursors()
|
||||
)
|
||||
|
||||
atom.commands.add 'atom-text-editor', stopEventPropagationAndGroupUndo(
|
||||
'core:backspace': -> @backspace()
|
||||
'core:delete': -> @delete()
|
||||
'core:cut': -> @cutSelectedText()
|
||||
'core:copy': -> @copySelectedText()
|
||||
'core:paste': -> @pasteText()
|
||||
'editor:delete-to-beginning-of-word': -> @deleteToBeginningOfWord()
|
||||
'editor:delete-to-beginning-of-line': -> @deleteToBeginningOfLine()
|
||||
'editor:delete-to-end-of-line': -> @deleteToEndOfLine()
|
||||
'editor:delete-to-end-of-word': -> @deleteToEndOfWord()
|
||||
'editor:delete-line': -> @deleteLine()
|
||||
'editor:cut-to-end-of-line': -> @cutToEndOfLine()
|
||||
'editor:transpose': -> @transpose()
|
||||
'editor:upper-case': -> @upperCase()
|
||||
'editor:lower-case': -> @lowerCase()
|
||||
)
|
||||
|
||||
atom.commands.add 'atom-text-editor:not([mini])', stopEventPropagationAndGroupUndo(
|
||||
atom.commands.add 'atom-text-editor:not([mini])', stopEventPropagation(
|
||||
'core:move-up': -> @moveUp()
|
||||
'core:move-down': -> @moveDown()
|
||||
'core:move-to-top': -> @moveToTop()
|
||||
@@ -239,13 +271,6 @@ atom.commands.add 'atom-text-editor:not([mini])', stopEventPropagationAndGroupUn
|
||||
'core:select-to-bottom': -> @selectToBottom()
|
||||
'core:select-page-up': -> @selectPageUp()
|
||||
'core:select-page-down': -> @selectPageDown()
|
||||
'editor:indent': -> @indent()
|
||||
'editor:auto-indent': -> @autoIndentSelectedRows()
|
||||
'editor:indent-selected-rows': -> @indentSelectedRows()
|
||||
'editor:outdent-selected-rows': -> @outdentSelectedRows()
|
||||
'editor:newline': -> @insertNewline()
|
||||
'editor:newline-below': -> @insertNewlineBelow()
|
||||
'editor:newline-above': -> @insertNewlineAbove()
|
||||
'editor:add-selection-below': -> @addSelectionBelow()
|
||||
'editor:add-selection-above': -> @addSelectionAbove()
|
||||
'editor:split-selections-into-lines': -> @splitSelectionsIntoLines()
|
||||
@@ -265,17 +290,27 @@ atom.commands.add 'atom-text-editor:not([mini])', stopEventPropagationAndGroupUn
|
||||
'editor:fold-at-indent-level-7': -> @foldAllAtIndentLevel(6)
|
||||
'editor:fold-at-indent-level-8': -> @foldAllAtIndentLevel(7)
|
||||
'editor:fold-at-indent-level-9': -> @foldAllAtIndentLevel(8)
|
||||
'editor:toggle-line-comments': -> @toggleLineCommentsInSelection()
|
||||
'editor:log-cursor-scope': -> @logCursorScope()
|
||||
'editor:checkout-head-revision': -> atom.project.getRepositories()[0]?.checkoutHeadForEditor(this)
|
||||
'editor:copy-path': -> @copyPathToClipboard()
|
||||
'editor:move-line-up': -> @moveLineUp()
|
||||
'editor:move-line-down': -> @moveLineDown()
|
||||
'editor:duplicate-lines': -> @duplicateLines()
|
||||
'editor:join-lines': -> @joinLines()
|
||||
'editor:toggle-indent-guide': -> atom.config.set('editor.showIndentGuide', not atom.config.get('editor.showIndentGuide'))
|
||||
'editor:toggle-line-numbers': -> atom.config.set('editor.showLineNumbers', not atom.config.get('editor.showLineNumbers'))
|
||||
'editor:scroll-to-cursor': -> @scrollToCursorPosition()
|
||||
)
|
||||
|
||||
atom.commands.add 'atom-text-editor:not([mini])', stopEventPropagationAndGroupUndo(
|
||||
'editor:indent': -> @indent()
|
||||
'editor:auto-indent': -> @autoIndentSelectedRows()
|
||||
'editor:indent-selected-rows': -> @indentSelectedRows()
|
||||
'editor:outdent-selected-rows': -> @outdentSelectedRows()
|
||||
'editor:newline': -> @insertNewline()
|
||||
'editor:newline-below': -> @insertNewlineBelow()
|
||||
'editor:newline-above': -> @insertNewlineAbove()
|
||||
'editor:toggle-line-comments': -> @toggleLineCommentsInSelection()
|
||||
'editor:checkout-head-revision': -> atom.project.getRepositories()[0]?.checkoutHeadForEditor(this)
|
||||
'editor:move-line-up': -> @moveLineUp()
|
||||
'editor:move-line-down': -> @moveLineDown()
|
||||
'editor:duplicate-lines': -> @duplicateLines()
|
||||
'editor:join-lines': -> @joinLines()
|
||||
)
|
||||
|
||||
module.exports = TextEditorElement = document.registerElement 'atom-text-editor', prototype: TextEditorElement.prototype
|
||||
|
||||
@@ -1263,18 +1263,33 @@ class TextEditor extends Model
|
||||
# ## Arguments
|
||||
#
|
||||
# * `marker` A {Marker} you want this decoration to follow.
|
||||
# * `decorationParams` An {Object} representing the decoration e.g. `{type: 'gutter', class: 'linter-error'}`
|
||||
# * `type` There are a few supported decoration types: `gutter`, `line`, and `highlight`
|
||||
# * `decorationParams` An {Object} representing the decoration e.g.
|
||||
# `{type: 'gutter', class: 'linter-error'}`
|
||||
# * `type` There are a few supported decoration types: `gutter`, `line`,
|
||||
# `highlight`, and `overlay`. The behavior of the types are as follows:
|
||||
# * `gutter` Adds the given `class` to the line numbers overlapping the
|
||||
# rows spanned by the marker.
|
||||
# * `line` Adds the given `class` to the lines overlapping the rows
|
||||
# spanned by the marker.
|
||||
# * `highlight` Creates a `.highlight` div with the nested class with up
|
||||
# to 3 nested regions that fill the area spanned by the marker.
|
||||
# * `overlay` Positions the view associated with the given item at the
|
||||
# head or tail of the given marker, depending on the `position`
|
||||
# property.
|
||||
# * `class` This CSS class will be applied to the decorated line number,
|
||||
# line, or highlight.
|
||||
# * `onlyHead` (optional) If `true`, the decoration will only be applied to the head
|
||||
# of the marker. Only applicable to the `line` and `gutter` types.
|
||||
# * `onlyEmpty` (optional) If `true`, the decoration will only be applied if the
|
||||
# associated marker is empty. Only applicable to the `line` and
|
||||
# * `onlyHead` (optional) If `true`, the decoration will only be applied to
|
||||
# the head of the marker. Only applicable to the `line` and `gutter`
|
||||
# types.
|
||||
# * `onlyEmpty` (optional) If `true`, the decoration will only be applied if
|
||||
# the associated marker is empty. Only applicable to the `line` and
|
||||
# `gutter` types.
|
||||
# * `onlyNonEmpty` (optional) If `true`, the decoration will only be applied if the
|
||||
# associated marker is non-empty. Only applicable to the `line` and
|
||||
# gutter types.
|
||||
# * `onlyNonEmpty` (optional) If `true`, the decoration will only be applied
|
||||
# if the associated marker is non-empty. Only applicable to the `line`
|
||||
# and gutter types.
|
||||
# * `position` (optional) Only applicable to decorations of type `overlay`,
|
||||
# controls where the overlay view is positioned relative to the marker.
|
||||
# Values can be `'head'` (the default), or `'tail'`.
|
||||
#
|
||||
# Returns a {Decoration} object
|
||||
decorateMarker: (marker, decorationParams) ->
|
||||
@@ -1293,6 +1308,51 @@ class TextEditor extends Model
|
||||
decorationsForScreenRowRange: (startScreenRow, endScreenRow) ->
|
||||
@displayBuffer.decorationsForScreenRowRange(startScreenRow, endScreenRow)
|
||||
|
||||
# Extended: Get all decorations.
|
||||
#
|
||||
# * `propertyFilter` (optional) An {Object} containing key value pairs that
|
||||
# the returned decorations' properties must match.
|
||||
#
|
||||
# Returns an {Array} of {Decoration}s.
|
||||
getDecorations: (propertyFilter) ->
|
||||
@displayBuffer.getDecorations(propertyFilter)
|
||||
|
||||
# Extended: Get all decorations of type 'line'.
|
||||
#
|
||||
# * `propertyFilter` (optional) An {Object} containing key value pairs that
|
||||
# the returned decorations' properties must match.
|
||||
#
|
||||
# Returns an {Array} of {Decoration}s.
|
||||
getLineDecorations: (propertyFilter) ->
|
||||
@displayBuffer.getLineDecorations(propertyFilter)
|
||||
|
||||
# Extended: Get all decorations of type 'gutter'.
|
||||
#
|
||||
# * `propertyFilter` (optional) An {Object} containing key value pairs that
|
||||
# the returned decorations' properties must match.
|
||||
#
|
||||
# Returns an {Array} of {Decoration}s.
|
||||
getGutterDecorations: (propertyFilter) ->
|
||||
@displayBuffer.getGutterDecorations(propertyFilter)
|
||||
|
||||
# Extended: Get all decorations of type 'highlight'.
|
||||
#
|
||||
# * `propertyFilter` (optional) An {Object} containing key value pairs that
|
||||
# the returned decorations' properties must match.
|
||||
#
|
||||
# Returns an {Array} of {Decoration}s.
|
||||
getHighlightDecorations: (propertyFilter) ->
|
||||
@displayBuffer.getHighlightDecorations(propertyFilter)
|
||||
|
||||
# Extended: Get all decorations of type 'overlay'.
|
||||
#
|
||||
# * `propertyFilter` (optional) An {Object} containing key value pairs that
|
||||
# the returned decorations' properties must match.
|
||||
#
|
||||
# Returns an {Array} of {Decoration}s.
|
||||
getOverlayDecorations: (propertyFilter) ->
|
||||
@displayBuffer.getOverlayDecorations(propertyFilter)
|
||||
|
||||
decorationForId: (id) ->
|
||||
@displayBuffer.decorationForId(id)
|
||||
|
||||
|
||||
@@ -3,6 +3,46 @@ _ = require 'underscore-plus'
|
||||
{$} = require './space-pen-extensions'
|
||||
|
||||
# Essential: Associates tooltips with HTML elements or selectors.
|
||||
#
|
||||
# You can get the `TooltipManager` via `atom.tooltips`.
|
||||
#
|
||||
# ## Examples
|
||||
#
|
||||
# The essence of displaying a tooltip
|
||||
#
|
||||
# ```coffee
|
||||
# # display it
|
||||
# disposable = atom.tooltips.add(div, {title: 'This is a tooltip'})
|
||||
#
|
||||
# # remove it
|
||||
# disposable.dispose()
|
||||
# ```
|
||||
#
|
||||
# In practice there are usually multiple tooltips. So we add them to a
|
||||
# CompositeDisposable
|
||||
#
|
||||
# ```coffee
|
||||
# {CompositeDisposable} = require 'atom'
|
||||
# subscriptions = new CompositeDisposable
|
||||
#
|
||||
# div1 = document.createElement('div')
|
||||
# div2 = document.createElement('div')
|
||||
# subscriptions.add atom.tooltips.add(div1, {title: 'This is a tooltip'})
|
||||
# subscriptions.add atom.tooltips.add(div2, {title: 'Another tooltip'})
|
||||
#
|
||||
# # remove them all
|
||||
# subscriptions.dispose()
|
||||
# ```
|
||||
#
|
||||
# You can display a key binding in the tooltip as well with the
|
||||
# `keyBindingCommand` option.
|
||||
#
|
||||
# ```coffee
|
||||
# disposable = atom.tooltips.add @caseOptionButton,
|
||||
# title: "Match Case"
|
||||
# keyBindingCommand: 'find-and-replace:toggle-case-option'
|
||||
# keyBindingTarget: @findEditor.element
|
||||
# ```
|
||||
module.exports =
|
||||
class TooltipManager
|
||||
defaults:
|
||||
@@ -36,15 +76,20 @@ class TooltipManager
|
||||
|
||||
if keyBindingCommand?
|
||||
bindings = atom.keymaps.findKeyBindings(command: keyBindingCommand, target: keyBindingTarget)
|
||||
if options.title?
|
||||
keystroke = getKeystroke(bindings)
|
||||
if options.title? and keystroke?
|
||||
options.title += " " + getKeystroke(bindings)
|
||||
else
|
||||
else if keystroke?
|
||||
options.title = getKeystroke(bindings)
|
||||
|
||||
$target = $(target)
|
||||
$target.tooltip(_.defaults(options, @defaults))
|
||||
|
||||
new Disposable -> $target.tooltip('destroy')
|
||||
new Disposable ->
|
||||
tooltip = $target.data('bs.tooltip')
|
||||
tooltip.leave(currentTarget: target)
|
||||
tooltip.hide()
|
||||
$target.tooltip('destroy')
|
||||
|
||||
humanizeKeystrokes = (keystroke) ->
|
||||
keystrokes = keystroke.split(' ')
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
Grim = require 'grim'
|
||||
{Disposable} = require 'event-kit'
|
||||
|
||||
# Essential: `ViewRegistry` handles the association between model and view
|
||||
@@ -10,7 +11,7 @@
|
||||
# application logic and is the primary point of API interaction. The view
|
||||
# just handles presentation.
|
||||
#
|
||||
# View providers to inform the workspace how your model objects should be
|
||||
# View providers inform the workspace how your model objects should be
|
||||
# presented in the DOM. A view provider must always return a DOM node, which
|
||||
# makes [HTML 5 custom elements](http://www.html5rocks.com/en/tutorials/webcomponents/customelements/)
|
||||
# an ideal tool for implementing views in Atom.
|
||||
@@ -76,10 +77,16 @@ class ViewRegistry
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to remove the
|
||||
# added provider.
|
||||
addViewProvider: (providerSpec) ->
|
||||
@providers.push(providerSpec)
|
||||
addViewProvider: (modelConstructor, createView) ->
|
||||
if arguments.length is 1
|
||||
Grim.deprecate("atom.views.addViewProvider now takes 2 arguments: a model constructor and a createView function. See docs for details.")
|
||||
provider = modelConstructor
|
||||
else
|
||||
provider = {modelConstructor, createView}
|
||||
|
||||
@providers.push(provider)
|
||||
new Disposable =>
|
||||
@providers = @providers.filter (provider) -> provider isnt providerSpec
|
||||
@providers = @providers.filter (p) -> p isnt provider
|
||||
|
||||
# Essential: Get the view associated with an object in the workspace.
|
||||
#
|
||||
@@ -131,7 +138,7 @@ class ViewRegistry
|
||||
element = provider.createView?(object)
|
||||
unless element?
|
||||
element = new provider.viewConstructor
|
||||
element.setModel(object)
|
||||
element.initialize?(object) ? element.setModel?(object)
|
||||
element
|
||||
else if viewConstructor = object?.getViewClass?()
|
||||
view = new viewConstructor(object)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
path = require 'path'
|
||||
{$} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
{Disposable} = require 'event-kit'
|
||||
ipc = require 'ipc'
|
||||
shell = require 'shell'
|
||||
{Subscriber} = require 'emissary'
|
||||
@@ -14,8 +15,28 @@ class WindowEventHandler
|
||||
constructor: ->
|
||||
@reloadRequested = false
|
||||
|
||||
@subscribe ipc, 'command', (command, args...) ->
|
||||
@subscribe ipc, 'message', (message, detail) ->
|
||||
switch message
|
||||
when 'open-path'
|
||||
{pathToOpen, initialLine, initialColumn} = detail
|
||||
|
||||
unless atom.project?.getPaths().length
|
||||
if fs.existsSync(pathToOpen) or fs.existsSync(path.dirname(pathToOpen))
|
||||
atom.project?.setPaths([pathToOpen])
|
||||
|
||||
unless fs.isDirectorySync(pathToOpen)
|
||||
atom.workspace?.open(pathToOpen, {initialLine, initialColumn})
|
||||
|
||||
when 'update-available'
|
||||
atom.updateAvailable(detail)
|
||||
|
||||
# FIXME: Remove this when deprecations are removed
|
||||
{releaseVersion, releaseNotes} = detail
|
||||
detail = [releaseVersion, releaseNotes]
|
||||
if workspaceElement = atom.views.getView(atom.workspace)
|
||||
atom.commands.dispatch workspaceElement, "window:update-available", detail
|
||||
|
||||
@subscribe ipc, 'command', (command, args...) ->
|
||||
activeElement = document.activeElement
|
||||
# Use the workspace element view if body has focus
|
||||
if activeElement is document.body and workspaceElement = atom.views.getView(atom.workspace)
|
||||
@@ -30,14 +51,6 @@ class WindowEventHandler
|
||||
|
||||
@subscribe $(window), 'blur', -> document.body.classList.add('is-blurred')
|
||||
|
||||
@subscribeToCommand $(window), 'window:open-path', (event, {pathToOpen, initialLine, initialColumn}) ->
|
||||
unless atom.project?.getPath()
|
||||
if fs.existsSync(pathToOpen) or fs.existsSync(path.dirname(pathToOpen))
|
||||
atom.project?.setPath(pathToOpen)
|
||||
|
||||
unless fs.isDirectorySync(pathToOpen)
|
||||
atom.workspace?.open(pathToOpen, {initialLine, initialColumn})
|
||||
|
||||
@subscribe $(window), 'beforeunload', =>
|
||||
confirmed = atom.workspace?.confirmClose()
|
||||
atom.hide() if confirmed and not @reloadRequested and atom.getCurrentWindow().isWebViewFocused()
|
||||
@@ -73,15 +86,13 @@ class WindowEventHandler
|
||||
|
||||
document.addEventListener 'keydown', @onKeydown
|
||||
|
||||
@subscribe $(document), 'drop', (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
pathsToOpen = _.pluck(e.originalEvent.dataTransfer.files, 'path')
|
||||
atom.open({pathsToOpen}) if pathsToOpen.length > 0
|
||||
document.addEventListener 'drop', @onDrop
|
||||
@subscribe new Disposable =>
|
||||
document.removeEventListener('drop', @onDrop)
|
||||
|
||||
@subscribe $(document), 'dragover', (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
document.addEventListener 'dragover', @onDragOver
|
||||
@subscribe new Disposable =>
|
||||
document.removeEventListener('dragover', @onKeydown)
|
||||
|
||||
@subscribe $(document), 'click', 'a', @openLink
|
||||
|
||||
@@ -112,6 +123,16 @@ class WindowEventHandler
|
||||
atom.keymaps.handleKeyboardEvent(event)
|
||||
event.stopImmediatePropagation()
|
||||
|
||||
onDrop: (event) ->
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
pathsToOpen = _.pluck(event.dataTransfer.files, 'path')
|
||||
atom.open({pathsToOpen}) if pathsToOpen.length > 0
|
||||
|
||||
onDragOver: (event) ->
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
|
||||
openLink: ({target, currentTarget}) ->
|
||||
location = target?.getAttribute('href') or currentTarget?.getAttribute('href')
|
||||
if location and location[0] isnt '#' and /^https?:\/\//.test(location)
|
||||
|
||||
@@ -62,19 +62,17 @@ class WorkspaceElement extends HTMLElement
|
||||
WorkspaceView ?= require './workspace-view'
|
||||
@__spacePenView = new WorkspaceView(this)
|
||||
|
||||
getModel: -> @model
|
||||
|
||||
setModel: (@model) ->
|
||||
initialize: (@model) ->
|
||||
@paneContainer = atom.views.getView(@model.paneContainer)
|
||||
@verticalAxis.appendChild(@paneContainer)
|
||||
@addEventListener 'focus', @handleFocus.bind(this)
|
||||
|
||||
@panelContainers =
|
||||
top: @model.panelContainers.top.getView()
|
||||
left: @model.panelContainers.left.getView()
|
||||
right: @model.panelContainers.right.getView()
|
||||
bottom: @model.panelContainers.bottom.getView()
|
||||
modal: @model.panelContainers.modal.getView()
|
||||
top: atom.views.getView(@model.panelContainers.top)
|
||||
left: atom.views.getView(@model.panelContainers.left)
|
||||
right: atom.views.getView(@model.panelContainers.right)
|
||||
bottom: atom.views.getView(@model.panelContainers.bottom)
|
||||
modal: atom.views.getView(@model.panelContainers.modal)
|
||||
|
||||
@horizontalAxis.insertBefore(@panelContainers.left, @verticalAxis)
|
||||
@horizontalAxis.appendChild(@panelContainers.right)
|
||||
@@ -85,6 +83,9 @@ class WorkspaceElement extends HTMLElement
|
||||
@appendChild(@panelContainers.modal)
|
||||
|
||||
@__spacePenView.setModel(@model)
|
||||
this
|
||||
|
||||
getModel: -> @model
|
||||
|
||||
setTextEditorFontSize: (fontSize) ->
|
||||
@updateGlobalEditorStyle('font-size', fontSize + 'px')
|
||||
@@ -149,7 +150,7 @@ atom.commands.add 'atom-workspace',
|
||||
'window:focus-pane-on-right': -> @focusPaneViewOnRight()
|
||||
'window:save-all': -> @getModel().saveAll()
|
||||
'window:toggle-invisibles': -> atom.config.toggle("editor.showInvisibles")
|
||||
'window:log-deprecation-warnings': -> Grim.logDeprecationWarnings()
|
||||
'window:log-deprecation-warnings': -> Grim.logDeprecations()
|
||||
'window:toggle-auto-indent': -> atom.config.toggle("editor.autoIndent")
|
||||
'pane:reopen-closed-item': -> @getModel().reopenItem()
|
||||
'core:close': -> @getModel().destroyActivePaneItemOrEmptyPane()
|
||||
|
||||
+117
-41
@@ -4,7 +4,6 @@ _ = require 'underscore-plus'
|
||||
{Model} = require 'theorist'
|
||||
Q = require 'q'
|
||||
Serializable = require 'serializable'
|
||||
Delegator = require 'delegato'
|
||||
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
|
||||
Grim = require 'grim'
|
||||
TextEditor = require './text-editor'
|
||||
@@ -14,7 +13,6 @@ Panel = require './panel'
|
||||
PanelElement = require './panel-element'
|
||||
PanelContainer = require './panel-container'
|
||||
PanelContainerElement = require './panel-container-element'
|
||||
ViewRegistry = require './view-registry'
|
||||
WorkspaceElement = require './workspace-element'
|
||||
|
||||
# Essential: Represents the state of the user interface for the entire window.
|
||||
@@ -31,10 +29,17 @@ class Workspace extends Model
|
||||
atom.deserializers.add(this)
|
||||
Serializable.includeInto(this)
|
||||
|
||||
@delegatesProperty 'activePane', 'activePaneItem', toProperty: 'paneContainer'
|
||||
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
|
||||
viewRegistry: null
|
||||
paneContainer: null
|
||||
fullScreen: false
|
||||
destroyedItemUris: -> []
|
||||
@@ -45,16 +50,15 @@ class Workspace extends Model
|
||||
@emitter = new Emitter
|
||||
@openers = []
|
||||
|
||||
viewRegistry = atom.views
|
||||
@paneContainer ?= new PaneContainer({viewRegistry})
|
||||
@paneContainer.onDidDestroyPaneItem(@onPaneItemDestroyed)
|
||||
@paneContainer ?= new PaneContainer()
|
||||
@paneContainer.onDidDestroyPaneItem(@didDestroyPaneItem)
|
||||
|
||||
@panelContainers =
|
||||
top: new PanelContainer({viewRegistry, location: 'top'})
|
||||
left: new PanelContainer({viewRegistry, location: 'left'})
|
||||
right: new PanelContainer({viewRegistry, location: 'right'})
|
||||
bottom: new PanelContainer({viewRegistry, location: 'bottom'})
|
||||
modal: new PanelContainer({viewRegistry, location: 'modal'})
|
||||
top: new PanelContainer({location: 'top'})
|
||||
left: new PanelContainer({location: 'left'})
|
||||
right: new PanelContainer({location: 'right'})
|
||||
bottom: new PanelContainer({location: 'bottom'})
|
||||
modal: new PanelContainer({location: 'modal'})
|
||||
|
||||
@subscribeToActiveItem()
|
||||
|
||||
@@ -69,24 +73,20 @@ class Workspace extends Model
|
||||
when 'atom://.atom/init-script'
|
||||
@open(atom.getUserInitScriptPath())
|
||||
|
||||
atom.views.addViewProvider
|
||||
modelConstructor: Workspace
|
||||
viewConstructor: WorkspaceElement
|
||||
atom.views.addViewProvider Workspace, (model) ->
|
||||
new WorkspaceElement().initialize(model)
|
||||
|
||||
atom.views.addViewProvider
|
||||
modelConstructor: PanelContainer
|
||||
viewConstructor: PanelContainerElement
|
||||
atom.views.addViewProvider PanelContainer, (model) ->
|
||||
new PanelContainerElement().initialize(model)
|
||||
|
||||
atom.views.addViewProvider
|
||||
modelConstructor: Panel
|
||||
viewConstructor: PanelElement
|
||||
atom.views.addViewProvider Panel, (model) ->
|
||||
new PanelElement().initialize(model)
|
||||
|
||||
# Called by the Serializable mixin during deserialization
|
||||
deserializeParams: (params) ->
|
||||
for packageName in params.packagesWithActiveGrammars ? []
|
||||
atom.packages.getLoadedPackage(packageName)?.loadGrammarsSync()
|
||||
|
||||
params.paneContainer.viewRegistry = atom.views
|
||||
params.paneContainer = PaneContainer.deserialize(params.paneContainer)
|
||||
params
|
||||
|
||||
@@ -240,6 +240,16 @@ class Workspace extends Model
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onDidAddPane: (callback) -> @paneContainer.onDidAddPane(callback)
|
||||
|
||||
# Extended: Invoke the given callback when a pane is destroyed in the
|
||||
# workspace.
|
||||
#
|
||||
# * `callback` {Function} to be called panes are destroyed.
|
||||
# * `event` {Object} with the following keys:
|
||||
# * `pane` The destroyed pane.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onDidDestroyPane: (callback) -> @paneContainer.onDidDestroyPane(callback)
|
||||
|
||||
# Extended: Invoke the given callback with all current and future panes in the
|
||||
# workspace.
|
||||
#
|
||||
@@ -271,7 +281,7 @@ class Workspace extends Model
|
||||
# Extended: Invoke the given callback when a pane item is added to the
|
||||
# workspace.
|
||||
#
|
||||
# * `callback` {Function} to be called when panes are added.
|
||||
# * `callback` {Function} to be called when pane items are added.
|
||||
# * `event` {Object} with the following keys:
|
||||
# * `item` The added pane item.
|
||||
# * `pane` {Pane} containing the added item.
|
||||
@@ -280,6 +290,31 @@ class Workspace extends Model
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onDidAddPaneItem: (callback) -> @paneContainer.onDidAddPaneItem(callback)
|
||||
|
||||
# Extended: Invoke the given callback when a pane item is about to be
|
||||
# destroyed, before the user is prompted to save it.
|
||||
#
|
||||
# * `callback` {Function} to be called before pane items are destroyed.
|
||||
# * `event` {Object} with the following keys:
|
||||
# * `item` The item to be destroyed.
|
||||
# * `pane` {Pane} containing the item to be destroyed.
|
||||
# * `index` {Number} indicating the index of the item to be destroyed in
|
||||
# its pane.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose` can be called to unsubscribe.
|
||||
onWillDestroyPaneItem: (callback) -> @paneContainer.onWillDestroyPaneItem(callback)
|
||||
|
||||
# Extended: Invoke the given callback when a pane item is destroyed.
|
||||
#
|
||||
# * `callback` {Function} to be called when pane items are destroyed.
|
||||
# * `event` {Object} with the following keys:
|
||||
# * `item` The destroyed item.
|
||||
# * `pane` {Pane} containing the destroyed item.
|
||||
# * `index` {Number} indicating the index of the destroyed item in its
|
||||
# pane.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose` can be called to unsubscribe.
|
||||
onDidDestroyPaneItem: (callback) -> @paneContainer.onDidDestroyPaneItem(callback)
|
||||
|
||||
# Extended: Invoke the given callback when a text editor is added to the
|
||||
# workspace.
|
||||
#
|
||||
@@ -377,25 +412,35 @@ class Workspace extends Model
|
||||
# * `activatePane` A {Boolean} indicating whether to call {Pane::activate} on
|
||||
# the containing pane. Defaults to `true`.
|
||||
openSync: (uri='', options={}) ->
|
||||
deprecate("Don't use the `changeFocus` option") if options.changeFocus?
|
||||
# TODO: Remove deprecated changeFocus option
|
||||
if options.changeFocus?
|
||||
deprecate("The `changeFocus` option has been renamed to `activatePane`")
|
||||
options.activatePane = options.changeFocus
|
||||
delete options.changeFocus
|
||||
|
||||
{initialLine, initialColumn} = options
|
||||
# TODO: Remove deprecated changeFocus option
|
||||
activatePane = options.activatePane ? options.changeFocus ? true
|
||||
activatePane = options.activatePane ? true
|
||||
|
||||
uri = atom.project.resolve(uri)
|
||||
|
||||
item = @activePane.itemForUri(uri)
|
||||
item = @getActivePane().itemForUri(uri)
|
||||
if uri
|
||||
item ?= opener(uri, options) for opener in @getOpeners() when !item
|
||||
item ?= atom.project.openSync(uri, {initialLine, initialColumn})
|
||||
|
||||
@activePane.activateItem(item)
|
||||
@getActivePane().activateItem(item)
|
||||
@itemOpened(item)
|
||||
@activePane.activate() if activatePane
|
||||
@getActivePane().activate() if activatePane
|
||||
item
|
||||
|
||||
openUriInPane: (uri, pane, options={}) ->
|
||||
changeFocus = options.changeFocus ? true
|
||||
# TODO: Remove deprecated changeFocus option
|
||||
if options.changeFocus?
|
||||
deprecate("The `changeFocus` option has been renamed to `activatePane`")
|
||||
options.activatePane = options.changeFocus
|
||||
delete options.changeFocus
|
||||
|
||||
activatePane = options.activatePane ? true
|
||||
|
||||
if uri?
|
||||
item = pane.itemForUri(uri)
|
||||
@@ -409,7 +454,7 @@ class Workspace extends Model
|
||||
@paneContainer.root = pane
|
||||
@itemOpened(item)
|
||||
pane.activateItem(item)
|
||||
pane.activate() if changeFocus
|
||||
pane.activate() if activatePane
|
||||
index = pane.getActiveItemIndex()
|
||||
@emit "uri-opened"
|
||||
@emitter.emit 'did-open', {uri, pane, item, index}
|
||||
@@ -493,9 +538,10 @@ class Workspace extends Model
|
||||
activeItem = @getActivePaneItem()
|
||||
activeItem if activeItem instanceof TextEditor
|
||||
|
||||
# Deprecated:
|
||||
# Deprecated
|
||||
getActiveEditor: ->
|
||||
@activePane?.getActiveEditor()
|
||||
Grim.deprecate "Call ::getActiveTextEditor instead"
|
||||
@getActivePane()?.getActiveEditor()
|
||||
|
||||
# Save all pane items.
|
||||
saveAll: ->
|
||||
@@ -511,7 +557,7 @@ class Workspace extends Model
|
||||
# {::saveActivePaneItemAs} # will be called instead. This method does nothing
|
||||
# if the active item does not implement a `.save` method.
|
||||
saveActivePaneItem: ->
|
||||
@activePane?.saveActiveItem()
|
||||
@getActivePane().saveActiveItem()
|
||||
|
||||
# Prompt the user for a path and save the active pane item to it.
|
||||
#
|
||||
@@ -519,14 +565,14 @@ class Workspace extends Model
|
||||
# `.saveAs` on the item with the selected path. This method does nothing if
|
||||
# the active item does not implement a `.saveAs` method.
|
||||
saveActivePaneItemAs: ->
|
||||
@activePane?.saveActiveItemAs()
|
||||
@getActivePane().saveActiveItemAs()
|
||||
|
||||
# Destroy (close) the active pane item.
|
||||
#
|
||||
# Removes the active pane item and calls the `.destroy` method on it if one is
|
||||
# defined.
|
||||
destroyActivePaneItem: ->
|
||||
@activePane?.destroyActiveItem()
|
||||
@getActivePane().destroyActiveItem()
|
||||
|
||||
###
|
||||
Section: Panes
|
||||
@@ -570,7 +616,7 @@ class Workspace extends Model
|
||||
|
||||
# Destroy (close) the active pane.
|
||||
destroyActivePane: ->
|
||||
@activePane?.destroy()
|
||||
@getActivePane()?.destroy()
|
||||
|
||||
# Destroy the active pane item or the active pane if it is empty.
|
||||
destroyActivePaneItemOrEmptyPane: ->
|
||||
@@ -595,7 +641,7 @@ class Workspace extends Model
|
||||
_.remove(@destroyedItemUris, uri)
|
||||
|
||||
# Adds the destroyed item's uri to the list of items to reopen.
|
||||
onPaneItemDestroyed: (item) =>
|
||||
didDestroyPaneItem: ({item}) =>
|
||||
if uri = item.getUri?()
|
||||
@destroyedItemUris.push(uri)
|
||||
|
||||
@@ -609,6 +655,10 @@ class Workspace extends Model
|
||||
Section: Panels
|
||||
###
|
||||
|
||||
# Essential: Get an {Array} of all the panel items at the bottom of the editor window.
|
||||
getBottomPanels: ->
|
||||
@getPanels('bottom')
|
||||
|
||||
# Essential: Adds a panel item to the bottom of the editor window.
|
||||
#
|
||||
# * `options` {Object}
|
||||
@@ -624,6 +674,10 @@ class Workspace extends Model
|
||||
addBottomPanel: (options) ->
|
||||
@addPanel('bottom', options)
|
||||
|
||||
# Essential: Get an {Array} of all the panel items to the left of the editor window.
|
||||
getLeftPanels: ->
|
||||
@getPanels('left')
|
||||
|
||||
# Essential: Adds a panel item to the left of the editor window.
|
||||
#
|
||||
# * `options` {Object}
|
||||
@@ -639,6 +693,10 @@ class Workspace extends Model
|
||||
addLeftPanel: (options) ->
|
||||
@addPanel('left', options)
|
||||
|
||||
# Essential: Get an {Array} of all the panel items to the right of the editor window.
|
||||
getRightPanels: ->
|
||||
@getPanels('right')
|
||||
|
||||
# Essential: Adds a panel item to the right of the editor window.
|
||||
#
|
||||
# * `options` {Object}
|
||||
@@ -654,6 +712,10 @@ class Workspace extends Model
|
||||
addRightPanel: (options) ->
|
||||
@addPanel('right', options)
|
||||
|
||||
# Essential: Get an {Array} of all the panel items at the top of the editor window.
|
||||
getTopPanels: ->
|
||||
@getPanels('top')
|
||||
|
||||
# Essential: Adds a panel item to the top of the editor window above the tabs.
|
||||
#
|
||||
# * `options` {Object}
|
||||
@@ -669,6 +731,10 @@ class Workspace extends Model
|
||||
addTopPanel: (options) ->
|
||||
@addPanel('top', options)
|
||||
|
||||
# Essential: Get an {Array} of all the modal panel items
|
||||
getModalPanels: ->
|
||||
@getPanels('modal')
|
||||
|
||||
# Essential: Adds a panel item as a modal dialog.
|
||||
#
|
||||
# * `options` {Object}
|
||||
@@ -682,11 +748,21 @@ class Workspace extends Model
|
||||
#
|
||||
# Returns a {Panel}
|
||||
addModalPanel: (options={}) ->
|
||||
# TODO: remove these default classes. They are to supoprt existing themes.
|
||||
options.className ?= 'overlay from-top'
|
||||
@addPanel('modal', options)
|
||||
|
||||
# Essential: Returns the {Panel} associated with the given item. Returns
|
||||
# `null` when the item has no panel.
|
||||
#
|
||||
# * `item` Item the panel contains
|
||||
panelForItem: (item) ->
|
||||
for location, container of @panelContainers
|
||||
panel = container.panelForItem(item)
|
||||
return panel if panel?
|
||||
null
|
||||
|
||||
getPanels: (location) ->
|
||||
@panelContainers[location].getPanels()
|
||||
|
||||
addPanel: (location, options) ->
|
||||
options ?= {}
|
||||
options.viewRegistry = atom.views
|
||||
@panelContainers[location].addPanel(new Panel(options))
|
||||
|
||||
@@ -19,6 +19,17 @@ body {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.reload-button {
|
||||
color: #333;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
|
||||
&:hover {
|
||||
background-color: #ddd;
|
||||
color: #222;
|
||||
}
|
||||
}
|
||||
|
||||
.symbol-header {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
@@ -140,6 +151,10 @@ body {
|
||||
color: darken(#f0ad4e, 20%);
|
||||
line-height: 1.4;
|
||||
|
||||
a {
|
||||
color: darken(#f0ad4e, 15%);
|
||||
}
|
||||
|
||||
code {
|
||||
color: darken(#f0ad4e, 20%);
|
||||
background: lighten(#f0ad4e, 35%);
|
||||
|
||||
+12
-14
@@ -1,19 +1,17 @@
|
||||
.source {
|
||||
.gfm {
|
||||
.markup.heading {
|
||||
font-weight: bold;
|
||||
}
|
||||
.source.gfm {
|
||||
.markup.heading {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.comment.quote {
|
||||
font-style: italic;
|
||||
}
|
||||
.comment.quote {
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário