diff --git a/.atom/.gitignore b/.atom/.gitignore deleted file mode 100644 index 81af3f6..0000000 --- a/.atom/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -storage -compile-cache -dev -.npm -.node-gyp diff --git a/.atom/config.cson b/.atom/config.cson deleted file mode 100644 index b80862a..0000000 --- a/.atom/config.cson +++ /dev/null @@ -1,22 +0,0 @@ -'editor': - 'fontSize': 12 - 'showIndentGuide': true - 'showInvisibles': true - 'preferredLineLength': 75 -'core': - 'themes': [ - 'spacegray-mocha-ui' - 'jellybeans-syntax' - ] - 'useReactEditor': true - 'projectHome': 'C:\\Projects' - 'audioBeep': false - 'disabledPackages': [ - 'welcome' - ] -'exception-reporting': - 'userId': '1c9d1b3d-fdb9-e390-da2c-bd840428aa77' -'welcome': - 'showOnStartup': false -'metrics': - 'userId': 'c4e928ad4b095ae6ca1595c2945c97457bc6fe1f' diff --git a/.atom/init.coffee b/.atom/init.coffee deleted file mode 100644 index 4d10e77..0000000 --- a/.atom/init.coffee +++ /dev/null @@ -1,14 +0,0 @@ -# Your init script -# -# Atom will evaluate this file each time a new window is opened. It is run -# after packages are loaded/activated and after the previous editor state -# has been restored. -# -# An example hack to make opened Markdown files always be soft wrapped: -# -# path = require 'path' -# -# atom.workspaceView.eachEditorView (editorView) -> -# editor = editorView.getEditor() -# if path.extname(editor.getPath()) is '.md' -# editor.setSoftWrap(true) diff --git a/.atom/keymap.cson b/.atom/keymap.cson deleted file mode 100644 index 43ec695..0000000 --- a/.atom/keymap.cson +++ /dev/null @@ -1,18 +0,0 @@ -# Your keymap -# -# Atom keymaps work similarly to stylesheets. Just as stylesheets use selectors -# to apply styles to elements, Atom keymaps use selectors to associate -# keystrokes with events in specific contexts. -# -# You can create a new keybinding in this file by typing "key" and then hitting -# tab. -# -# Here's an example taken from Atom's built-in keymap: -# -# '.editor': -# 'enter': 'editor:newline' -# -# '.workspace': -# 'ctrl-P': 'core:move-up' -# 'ctrl-p': 'core:move-down' -# diff --git a/.atom/packages/README.md b/.atom/packages/README.md deleted file mode 100644 index 540b694..0000000 --- a/.atom/packages/README.md +++ /dev/null @@ -1 +0,0 @@ -All packages in this directory will be automatically loaded diff --git a/.atom/packages/atom-terminal/.npmignore b/.atom/packages/atom-terminal/.npmignore deleted file mode 100644 index ade14b9..0000000 --- a/.atom/packages/atom-terminal/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -npm-debug.log -node_modules diff --git a/.atom/packages/atom-terminal/LICENSE.md b/.atom/packages/atom-terminal/LICENSE.md deleted file mode 100644 index 5e18ad8..0000000 --- a/.atom/packages/atom-terminal/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 Karan Goel - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/atom-terminal/README.md b/.atom/packages/atom-terminal/README.md deleted file mode 100644 index 5e3649a..0000000 --- a/.atom/packages/atom-terminal/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# atom-terminal - -Open terminal on current file's directory with `ctrl-shift-t`. - -Open a terminal in the project's root directory with `alt-shift-t`. - -Keybindings: `ctrl-shift-t`, `alt-shift-t` - -Install: `apm install atom-terminal` - -![atom-terminal](https://raw.github.com/karan/atom-terminal/master/terminal.gif) diff --git a/.atom/packages/atom-terminal/keymaps/atom-terminal.cson b/.atom/packages/atom-terminal/keymaps/atom-terminal.cson deleted file mode 100644 index 56cbe3d..0000000 --- a/.atom/packages/atom-terminal/keymaps/atom-terminal.cson +++ /dev/null @@ -1,12 +0,0 @@ -# Keybindings require three things to be fully defined: A selector that is -# matched against the focused element, the keystroke and the command to -# execute. -# -# Below is a basic keybinding which registers on all platforms by applying to -# the root workspace element. - -# For more detailed documentation see -# https://atom.io/docs/latest/advanced/keymaps -'.workspace': - 'ctrl-shift-t': 'atom-terminal:open' - 'alt-shift-t': 'atom-terminal:open-project-root' diff --git a/.atom/packages/atom-terminal/lib/atom-terminal.coffee b/.atom/packages/atom-terminal/lib/atom-terminal.coffee deleted file mode 100644 index fcb2741..0000000 --- a/.atom/packages/atom-terminal/lib/atom-terminal.coffee +++ /dev/null @@ -1,79 +0,0 @@ -exec = require('child_process').exec -path = require('path') -platform = require('os').platform - -### - Opens a terminal in the given directory, as specefied by the config -### -open_terminal = (dirpath) -> - # Figure out the app and the arguments - app = atom.config.get('atom-terminal.app') - args = atom.config.get('atom-terminal.args') - - # get options - setWorkingDirectory = atom.config.get('atom-terminal.setWorkingDirectory') - surpressDirArg = atom.config.get('atom-terminal.surpressDirectoryArgument') - runDirectly = atom.config.get('atom-terminal.MacWinRunDirectly') - - # Start assembling the command line - cmdline = "\"#{app}\" #{args}" - - # If we do not supress the directory argument, add the directory as an argument - if !surpressDirArg - cmdline += "\"#{dirpath}\"" - - # For mac, we prepend open -a unless we run it directly - if platform() == "darwin" && !runDirectly - cmdline = "open -a " + cmdline - - # for windows, we prepend start unless we run it directly. - if platform() == "win32" && !runDirectly - cmdline = "start \"\" " + cmdline - - # Set the working directory if configured - if setWorkingDirectory - exec cmdline, cwd: dirpath if dirpath? - else - exec cmdline if dirpath? - - -module.exports = - activate: -> - atom.workspaceView.command "atom-terminal:open", => @open() - atom.workspaceView.command "atom-terminal:open-project-root", => @openroot() - open: -> - filepath = atom.workspaceView.find('.tree-view .selected')?.view()?.getPath?() - if filepath - open_terminal path.dirname(filepath) - openroot: -> - if atom.project.path - open_terminal atom.project.path - -# Set per-platform defaults -if platform() == 'darwin' - # Defaults for Mac, use Terminal.app - module.exports.configDefaults = { - app: 'Terminal.app' - args: '' - surpressDirectoryArgument: false - setWorkingDirectory: false - MacWinRunDirectly: false - } -else if platform() == 'win32' - # Defaults for windows, use cmd.exe as default - module.exports.configDefaults = { - app: 'C:\\Windows\\System32\\cmd.exe' - args: '' - surpressDirectoryArgument: false - setWorkingDirectory: true - MacWinRunDirectly: false - } -else - # Defaults for all other systems (linux I assume), use xterm - module.exports.configDefaults = { - app: '/usr/bin/xterm' - args: '' - surpressDirectoryArgument: true - setWorkingDirectory: true - MacWinRunDirectly: false - } diff --git a/.atom/packages/atom-terminal/package.json b/.atom/packages/atom-terminal/package.json deleted file mode 100644 index 5207b6a..0000000 --- a/.atom/packages/atom-terminal/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "atom-terminal", - "main": "./lib/atom-terminal", - "version": "0.5.0", - "description": "Open terminal in the current file's directory.", - "activationEvents": [ - "atom-terminal:open", - "atom-terminal:open-project-root" - ], - "repository": { - "type": "git", - "url": "https://github.com/karan/atom-terminal" - }, - "license": "MIT", - "engines": { - "atom": ">0.50.0" - }, - "dependencies": {}, - "readme": "# atom-terminal\n\nOpen terminal on current file's directory with `ctrl-shift-t`.\n\nOpen a terminal in the project's root directory with `alt-shift-t`. \n\nKeybindings: `ctrl-shift-t`, `alt-shift-t`\n\nInstall: `apm install atom-terminal`\n\n![atom-terminal](https://raw.github.com/karan/atom-terminal/master/terminal.gif)\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/karan/atom-terminal/issues" - }, - "homepage": "https://github.com/karan/atom-terminal", - "_id": "atom-terminal@0.5.0", - "dist": { - "shasum": "65b9014a4568097dc6534231963286eefbf308c5" - }, - "_resolved": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114628-528-26f7q\\package.tgz", - "_from": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114628-528-26f7q\\package.tgz" -} diff --git a/.atom/packages/atom-terminal/terminal.gif b/.atom/packages/atom-terminal/terminal.gif deleted file mode 100644 index 1c129db..0000000 Binary files a/.atom/packages/atom-terminal/terminal.gif and /dev/null differ diff --git a/.atom/packages/color-picker/.npmignore b/.atom/packages/color-picker/.npmignore deleted file mode 100644 index ade14b9..0000000 --- a/.atom/packages/color-picker/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -npm-debug.log -node_modules diff --git a/.atom/packages/color-picker/LICENSE.md b/.atom/packages/color-picker/LICENSE.md deleted file mode 100644 index 4b0954f..0000000 --- a/.atom/packages/color-picker/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 Thomas Lindstrøm - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/color-picker/README.md b/.atom/packages/color-picker/README.md deleted file mode 100644 index c6152eb..0000000 --- a/.atom/packages/color-picker/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# A Color Picker for Atom - -A color picker for Atom. Either right click a color and select `Color picker`, or hit `CMD-SHIFT-C`/`CTRL-ALT-C` anywhere. Currently reads HEX, HEXA, RGB, RGBA, HSL and HSLA. - -Inspects Sass/LESS variables! [Take a look here.](http://t.hom.as/colorpicker4.mov) - -**NEW:** You can now open the color picker whenever, without input, using `CMD-SHIFT-C`/`CTRL-ALT-C`! - -## Preview - -![Color Picker in action](http://f.cl.ly/items/3g3T401o0o0F2m2O1z1K/output.gif) - -## To do - -- Stylus variable lookup -- Context menu convertions -- Preview color manipulation functions (lighten, darken) -- Edit the color value diff --git a/.atom/packages/color-picker/keymaps/color-picker.cson b/.atom/packages/color-picker/keymaps/color-picker.cson deleted file mode 100644 index 2e240e8..0000000 --- a/.atom/packages/color-picker/keymaps/color-picker.cson +++ /dev/null @@ -1,14 +0,0 @@ -# Keybindings require three things to be fully defined: A selector that is -# matched against the focused element, the keystroke and the command to -# execute. -# -# Below is a basic keybinding which registers on all platforms by applying to -# the root workspace element. - -# For more detailed documentation see -# https://atom.io/docs/latest/advanced/keymaps -'.platform-darwin .workspace': - 'cmd-C': 'color-picker:open' - -'.platform-win32 .workspace, .platform-linux .workspace': - 'ctrl-alt-c': 'color-picker:open' diff --git a/.atom/packages/color-picker/lib/ColorPicker-alphaSelector.coffee b/.atom/packages/color-picker/lib/ColorPicker-alphaSelector.coffee deleted file mode 100644 index dc7ef90..0000000 --- a/.atom/packages/color-picker/lib/ColorPicker-alphaSelector.coffee +++ /dev/null @@ -1,31 +0,0 @@ -# ---------------------------------------------------------------------------- -# ColorPicker: Alpha selector -# ---------------------------------------------------------------------------- - Convert = require './ColorPicker-convert' - - $el = atom.workspaceView.find '#ColorPicker-alphaSelector' - $selection = atom.workspaceView.find '#ColorPicker-alphaSelection' - _context = $el[0].getContext '2d' - _width = $el.width() - _height = $el.height() - - # ------------------------------------- - # Public functionality - # ------------------------------------- - module.exports = - $el: $el - $selection: $selection - width: _width - height: _height - - # Draw the alpha selector gradient - render: (color) -> - _gradient = _context.createLinearGradient 0, 0, 1, _height - _context.clearRect 0, 0, _width, _height - - _rgbString = color.join ', ' - _gradient.addColorStop 0, "rgba(#{ _rgbString }, 1)" - _gradient.addColorStop 1, "rgba(#{ _rgbString }, 0)" - - _context.fillStyle = _gradient - _context.fillRect 0, 0, _width, _height diff --git a/.atom/packages/color-picker/lib/ColorPicker-convert.coffee b/.atom/packages/color-picker/lib/ColorPicker-convert.coffee deleted file mode 100644 index d526389..0000000 --- a/.atom/packages/color-picker/lib/ColorPicker-convert.coffee +++ /dev/null @@ -1,150 +0,0 @@ -# ---------------------------------------------------------------------------- -# ColorPicker: Convert -# ---------------------------------------------------------------------------- - - module.exports = - # ------------------------------------- - # HEX to RGB - # ------------------------------------- - hexToRgb: (hex) -> - hex = hex.replace '#', '' - if hex.length is 3 then hex = hex.replace /(.)(.)(.)/, "$1$1$2$2$3$3" - - return [ - (parseInt (hex.substr 0, 2), 16), - (parseInt (hex.substr 2, 2), 16), - (parseInt (hex.substr 4, 2), 16) - ] - - # ------------------------------------- - # HEXA to RGB - # ------------------------------------- - hexaToRgb: (hexa) -> - return @hexToRgb (hexa.match /rgba\((\#.+),/)[1] - - # ------------------------------------- - # HEX to HSL - # ------------------------------------- - hexToHsl: (hex) -> - hex = hex.replace '#', '' - return @rgbToHsl @hexToRgb hex - - # ------------------------------------- - # RGB to HEX - # ------------------------------------- - rgbToHex: (rgb) -> - _componentToHex = (component) -> - _hex = component.toString 16 - return if _hex.length is 1 then "0#{ _hex }" else _hex - - return [ - (_componentToHex rgb[0]), - (_componentToHex rgb[1]), - (_componentToHex rgb[2]) - ].join '' - - # ------------------------------------- - # RGB to HSL - # ------------------------------------- - rgbToHsl: ([r, g, b]) -> - r /= 255 - g /= 255 - b /= 255 - - _max = Math.max r, g, b - _min = Math.min r, g, b - - _l = (_max + _min) / 2 - - if _max is _min then return [0, 0, Math.floor _l * 100] - - _d = _max - _min - _s = if _l > 0.5 then _d / (2 - _max - _min) else _d / (_max + _min) - - switch _max - when r then _h = (g - b) / _d + (if g < b then 6 else 0) - when g then _h = (b - r) / _d + 2 - when b then _h = (r - g) / _d + 4 - - _h /= 6 - - return [ - Math.floor _h * 360 - Math.floor _s * 100 - Math.floor _l * 100 - ] - - # ------------------------------------- - # RGB to HSV - # ------------------------------------- - rgbToHsv: (rgb) -> - if typeof rgb is 'string' then rgb = rgb.match /(\d+)/g - - [r, g, b] = rgb - - computedH = 0 - computedS = 0 - computedV = 0 - - #remove spaces from input RGB values, convert to int - r = parseInt(("" + r).replace(/\s/g, ""), 10) - g = parseInt(("" + g).replace(/\s/g, ""), 10) - b = parseInt(("" + b).replace(/\s/g, ""), 10) - - if not r? or not g? or not b? or isNaN(r) or isNaN(g) or isNaN(b) - alert "Please enter numeric RGB values!" - return - if r < 0 or g < 0 or b < 0 or r > 255 or g > 255 or b > 255 - alert "RGB values must be in the range 0 to 255." - return - - r = r / 255 - g = g / 255 - b = b / 255 - - minRGB = Math.min(r, Math.min(g, b)) - maxRGB = Math.max(r, Math.max(g, b)) - - # Black-gray-white - if minRGB is maxRGB - computedV = minRGB - return [ - 0 - 0 - computedV - ] - - # Colors other than black-gray-white: - d = (if (r is minRGB) then g - b else ((if (b is minRGB) then r - g else b - r))) - h = (if (r is minRGB) then 3 else ((if (b is minRGB) then 1 else 5))) - computedH = 60 * (h - d / (maxRGB - minRGB)) - computedS = (maxRGB - minRGB) / maxRGB - computedV = maxRGB - - return [ - computedH - computedS - computedV - ] - - # ------------------------------------- - # HSV to HSL - # ------------------------------------- - hsvToHsl: ([h, s, v]) -> - return [ - h, - s * v / (if (h = (2 - s) * v) < 1 then h else 2 - h) - h / 2 - ] - - # ------------------------------------- - # HSL to HSV - # ------------------------------------- - hslToHsv: ([h, s, l]) -> - s *= if l < .5 then l else 1 - l - - return [ - h, - 2 * s / (l + s) - l + s - ] diff --git a/.atom/packages/color-picker/lib/ColorPicker-hueSelector.coffee b/.atom/packages/color-picker/lib/ColorPicker-hueSelector.coffee deleted file mode 100644 index dd4b6b4..0000000 --- a/.atom/packages/color-picker/lib/ColorPicker-hueSelector.coffee +++ /dev/null @@ -1,38 +0,0 @@ -# ---------------------------------------------------------------------------- -# ColorPicker: Hue selector -# ---------------------------------------------------------------------------- - Convert = require './ColorPicker-convert' - _hexes = ['FF0000', 'FFFF00', '00FF00', '00FFFF', '0000FF', 'FF00FF', 'FF0000'] - - $el = atom.workspaceView.find '#ColorPicker-hueSelector' - $selection = atom.workspaceView.find '#ColorPicker-hueSelection' - _context = $el[0].getContext '2d' - _width = $el.width() - _height = $el.height() - - # ------------------------------------- - # Public functionality - # ------------------------------------- - module.exports = - $el: $el - $selection: $selection - width: _width - height: _height - - # Draw the hue selector gradient - render: -> - _gradient = _context.createLinearGradient 0, 0, 1, _height - _step = 1 / (_hexes.length - 1) - - _gradient.addColorStop (_step * i), hex for hex, i in _hexes - _context.fillStyle = _gradient - _context.fillRect 0, 0, _width, _height - - # Returns a color from a position on the canvas - getColorAtPosition: (positionY) -> - _data = (_context.getImageData 1, (positionY - 1), 1, 1).data - - return { - color: ('#' + Convert.rgbToHex _data), - type: 'hex' - } diff --git a/.atom/packages/color-picker/lib/ColorPicker-regexes.coffee b/.atom/packages/color-picker/lib/ColorPicker-regexes.coffee deleted file mode 100644 index a8f0c22..0000000 --- a/.atom/packages/color-picker/lib/ColorPicker-regexes.coffee +++ /dev/null @@ -1,36 +0,0 @@ -# ---------------------------------------------------------------------------- -# ColorPicker: Regexes -# ---------------------------------------------------------------------------- - module.exports = [ - # Matches Sass variable: eg. - # $color-var - { type: 'variable:sass', regex: /([\$])([\w0-9-_]+)/ig } - - # Matches LESS variable: eg. - # @color-var - { type: 'variable:less', regex: /([\@])([\w0-9-_]+)/ig } - - # Matches HSL + A: eg - # hsla(320, 100%, 38%, 0.3) and hsla(26, 57, 32, .3) - { type: 'hsla', regex: /hsla\(([0-9]|[1-9][0-9]|[1|2][0-9][0-9]|3[0-5][0-9]|360),\s*([0-9]|[1-9][0-9]|100)\%?,\s*([0-9]|[1-9][0-9]|100)\%?,\s*(0|1|0*\.\d+)\)/ig } - - # Matches HSL: eg - # hsl(320, 100%, 38%) and hsl(26, 57, 32) - { type: 'hsl', regex: /hsl\(([0-9]|[1-9][0-9]|[1|2][0-9][0-9]|3[0-5][0-9]|360),\s*([0-9]|[1-9][0-9]|100)\%?,\s*([0-9]|[1-9][0-9]|100)\%?\)/ig } - - # Matches HEX + A: eg - # rgba(#fff, 0.3) and rgba(#000000, .8) - { type: 'hexa', regex: /(rgba\(((\#[a-f0-9]{6}|\#[a-f0-9]{3}))\s*,\s*(0|1|0*\.\d+)\))/ig } - - # Matches RGB + A: eg. - # rgba(0, 99, 199, 0.3) - { type: 'rgba', regex: /(rgba\(((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s*,\s*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s*,\s*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])))\s*,\s*(0|1|0*\.\d+)\))/ig } - - # Matches RGB: eg. - # rgb(0, 99, 199) - { type: 'rgb', regex: /(rgb\(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s*,\s*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s*,\s*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\))/ig } - - # Matches HEX: - # eg. #000 and #ffffff - { type: 'hex', regex: /(\#[a-f0-9]{6}|\#[a-f0-9]{3})/ig } - ] diff --git a/.atom/packages/color-picker/lib/ColorPicker-saturationSelector.coffee b/.atom/packages/color-picker/lib/ColorPicker-saturationSelector.coffee deleted file mode 100644 index 0b68b9b..0000000 --- a/.atom/packages/color-picker/lib/ColorPicker-saturationSelector.coffee +++ /dev/null @@ -1,49 +0,0 @@ -# ---------------------------------------------------------------------------- -# ColorPicker: Saturation selector -# ---------------------------------------------------------------------------- - Convert = require './ColorPicker-convert' - - $el = atom.workspaceView.find '#ColorPicker-saturationSelector' - $selection = atom.workspaceView.find '#ColorPicker-saturationSelection' - _context = $el[0].getContext '2d' - _width = $el.width() - _height = $el.height() - - # ------------------------------------- - # Public functionality - # ------------------------------------- - module.exports = - $el: $el - $selection: $selection - width: _width - height: _height - - # Draw the saturation selector - render: (hex) -> - _hsl = Convert.hexToHsl hex - _context.clearRect 0, 0, _width, _height - - # Draw the hue channel - _gradient = _context.createLinearGradient 0, 0, _width, 1 - _gradient.addColorStop .01, '#fff' - _gradient.addColorStop .99, "hsl(#{ _hsl[0] }, 100%, 50%)" - - _context.fillStyle = _gradient - _context.fillRect 0, 0, _width, _height - - # Draw the saturation channel - _gradient = _context.createLinearGradient 0, 0, 1, _height - _gradient.addColorStop .01, 'rgba(0, 0, 0, 0)' - _gradient.addColorStop .99, '#000' - - _context.fillStyle = _gradient - _context.fillRect 0, 0, _width, _height - - # Returns a color from a position on the canvas - getColorAtPosition: (positionX, positionY) -> - _data = (_context.getImageData (positionX - 1), (positionY - 1), 1, 1).data - - return { - color: ('#' + Convert.rgbToHex _data), - type: 'hex' - } diff --git a/.atom/packages/color-picker/lib/ColorPicker-view.coffee b/.atom/packages/color-picker/lib/ColorPicker-view.coffee deleted file mode 100644 index dce3c0d..0000000 --- a/.atom/packages/color-picker/lib/ColorPicker-view.coffee +++ /dev/null @@ -1,453 +0,0 @@ -# ---------------------------------------------------------------------------- -# ColorPicker: View -# ---------------------------------------------------------------------------- - { View } = require 'atom' - Convert = require './ColorPicker-convert' - - ColorPicker = null - SaturationSelector = null - HueSelector = null - AlphaSelector = null - - module.exports = class ColorPickerView extends View - @content: -> - c = 'ColorPicker-' - - @div id: 'ColorPicker', class: 'ColorPicker', => - @div id: "#{ c }loader", class: "#{ c }loader", => - @div class: "#{ c }loaderDot" - @div class: "#{ c }loaderDot" - @div class: "#{ c }loaderDot" - - @div id: "#{ c }color", class: "#{ c }color", => - @div id: "#{ c }value", class: "#{ c }value" - - @div id: "#{ c }initialWrapper", class: "#{ c }initialWrapper", => - @div id: "#{ c }initial", class: "#{ c }initial" - - @div id: "#{ c }picker", class: "#{ c }picker", => - @div id: "#{ c }saturationSelectorWrapper", class: "#{ c }saturationSelectorWrapper", => - @div id: "#{ c }saturationSelection", class: "#{ c }saturationSelection" - @canvas id: "#{ c }saturationSelector", class: "#{ c }saturationSelector", width: '180px', height: '180px' - @div id: "#{ c }alphaSelectorWrapper", class: "#{ c }alphaSelectorWrapper", => - @div id: "#{ c }alphaSelection", class: "#{ c }alphaSelection" - @canvas id: "#{ c }alphaSelector", class: "#{ c }alphaSelector", width: '20px', height: '180px' - @div id: "#{ c }hueSelectorWrapper", class: "#{ c }hueSelectorWrapper", => - @div id: "#{ c }hueSelection", class: "#{ c }hueSelection" - @canvas id: "#{ c }hueSelector", class: "#{ c }hueSelector", width: '20px', height: '180px' - - initialize: -> - (atom.workspaceView.find '.vertical').append this - - ColorPicker = require './ColorPicker' - SaturationSelector = require './ColorPicker-saturationSelector' - AlphaSelector = require './ColorPicker-alphaSelector' - HueSelector = require './ColorPicker-hueSelector' - - HueSelector.render() - - @bind() - - # Tear down any state and detach - destroy: -> - @close() - this.remove() - @detach() - - # ------------------------------------- - # Controller state storage - # ------------------------------------- - storage: { - activeView: null - selectedColor: null - pickedColor: null - - saturation: x: 0, y: 0 - hue: 0 - alpha: 0 - } - - # ------------------------------------- - # Show or hide color picker - # ------------------------------------- - isOpen: false - - reset: -> - this.addClass 'is--visible is--initial' - this.removeClass 'no--arrow is--pointer is--searching' - - (this.find '#ColorPicker-color') - .css 'background-color', '' - .css 'border-bottom-color', '' - (this.find '#ColorPicker-value') - .attr 'data-variable', '' - .html '' - - open: -> - @isOpen = true - _selectedColor = @storage.selectedColor - - if not _selectedColor or _selectedColor.hasOwnProperty 'pointer' - this.addClass 'is--pointer' - if not _selectedColor then this.addClass 'is--searching' - - _colorPickerWidth = this.width() - _colorPickerHeight = this.height() - _halfColorPickerWidth = _colorPickerWidth / 2 - - _pane = atom.workspaceView.getActivePaneView() - _paneOffset = top: _pane[0].offsetTop, left: _pane[0].offsetLeft - _tabBarHeight = (_pane.find '.tab-bar').height() - - @storage.activeView = _view = _pane.activeView - _position = _view.pixelPositionForScreenPosition _view.getEditor().getCursorScreenPosition() - _gutterWidth = (_view.find '.gutter').width() - - _scroll = top: _view.scrollTop(), left: _view.scrollLeft() - _scrollbar = _view.verticalScrollbar - if _scrollbar then _scrollbar.on 'scroll.color-picker', => @scroll() - - # Add 15 to account for the arrow on top of the color picker - _top = 15 + _position.top - _scroll.top + _view.lineHeight + _tabBarHeight - _left = _position.left - _scroll.left + _gutterWidth - - # Make adjustments based on view size: don't let the color picker - # disappear or overflow - _viewWidth = _view.width() - _viewHeight = _view.height() - - # Remove 15 to ignore the arrow on top of the color picker - if _top + _colorPickerHeight - 15 > _viewHeight - _top = _viewHeight + _tabBarHeight - _colorPickerHeight - 20 - this.addClass 'no--arrow' - _top += _paneOffset.top - - if _left + _halfColorPickerWidth > _viewWidth - _left = _viewWidth - _halfColorPickerWidth - 20 - this.addClass 'no--arrow' - _left += _paneOffset.left - _halfColorPickerWidth - - this # Place the color picker - .css 'top', Math.max 20, _top - .css 'left', Math.max 20, _left - - close: -> - @isOpen = false - this.removeClass 'is--visible is--initial is--searching is--error' - - return unless @storage.activeView and @storage.activeView.verticalScrollbar - @storage.activeView.verticalScrollbar.off 'scroll.color-picker' - - error: -> - @storage.selectedColor = null - - this - .removeClass 'is--searching' - .addClass 'is--error' - - scroll: -> if @isOpen then @close() - - # ------------------------------------- - # Bind controls - # ------------------------------------- - bind: -> - window.onresize = => if @isOpen then @close() - atom.workspaceView.on 'pane:active-item-changed', => @close() - - $body = this.parents 'body' - - do => # Bind the color output control - $body.on 'mousedown', (e) => - _target = e.target - _className = _target.className - - # Close unless the click target is something related to - # the color picker - return @close() unless /ColorPicker/.test _className - - _color = @storage.selectedColor - - switch _className - when 'ColorPicker-color' - if (_color?.hasOwnProperty 'pointer') and _pointer = _color.pointer - (atom.workspace.open _pointer.filePath).finally => - _editor = atom.workspace.activePaneItem - _editor.clearSelections() - _editor.setSelectedBufferRange _pointer.range - else @replaceColor() - - @close() - when 'ColorPicker-initialWrapper' - @inputColor _color - this.addClass 'is--initial' - .on 'keydown', (e) => - return unless @isOpen - return @close() unless e.which is 13 - - e.preventDefault() - e.stopPropagation() - - @replaceColor() - @close() - - do => # Bind the saturation selector controls - _isGrabbingSaturationSelection = false - - $body.on 'mousedown mousemove mouseup', (e) => - _offset = SaturationSelector.$el.offset() - _offsetY = Math.max 1, (Math.min SaturationSelector.height, (e.pageY - _offset.top)) - _offsetX = Math.max 1, (Math.min SaturationSelector.width, (e.pageX - _offset.left)) - - switch e.type - when 'mousedown' - return unless e.target.className is 'ColorPicker-saturationSelector' - e.preventDefault() - _isGrabbingSaturationSelection = true - when 'mousemove' - return unless _isGrabbingSaturationSelection - e.preventDefault() - when 'mouseup' - _isGrabbingSaturationSelection = false - return unless _isGrabbingSaturationSelection - - @setSaturation _offsetX, _offsetY - @refreshColor 'saturation' - - do => # Bind the alpha selector controls - _isGrabbingAlphaSelection = false - - $body.on 'mousedown mousemove mouseup', (e) => - _offsetTop = AlphaSelector.$el.offset().top - _offsetY = Math.max 1, (Math.min AlphaSelector.height, (e.pageY - _offsetTop)) - - switch e.type - when 'mousedown' - return unless e.target.className is 'ColorPicker-alphaSelector' - e.preventDefault() - _isGrabbingAlphaSelection = true - when 'mousemove' - return unless _isGrabbingAlphaSelection - e.preventDefault() - when 'mouseup' - _isGrabbingAlphaSelection = false - return unless _isGrabbingAlphaSelection - - @setAlpha _offsetY - @refreshColor 'alpha' - - do => # Bind the hue selector controls - _isGrabbingHueSelection = false - - $body.on 'mousedown mousemove mouseup', (e) => - _offsetTop = HueSelector.$el.offset().top - _offsetY = Math.max 1, (Math.min HueSelector.height, (e.pageY - _offsetTop)) - - switch e.type - when 'mousedown' - return unless e.target.className is 'ColorPicker-hueSelector' - e.preventDefault() - _isGrabbingHueSelection = true - when 'mousemove' - return unless _isGrabbingHueSelection - e.preventDefault() - when 'mouseup' - _isGrabbingHueSelection = false - return unless _isGrabbingHueSelection - - @setHue _offsetY - @refreshColor 'hue' - - # ------------------------------------- - # Saturation - # ------------------------------------- - setSaturation: (positionX, positionY) -> - @storage.saturation.x = positionX - @storage.saturation.y = positionY - - _percentageTop = (positionY / SaturationSelector.height) * 100 - _percentageLeft = (positionX / SaturationSelector.width) * 100 - - SaturationSelector.$selection - .css 'top', _percentageTop + '%' - .css 'left', _percentageLeft + '%' - - refreshSaturationCanvas: -> - _color = HueSelector.getColorAtPosition @storage.hue - SaturationSelector.render _color.color - - # ------------------------------------- - # Alpha - # ------------------------------------- - setAlpha: (positionY) -> - @storage.alpha = positionY - AlphaSelector.$selection - .css 'top', (positionY / AlphaSelector.height) * 100 + '%' - - refreshAlphaCanvas: -> - _saturation = @storage.saturation - _color = SaturationSelector.getColorAtPosition _saturation.x, _saturation.y - AlphaSelector.render Convert.hexToRgb _color.color - - # ------------------------------------- - # Hue - # ------------------------------------- - setHue: (positionY) -> - @storage.hue = positionY - HueSelector.$selection - .css 'top', (positionY / HueSelector.height) * 100 + '%' - - # ------------------------------------- - # Color - # ------------------------------------- - - # Set the current color after control interaction - setColor: (color, preferredColorType) -> - unless color then this.removeClass 'is--initial' - else _setInitialColor = true - - _saturation = @storage.saturation - color ?= SaturationSelector.getColorAtPosition _saturation.x, _saturation.y - _color = _displayColor = color.color - - _alphaValue = 100 - (((@storage.alpha / AlphaSelector.height) * 100) << 0) - _alphaFactor = _alphaValue / 100 - - # Spit the same color type as the input (selected) color - if preferredColorType - if preferredColorType is 'hsl' or preferredColorType is 'hsla' - _hsl = Convert.hsvToHsl Convert.rgbToHsv Convert.hexToRgb _color - _h = (_hsl[0]) << 0 - _s = (_hsl[1] * 100) << 0 - _l = (_hsl[2] * 100) << 0 - else _hexRgbFragments = (Convert.hexToRgb _color).join ', ' - - if _alphaValue is 100 then _displayColor = switch preferredColorType - when 'rgb', 'rgba' then "rgb(#{ _hexRgbFragments })" - when 'hsl', 'hsla' then "hsl(#{ _h }, #{ _s }%, #{ _l }%)" - else _color - else _displayColor = switch preferredColorType - when 'rgb', 'rgba', 'hex' then "rgba(#{ _hexRgbFragments }, #{ _alphaFactor })" - when 'hexa' then "rgba(#{ _color }, #{ _alphaFactor })" - when 'hsl', 'hsla' then "hsla(#{ _h }, #{ _s }%, #{ _l }%, #{ _alphaFactor })" - - # Translate the color to rgba if an alpha value is set - if _alphaValue isnt 100 - _rgb = switch color.type - when 'hexa' then Convert.hexaToRgb _color - when 'hex' then Convert.hexToRgb _color - when 'rgb' then _color - if _rgb then _color = "rgba(#{ _rgb.join ', ' }, #{ _alphaFactor })" - - @storage.pickedColor = _displayColor - - # Set the color - (this.find '#ColorPicker-color') - .css 'background-color', _color - .css 'border-bottom-color', _color - (this.find '#ColorPicker-value').html _displayColor - - # Save the initial color this function is given it - if _setInitialColor - (this.find '#ColorPicker-initial') - .css 'background-color', _color - .html _displayColor - - # The color is a variable - if color.hasOwnProperty 'pointer' - this.removeClass 'is--searching' - .find '#ColorPicker-value' - .attr 'data-variable', color.match - - refreshColor: (trigger) -> - if trigger is 'hue' then @refreshSaturationCanvas() - if trigger is 'hue' or trigger is 'saturation' then @refreshAlphaCanvas() - - # Send the preferred color type as well - @setColor undefined, @storage.selectedColor.type - - # User selects a new color, reflect the change - inputColor: (color) -> - _hasClass = this[0].className.match /(is\-\-color\_(\w+))\s/ - - this.removeClass _hasClass[1] if _hasClass - this.addClass "is--color_#{ color.type }" - - _color = color.color - - # Convert the color to HSV - # _hsv needs to be an array [h, s, v] - _hsv = switch color.type - when 'hex' then Convert.rgbToHsv Convert.hexToRgb _color - when 'hexa' then Convert.rgbToHsv Convert.hexaToRgb _color - when 'rgb', 'rgba' then Convert.rgbToHsv _color - when 'hsl', 'hsla' then Convert.hslToHsv [ - (parseInt color.regexMatch[1], 10) - (parseInt color.regexMatch[2], 10) / 100 - (parseInt color.regexMatch[3], 10) / 100] - return unless _hsv - - # Set all controls in the right place to reflect the input color - - # Get the hue. 360 is the H max - @setHue (HueSelector.height / 360) * _hsv[0] - - # Get the saturation - _saturationX = Math.max 1, SaturationSelector.width * _hsv[1] - _saturationY = Math.max 1, SaturationSelector.height * (1 - _hsv[2]) - @setSaturation _saturationX, _saturationY - @refreshSaturationCanvas() - - # Get the alpha - _alpha = switch color.type - when 'rgba' then color.regexMatch[7] - when 'hexa' then color.regexMatch[4] - when 'hsla' then color.regexMatch[4] - # Set the alpha - if _alpha then @setAlpha AlphaSelector.height * (1 - parseFloat _alpha) - else if not _alpha then @setAlpha 0 - - @refreshAlphaCanvas() - @setColor color - - # ------------------------------------- - # Selection - # ------------------------------------- - - # Select the color in the editor - selectColor: -> - _color = @storage.selectedColor - _editor = atom.workspace.getActiveEditor() - - return unless _color - - # Clear selections and select the color - _editor.clearSelections() - _editor.addSelectionForBufferRange - start: - column: _color.index - row: _color.row - end: - column: _color.end - row: _color.row - - replaceColor: -> - _color = @storage.selectedColor - _newColor = @storage.pickedColor - _editor = atom.workspace.getActiveEditor() - - return unless _color - - @selectColor() - - # Replace the text - _editor.replaceSelectedText null, => return _newColor - - # Clear selections and select the color - _editor.clearSelections() - _editor.addSelectionForBufferRange - start: - column: _color.index - row: _color.row - end: - column: _color.index + _newColor.length - row: _color.row diff --git a/.atom/packages/color-picker/lib/ColorPicker.coffee b/.atom/packages/color-picker/lib/ColorPicker.coffee deleted file mode 100644 index fdade44..0000000 --- a/.atom/packages/color-picker/lib/ColorPicker.coffee +++ /dev/null @@ -1,157 +0,0 @@ -# ---------------------------------------------------------------------------- -# ColorPicker -# ---------------------------------------------------------------------------- - - Convert = require './ColorPicker-convert' - ConditionalContextMenu = require './conditional-contextmenu' - VariableInspector = require './variable-inspector' - - _regexes = require './ColorPicker-regexes' - - # ------------------------------------- - # Public functionality - # ------------------------------------- - module.exports = - view: null - match: null - - activate: -> - atom.workspaceView.command "color-picker:open", => @open true - - ConditionalContextMenu.item { - label: 'Color picker' - command: 'color-picker:open', - }, => return true if @match = @getMatchAtCursor() - - ColorPickerView = require './ColorPicker-view' - @view = new ColorPickerView - - deactivate: -> @view.destroy() - - # Get a match at the current cursor position - getMatchAtCursor: -> - return unless _editor = atom.workspace.getActiveEditor() - - _line = _editor.getCursor().getCurrentBufferLine() - _cursorBuffer = _editor.getCursorBufferPosition() - _cursorRow = _cursorBuffer.row - _cursorColumn = _cursorBuffer.column - - return @matchAtPosition _cursorColumn, (@matchesOnLine _line, _cursorRow) - - # Match the current line against the regexes - # @String line - # @Number cursorRow - matchesOnLine: (line, cursorRow) -> - return unless line and typeof cursorRow is 'number' - - _filteredMatches = []; for { type, regex } in _regexes - continue unless _matches = line.match regex - - for match in _matches - # Skip if the match has “been used” already - continue if (_index = line.indexOf match) is -1 - - _filteredMatches.push - match: match - regexMatch: match.match RegExp regex.source, 'i' - type: type - index: _index - end: _index + match.length - row: cursorRow - - # Make sure the indices are correct by removing - # the instances from the string after use - line = line.replace match, (Array match.length + 1).join ' ' - return unless _filteredMatches.length > 0 - - return _filteredMatches - - # Get a single match on a position based on a match array - # as seen in matchesOnLine - # @Number column - # @Array matches - matchAtPosition: (column, matches) -> - return unless column and matches - - _match = do -> for match in matches - if match.index <= column and match.end >= column - return match - return _match - - open: (getMatch = false) -> - if getMatch then @match = @getMatchAtCursor() - - if not @match - randomRGBFragment = -> (Math.random() * 255) << 0 - - _line = '#' + Convert.rgbToHex [randomRGBFragment(), randomRGBFragment(), randomRGBFragment()] - _cursorBuffer = atom.workspace.getActiveEditor().getCursorBufferPosition() - _cursorRow = _cursorBuffer.row - _cursorColumn = _cursorBuffer.column - - _match = (@matchesOnLine _line, _cursorRow)[0] - _match.index = _cursorColumn - _match.end = _cursorColumn - - @match = _match - return unless @match - - @view.reset() - @setMatchColor() - @view.open() - - # Set the color of a match to its object, and then send it - # to the color picker view - # @Object match - # @Function callback - setMatchColor: -> - return unless @match - - @view.storage.selectedColor = null - - if @match.hasOwnProperty 'color' - @view.storage.selectedColor = @match - @view.inputColor @match - return - - _callback = => @setMatchColor() - - return switch @match.type - when 'variable:sass' then @setVariableDefinitionColor @match, _callback - when 'variable:less' then @setVariableDefinitionColor @match, _callback - else do => @match.color = @match.match; _callback @match - - # Set the variable definition by sending it through a - # provided callback when found - # @Object match - # @Function callback - setVariableDefinitionColor: (match, callback) -> - return unless match and callback - - _matchRegex = regex for { type, regex } in _regexes when type is match.type - _variableName = (match.match.match RegExp _matchRegex.source, 'i')[2] # hahaha - - (@findVariableDefinition _variableName, match.type).then ({ color, pointer }) -> - match.color = color.match - match.type = color.type - match.pointer = pointer - - callback match - - # Find variable definition by searching recursively until a - # non-variable (a color) is found - # @String name - # @String type - findVariableDefinition: (name, type, pointer) -> - return (VariableInspector.findDefinition name, type).then (definition) => - pointer ?= definition.pointer # remember the initial pointer - _matches = @matchesOnLine definition.definition, 1 - - return @view.error() unless _matches and _color = _matches[0] - - # Continue digging for the truth and real definition - if (_color.type.split ':')[0] is 'variable' - return @findVariableDefinition _color.regexMatch[2], _color.type, pointer - - return { color: _color, pointer: pointer } diff --git a/.atom/packages/color-picker/lib/conditional-contextmenu.coffee b/.atom/packages/color-picker/lib/conditional-contextmenu.coffee deleted file mode 100644 index bc737e6..0000000 --- a/.atom/packages/color-picker/lib/conditional-contextmenu.coffee +++ /dev/null @@ -1,22 +0,0 @@ -# ---------------------------------------------------------------------------- -# Conditional Context Menu items -# ---------------------------------------------------------------------------- - - module.exports = - # Add a context menu item and show it or not based on a condition - # @Object definition { label: '', command: '' } - # @Function condition - item: (definition, condition) -> atom.workspaceView.contextmenu => - _label = definition.label - _command = definition.command - - _definitions = atom.contextMenu.definitions['.overlayer'] - _hasItem = true for item in _definitions when item.label is _label and item.command is _command - - if condition() then unless _hasItem - _definitions.unshift - label: _label - command: _command - else for item, i in _definitions when item - if item.label is _label - _definitions.splice i, 1 diff --git a/.atom/packages/color-picker/lib/variable-inspector.coffee b/.atom/packages/color-picker/lib/variable-inspector.coffee deleted file mode 100644 index fe49805..0000000 --- a/.atom/packages/color-picker/lib/variable-inspector.coffee +++ /dev/null @@ -1,86 +0,0 @@ -# ---------------------------------------------------------------------------- -# Variable inspector -# ---------------------------------------------------------------------------- - - _definitions = {} - - # ------------------------------------- - # Variable patterns - # ------------------------------------- - _variablePatterns = { - 'variable:sass': '\\${{ VARIABLE }}[\\s]*\\:[\\s]*(.+)[\\;|\\n]?' - 'variable:less': '\\@{{ VARIABLE }}[\\s]*\\:[\\s]*(.+)[\\;|\\n]?' - } - - # ------------------------------------- - # File path patterns - # ------------------------------------- - _globPatterns = { - 'variable:sass': ['**/*.scss', '**/*.sass'] - 'variable:less': ['**/*.less'] - } - - # ------------------------------------- - # Public functionality - # ------------------------------------- - module.exports = - # Find a variable definition in the project - # @String name - # @String type - findDefinition: (name, type) -> - return unless _regexString = _variablePatterns[type] - _regex = RegExp (_regexString.replace '{{ VARIABLE }}', name) - - _results = [] - - # We already know where the definition is - if _definition = _definitions[name] - _pointer = _definition.pointer - - return (atom.project.bufferForPath _pointer.filePath).then (buffer) => - _text = buffer.getTextInRange _pointer.range - _match = _text.match _regex - - unless _match - _definitions[name] = null - return @findDefinition name, type - - _definition.definition = _match[1] - return _definition - - _options = unless _globPatterns[type] then null else { - paths: _globPatterns[type] - } - - # We don't know where the definition is, look it up - atom.project.scan _regex, _options, (result) -> - _results.push result - .then => - # Figure out what file is holding the definition - # Assume it's the one closest to the current path - _targetPath = atom.workspaceView.getActivePaneItem().getPath() - _targetFragments = _targetPath.split '/' - - _bestMatch = null - _bestMatchHits = 0 - - for result in _results - _thisMatchHits = 0 - _pathFragments = result.filePath.split '/' - _thisMatchHits++ for pathFragment, i in _pathFragments when pathFragment is _targetFragments[i] - - if _thisMatchHits > _bestMatchHits - _bestMatch = result - _bestMatchHits = _thisMatchHits - return this unless _bestMatch and _match = _bestMatch.matches[0] - - _definitions[name] = { - name: name - type: type - - pointer: - filePath: _bestMatch.filePath - range: _match.range - } - - return @findDefinition name, type diff --git a/.atom/packages/color-picker/menus/color-picker.cson b/.atom/packages/color-picker/menus/color-picker.cson deleted file mode 100644 index c83a922..0000000 --- a/.atom/packages/color-picker/menus/color-picker.cson +++ /dev/null @@ -1,4 +0,0 @@ -# See https://atom.io/docs/latest/creating-a-package#menus for more details -'context-menu': - '.overlayer': - 'Color picker': 'color-picker:open' diff --git a/.atom/packages/color-picker/package.json b/.atom/packages/color-picker/package.json deleted file mode 100644 index 7b7c059..0000000 --- a/.atom/packages/color-picker/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "color-picker", - "main": "./lib/ColorPicker", - "version": "1.1.0", - "private": true, - "description": "A Color Picker for the Atom Editor. Right click a color and select color picker to open it.", - "repository": { - "type": "git", - "url": "https://github.com/thomaslindstrom/color-picker" - }, - "license": "MIT", - "engines": { - "atom": ">0.50.0" - }, - "readme": "# A Color Picker for Atom\n\nA color picker for Atom. Either right click a color and select `Color picker`, or hit `CMD-SHIFT-C`/`CTRL-ALT-C` anywhere. Currently reads HEX, HEXA, RGB, RGBA, HSL and HSLA.\n\nInspects Sass/LESS variables! [Take a look here.](http://t.hom.as/colorpicker4.mov)\n\n**NEW:** You can now open the color picker whenever, without input, using `CMD-SHIFT-C`/`CTRL-ALT-C`!\n\n## Preview\n\n![Color Picker in action](http://f.cl.ly/items/3g3T401o0o0F2m2O1z1K/output.gif)\n\n## To do\n\n- Stylus variable lookup\n- Context menu convertions\n- Preview color manipulation functions (lighten, darken)\n- Edit the color value\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/thomaslindstrom/color-picker/issues" - }, - "homepage": "https://github.com/thomaslindstrom/color-picker", - "_id": "color-picker@1.1.0", - "dist": { - "shasum": "10f79bca9751160c5f2a2c97bbbfdff3fe68f26c" - }, - "_resolved": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114614-4292-pnjmsa\\package.tgz", - "_from": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114614-4292-pnjmsa\\package.tgz" -} diff --git a/.atom/packages/color-picker/stylesheets/AlphaSelector.less b/.atom/packages/color-picker/stylesheets/AlphaSelector.less deleted file mode 100644 index cc0205e..0000000 --- a/.atom/packages/color-picker/stylesheets/AlphaSelector.less +++ /dev/null @@ -1,59 +0,0 @@ -// --------------------------------------------------------------------------- -// Alpha selector -// --------------------------------------------------------------------------- - @import (reference) "color-picker.less"; - - .ColorPicker-alphaSelectorWrapper { - position: absolute; - bottom: @controls-margin; right: 20px + (@controls-margin * 2); - pointer-events: none; - - &:before { - content: ''; - background: @image-transparency; - background-size: 10px 10px; - width: 100%; height: 100%; - position: absolute; - top: 0; right: 0; left: 0; - z-index: -1; - opacity: .1; } - &:after { - content: ''; - border: 2px solid @color-ui; - border-radius: 3px; - box-shadow: inset 0 0 1px rgba(0, 0, 0, .5); - position: absolute; - top: -2px; right: -2px; bottom: -2px; left: -2px; - z-index: 10; } - } - - // ------------------------------------- - // Current selection - // ------------------------------------- - .ColorPicker-alphaSelection { - width: 18px; height: 7px; - margin-top: -4px; - border: 2px solid #fff; - border-radius: 1px; - box-shadow: - 0 0 1px rgba(0, 0, 0, .3), - inset 0 0 1px rgba(0, 0, 0, .6); - position: absolute; - top: 0; right: 1px; left: 1px; - z-index: 20; - pointer-events: none; } - - // ------------------------------------- - // Selector bar - // ------------------------------------- - .ColorPicker-alphaSelector { - width: 20px; height: @controls-height; - display: block; - cursor: -webkit-grab; - cursor: grab; - pointer-events: all; - - &:active { - cursor: -webkit-grabbing; - cursor: grabbing; } - } diff --git a/.atom/packages/color-picker/stylesheets/ColorOutput.less b/.atom/packages/color-picker/stylesheets/ColorOutput.less deleted file mode 100644 index 8a69d74..0000000 --- a/.atom/packages/color-picker/stylesheets/ColorOutput.less +++ /dev/null @@ -1,138 +0,0 @@ -// --------------------------------------------------------------------------- -// Color output -// --------------------------------------------------------------------------- - @import (reference) "color-picker.less"; - - .ColorPicker-color { - width: 100%; height: @picker-height--pointer; - cursor: pointer; - text-align: center; - border-radius: 2px 2px 0 0; - position: absolute; - top: 0; - - &:before { - content: ''; - background: @image-transparency; - background-size: 10px 10px; - width: 100%; height: 100%; - position: absolute; - top: 0; right: 0; left: 0; - z-index: -1; - opacity: .1; } - &:after { - content: ''; - width: 0; height: 0; - margin: auto; - border: 8px solid transparent; - border-bottom-color: inherit; - position: absolute; - top: -16px; left: 0; right: 0; } - - .no--arrow &:after { display: none; } - .is--pointer & { border-radius: 2px; } - .is--searching &:after { display: none; } - } - - .ColorPicker-value, - .ColorPicker-initial { - font-family: 'Source Code Pro', @font-family; - color: #fff; - text-align: center; - text-shadow: - 0 2px 30px rgba(0, 0, 0, .5), - 0 0 2px rgba(0, 0, 0, .3), - 0 1px 1px rgba(0, 0, 0, .1), - 0 1px rgba(0, 0, 0, .1), - 0 -1px 4px rgba(0, 0, 0, .1), - 0 0 1px rgba(0, 0, 0, .3); } - - // ------------------------------------- - // Current color - // ------------------------------------- - .ColorPicker-value { - font-size: 17px; - font-weight: 400; - position: absolute; - top: 50%; right: 0; left: 0; - pointer-events: none; - - -webkit-transition: -webkit-transform .3s; - -webkit-transform: translate(0, -105%); - - -webkit-backface-visibility: hidden; - -webkit-transform-style: preserve-3d; - - .is--color_hsla & { font-size: 15px; } - - .ColorPicker-color:hover & { -webkit-transform: translate(0, -140%); } - - .is--initial & { -webkit-transform: translate(0, -50%); } - .is--initial .ColorPicker-color:hover & { -webkit-transform: translate(0, -90%); } - .is--pointer & { -webkit-transform: translate(0, -90%); } - .is--pointer .ColorPicker-color:hover & { -webkit-transform: translate(0, -95%) scale(1.1); } - - .is--error &, - .is--error .ColorPicker-color:hover & { -webkit-transform: translate(0, -50%); } - - .is--pointer &:after { - content: attr(data-variable); - font-size: 11px; - color: #fff; - text-overflow: ellipsis; - text-shadow: 0 0 1px #000; - white-space: nowrap; - margin: auto; - overflow: hidden; - position: absolute; - top: 30px; right: 5px; left: 5px; } - - .is--searching & { display: none; } - - .is--error &:after { - content: 'No color found :('; - font-size: 11px; - color: #000; - text-shadow: none; - margin: auto; - overflow: hidden; - top: -5px; right: 5px; left: 5px; } - } - - // ------------------------------------- - // Initial color - // ------------------------------------- - .ColorPicker-initialWrapper { - background: #fff; - width: 100%; - cursor: pointer; - position: absolute; - top: @picker-height--pointer - 30; - - -webkit-backface-visibility: hidden; - -webkit-transition: -webkit-transform .3s; - -webkit-transform: translate3d(0, 0, 0); - - &:hover { -webkit-transform: translate(0, -20%); } - - .is--initial & { - pointer-events: none; - -webkit-transform: translate(0, 100%); } - - .is--pointer & { display: none; } - - &:before { - content: ''; - background: @image-transparency; - background-size: 10px 10px; - width: 100%; height: 100%; - position: absolute; - top: 0; right: 0; left: 0; - z-index: -1; - opacity: .1; } - } - - .ColorPicker-initial { - font-weight: 300; - padding: 6px 0 20px; - pointer-events: none; } diff --git a/.atom/packages/color-picker/stylesheets/HueSelector.less b/.atom/packages/color-picker/stylesheets/HueSelector.less deleted file mode 100644 index 8b5065a..0000000 --- a/.atom/packages/color-picker/stylesheets/HueSelector.less +++ /dev/null @@ -1,47 +0,0 @@ -// --------------------------------------------------------------------------- -// Hue selector -// --------------------------------------------------------------------------- - @import (reference) "color-picker.less"; - - .ColorPicker-hueSelectorWrapper { - position: absolute; - bottom: @controls-margin; right: @controls-margin; - pointer-events: none; - - &:after { - content: ''; - border: 2px solid @color-ui; - border-radius: 3px; - box-shadow: inset 0 0 1px rgba(0, 0, 0, .5); - position: absolute; - top: -2px; right: -2px; bottom: -2px; left: -2px; - z-index: 10; } - } - - // ------------------------------------- - // Current selection - // ------------------------------------- - .ColorPicker-hueSelection { - width: 18px; height: 7px; - margin-top: -4px; - border: 2px solid #fff; - border-radius: 1px; - box-shadow: - 0 0 1px rgba(0, 0, 0, .3), - inset 0 0 1px rgba(0, 0, 0, .6); - position: absolute; - top: 1px; right: 1px; left: 1px; - z-index: 20; - pointer-events: none; } - - // ------------------------------------- - // Selector bar - // ------------------------------------- - .ColorPicker-hueSelector { - width: 20px; height: @controls-height; - display: block; - cursor: -webkit-grab; - pointer-events: all; - - &:active { cursor: -webkit-grabbing; } - } diff --git a/.atom/packages/color-picker/stylesheets/Loader.less b/.atom/packages/color-picker/stylesheets/Loader.less deleted file mode 100644 index d9fcceb..0000000 --- a/.atom/packages/color-picker/stylesheets/Loader.less +++ /dev/null @@ -1,46 +0,0 @@ -// --------------------------------------------------------------------------- -// Loader -// --------------------------------------------------------------------------- - @import (reference) "color-picker.less"; - - .ColorPicker-loader { - background: rgba(0, 0, 0, .4); - width: 100%; height: @picker-height--pointer; - font-size: 0; - text-align: center; - pointer-events: none; - position: absolute; - top: 0; - z-index: 40; - opacity: 0; - - -webkit-transition: opacity .3s; - - .is--searching & { opacity: 1; } - .is--error & { opacity: 0; } - } - - .is--searching .ColorPicker-loaderDot { - background: #fff; - width: 14px; height: 14px; - border-radius: 100%; - margin: -7px 4px 0; - position: relative; - top: 50%; - display: inline-block; - - -webkit-transform-style: preserve-3d; - -webkit-backface-visibility: hidden; - -webkit-animation: inflate alternate infinite .7s ease-in-out; - -webkit-animation-fill-mode: both; - -webkit-animation-play-state: running; - - &:nth-child(2) { -webkit-animation-delay: .1s; } - &:nth-child(3) { -webkit-animation-delay: .2s; } - } - - - @-webkit-keyframes inflate { - 0%, 40% { -webkit-transform: scale(0); } - 100% { -webkit-transform: scale(1); } - } diff --git a/.atom/packages/color-picker/stylesheets/SaturationSelector.less b/.atom/packages/color-picker/stylesheets/SaturationSelector.less deleted file mode 100644 index 319405c..0000000 --- a/.atom/packages/color-picker/stylesheets/SaturationSelector.less +++ /dev/null @@ -1,44 +0,0 @@ -// --------------------------------------------------------------------------- -// Saturation selector -// --------------------------------------------------------------------------- - @import (reference) "color-picker.less"; - - .ColorPicker-saturationSelectorWrapper { - position: absolute; - bottom: @controls-margin; left: @controls-margin; - pointer-events: none; - - &:after { - content: ''; - border: 2px solid @color-ui; - border-radius: 3px; - box-shadow: inset 0 0 1px rgba(0, 0, 0, .5); - position: absolute; - top: -2px; right: -2px; bottom: -2px; left: -2px; - z-index: 10; } - } - - // ------------------------------------- - // Current selection - // ------------------------------------- - .ColorPicker-saturationSelection { - width: 10px; height: 10px; - margin: -5px 0 0 -5px; - border: 2px solid #fff; - border-radius: 100%; - box-shadow: - 0 0 1px rgba(0, 0, 0, .3), - inset 0 0 1px rgba(0, 0, 0, .8); - position: absolute; - top: 100%; left: 0; - z-index: 20; - pointer-events: none; } - - // ------------------------------------- - // Selector area - // ------------------------------------- - .ColorPicker-saturationSelector { - width: @controls-height; height: @controls-height; - cursor: crosshair; - display: block; - pointer-events: all; } diff --git a/.atom/packages/color-picker/stylesheets/color-picker.less b/.atom/packages/color-picker/stylesheets/color-picker.less deleted file mode 100644 index 1bebac3..0000000 --- a/.atom/packages/color-picker/stylesheets/color-picker.less +++ /dev/null @@ -1,69 +0,0 @@ -// The ui-variables file is provided by base themes provided by Atom. -// -// See https://github.com/atom/atom-dark-ui/blob/master/stylesheets/ui-variables.less -// for a full listing of what's available. - @import "ui-variables"; - -// --------------------------------------------------------------------------- -// Color picker: style -// --------------------------------------------------------------------------- - @color-ui: #ebebeb; - - @picker-width: 260px; - @picker-height: 300px; - @picker-height--pointer: 100px; - - @controls-height: 180px; - @controls-margin: 10px; - - @image-transparency: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAJElEQVQIW2PcvXv3fwYg6OzsBFEMjBgCLi4uYBXl5eUQFegCAIYVD/syLxKnAAAAAElFTkSuQmCC); - - .ColorPicker { - background: #fff; - width: @picker-width; height: @picker-height; - border-radius: 3px 3px 2px 2px; - box-shadow: 0 10px 30px 10px rgba(0, 0, 0, .3); - position: absolute; - top: 50%; bottom: 0; - z-index: 40; - visibility: hidden; - opacity: 0; - pointer-events: none; - - -webkit-transform-origin: 50% 0; - -webkit-transition: - -webkit-transform .15s, - opacity .15s, - visibility 0 .15s; - -webkit-transform: scale(.6); - - -webkit-backface-visibility: hidden; - -webkit-transform-style: preserve-3d; - - &.is--visible { - visibility: visible; - opacity: 1; - pointer-events: all; - - -webkit-transition: - -webkit-transform .2s, - opacity .2s; - -webkit-transform: scale(1); } - - &.is--pointer { height: @picker-height--pointer; } - } - - // ------------------------------------- - // Picker - // ------------------------------------- - .ColorPicker-picker { - background: @color-ui; - width: 100%; height: @controls-height + (@controls-margin * 2); - box-shadow: 0 -1px rgba(0, 0, 0, .2); - position: absolute; - bottom: 0; - z-index: 1; - border-radius: 0 0 3px 3px; - - .is--pointer & { display: none; } - } diff --git a/.atom/packages/editor-stats/.npmignore b/.atom/packages/editor-stats/.npmignore deleted file mode 100644 index 3c3629e..0000000 --- a/.atom/packages/editor-stats/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/.atom/packages/editor-stats/.travis.yml b/.atom/packages/editor-stats/.travis.yml deleted file mode 100644 index 31be69d..0000000 --- a/.atom/packages/editor-stats/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: objective-c - -notifications: - email: - on_success: never - on_failure: change - -script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh' diff --git a/.atom/packages/editor-stats/CONTRIBUTING.md b/.atom/packages/editor-stats/CONTRIBUTING.md deleted file mode 100644 index 0fd0ad6..0000000 --- a/.atom/packages/editor-stats/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -See the [Atom contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md) diff --git a/.atom/packages/editor-stats/LICENSE.md b/.atom/packages/editor-stats/LICENSE.md deleted file mode 100644 index 4d231b4..0000000 --- a/.atom/packages/editor-stats/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 GitHub Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/editor-stats/README.md b/.atom/packages/editor-stats/README.md deleted file mode 100644 index 7d2cb22..0000000 --- a/.atom/packages/editor-stats/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Editor Stats package [![Build Status](https://travis-ci.org/atom/editor-stats.svg?branch=master)](https://travis-ci.org/atom/editor-stats) - -View a graph of your mouse and keyboard activity for the last 6 hours. - -The blue bar indicates the time of greatest activity. - -Use `cmd-alt-s` to open and close the graph. - -![](https://f.cloud.github.com/assets/671378/2262223/843b1172-9e57-11e3-9c60-8d28d542f39c.png) diff --git a/.atom/packages/editor-stats/keymaps/editor-stats.cson b/.atom/packages/editor-stats/keymaps/editor-stats.cson deleted file mode 100644 index 8d73ea5..0000000 --- a/.atom/packages/editor-stats/keymaps/editor-stats.cson +++ /dev/null @@ -1,5 +0,0 @@ -'.platform-darwin': - 'cmd-alt-s': 'editor-stats:toggle' - -'.platform-win32': - 'alt-ctrl-s': 'editor-stats:toggle' diff --git a/.atom/packages/editor-stats/lib/editor-stats-view.coffee b/.atom/packages/editor-stats/lib/editor-stats-view.coffee deleted file mode 100644 index ecca068..0000000 --- a/.atom/packages/editor-stats/lib/editor-stats-view.coffee +++ /dev/null @@ -1,103 +0,0 @@ -_ = require 'underscore-plus' -{$, ScrollView} = require 'atom' -d3 = require 'd3-browserify' - -module.exports = -class EditorStatsView extends ScrollView - @activate: -> - new EditorStatsView - - @content: -> - @div class: 'editor-stats-wrapper', tabindex: -1, => - @div class: 'editor-stats', outlet: 'editorStats' - - pt: 15 - pl: 10 - pb: 3 - pr: 25 - - initialize: -> - super - - resizer = => - return unless @isOnDom() - @draw() - @update() - @subscribe $(window), 'resize', _.debounce(resizer, 300) - - draw: -> - @editorStats.empty() - @x ?= d3.scale.ordinal().domain d3.range(@stats.hours * 60) - @y ?= d3.scale.linear() - w = atom.workspaceView.vertical.width() - h = @height() - data = d3.entries @stats.eventLog - max = d3.max data, (d) -> d.value - - @x.rangeBands [0, w - @pl - @pr], 0.2 - @y.domain([0, max]).range [h - @pt - @pb, 0] - - @xaxis ?= d3.svg.axis().scale(@x).orient('top') - .tickSize(-h + @pt + @pb) - .tickFormat (d) => - d = new Date(@stats.startDate.getTime() + (d * 6e4)) - mins = d.getMinutes() - mins = "0#{mins}" if mins <= 9 - "#{d.getHours()}:#{mins}" - - vis = d3.select(@editorStats.get(0)).append('svg') - .attr('width', w) - .attr('height', h) - .append('g') - .attr('transform', "translate(#{@pl},#{@pt})") - - vis.append('g') - .attr('class', 'x axis') - .call(@xaxis) - .selectAll('g') - .classed('minor', (d, i) -> i % 5 == 0 && i % 15 != 0) - .style 'display', (d, i) -> - if i % 15 == 0 || i % 5 == 0 || i == data.length - 1 - 'block' - else - 'none' - - @bars = vis.selectAll('rect.bar') - .data(data) - .enter().append('rect') - .attr('x', (d, i) => @x i) - .attr('height', (d, i) => h - @y(d.value) - @pt - @pb) - .attr('y', (d) => @y(d.value)) - .attr('width', @x.rangeBand()) - .attr('class', 'bar') - - clearInterval(@updateInterval) - updater = => @update() if @isOnDom() - setTimeout(updater, 100) - @updateInterval = setInterval(updater, 5000) - - update: -> - newData = d3.entries @stats.eventLog - max = d3.max newData, (d) -> d.value - @y.domain [0, max] - h = @height() - @bars.data(newData).transition() - .attr('height', (d, i) => h - @y(d.value) - @pt - @pb) - .attr('y', (d, i) => @y(d.value)) - @bars.classed('max', (d, i) -> d.value == max) - - toggle: (@stats) -> - if @hasParent() - @detach() - else - @attach() - - attach: -> - atom.workspaceView.prependToBottom(this) - @draw() - - detach: -> - super - - clearInterval(@updateInterval) - atom.workspaceView.focus() diff --git a/.atom/packages/editor-stats/lib/editor-stats.coffee b/.atom/packages/editor-stats/lib/editor-stats.coffee deleted file mode 100644 index 4353aa4..0000000 --- a/.atom/packages/editor-stats/lib/editor-stats.coffee +++ /dev/null @@ -1,17 +0,0 @@ -StatsTracker = require './stats-tracker' - -module.exports = - activate: -> - @stats = new StatsTracker() - atom.workspaceView.command 'editor-stats:toggle', => - @createView().toggle(@stats) - - deactivate: -> - @editorStatsView = null - @stats = null - - createView: -> - unless @editorStatsView - EditorStatsView = require './editor-stats-view' - @editorStatsView = new EditorStatsView() - @editorStatsView diff --git a/.atom/packages/editor-stats/lib/stats-tracker.coffee b/.atom/packages/editor-stats/lib/stats-tracker.coffee deleted file mode 100644 index 27ecc7f..0000000 --- a/.atom/packages/editor-stats/lib/stats-tracker.coffee +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = -class StatsTracker - startDate: new Date - hours: 6 - eventLog: {} - - constructor: -> - date = new Date(@startDate) - future = new Date(date.getTime() + (36e5 * @hours)) - @eventLog[@time(date)] = 0 - - while date < future - @eventLog[@time(date)] = 0 - - atom.workspaceView.on 'keydown', => @track() - atom.workspaceView.on 'mouseup', => @track() - - clear: -> - @eventLog = {} - - track: -> - date = new Date - times = @time date - @eventLog[times] ?= 0 - @eventLog[times] += 1 - @eventLog.shift() if @eventLog.length > (@hours * 60) - - time: (date) -> - date.setTime(date.getTime() + 6e4) - hour = date.getHours() - minute = date.getMinutes() - "#{hour}:#{minute}" diff --git a/.atom/packages/editor-stats/menus/editor-stats.cson b/.atom/packages/editor-stats/menus/editor-stats.cson deleted file mode 100644 index 5407986..0000000 --- a/.atom/packages/editor-stats/menus/editor-stats.cson +++ /dev/null @@ -1,9 +0,0 @@ -'menu': [ - 'label': 'Packages' - 'submenu': [ - 'label': 'Editor Stats' - 'submenu': [ - { 'label': 'Toggle', 'command': 'editor-stats:toggle' } - ] - ] -] diff --git a/.atom/packages/editor-stats/node_modules/d3-browserify/README.md b/.atom/packages/editor-stats/node_modules/d3-browserify/README.md deleted file mode 100644 index 696b4f3..0000000 --- a/.atom/packages/editor-stats/node_modules/d3-browserify/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# d3-browserify - -D3 distribution that used for browserify-like environment. diff --git a/.atom/packages/editor-stats/node_modules/d3-browserify/d3.js b/.atom/packages/editor-stats/node_modules/d3-browserify/d3.js deleted file mode 100644 index 1b07d02..0000000 --- a/.atom/packages/editor-stats/node_modules/d3-browserify/d3.js +++ /dev/null @@ -1,9293 +0,0 @@ -module.exports = function() { - var d3 = { - version: "3.3.13" - }; - if (!Date.now) Date.now = function() { - return +new Date(); - }; - var d3_arraySlice = [].slice, d3_array = function(list) { - return d3_arraySlice.call(list); - }; - var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window; - try { - d3_array(d3_documentElement.childNodes)[0].nodeType; - } catch (e) { - d3_array = function(list) { - var i = list.length, array = new Array(i); - while (i--) array[i] = list[i]; - return array; - }; - } - try { - d3_document.createElement("div").style.setProperty("opacity", 0, ""); - } catch (error) { - var d3_element_prototype = d3_window.Element.prototype, d3_element_setAttribute = d3_element_prototype.setAttribute, d3_element_setAttributeNS = d3_element_prototype.setAttributeNS, d3_style_prototype = d3_window.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty; - d3_element_prototype.setAttribute = function(name, value) { - d3_element_setAttribute.call(this, name, value + ""); - }; - d3_element_prototype.setAttributeNS = function(space, local, value) { - d3_element_setAttributeNS.call(this, space, local, value + ""); - }; - d3_style_prototype.setProperty = function(name, value, priority) { - d3_style_setProperty.call(this, name, value + "", priority); - }; - } - d3.ascending = function(a, b) { - return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; - }; - d3.descending = function(a, b) { - return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; - }; - d3.min = function(array, f) { - var i = -1, n = array.length, a, b; - if (arguments.length === 1) { - while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined; - while (++i < n) if ((b = array[i]) != null && a > b) a = b; - } else { - while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined; - while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; - } - return a; - }; - d3.max = function(array, f) { - var i = -1, n = array.length, a, b; - if (arguments.length === 1) { - while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined; - while (++i < n) if ((b = array[i]) != null && b > a) a = b; - } else { - while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined; - while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b; - } - return a; - }; - d3.extent = function(array, f) { - var i = -1, n = array.length, a, b, c; - if (arguments.length === 1) { - while (++i < n && !((a = c = array[i]) != null && a <= a)) a = c = undefined; - while (++i < n) if ((b = array[i]) != null) { - if (a > b) a = b; - if (c < b) c = b; - } - } else { - while (++i < n && !((a = c = f.call(array, array[i], i)) != null && a <= a)) a = undefined; - while (++i < n) if ((b = f.call(array, array[i], i)) != null) { - if (a > b) a = b; - if (c < b) c = b; - } - } - return [ a, c ]; - }; - d3.sum = function(array, f) { - var s = 0, n = array.length, a, i = -1; - if (arguments.length === 1) { - while (++i < n) if (!isNaN(a = +array[i])) s += a; - } else { - while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a; - } - return s; - }; - function d3_number(x) { - return x != null && !isNaN(x); - } - d3.mean = function(array, f) { - var n = array.length, a, m = 0, i = -1, j = 0; - if (arguments.length === 1) { - while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j; - } else { - while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j; - } - return j ? m : undefined; - }; - d3.quantile = function(values, p) { - var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h; - return e ? v + e * (values[h] - v) : v; - }; - d3.median = function(array, f) { - if (arguments.length > 1) array = array.map(f); - array = array.filter(d3_number); - return array.length ? d3.quantile(array.sort(d3.ascending), .5) : undefined; - }; - d3.bisector = function(f) { - return { - left: function(a, x, lo, hi) { - if (arguments.length < 3) lo = 0; - if (arguments.length < 4) hi = a.length; - while (lo < hi) { - var mid = lo + hi >>> 1; - if (f.call(a, a[mid], mid) < x) lo = mid + 1; else hi = mid; - } - return lo; - }, - right: function(a, x, lo, hi) { - if (arguments.length < 3) lo = 0; - if (arguments.length < 4) hi = a.length; - while (lo < hi) { - var mid = lo + hi >>> 1; - if (x < f.call(a, a[mid], mid)) hi = mid; else lo = mid + 1; - } - return lo; - } - }; - }; - var d3_bisector = d3.bisector(function(d) { - return d; - }); - d3.bisectLeft = d3_bisector.left; - d3.bisect = d3.bisectRight = d3_bisector.right; - d3.shuffle = function(array) { - var m = array.length, t, i; - while (m) { - i = Math.random() * m-- | 0; - t = array[m], array[m] = array[i], array[i] = t; - } - return array; - }; - d3.permute = function(array, indexes) { - var i = indexes.length, permutes = new Array(i); - while (i--) permutes[i] = array[indexes[i]]; - return permutes; - }; - d3.pairs = function(array) { - var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n); - while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ]; - return pairs; - }; - d3.zip = function() { - if (!(n = arguments.length)) return []; - for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) { - for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n; ) { - zip[j] = arguments[j][i]; - } - } - return zips; - }; - function d3_zipLength(d) { - return d.length; - } - d3.transpose = function(matrix) { - return d3.zip.apply(d3, matrix); - }; - d3.keys = function(map) { - var keys = []; - for (var key in map) keys.push(key); - return keys; - }; - d3.values = function(map) { - var values = []; - for (var key in map) values.push(map[key]); - return values; - }; - d3.entries = function(map) { - var entries = []; - for (var key in map) entries.push({ - key: key, - value: map[key] - }); - return entries; - }; - d3.merge = function(arrays) { - var n = arrays.length, m, i = -1, j = 0, merged, array; - while (++i < n) j += arrays[i].length; - merged = new Array(j); - while (--n >= 0) { - array = arrays[n]; - m = array.length; - while (--m >= 0) { - merged[--j] = array[m]; - } - } - return merged; - }; - var abs = Math.abs; - d3.range = function(start, stop, step) { - if (arguments.length < 3) { - step = 1; - if (arguments.length < 2) { - stop = start; - start = 0; - } - } - if ((stop - start) / step === Infinity) throw new Error("infinite range"); - var range = [], k = d3_range_integerScale(abs(step)), i = -1, j; - start *= k, stop *= k, step *= k; - if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k); - return range; - }; - function d3_range_integerScale(x) { - var k = 1; - while (x * k % 1) k *= 10; - return k; - } - function d3_class(ctor, properties) { - try { - for (var key in properties) { - Object.defineProperty(ctor.prototype, key, { - value: properties[key], - enumerable: false - }); - } - } catch (e) { - ctor.prototype = properties; - } - } - d3.map = function(object) { - var map = new d3_Map(); - if (object instanceof d3_Map) object.forEach(function(key, value) { - map.set(key, value); - }); else for (var key in object) map.set(key, object[key]); - return map; - }; - function d3_Map() {} - d3_class(d3_Map, { - has: function(key) { - return d3_map_prefix + key in this; - }, - get: function(key) { - return this[d3_map_prefix + key]; - }, - set: function(key, value) { - return this[d3_map_prefix + key] = value; - }, - remove: function(key) { - key = d3_map_prefix + key; - return key in this && delete this[key]; - }, - keys: function() { - var keys = []; - this.forEach(function(key) { - keys.push(key); - }); - return keys; - }, - values: function() { - var values = []; - this.forEach(function(key, value) { - values.push(value); - }); - return values; - }, - entries: function() { - var entries = []; - this.forEach(function(key, value) { - entries.push({ - key: key, - value: value - }); - }); - return entries; - }, - forEach: function(f) { - for (var key in this) { - if (key.charCodeAt(0) === d3_map_prefixCode) { - f.call(this, key.substring(1), this[key]); - } - } - } - }); - var d3_map_prefix = "\x00", d3_map_prefixCode = d3_map_prefix.charCodeAt(0); - d3.nest = function() { - var nest = {}, keys = [], sortKeys = [], sortValues, rollup; - function map(mapType, array, depth) { - if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array; - var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values; - while (++i < n) { - if (values = valuesByKey.get(keyValue = key(object = array[i]))) { - values.push(object); - } else { - valuesByKey.set(keyValue, [ object ]); - } - } - if (mapType) { - object = mapType(); - setter = function(keyValue, values) { - object.set(keyValue, map(mapType, values, depth)); - }; - } else { - object = {}; - setter = function(keyValue, values) { - object[keyValue] = map(mapType, values, depth); - }; - } - valuesByKey.forEach(setter); - return object; - } - function entries(map, depth) { - if (depth >= keys.length) return map; - var array = [], sortKey = sortKeys[depth++]; - map.forEach(function(key, keyMap) { - array.push({ - key: key, - values: entries(keyMap, depth) - }); - }); - return sortKey ? array.sort(function(a, b) { - return sortKey(a.key, b.key); - }) : array; - } - nest.map = function(array, mapType) { - return map(mapType, array, 0); - }; - nest.entries = function(array) { - return entries(map(d3.map, array, 0), 0); - }; - nest.key = function(d) { - keys.push(d); - return nest; - }; - nest.sortKeys = function(order) { - sortKeys[keys.length - 1] = order; - return nest; - }; - nest.sortValues = function(order) { - sortValues = order; - return nest; - }; - nest.rollup = function(f) { - rollup = f; - return nest; - }; - return nest; - }; - d3.set = function(array) { - var set = new d3_Set(); - if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); - return set; - }; - function d3_Set() {} - d3_class(d3_Set, { - has: function(value) { - return d3_map_prefix + value in this; - }, - add: function(value) { - this[d3_map_prefix + value] = true; - return value; - }, - remove: function(value) { - value = d3_map_prefix + value; - return value in this && delete this[value]; - }, - values: function() { - var values = []; - this.forEach(function(value) { - values.push(value); - }); - return values; - }, - forEach: function(f) { - for (var value in this) { - if (value.charCodeAt(0) === d3_map_prefixCode) { - f.call(this, value.substring(1)); - } - } - } - }); - d3.behavior = {}; - d3.rebind = function(target, source) { - var i = 1, n = arguments.length, method; - while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]); - return target; - }; - function d3_rebind(target, source, method) { - return function() { - var value = method.apply(source, arguments); - return value === source ? target : value; - }; - } - function d3_vendorSymbol(object, name) { - if (name in object) return name; - name = name.charAt(0).toUpperCase() + name.substring(1); - for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { - var prefixName = d3_vendorPrefixes[i] + name; - if (prefixName in object) return prefixName; - } - } - var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ]; - function d3_noop() {} - d3.dispatch = function() { - var dispatch = new d3_dispatch(), i = -1, n = arguments.length; - while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); - return dispatch; - }; - function d3_dispatch() {} - d3_dispatch.prototype.on = function(type, listener) { - var i = type.indexOf("."), name = ""; - if (i >= 0) { - name = type.substring(i + 1); - type = type.substring(0, i); - } - if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); - if (arguments.length === 2) { - if (listener == null) for (type in this) { - if (this.hasOwnProperty(type)) this[type].on(name, null); - } - return this; - } - }; - function d3_dispatch_event(dispatch) { - var listeners = [], listenerByName = new d3_Map(); - function event() { - var z = listeners, i = -1, n = z.length, l; - while (++i < n) if (l = z[i].on) l.apply(this, arguments); - return dispatch; - } - event.on = function(name, listener) { - var l = listenerByName.get(name), i; - if (arguments.length < 2) return l && l.on; - if (l) { - l.on = null; - listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); - listenerByName.remove(name); - } - if (listener) listeners.push(listenerByName.set(name, { - on: listener - })); - return dispatch; - }; - return event; - } - d3.event = null; - function d3_eventPreventDefault() { - d3.event.preventDefault(); - } - function d3_eventSource() { - var e = d3.event, s; - while (s = e.sourceEvent) e = s; - return e; - } - function d3_eventDispatch(target) { - var dispatch = new d3_dispatch(), i = 0, n = arguments.length; - while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); - dispatch.of = function(thiz, argumentz) { - return function(e1) { - try { - var e0 = e1.sourceEvent = d3.event; - e1.target = target; - d3.event = e1; - dispatch[e1.type].apply(thiz, argumentz); - } finally { - d3.event = e0; - } - }; - }; - return dispatch; - } - d3.requote = function(s) { - return s.replace(d3_requote_re, "\\$&"); - }; - var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; - var d3_subclass = {}.__proto__ ? function(object, prototype) { - object.__proto__ = prototype; - } : function(object, prototype) { - for (var property in prototype) object[property] = prototype[property]; - }; - function d3_selection(groups) { - d3_subclass(groups, d3_selectionPrototype); - return groups; - } - var d3_select = function(s, n) { - return n.querySelector(s); - }, d3_selectAll = function(s, n) { - return n.querySelectorAll(s); - }, d3_selectMatcher = d3_documentElement[d3_vendorSymbol(d3_documentElement, "matchesSelector")], d3_selectMatches = function(n, s) { - return d3_selectMatcher.call(n, s); - }; - if (typeof Sizzle === "function") { - d3_select = function(s, n) { - return Sizzle(s, n)[0] || null; - }; - d3_selectAll = function(s, n) { - return Sizzle.uniqueSort(Sizzle(s, n)); - }; - d3_selectMatches = Sizzle.matchesSelector; - } - d3.selection = function() { - return d3_selectionRoot; - }; - var d3_selectionPrototype = d3.selection.prototype = []; - d3_selectionPrototype.select = function(selector) { - var subgroups = [], subgroup, subnode, group, node; - selector = d3_selection_selector(selector); - for (var j = -1, m = this.length; ++j < m; ) { - subgroups.push(subgroup = []); - subgroup.parentNode = (group = this[j]).parentNode; - for (var i = -1, n = group.length; ++i < n; ) { - if (node = group[i]) { - subgroup.push(subnode = selector.call(node, node.__data__, i, j)); - if (subnode && "__data__" in node) subnode.__data__ = node.__data__; - } else { - subgroup.push(null); - } - } - } - return d3_selection(subgroups); - }; - function d3_selection_selector(selector) { - return typeof selector === "function" ? selector : function() { - return d3_select(selector, this); - }; - } - d3_selectionPrototype.selectAll = function(selector) { - var subgroups = [], subgroup, node; - selector = d3_selection_selectorAll(selector); - for (var j = -1, m = this.length; ++j < m; ) { - for (var group = this[j], i = -1, n = group.length; ++i < n; ) { - if (node = group[i]) { - subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j))); - subgroup.parentNode = node; - } - } - } - return d3_selection(subgroups); - }; - function d3_selection_selectorAll(selector) { - return typeof selector === "function" ? selector : function() { - return d3_selectAll(selector, this); - }; - } - var d3_nsPrefix = { - svg: "http://www.w3.org/2000/svg", - xhtml: "http://www.w3.org/1999/xhtml", - xlink: "http://www.w3.org/1999/xlink", - xml: "http://www.w3.org/XML/1998/namespace", - xmlns: "http://www.w3.org/2000/xmlns/" - }; - d3.ns = { - prefix: d3_nsPrefix, - qualify: function(name) { - var i = name.indexOf(":"), prefix = name; - if (i >= 0) { - prefix = name.substring(0, i); - name = name.substring(i + 1); - } - return d3_nsPrefix.hasOwnProperty(prefix) ? { - space: d3_nsPrefix[prefix], - local: name - } : name; - } - }; - d3_selectionPrototype.attr = function(name, value) { - if (arguments.length < 2) { - if (typeof name === "string") { - var node = this.node(); - name = d3.ns.qualify(name); - return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); - } - for (value in name) this.each(d3_selection_attr(value, name[value])); - return this; - } - return this.each(d3_selection_attr(name, value)); - }; - function d3_selection_attr(name, value) { - name = d3.ns.qualify(name); - function attrNull() { - this.removeAttribute(name); - } - function attrNullNS() { - this.removeAttributeNS(name.space, name.local); - } - function attrConstant() { - this.setAttribute(name, value); - } - function attrConstantNS() { - this.setAttributeNS(name.space, name.local, value); - } - function attrFunction() { - var x = value.apply(this, arguments); - if (x == null) this.removeAttribute(name); else this.setAttribute(name, x); - } - function attrFunctionNS() { - var x = value.apply(this, arguments); - if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x); - } - return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; - } - function d3_collapse(s) { - return s.trim().replace(/\s+/g, " "); - } - d3_selectionPrototype.classed = function(name, value) { - if (arguments.length < 2) { - if (typeof name === "string") { - var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1; - if (value = node.classList) { - while (++i < n) if (!value.contains(name[i])) return false; - } else { - value = node.getAttribute("class"); - while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; - } - return true; - } - for (value in name) this.each(d3_selection_classed(value, name[value])); - return this; - } - return this.each(d3_selection_classed(name, value)); - }; - function d3_selection_classedRe(name) { - return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); - } - function d3_selection_classes(name) { - return name.trim().split(/^|\s+/); - } - function d3_selection_classed(name, value) { - name = d3_selection_classes(name).map(d3_selection_classedName); - var n = name.length; - function classedConstant() { - var i = -1; - while (++i < n) name[i](this, value); - } - function classedFunction() { - var i = -1, x = value.apply(this, arguments); - while (++i < n) name[i](this, x); - } - return typeof value === "function" ? classedFunction : classedConstant; - } - function d3_selection_classedName(name) { - var re = d3_selection_classedRe(name); - return function(node, value) { - if (c = node.classList) return value ? c.add(name) : c.remove(name); - var c = node.getAttribute("class") || ""; - if (value) { - re.lastIndex = 0; - if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name)); - } else { - node.setAttribute("class", d3_collapse(c.replace(re, " "))); - } - }; - } - d3_selectionPrototype.style = function(name, value, priority) { - var n = arguments.length; - if (n < 3) { - if (typeof name !== "string") { - if (n < 2) value = ""; - for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); - return this; - } - if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name); - priority = ""; - } - return this.each(d3_selection_style(name, value, priority)); - }; - function d3_selection_style(name, value, priority) { - function styleNull() { - this.style.removeProperty(name); - } - function styleConstant() { - this.style.setProperty(name, value, priority); - } - function styleFunction() { - var x = value.apply(this, arguments); - if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority); - } - return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; - } - d3_selectionPrototype.property = function(name, value) { - if (arguments.length < 2) { - if (typeof name === "string") return this.node()[name]; - for (value in name) this.each(d3_selection_property(value, name[value])); - return this; - } - return this.each(d3_selection_property(name, value)); - }; - function d3_selection_property(name, value) { - function propertyNull() { - delete this[name]; - } - function propertyConstant() { - this[name] = value; - } - function propertyFunction() { - var x = value.apply(this, arguments); - if (x == null) delete this[name]; else this[name] = x; - } - return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; - } - d3_selectionPrototype.text = function(value) { - return arguments.length ? this.each(typeof value === "function" ? function() { - var v = value.apply(this, arguments); - this.textContent = v == null ? "" : v; - } : value == null ? function() { - this.textContent = ""; - } : function() { - this.textContent = value; - }) : this.node().textContent; - }; - d3_selectionPrototype.html = function(value) { - return arguments.length ? this.each(typeof value === "function" ? function() { - var v = value.apply(this, arguments); - this.innerHTML = v == null ? "" : v; - } : value == null ? function() { - this.innerHTML = ""; - } : function() { - this.innerHTML = value; - }) : this.node().innerHTML; - }; - d3_selectionPrototype.append = function(name) { - name = d3_selection_creator(name); - return this.select(function() { - return this.appendChild(name.apply(this, arguments)); - }); - }; - function d3_selection_creator(name) { - return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? function() { - return this.ownerDocument.createElementNS(name.space, name.local); - } : function() { - return this.ownerDocument.createElementNS(this.namespaceURI, name); - }; - } - d3_selectionPrototype.insert = function(name, before) { - name = d3_selection_creator(name); - before = d3_selection_selector(before); - return this.select(function() { - return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null); - }); - }; - d3_selectionPrototype.remove = function() { - return this.each(function() { - var parent = this.parentNode; - if (parent) parent.removeChild(this); - }); - }; - d3_selectionPrototype.data = function(value, key) { - var i = -1, n = this.length, group, node; - if (!arguments.length) { - value = new Array(n = (group = this[0]).length); - while (++i < n) { - if (node = group[i]) { - value[i] = node.__data__; - } - } - return value; - } - function bind(group, groupData) { - var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; - if (key) { - var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue; - for (i = -1; ++i < n; ) { - keyValue = key.call(node = group[i], node.__data__, i); - if (nodeByKeyValue.has(keyValue)) { - exitNodes[i] = node; - } else { - nodeByKeyValue.set(keyValue, node); - } - keyValues.push(keyValue); - } - for (i = -1; ++i < m; ) { - keyValue = key.call(groupData, nodeData = groupData[i], i); - if (node = nodeByKeyValue.get(keyValue)) { - updateNodes[i] = node; - node.__data__ = nodeData; - } else if (!dataByKeyValue.has(keyValue)) { - enterNodes[i] = d3_selection_dataNode(nodeData); - } - dataByKeyValue.set(keyValue, nodeData); - nodeByKeyValue.remove(keyValue); - } - for (i = -1; ++i < n; ) { - if (nodeByKeyValue.has(keyValues[i])) { - exitNodes[i] = group[i]; - } - } - } else { - for (i = -1; ++i < n0; ) { - node = group[i]; - nodeData = groupData[i]; - if (node) { - node.__data__ = nodeData; - updateNodes[i] = node; - } else { - enterNodes[i] = d3_selection_dataNode(nodeData); - } - } - for (;i < m; ++i) { - enterNodes[i] = d3_selection_dataNode(groupData[i]); - } - for (;i < n; ++i) { - exitNodes[i] = group[i]; - } - } - enterNodes.update = updateNodes; - enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode; - enter.push(enterNodes); - update.push(updateNodes); - exit.push(exitNodes); - } - var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]); - if (typeof value === "function") { - while (++i < n) { - bind(group = this[i], value.call(group, group.parentNode.__data__, i)); - } - } else { - while (++i < n) { - bind(group = this[i], value); - } - } - update.enter = function() { - return enter; - }; - update.exit = function() { - return exit; - }; - return update; - }; - function d3_selection_dataNode(data) { - return { - __data__: data - }; - } - d3_selectionPrototype.datum = function(value) { - return arguments.length ? this.property("__data__", value) : this.property("__data__"); - }; - d3_selectionPrototype.filter = function(filter) { - var subgroups = [], subgroup, group, node; - if (typeof filter !== "function") filter = d3_selection_filter(filter); - for (var j = 0, m = this.length; j < m; j++) { - subgroups.push(subgroup = []); - subgroup.parentNode = (group = this[j]).parentNode; - for (var i = 0, n = group.length; i < n; i++) { - if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { - subgroup.push(node); - } - } - } - return d3_selection(subgroups); - }; - function d3_selection_filter(selector) { - return function() { - return d3_selectMatches(this, selector); - }; - } - d3_selectionPrototype.order = function() { - for (var j = -1, m = this.length; ++j < m; ) { - for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) { - if (node = group[i]) { - if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); - next = node; - } - } - } - return this; - }; - d3_selectionPrototype.sort = function(comparator) { - comparator = d3_selection_sortComparator.apply(this, arguments); - for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator); - return this.order(); - }; - function d3_selection_sortComparator(comparator) { - if (!arguments.length) comparator = d3.ascending; - return function(a, b) { - return a && b ? comparator(a.__data__, b.__data__) : !a - !b; - }; - } - d3_selectionPrototype.each = function(callback) { - return d3_selection_each(this, function(node, i, j) { - callback.call(node, node.__data__, i, j); - }); - }; - function d3_selection_each(groups, callback) { - for (var j = 0, m = groups.length; j < m; j++) { - for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) { - if (node = group[i]) callback(node, i, j); - } - } - return groups; - } - d3_selectionPrototype.call = function(callback) { - var args = d3_array(arguments); - callback.apply(args[0] = this, args); - return this; - }; - d3_selectionPrototype.empty = function() { - return !this.node(); - }; - d3_selectionPrototype.node = function() { - for (var j = 0, m = this.length; j < m; j++) { - for (var group = this[j], i = 0, n = group.length; i < n; i++) { - var node = group[i]; - if (node) return node; - } - } - return null; - }; - d3_selectionPrototype.size = function() { - var n = 0; - this.each(function() { - ++n; - }); - return n; - }; - function d3_selection_enter(selection) { - d3_subclass(selection, d3_selection_enterPrototype); - return selection; - } - var d3_selection_enterPrototype = []; - d3.selection.enter = d3_selection_enter; - d3.selection.enter.prototype = d3_selection_enterPrototype; - d3_selection_enterPrototype.append = d3_selectionPrototype.append; - d3_selection_enterPrototype.empty = d3_selectionPrototype.empty; - d3_selection_enterPrototype.node = d3_selectionPrototype.node; - d3_selection_enterPrototype.call = d3_selectionPrototype.call; - d3_selection_enterPrototype.size = d3_selectionPrototype.size; - d3_selection_enterPrototype.select = function(selector) { - var subgroups = [], subgroup, subnode, upgroup, group, node; - for (var j = -1, m = this.length; ++j < m; ) { - upgroup = (group = this[j]).update; - subgroups.push(subgroup = []); - subgroup.parentNode = group.parentNode; - for (var i = -1, n = group.length; ++i < n; ) { - if (node = group[i]) { - subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j)); - subnode.__data__ = node.__data__; - } else { - subgroup.push(null); - } - } - } - return d3_selection(subgroups); - }; - d3_selection_enterPrototype.insert = function(name, before) { - if (arguments.length < 2) before = d3_selection_enterInsertBefore(this); - return d3_selectionPrototype.insert.call(this, name, before); - }; - function d3_selection_enterInsertBefore(enter) { - var i0, j0; - return function(d, i, j) { - var group = enter[j].update, n = group.length, node; - if (j != j0) j0 = j, i0 = 0; - if (i >= i0) i0 = i + 1; - while (!(node = group[i0]) && ++i0 < n) ; - return node; - }; - } - d3_selectionPrototype.transition = function() { - var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = d3_transitionInherit || { - time: Date.now(), - ease: d3_ease_cubicInOut, - delay: 0, - duration: 250 - }; - for (var j = -1, m = this.length; ++j < m; ) { - subgroups.push(subgroup = []); - for (var group = this[j], i = -1, n = group.length; ++i < n; ) { - if (node = group[i]) d3_transitionNode(node, i, id, transition); - subgroup.push(node); - } - } - return d3_transition(subgroups, id); - }; - d3_selectionPrototype.interrupt = function() { - return this.each(d3_selection_interrupt); - }; - function d3_selection_interrupt() { - var lock = this.__transition__; - if (lock) ++lock.active; - } - d3.select = function(node) { - var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ]; - group.parentNode = d3_documentElement; - return d3_selection([ group ]); - }; - d3.selectAll = function(nodes) { - var group = d3_array(typeof nodes === "string" ? d3_selectAll(nodes, d3_document) : nodes); - group.parentNode = d3_documentElement; - return d3_selection([ group ]); - }; - var d3_selectionRoot = d3.select(d3_documentElement); - d3_selectionPrototype.on = function(type, listener, capture) { - var n = arguments.length; - if (n < 3) { - if (typeof type !== "string") { - if (n < 2) listener = false; - for (capture in type) this.each(d3_selection_on(capture, type[capture], listener)); - return this; - } - if (n < 2) return (n = this.node()["__on" + type]) && n._; - capture = false; - } - return this.each(d3_selection_on(type, listener, capture)); - }; - function d3_selection_on(type, listener, capture) { - var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener; - if (i > 0) type = type.substring(0, i); - var filter = d3_selection_onFilters.get(type); - if (filter) type = filter, wrap = d3_selection_onFilter; - function onRemove() { - var l = this[name]; - if (l) { - this.removeEventListener(type, l, l.$); - delete this[name]; - } - } - function onAdd() { - var l = wrap(listener, d3_array(arguments)); - onRemove.call(this); - this.addEventListener(type, this[name] = l, l.$ = capture); - l._ = listener; - } - function removeAll() { - var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match; - for (var name in this) { - if (match = name.match(re)) { - var l = this[name]; - this.removeEventListener(match[1], l, l.$); - delete this[name]; - } - } - } - return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll; - } - var d3_selection_onFilters = d3.map({ - mouseenter: "mouseover", - mouseleave: "mouseout" - }); - d3_selection_onFilters.forEach(function(k) { - if ("on" + k in d3_document) d3_selection_onFilters.remove(k); - }); - function d3_selection_onListener(listener, argumentz) { - return function(e) { - var o = d3.event; - d3.event = e; - argumentz[0] = this.__data__; - try { - listener.apply(this, argumentz); - } finally { - d3.event = o; - } - }; - } - function d3_selection_onFilter(listener, argumentz) { - var l = d3_selection_onListener(listener, argumentz); - return function(e) { - var target = this, related = e.relatedTarget; - if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) { - l.call(target, e); - } - }; - } - var d3_event_dragSelect = "onselectstart" in d3_document ? null : d3_vendorSymbol(d3_documentElement.style, "userSelect"), d3_event_dragId = 0; - function d3_event_dragSuppress() { - var name = ".dragsuppress-" + ++d3_event_dragId, click = "click" + name, w = d3.select(d3_window).on("touchmove" + name, d3_eventPreventDefault).on("dragstart" + name, d3_eventPreventDefault).on("selectstart" + name, d3_eventPreventDefault); - if (d3_event_dragSelect) { - var style = d3_documentElement.style, select = style[d3_event_dragSelect]; - style[d3_event_dragSelect] = "none"; - } - return function(suppressClick) { - w.on(name, null); - if (d3_event_dragSelect) style[d3_event_dragSelect] = select; - if (suppressClick) { - function off() { - w.on(click, null); - } - w.on(click, function() { - d3_eventPreventDefault(); - off(); - }, true); - setTimeout(off, 0); - } - }; - } - d3.mouse = function(container) { - return d3_mousePoint(container, d3_eventSource()); - }; - var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0; - function d3_mousePoint(container, e) { - if (e.changedTouches) e = e.changedTouches[0]; - var svg = container.ownerSVGElement || container; - if (svg.createSVGPoint) { - var point = svg.createSVGPoint(); - if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) { - svg = d3.select("body").append("svg").style({ - position: "absolute", - top: 0, - left: 0, - margin: 0, - padding: 0, - border: "none" - }, "important"); - var ctm = svg[0][0].getScreenCTM(); - d3_mouse_bug44083 = !(ctm.f || ctm.e); - svg.remove(); - } - if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX, - point.y = e.clientY; - point = point.matrixTransform(container.getScreenCTM().inverse()); - return [ point.x, point.y ]; - } - var rect = container.getBoundingClientRect(); - return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ]; - } - d3.touches = function(container, touches) { - if (arguments.length < 2) touches = d3_eventSource().touches; - return touches ? d3_array(touches).map(function(touch) { - var point = d3_mousePoint(container, touch); - point.identifier = touch.identifier; - return point; - }) : []; - }; - d3.behavior.drag = function() { - var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, "mousemove", "mouseup"), touchstart = dragstart(touchid, touchposition, "touchmove", "touchend"); - function drag() { - this.on("mousedown.drag", mousedown).on("touchstart.drag", touchstart); - } - function touchid() { - return d3.event.changedTouches[0].identifier; - } - function touchposition(parent, id) { - return d3.touches(parent).filter(function(p) { - return p.identifier === id; - })[0]; - } - function dragstart(id, position, move, end) { - return function() { - var target = this, parent = target.parentNode, event_ = event.of(target, arguments), eventTarget = d3.event.target, eventId = id(), drag = eventId == null ? "drag" : "drag-" + eventId, origin_ = position(parent, eventId), dragged = 0, offset, w = d3.select(d3_window).on(move + "." + drag, moved).on(end + "." + drag, ended), dragRestore = d3_event_dragSuppress(); - if (origin) { - offset = origin.apply(target, arguments); - offset = [ offset.x - origin_[0], offset.y - origin_[1] ]; - } else { - offset = [ 0, 0 ]; - } - event_({ - type: "dragstart" - }); - function moved() { - var p = position(parent, eventId), dx = p[0] - origin_[0], dy = p[1] - origin_[1]; - dragged |= dx | dy; - origin_ = p; - event_({ - type: "drag", - x: p[0] + offset[0], - y: p[1] + offset[1], - dx: dx, - dy: dy - }); - } - function ended() { - w.on(move + "." + drag, null).on(end + "." + drag, null); - dragRestore(dragged && d3.event.target === eventTarget); - event_({ - type: "dragend" - }); - } - }; - } - drag.origin = function(x) { - if (!arguments.length) return origin; - origin = x; - return drag; - }; - return d3.rebind(drag, event, "on"); - }; - var π = Math.PI, τ = 2 * π, halfπ = π / 2, ε = 1e-6, ε2 = ε * ε, d3_radians = π / 180, d3_degrees = 180 / π; - function d3_sgn(x) { - return x > 0 ? 1 : x < 0 ? -1 : 0; - } - function d3_acos(x) { - return x > 1 ? 0 : x < -1 ? π : Math.acos(x); - } - function d3_asin(x) { - return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x); - } - function d3_sinh(x) { - return ((x = Math.exp(x)) - 1 / x) / 2; - } - function d3_cosh(x) { - return ((x = Math.exp(x)) + 1 / x) / 2; - } - function d3_tanh(x) { - return ((x = Math.exp(2 * x)) - 1) / (x + 1); - } - function d3_haversin(x) { - return (x = Math.sin(x / 2)) * x; - } - var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4; - d3.interpolateZoom = function(p0, p1) { - var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2]; - var dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1), dr = r1 - r0, S = (dr || Math.log(w1 / w0)) / ρ; - function interpolate(t) { - var s = t * S; - if (dr) { - var coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0)); - return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ]; - } - return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * s) ]; - } - interpolate.duration = S * 1e3; - return interpolate; - }; - d3.behavior.zoom = function() { - var view = { - x: 0, - y: 0, - k: 1 - }, translate0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1; - function zoom(g) { - g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on(mousemove, mousewheelreset).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); - } - zoom.event = function(g) { - g.each(function() { - var event_ = event.of(this, arguments), view1 = view; - if (d3_transitionInheritId) { - d3.select(this).transition().each("start.zoom", function() { - view = this.__chart__ || { - x: 0, - y: 0, - k: 1 - }; - zoomstarted(event_); - }).tween("zoom:zoom", function() { - var dx = size[0], dy = size[1], cx = dx / 2, cy = dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]); - return function(t) { - var l = i(t), k = dx / l[2]; - this.__chart__ = view = { - x: cx - l[0] * k, - y: cy - l[1] * k, - k: k - }; - zoomed(event_); - }; - }).each("end.zoom", function() { - zoomended(event_); - }); - } else { - this.__chart__ = view; - zoomstarted(event_); - zoomed(event_); - zoomended(event_); - } - }); - }; - zoom.translate = function(_) { - if (!arguments.length) return [ view.x, view.y ]; - view = { - x: +_[0], - y: +_[1], - k: view.k - }; - rescale(); - return zoom; - }; - zoom.scale = function(_) { - if (!arguments.length) return view.k; - view = { - x: view.x, - y: view.y, - k: +_ - }; - rescale(); - return zoom; - }; - zoom.scaleExtent = function(_) { - if (!arguments.length) return scaleExtent; - scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ]; - return zoom; - }; - zoom.center = function(_) { - if (!arguments.length) return center; - center = _ && [ +_[0], +_[1] ]; - return zoom; - }; - zoom.size = function(_) { - if (!arguments.length) return size; - size = _ && [ +_[0], +_[1] ]; - return zoom; - }; - zoom.x = function(z) { - if (!arguments.length) return x1; - x1 = z; - x0 = z.copy(); - view = { - x: 0, - y: 0, - k: 1 - }; - return zoom; - }; - zoom.y = function(z) { - if (!arguments.length) return y1; - y1 = z; - y0 = z.copy(); - view = { - x: 0, - y: 0, - k: 1 - }; - return zoom; - }; - function location(p) { - return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ]; - } - function point(l) { - return [ l[0] * view.k + view.x, l[1] * view.k + view.y ]; - } - function scaleTo(s) { - view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s)); - } - function translateTo(p, l) { - l = point(l); - view.x += p[0] - l[0]; - view.y += p[1] - l[1]; - } - function rescale() { - if (x1) x1.domain(x0.range().map(function(x) { - return (x - view.x) / view.k; - }).map(x0.invert)); - if (y1) y1.domain(y0.range().map(function(y) { - return (y - view.y) / view.k; - }).map(y0.invert)); - } - function zoomstarted(event) { - event({ - type: "zoomstart" - }); - } - function zoomed(event) { - rescale(); - event({ - type: "zoom", - scale: view.k, - translate: [ view.x, view.y ] - }); - } - function zoomended(event) { - event({ - type: "zoomend" - }); - } - function mousedowned() { - var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, dragged = 0, w = d3.select(d3_window).on(mousemove, moved).on(mouseup, ended), l = location(d3.mouse(target)), dragRestore = d3_event_dragSuppress(); - d3_selection_interrupt.call(target); - zoomstarted(event_); - function moved() { - dragged = 1; - translateTo(d3.mouse(target), l); - zoomed(event_); - } - function ended() { - w.on(mousemove, d3_window === target ? mousewheelreset : null).on(mouseup, null); - dragRestore(dragged && d3.event.target === eventTarget); - zoomended(event_); - } - } - function touchstarted() { - var target = this, event_ = event.of(target, arguments), locations0 = {}, distance0 = 0, scale0, eventId = d3.event.changedTouches[0].identifier, touchmove = "touchmove.zoom-" + eventId, touchend = "touchend.zoom-" + eventId, w = d3.select(d3_window).on(touchmove, moved).on(touchend, ended), t = d3.select(target).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress(); - d3_selection_interrupt.call(target); - started(); - zoomstarted(event_); - function relocate() { - var touches = d3.touches(target); - scale0 = view.k; - touches.forEach(function(t) { - if (t.identifier in locations0) locations0[t.identifier] = location(t); - }); - return touches; - } - function started() { - var changed = d3.event.changedTouches; - for (var i = 0, n = changed.length; i < n; ++i) { - locations0[changed[i].identifier] = null; - } - var touches = relocate(), now = Date.now(); - if (touches.length === 1) { - if (now - touchtime < 500) { - var p = touches[0], l = locations0[p.identifier]; - scaleTo(view.k * 2); - translateTo(p, l); - d3_eventPreventDefault(); - zoomed(event_); - } - touchtime = now; - } else if (touches.length > 1) { - var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1]; - distance0 = dx * dx + dy * dy; - } - } - function moved() { - var touches = d3.touches(target), p0, l0, p1, l1; - for (var i = 0, n = touches.length; i < n; ++i, l1 = null) { - p1 = touches[i]; - if (l1 = locations0[p1.identifier]) { - if (l0) break; - p0 = p1, l0 = l1; - } - } - if (l1) { - var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0); - p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ]; - l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ]; - scaleTo(scale1 * scale0); - } - touchtime = null; - translateTo(p0, l0); - zoomed(event_); - } - function ended() { - if (d3.event.touches.length) { - var changed = d3.event.changedTouches; - for (var i = 0, n = changed.length; i < n; ++i) { - delete locations0[changed[i].identifier]; - } - for (var identifier in locations0) { - return void relocate(); - } - } - w.on(touchmove, null).on(touchend, null); - t.on(mousedown, mousedowned).on(touchstart, touchstarted); - dragRestore(); - zoomended(event_); - } - } - function mousewheeled() { - var event_ = event.of(this, arguments); - if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), - zoomstarted(event_); - mousewheelTimer = setTimeout(function() { - mousewheelTimer = null; - zoomended(event_); - }, 50); - d3_eventPreventDefault(); - var point = center || d3.mouse(this); - if (!translate0) translate0 = location(point); - scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k); - translateTo(point, translate0); - zoomed(event_); - } - function mousewheelreset() { - translate0 = null; - } - function dblclicked() { - var event_ = event.of(this, arguments), p = d3.mouse(this), l = location(p), k = Math.log(view.k) / Math.LN2; - zoomstarted(event_); - scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1)); - translateTo(p, l); - zoomed(event_); - zoomended(event_); - } - return d3.rebind(zoom, event, "on"); - }; - var d3_behavior_zoomInfinity = [ 0, Infinity ]; - var d3_behavior_zoomDelta, d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() { - return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1); - }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() { - return d3.event.wheelDelta; - }, "mousewheel") : (d3_behavior_zoomDelta = function() { - return -d3.event.detail; - }, "MozMousePixelScroll"); - function d3_Color() {} - d3_Color.prototype.toString = function() { - return this.rgb() + ""; - }; - d3.hsl = function(h, s, l) { - return arguments.length === 1 ? h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : d3_hsl(+h, +s, +l); - }; - function d3_hsl(h, s, l) { - return new d3_Hsl(h, s, l); - } - function d3_Hsl(h, s, l) { - this.h = h; - this.s = s; - this.l = l; - } - var d3_hslPrototype = d3_Hsl.prototype = new d3_Color(); - d3_hslPrototype.brighter = function(k) { - k = Math.pow(.7, arguments.length ? k : 1); - return d3_hsl(this.h, this.s, this.l / k); - }; - d3_hslPrototype.darker = function(k) { - k = Math.pow(.7, arguments.length ? k : 1); - return d3_hsl(this.h, this.s, k * this.l); - }; - d3_hslPrototype.rgb = function() { - return d3_hsl_rgb(this.h, this.s, this.l); - }; - function d3_hsl_rgb(h, s, l) { - var m1, m2; - h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h; - s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s; - l = l < 0 ? 0 : l > 1 ? 1 : l; - m2 = l <= .5 ? l * (1 + s) : l + s - l * s; - m1 = 2 * l - m2; - function v(h) { - if (h > 360) h -= 360; else if (h < 0) h += 360; - if (h < 60) return m1 + (m2 - m1) * h / 60; - if (h < 180) return m2; - if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60; - return m1; - } - function vv(h) { - return Math.round(v(h) * 255); - } - return d3_rgb(vv(h + 120), vv(h), vv(h - 120)); - } - d3.hcl = function(h, c, l) { - return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l); - }; - function d3_hcl(h, c, l) { - return new d3_Hcl(h, c, l); - } - function d3_Hcl(h, c, l) { - this.h = h; - this.c = c; - this.l = l; - } - var d3_hclPrototype = d3_Hcl.prototype = new d3_Color(); - d3_hclPrototype.brighter = function(k) { - return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); - }; - d3_hclPrototype.darker = function(k) { - return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); - }; - d3_hclPrototype.rgb = function() { - return d3_hcl_lab(this.h, this.c, this.l).rgb(); - }; - function d3_hcl_lab(h, c, l) { - if (isNaN(h)) h = 0; - if (isNaN(c)) c = 0; - return d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); - } - d3.lab = function(l, a, b) { - return arguments.length === 1 ? l instanceof d3_Lab ? d3_lab(l.l, l.a, l.b) : l instanceof d3_Hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3.rgb(l)).r, l.g, l.b) : d3_lab(+l, +a, +b); - }; - function d3_lab(l, a, b) { - return new d3_Lab(l, a, b); - } - function d3_Lab(l, a, b) { - this.l = l; - this.a = a; - this.b = b; - } - var d3_lab_K = 18; - var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; - var d3_labPrototype = d3_Lab.prototype = new d3_Color(); - d3_labPrototype.brighter = function(k) { - return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); - }; - d3_labPrototype.darker = function(k) { - return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); - }; - d3_labPrototype.rgb = function() { - return d3_lab_rgb(this.l, this.a, this.b); - }; - function d3_lab_rgb(l, a, b) { - var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; - x = d3_lab_xyz(x) * d3_lab_X; - y = d3_lab_xyz(y) * d3_lab_Y; - z = d3_lab_xyz(z) * d3_lab_Z; - return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); - } - function d3_lab_hcl(l, a, b) { - return l > 0 ? d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : d3_hcl(NaN, NaN, l); - } - function d3_lab_xyz(x) { - return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; - } - function d3_xyz_lab(x) { - return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; - } - function d3_xyz_rgb(r) { - return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); - } - d3.rgb = function(r, g, b) { - return arguments.length === 1 ? r instanceof d3_Rgb ? d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : d3_rgb(~~r, ~~g, ~~b); - }; - function d3_rgbNumber(value) { - return d3_rgb(value >> 16, value >> 8 & 255, value & 255); - } - function d3_rgbString(value) { - return d3_rgbNumber(value) + ""; - } - function d3_rgb(r, g, b) { - return new d3_Rgb(r, g, b); - } - function d3_Rgb(r, g, b) { - this.r = r; - this.g = g; - this.b = b; - } - var d3_rgbPrototype = d3_Rgb.prototype = new d3_Color(); - d3_rgbPrototype.brighter = function(k) { - k = Math.pow(.7, arguments.length ? k : 1); - var r = this.r, g = this.g, b = this.b, i = 30; - if (!r && !g && !b) return d3_rgb(i, i, i); - if (r && r < i) r = i; - if (g && g < i) g = i; - if (b && b < i) b = i; - return d3_rgb(Math.min(255, ~~(r / k)), Math.min(255, ~~(g / k)), Math.min(255, ~~(b / k))); - }; - d3_rgbPrototype.darker = function(k) { - k = Math.pow(.7, arguments.length ? k : 1); - return d3_rgb(~~(k * this.r), ~~(k * this.g), ~~(k * this.b)); - }; - d3_rgbPrototype.hsl = function() { - return d3_rgb_hsl(this.r, this.g, this.b); - }; - d3_rgbPrototype.toString = function() { - return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b); - }; - function d3_rgb_hex(v) { - return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); - } - function d3_rgb_parse(format, rgb, hsl) { - var r = 0, g = 0, b = 0, m1, m2, name; - m1 = /([a-z]+)\((.*)\)/i.exec(format); - if (m1) { - m2 = m1[2].split(","); - switch (m1[1]) { - case "hsl": - { - return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100); - } - - case "rgb": - { - return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2])); - } - } - } - if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b); - if (format != null && format.charAt(0) === "#") { - if (format.length === 4) { - r = format.charAt(1); - r += r; - g = format.charAt(2); - g += g; - b = format.charAt(3); - b += b; - } else if (format.length === 7) { - r = format.substring(1, 3); - g = format.substring(3, 5); - b = format.substring(5, 7); - } - r = parseInt(r, 16); - g = parseInt(g, 16); - b = parseInt(b, 16); - } - return rgb(r, g, b); - } - function d3_rgb_hsl(r, g, b) { - var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2; - if (d) { - s = l < .5 ? d / (max + min) : d / (2 - max - min); - if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4; - h *= 60; - } else { - h = NaN; - s = l > 0 && l < 1 ? 0 : h; - } - return d3_hsl(h, s, l); - } - function d3_rgb_lab(r, g, b) { - r = d3_rgb_xyz(r); - g = d3_rgb_xyz(g); - b = d3_rgb_xyz(b); - var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z); - return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); - } - function d3_rgb_xyz(r) { - return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4); - } - function d3_rgb_parseNumber(c) { - var f = parseFloat(c); - return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; - } - var d3_rgb_names = d3.map({ - aliceblue: 15792383, - antiquewhite: 16444375, - aqua: 65535, - aquamarine: 8388564, - azure: 15794175, - beige: 16119260, - bisque: 16770244, - black: 0, - blanchedalmond: 16772045, - blue: 255, - blueviolet: 9055202, - brown: 10824234, - burlywood: 14596231, - cadetblue: 6266528, - chartreuse: 8388352, - chocolate: 13789470, - coral: 16744272, - cornflowerblue: 6591981, - cornsilk: 16775388, - crimson: 14423100, - cyan: 65535, - darkblue: 139, - darkcyan: 35723, - darkgoldenrod: 12092939, - darkgray: 11119017, - darkgreen: 25600, - darkgrey: 11119017, - darkkhaki: 12433259, - darkmagenta: 9109643, - darkolivegreen: 5597999, - darkorange: 16747520, - darkorchid: 10040012, - darkred: 9109504, - darksalmon: 15308410, - darkseagreen: 9419919, - darkslateblue: 4734347, - darkslategray: 3100495, - darkslategrey: 3100495, - darkturquoise: 52945, - darkviolet: 9699539, - deeppink: 16716947, - deepskyblue: 49151, - dimgray: 6908265, - dimgrey: 6908265, - dodgerblue: 2003199, - firebrick: 11674146, - floralwhite: 16775920, - forestgreen: 2263842, - fuchsia: 16711935, - gainsboro: 14474460, - ghostwhite: 16316671, - gold: 16766720, - goldenrod: 14329120, - gray: 8421504, - green: 32768, - greenyellow: 11403055, - grey: 8421504, - honeydew: 15794160, - hotpink: 16738740, - indianred: 13458524, - indigo: 4915330, - ivory: 16777200, - khaki: 15787660, - lavender: 15132410, - lavenderblush: 16773365, - lawngreen: 8190976, - lemonchiffon: 16775885, - lightblue: 11393254, - lightcoral: 15761536, - lightcyan: 14745599, - lightgoldenrodyellow: 16448210, - lightgray: 13882323, - lightgreen: 9498256, - lightgrey: 13882323, - lightpink: 16758465, - lightsalmon: 16752762, - lightseagreen: 2142890, - lightskyblue: 8900346, - lightslategray: 7833753, - lightslategrey: 7833753, - lightsteelblue: 11584734, - lightyellow: 16777184, - lime: 65280, - limegreen: 3329330, - linen: 16445670, - magenta: 16711935, - maroon: 8388608, - mediumaquamarine: 6737322, - mediumblue: 205, - mediumorchid: 12211667, - mediumpurple: 9662683, - mediumseagreen: 3978097, - mediumslateblue: 8087790, - mediumspringgreen: 64154, - mediumturquoise: 4772300, - mediumvioletred: 13047173, - midnightblue: 1644912, - mintcream: 16121850, - mistyrose: 16770273, - moccasin: 16770229, - navajowhite: 16768685, - navy: 128, - oldlace: 16643558, - olive: 8421376, - olivedrab: 7048739, - orange: 16753920, - orangered: 16729344, - orchid: 14315734, - palegoldenrod: 15657130, - palegreen: 10025880, - paleturquoise: 11529966, - palevioletred: 14381203, - papayawhip: 16773077, - peachpuff: 16767673, - peru: 13468991, - pink: 16761035, - plum: 14524637, - powderblue: 11591910, - purple: 8388736, - red: 16711680, - rosybrown: 12357519, - royalblue: 4286945, - saddlebrown: 9127187, - salmon: 16416882, - sandybrown: 16032864, - seagreen: 3050327, - seashell: 16774638, - sienna: 10506797, - silver: 12632256, - skyblue: 8900331, - slateblue: 6970061, - slategray: 7372944, - slategrey: 7372944, - snow: 16775930, - springgreen: 65407, - steelblue: 4620980, - tan: 13808780, - teal: 32896, - thistle: 14204888, - tomato: 16737095, - turquoise: 4251856, - violet: 15631086, - wheat: 16113331, - white: 16777215, - whitesmoke: 16119285, - yellow: 16776960, - yellowgreen: 10145074 - }); - d3_rgb_names.forEach(function(key, value) { - d3_rgb_names.set(key, d3_rgbNumber(value)); - }); - function d3_functor(v) { - return typeof v === "function" ? v : function() { - return v; - }; - } - d3.functor = d3_functor; - function d3_identity(d) { - return d; - } - d3.xhr = d3_xhrType(d3_identity); - function d3_xhrType(response) { - return function(url, mimeType, callback) { - if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType, - mimeType = null; - return d3_xhr(url, mimeType, response, callback); - }; - } - function d3_xhr(url, mimeType, response, callback) { - var xhr = {}, dispatch = d3.dispatch("beforesend", "progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null; - if (d3_window.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest(); - "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() { - request.readyState > 3 && respond(); - }; - function respond() { - var status = request.status, result; - if (!status && request.responseText || status >= 200 && status < 300 || status === 304) { - try { - result = response.call(xhr, request); - } catch (e) { - dispatch.error.call(xhr, e); - return; - } - dispatch.load.call(xhr, result); - } else { - dispatch.error.call(xhr, request); - } - } - request.onprogress = function(event) { - var o = d3.event; - d3.event = event; - try { - dispatch.progress.call(xhr, request); - } finally { - d3.event = o; - } - }; - xhr.header = function(name, value) { - name = (name + "").toLowerCase(); - if (arguments.length < 2) return headers[name]; - if (value == null) delete headers[name]; else headers[name] = value + ""; - return xhr; - }; - xhr.mimeType = function(value) { - if (!arguments.length) return mimeType; - mimeType = value == null ? null : value + ""; - return xhr; - }; - xhr.responseType = function(value) { - if (!arguments.length) return responseType; - responseType = value; - return xhr; - }; - xhr.response = function(value) { - response = value; - return xhr; - }; - [ "get", "post" ].forEach(function(method) { - xhr[method] = function() { - return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments))); - }; - }); - xhr.send = function(method, data, callback) { - if (arguments.length === 2 && typeof data === "function") callback = data, data = null; - request.open(method, url, true); - if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*"; - if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]); - if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType); - if (responseType != null) request.responseType = responseType; - if (callback != null) xhr.on("error", callback).on("load", function(request) { - callback(null, request); - }); - dispatch.beforesend.call(xhr, request); - request.send(data == null ? null : data); - return xhr; - }; - xhr.abort = function() { - request.abort(); - return xhr; - }; - d3.rebind(xhr, dispatch, "on"); - return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback)); - } - function d3_xhr_fixCallback(callback) { - return callback.length === 1 ? function(error, request) { - callback(error == null ? request : null); - } : callback; - } - d3.dsv = function(delimiter, mimeType) { - var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); - function dsv(url, row, callback) { - if (arguments.length < 3) callback = row, row = null; - var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback); - xhr.row = function(_) { - return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row; - }; - return xhr; - } - function response(request) { - return dsv.parse(request.responseText); - } - function typedResponse(f) { - return function(request) { - return dsv.parse(request.responseText, f); - }; - } - dsv.parse = function(text, f) { - var o; - return dsv.parseRows(text, function(row, i) { - if (o) return o(row, i - 1); - var a = new Function("d", "return {" + row.map(function(name, i) { - return JSON.stringify(name) + ": d[" + i + "]"; - }).join(",") + "}"); - o = f ? function(row, i) { - return f(a(row), i); - } : a; - }); - }; - dsv.parseRows = function(text, f) { - var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol; - function token() { - if (I >= N) return EOF; - if (eol) return eol = false, EOL; - var j = I; - if (text.charCodeAt(j) === 34) { - var i = j; - while (i++ < N) { - if (text.charCodeAt(i) === 34) { - if (text.charCodeAt(i + 1) !== 34) break; - ++i; - } - } - I = i + 2; - var c = text.charCodeAt(i + 1); - if (c === 13) { - eol = true; - if (text.charCodeAt(i + 2) === 10) ++I; - } else if (c === 10) { - eol = true; - } - return text.substring(j + 1, i).replace(/""/g, '"'); - } - while (I < N) { - var c = text.charCodeAt(I++), k = 1; - if (c === 10) eol = true; else if (c === 13) { - eol = true; - if (text.charCodeAt(I) === 10) ++I, ++k; - } else if (c !== delimiterCode) continue; - return text.substring(j, I - k); - } - return text.substring(j); - } - while ((t = token()) !== EOF) { - var a = []; - while (t !== EOL && t !== EOF) { - a.push(t); - t = token(); - } - if (f && !(a = f(a, n++))) continue; - rows.push(a); - } - return rows; - }; - dsv.format = function(rows) { - if (Array.isArray(rows[0])) return dsv.formatRows(rows); - var fieldSet = new d3_Set(), fields = []; - rows.forEach(function(row) { - for (var field in row) { - if (!fieldSet.has(field)) { - fields.push(fieldSet.add(field)); - } - } - }); - return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) { - return fields.map(function(field) { - return formatValue(row[field]); - }).join(delimiter); - })).join("\n"); - }; - dsv.formatRows = function(rows) { - return rows.map(formatRow).join("\n"); - }; - function formatRow(row) { - return row.map(formatValue).join(delimiter); - } - function formatValue(text) { - return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text; - } - return dsv; - }; - d3.csv = d3.dsv(",", "text/csv"); - d3.tsv = d3.dsv(" ", "text/tab-separated-values"); - var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_active, d3_timer_frame = d3_window[d3_vendorSymbol(d3_window, "requestAnimationFrame")] || function(callback) { - setTimeout(callback, 17); - }; - d3.timer = function(callback, delay, then) { - var n = arguments.length; - if (n < 2) delay = 0; - if (n < 3) then = Date.now(); - var time = then + delay, timer = { - c: callback, - t: time, - f: false, - n: null - }; - if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer; - d3_timer_queueTail = timer; - if (!d3_timer_interval) { - d3_timer_timeout = clearTimeout(d3_timer_timeout); - d3_timer_interval = 1; - d3_timer_frame(d3_timer_step); - } - }; - function d3_timer_step() { - var now = d3_timer_mark(), delay = d3_timer_sweep() - now; - if (delay > 24) { - if (isFinite(delay)) { - clearTimeout(d3_timer_timeout); - d3_timer_timeout = setTimeout(d3_timer_step, delay); - } - d3_timer_interval = 0; - } else { - d3_timer_interval = 1; - d3_timer_frame(d3_timer_step); - } - } - d3.timer.flush = function() { - d3_timer_mark(); - d3_timer_sweep(); - }; - function d3_timer_mark() { - var now = Date.now(); - d3_timer_active = d3_timer_queueHead; - while (d3_timer_active) { - if (now >= d3_timer_active.t) d3_timer_active.f = d3_timer_active.c(now - d3_timer_active.t); - d3_timer_active = d3_timer_active.n; - } - return now; - } - function d3_timer_sweep() { - var t0, t1 = d3_timer_queueHead, time = Infinity; - while (t1) { - if (t1.f) { - t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n; - } else { - if (t1.t < time) time = t1.t; - t1 = (t0 = t1).n; - } - } - d3_timer_queueTail = t0; - return time; - } - var d3_format_decimalPoint = ".", d3_format_thousandsSeparator = ",", d3_format_grouping = [ 3, 3 ], d3_format_currencySymbol = "$"; - var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix); - d3.formatPrefix = function(value, precision) { - var i = 0; - if (value) { - if (value < 0) value *= -1; - if (precision) value = d3.round(value, d3_format_precision(value, precision)); - i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10); - i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3)); - } - return d3_formatPrefixes[8 + i / 3]; - }; - function d3_formatPrefix(d, i) { - var k = Math.pow(10, abs(8 - i) * 3); - return { - scale: i > 8 ? function(d) { - return d / k; - } : function(d) { - return d * k; - }, - symbol: d - }; - } - d3.round = function(x, n) { - return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); - }; - d3.format = function(specifier) { - var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, suffix = "", integer = false; - if (precision) precision = +precision.substring(1); - if (zfill || fill === "0" && align === "=") { - zfill = fill = "0"; - align = "="; - if (comma) width -= Math.floor((width - 1) / 4); - } - switch (type) { - case "n": - comma = true; - type = "g"; - break; - - case "%": - scale = 100; - suffix = "%"; - type = "f"; - break; - - case "p": - scale = 100; - suffix = "%"; - type = "r"; - break; - - case "b": - case "o": - case "x": - case "X": - if (symbol === "#") symbol = "0" + type.toLowerCase(); - - case "c": - case "d": - integer = true; - precision = 0; - break; - - case "s": - scale = -1; - type = "r"; - break; - } - if (symbol === "#") symbol = ""; else if (symbol === "$") symbol = d3_format_currencySymbol; - if (type == "r" && !precision) type = "g"; - if (precision != null) { - if (type == "g") precision = Math.max(1, Math.min(21, precision)); else if (type == "e" || type == "f") precision = Math.max(0, Math.min(20, precision)); - } - type = d3_format_types.get(type) || d3_format_typeDefault; - var zcomma = zfill && comma; - return function(value) { - if (integer && value % 1) return ""; - var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign; - if (scale < 0) { - var prefix = d3.formatPrefix(value, precision); - value = prefix.scale(value); - suffix = prefix.symbol; - } else { - value *= scale; - } - value = type(value, precision); - var i = value.lastIndexOf("."), before = i < 0 ? value : value.substring(0, i), after = i < 0 ? "" : d3_format_decimalPoint + value.substring(i + 1); - if (!zfill && comma) before = d3_format_group(before); - var length = symbol.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : ""; - if (zcomma) before = d3_format_group(padding + before); - negative += symbol; - value = before + after; - return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + suffix; - }; - }; - var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i; - var d3_format_types = d3.map({ - b: function(x) { - return x.toString(2); - }, - c: function(x) { - return String.fromCharCode(x); - }, - o: function(x) { - return x.toString(8); - }, - x: function(x) { - return x.toString(16); - }, - X: function(x) { - return x.toString(16).toUpperCase(); - }, - g: function(x, p) { - return x.toPrecision(p); - }, - e: function(x, p) { - return x.toExponential(p); - }, - f: function(x, p) { - return x.toFixed(p); - }, - r: function(x, p) { - return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p)))); - } - }); - function d3_format_precision(x, p) { - return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1); - } - function d3_format_typeDefault(x) { - return x + ""; - } - var d3_format_group = d3_identity; - if (d3_format_grouping) { - var d3_format_groupingLength = d3_format_grouping.length; - d3_format_group = function(value) { - var i = value.length, t = [], j = 0, g = d3_format_grouping[0]; - while (i > 0 && g > 0) { - t.push(value.substring(i -= g, i + g)); - g = d3_format_grouping[j = (j + 1) % d3_format_groupingLength]; - } - return t.reverse().join(d3_format_thousandsSeparator); - }; - } - d3.geo = {}; - function d3_adder() {} - d3_adder.prototype = { - s: 0, - t: 0, - add: function(y) { - d3_adderSum(y, this.t, d3_adderTemp); - d3_adderSum(d3_adderTemp.s, this.s, this); - if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t; - }, - reset: function() { - this.s = this.t = 0; - }, - valueOf: function() { - return this.s; - } - }; - var d3_adderTemp = new d3_adder(); - function d3_adderSum(a, b, o) { - var x = o.s = a + b, bv = x - a, av = x - bv; - o.t = a - av + (b - bv); - } - d3.geo.stream = function(object, listener) { - if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) { - d3_geo_streamObjectType[object.type](object, listener); - } else { - d3_geo_streamGeometry(object, listener); - } - }; - function d3_geo_streamGeometry(geometry, listener) { - if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) { - d3_geo_streamGeometryType[geometry.type](geometry, listener); - } - } - var d3_geo_streamObjectType = { - Feature: function(feature, listener) { - d3_geo_streamGeometry(feature.geometry, listener); - }, - FeatureCollection: function(object, listener) { - var features = object.features, i = -1, n = features.length; - while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener); - } - }; - var d3_geo_streamGeometryType = { - Sphere: function(object, listener) { - listener.sphere(); - }, - Point: function(object, listener) { - object = object.coordinates; - listener.point(object[0], object[1], object[2]); - }, - MultiPoint: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]); - }, - LineString: function(object, listener) { - d3_geo_streamLine(object.coordinates, listener, 0); - }, - MultiLineString: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0); - }, - Polygon: function(object, listener) { - d3_geo_streamPolygon(object.coordinates, listener); - }, - MultiPolygon: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) d3_geo_streamPolygon(coordinates[i], listener); - }, - GeometryCollection: function(object, listener) { - var geometries = object.geometries, i = -1, n = geometries.length; - while (++i < n) d3_geo_streamGeometry(geometries[i], listener); - } - }; - function d3_geo_streamLine(coordinates, listener, closed) { - var i = -1, n = coordinates.length - closed, coordinate; - listener.lineStart(); - while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]); - listener.lineEnd(); - } - function d3_geo_streamPolygon(coordinates, listener) { - var i = -1, n = coordinates.length; - listener.polygonStart(); - while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1); - listener.polygonEnd(); - } - d3.geo.area = function(object) { - d3_geo_areaSum = 0; - d3.geo.stream(object, d3_geo_area); - return d3_geo_areaSum; - }; - var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder(); - var d3_geo_area = { - sphere: function() { - d3_geo_areaSum += 4 * π; - }, - point: d3_noop, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: function() { - d3_geo_areaRingSum.reset(); - d3_geo_area.lineStart = d3_geo_areaRingStart; - }, - polygonEnd: function() { - var area = 2 * d3_geo_areaRingSum; - d3_geo_areaSum += area < 0 ? 4 * π + area : area; - d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop; - } - }; - function d3_geo_areaRingStart() { - var λ00, φ00, λ0, cosφ0, sinφ0; - d3_geo_area.point = function(λ, φ) { - d3_geo_area.point = nextPoint; - λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), - sinφ0 = Math.sin(φ); - }; - function nextPoint(λ, φ) { - λ *= d3_radians; - φ = φ * d3_radians / 2 + π / 4; - var dλ = λ - λ0, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(dλ), v = k * Math.sin(dλ); - d3_geo_areaRingSum.add(Math.atan2(v, u)); - λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ; - } - d3_geo_area.lineEnd = function() { - nextPoint(λ00, φ00); - }; - } - function d3_geo_cartesian(spherical) { - var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ); - return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ]; - } - function d3_geo_cartesianDot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; - } - function d3_geo_cartesianCross(a, b) { - return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ]; - } - function d3_geo_cartesianAdd(a, b) { - a[0] += b[0]; - a[1] += b[1]; - a[2] += b[2]; - } - function d3_geo_cartesianScale(vector, k) { - return [ vector[0] * k, vector[1] * k, vector[2] * k ]; - } - function d3_geo_cartesianNormalize(d) { - var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); - d[0] /= l; - d[1] /= l; - d[2] /= l; - } - function d3_geo_spherical(cartesian) { - return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ]; - } - function d3_geo_sphericalEqual(a, b) { - return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε; - } - d3.geo.bounds = function() { - var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range; - var bound = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - bound.point = ringPoint; - bound.lineStart = ringStart; - bound.lineEnd = ringEnd; - dλSum = 0; - d3_geo_area.polygonStart(); - }, - polygonEnd: function() { - d3_geo_area.polygonEnd(); - bound.point = point; - bound.lineStart = lineStart; - bound.lineEnd = lineEnd; - if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90; - range[0] = λ0, range[1] = λ1; - } - }; - function point(λ, φ) { - ranges.push(range = [ λ0 = λ, λ1 = λ ]); - if (φ < φ0) φ0 = φ; - if (φ > φ1) φ1 = φ; - } - function linePoint(λ, φ) { - var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]); - if (p0) { - var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal); - d3_geo_cartesianNormalize(inflection); - inflection = d3_geo_spherical(inflection); - var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs(dλ) > 180; - if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) { - var φi = inflection[1] * d3_degrees; - if (φi > φ1) φ1 = φi; - } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) { - var φi = -inflection[1] * d3_degrees; - if (φi < φ0) φ0 = φi; - } else { - if (φ < φ0) φ0 = φ; - if (φ > φ1) φ1 = φ; - } - if (antimeridian) { - if (λ < λ_) { - if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; - } else { - if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; - } - } else { - if (λ1 >= λ0) { - if (λ < λ0) λ0 = λ; - if (λ > λ1) λ1 = λ; - } else { - if (λ > λ_) { - if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; - } else { - if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; - } - } - } - } else { - point(λ, φ); - } - p0 = p, λ_ = λ; - } - function lineStart() { - bound.point = linePoint; - } - function lineEnd() { - range[0] = λ0, range[1] = λ1; - bound.point = point; - p0 = null; - } - function ringPoint(λ, φ) { - if (p0) { - var dλ = λ - λ_; - dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ; - } else λ__ = λ, φ__ = φ; - d3_geo_area.point(λ, φ); - linePoint(λ, φ); - } - function ringStart() { - d3_geo_area.lineStart(); - } - function ringEnd() { - ringPoint(λ__, φ__); - d3_geo_area.lineEnd(); - if (abs(dλSum) > ε) λ0 = -(λ1 = 180); - range[0] = λ0, range[1] = λ1; - p0 = null; - } - function angle(λ0, λ1) { - return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1; - } - function compareRanges(a, b) { - return a[0] - b[0]; - } - function withinRange(x, range) { - return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x; - } - return function(feature) { - φ1 = λ1 = -(λ0 = φ0 = Infinity); - ranges = []; - d3.geo.stream(feature, bound); - var n = ranges.length; - if (n) { - ranges.sort(compareRanges); - for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) { - b = ranges[i]; - if (withinRange(b[0], a) || withinRange(b[1], a)) { - if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1]; - if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0]; - } else { - merged.push(a = b); - } - } - var best = -Infinity, dλ; - for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) { - b = merged[i]; - if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1]; - } - } - ranges = range = null; - return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ]; - }; - }(); - d3.geo.centroid = function(object) { - d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; - d3.geo.stream(object, d3_geo_centroid); - var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z; - if (m < ε2) { - x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1; - if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0; - m = x * x + y * y + z * z; - if (m < ε2) return [ NaN, NaN ]; - } - return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ]; - }; - var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2; - var d3_geo_centroid = { - sphere: d3_noop, - point: d3_geo_centroidPoint, - lineStart: d3_geo_centroidLineStart, - lineEnd: d3_geo_centroidLineEnd, - polygonStart: function() { - d3_geo_centroid.lineStart = d3_geo_centroidRingStart; - }, - polygonEnd: function() { - d3_geo_centroid.lineStart = d3_geo_centroidLineStart; - } - }; - function d3_geo_centroidPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ)); - } - function d3_geo_centroidPointXYZ(x, y, z) { - ++d3_geo_centroidW0; - d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0; - d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0; - d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0; - } - function d3_geo_centroidLineStart() { - var x0, y0, z0; - d3_geo_centroid.point = function(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - x0 = cosφ * Math.cos(λ); - y0 = cosφ * Math.sin(λ); - z0 = Math.sin(φ); - d3_geo_centroid.point = nextPoint; - d3_geo_centroidPointXYZ(x0, y0, z0); - }; - function nextPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z); - d3_geo_centroidW1 += w; - d3_geo_centroidX1 += w * (x0 + (x0 = x)); - d3_geo_centroidY1 += w * (y0 + (y0 = y)); - d3_geo_centroidZ1 += w * (z0 + (z0 = z)); - d3_geo_centroidPointXYZ(x0, y0, z0); - } - } - function d3_geo_centroidLineEnd() { - d3_geo_centroid.point = d3_geo_centroidPoint; - } - function d3_geo_centroidRingStart() { - var λ00, φ00, x0, y0, z0; - d3_geo_centroid.point = function(λ, φ) { - λ00 = λ, φ00 = φ; - d3_geo_centroid.point = nextPoint; - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - x0 = cosφ * Math.cos(λ); - y0 = cosφ * Math.sin(λ); - z0 = Math.sin(φ); - d3_geo_centroidPointXYZ(x0, y0, z0); - }; - d3_geo_centroid.lineEnd = function() { - nextPoint(λ00, φ00); - d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd; - d3_geo_centroid.point = d3_geo_centroidPoint; - }; - function nextPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u); - d3_geo_centroidX2 += v * cx; - d3_geo_centroidY2 += v * cy; - d3_geo_centroidZ2 += v * cz; - d3_geo_centroidW1 += w; - d3_geo_centroidX1 += w * (x0 + (x0 = x)); - d3_geo_centroidY1 += w * (y0 + (y0 = y)); - d3_geo_centroidZ1 += w * (z0 + (z0 = z)); - d3_geo_centroidPointXYZ(x0, y0, z0); - } - } - function d3_true() { - return true; - } - function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) { - var subject = [], clip = []; - segments.forEach(function(segment) { - if ((n = segment.length - 1) <= 0) return; - var n, p0 = segment[0], p1 = segment[n]; - if (d3_geo_sphericalEqual(p0, p1)) { - listener.lineStart(); - for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]); - listener.lineEnd(); - return; - } - var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false); - a.o = b; - subject.push(a); - clip.push(b); - a = new d3_geo_clipPolygonIntersection(p1, segment, null, false); - b = new d3_geo_clipPolygonIntersection(p1, null, a, true); - a.o = b; - subject.push(a); - clip.push(b); - }); - clip.sort(compare); - d3_geo_clipPolygonLinkCircular(subject); - d3_geo_clipPolygonLinkCircular(clip); - if (!subject.length) return; - for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) { - clip[i].e = entry = !entry; - } - var start = subject[0], points, point; - while (1) { - var current = start, isSubject = true; - while (current.v) if ((current = current.n) === start) return; - points = current.z; - listener.lineStart(); - do { - current.v = current.o.v = true; - if (current.e) { - if (isSubject) { - for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]); - } else { - interpolate(current.x, current.n.x, 1, listener); - } - current = current.n; - } else { - if (isSubject) { - points = current.p.z; - for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]); - } else { - interpolate(current.x, current.p.x, -1, listener); - } - current = current.p; - } - current = current.o; - points = current.z; - isSubject = !isSubject; - } while (!current.v); - listener.lineEnd(); - } - } - function d3_geo_clipPolygonLinkCircular(array) { - if (!(n = array.length)) return; - var n, i = 0, a = array[0], b; - while (++i < n) { - a.n = b = array[i]; - b.p = a; - a = b; - } - a.n = b = array[0]; - b.p = a; - } - function d3_geo_clipPolygonIntersection(point, points, other, entry) { - this.x = point; - this.z = points; - this.o = other; - this.e = entry; - this.v = false; - this.n = this.p = null; - } - function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) { - return function(rotate, listener) { - var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]); - var clip = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - clip.point = pointRing; - clip.lineStart = ringStart; - clip.lineEnd = ringEnd; - segments = []; - polygon = []; - listener.polygonStart(); - }, - polygonEnd: function() { - clip.point = point; - clip.lineStart = lineStart; - clip.lineEnd = lineEnd; - segments = d3.merge(segments); - var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon); - if (segments.length) { - d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener); - } else if (clipStartInside) { - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - } - listener.polygonEnd(); - segments = polygon = null; - }, - sphere: function() { - listener.polygonStart(); - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - listener.polygonEnd(); - } - }; - function point(λ, φ) { - var point = rotate(λ, φ); - if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ); - } - function pointLine(λ, φ) { - var point = rotate(λ, φ); - line.point(point[0], point[1]); - } - function lineStart() { - clip.point = pointLine; - line.lineStart(); - } - function lineEnd() { - clip.point = point; - line.lineEnd(); - } - var segments; - var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygon, ring; - function pointRing(λ, φ) { - ring.push([ λ, φ ]); - var point = rotate(λ, φ); - ringListener.point(point[0], point[1]); - } - function ringStart() { - ringListener.lineStart(); - ring = []; - } - function ringEnd() { - pointRing(ring[0][0], ring[0][1]); - ringListener.lineEnd(); - var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length; - ring.pop(); - polygon.push(ring); - ring = null; - if (!n) return; - if (clean & 1) { - segment = ringSegments[0]; - var n = segment.length - 1, i = -1, point; - listener.lineStart(); - while (++i < n) listener.point((point = segment[i])[0], point[1]); - listener.lineEnd(); - return; - } - if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); - segments.push(ringSegments.filter(d3_geo_clipSegmentLength1)); - } - return clip; - }; - } - function d3_geo_clipSegmentLength1(segment) { - return segment.length > 1; - } - function d3_geo_clipBufferListener() { - var lines = [], line; - return { - lineStart: function() { - lines.push(line = []); - }, - point: function(λ, φ) { - line.push([ λ, φ ]); - }, - lineEnd: d3_noop, - buffer: function() { - var buffer = lines; - lines = []; - line = null; - return buffer; - }, - rejoin: function() { - if (lines.length > 1) lines.push(lines.pop().concat(lines.shift())); - } - }; - } - function d3_geo_clipSort(a, b) { - return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]); - } - function d3_geo_pointInPolygon(point, polygon) { - var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0; - d3_geo_areaRingSum.reset(); - for (var i = 0, n = polygon.length; i < n; ++i) { - var ring = polygon[i], m = ring.length; - if (!m) continue; - var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1; - while (true) { - if (j === m) j = 0; - point = ring[j]; - var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, antimeridian = abs(dλ) > π, k = sinφ0 * sinφ; - d3_geo_areaRingSum.add(Math.atan2(k * Math.sin(dλ), cosφ0 * cosφ + k * Math.cos(dλ))); - polarAngle += antimeridian ? dλ + (dλ >= 0 ? τ : -τ) : dλ; - if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { - var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); - d3_geo_cartesianNormalize(arc); - var intersection = d3_geo_cartesianCross(meridianNormal, arc); - d3_geo_cartesianNormalize(intersection); - var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); - if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) { - winding += antimeridian ^ dλ >= 0 ? 1 : -1; - } - } - if (!j++) break; - λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; - } - } - return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; - } - var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]); - function d3_geo_clipAntimeridianLine(listener) { - var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean; - return { - lineStart: function() { - listener.lineStart(); - clean = 1; - }, - point: function(λ1, φ1) { - var sλ1 = λ1 > 0 ? π : -π, dλ = abs(λ1 - λ0); - if (abs(dλ - π) < ε) { - listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ); - listener.point(sλ0, φ0); - listener.lineEnd(); - listener.lineStart(); - listener.point(sλ1, φ0); - listener.point(λ1, φ0); - clean = 0; - } else if (sλ0 !== sλ1 && dλ >= π) { - if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε; - if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε; - φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1); - listener.point(sλ0, φ0); - listener.lineEnd(); - listener.lineStart(); - listener.point(sλ1, φ0); - clean = 0; - } - listener.point(λ0 = λ1, φ0 = φ1); - sλ0 = sλ1; - }, - lineEnd: function() { - listener.lineEnd(); - λ0 = φ0 = NaN; - }, - clean: function() { - return 2 - clean; - } - }; - } - function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) { - var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1); - return abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) / (cosφ0 * cosφ1 * sinλ0_λ1)) : (φ0 + φ1) / 2; - } - function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) { - var φ; - if (from == null) { - φ = direction * halfπ; - listener.point(-π, φ); - listener.point(0, φ); - listener.point(π, φ); - listener.point(π, 0); - listener.point(π, -φ); - listener.point(0, -φ); - listener.point(-π, -φ); - listener.point(-π, 0); - listener.point(-π, φ); - } else if (abs(from[0] - to[0]) > ε) { - var s = from[0] < to[0] ? π : -π; - φ = direction * s / 2; - listener.point(-s, φ); - listener.point(0, φ); - listener.point(s, φ); - } else { - listener.point(to[0], to[1]); - } - } - function d3_geo_clipCircle(radius) { - var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); - return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]); - function visible(λ, φ) { - return Math.cos(λ) * Math.cos(φ) > cr; - } - function clipLine(listener) { - var point0, c0, v0, v00, clean; - return { - lineStart: function() { - v00 = v0 = false; - clean = 1; - }, - point: function(λ, φ) { - var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0; - if (!point0 && (v00 = v0 = v)) listener.lineStart(); - if (v !== v0) { - point2 = intersect(point0, point1); - if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) { - point1[0] += ε; - point1[1] += ε; - v = visible(point1[0], point1[1]); - } - } - if (v !== v0) { - clean = 0; - if (v) { - listener.lineStart(); - point2 = intersect(point1, point0); - listener.point(point2[0], point2[1]); - } else { - point2 = intersect(point0, point1); - listener.point(point2[0], point2[1]); - listener.lineEnd(); - } - point0 = point2; - } else if (notHemisphere && point0 && smallRadius ^ v) { - var t; - if (!(c & c0) && (t = intersect(point1, point0, true))) { - clean = 0; - if (smallRadius) { - listener.lineStart(); - listener.point(t[0][0], t[0][1]); - listener.point(t[1][0], t[1][1]); - listener.lineEnd(); - } else { - listener.point(t[1][0], t[1][1]); - listener.lineEnd(); - listener.lineStart(); - listener.point(t[0][0], t[0][1]); - } - } - } - if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) { - listener.point(point1[0], point1[1]); - } - point0 = point1, v0 = v, c0 = c; - }, - lineEnd: function() { - if (v0) listener.lineEnd(); - point0 = null; - }, - clean: function() { - return clean | (v00 && v0) << 1; - } - }; - } - function intersect(a, b, two) { - var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b); - var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2; - if (!determinant) return !two && a; - var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2); - d3_geo_cartesianAdd(A, B); - var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1); - if (t2 < 0) return; - var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu); - d3_geo_cartesianAdd(q, A); - q = d3_geo_spherical(q); - if (!two) return q; - var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z; - if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z; - var δλ = λ1 - λ0, polar = abs(δλ - π) < ε, meridian = polar || δλ < ε; - if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z; - if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) { - var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); - d3_geo_cartesianAdd(q1, A); - return [ q, d3_geo_spherical(q1) ]; - } - } - function code(λ, φ) { - var r = smallRadius ? radius : π - radius, code = 0; - if (λ < -r) code |= 1; else if (λ > r) code |= 2; - if (φ < -r) code |= 4; else if (φ > r) code |= 8; - return code; - } - } - function d3_geom_clipLine(x0, y0, x1, y1) { - return function(line) { - var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r; - r = x0 - ax; - if (!dx && r > 0) return; - r /= dx; - if (dx < 0) { - if (r < t0) return; - if (r < t1) t1 = r; - } else if (dx > 0) { - if (r > t1) return; - if (r > t0) t0 = r; - } - r = x1 - ax; - if (!dx && r < 0) return; - r /= dx; - if (dx < 0) { - if (r > t1) return; - if (r > t0) t0 = r; - } else if (dx > 0) { - if (r < t0) return; - if (r < t1) t1 = r; - } - r = y0 - ay; - if (!dy && r > 0) return; - r /= dy; - if (dy < 0) { - if (r < t0) return; - if (r < t1) t1 = r; - } else if (dy > 0) { - if (r > t1) return; - if (r > t0) t0 = r; - } - r = y1 - ay; - if (!dy && r < 0) return; - r /= dy; - if (dy < 0) { - if (r > t1) return; - if (r > t0) t0 = r; - } else if (dy > 0) { - if (r < t0) return; - if (r < t1) t1 = r; - } - if (t0 > 0) line.a = { - x: ax + t0 * dx, - y: ay + t0 * dy - }; - if (t1 < 1) line.b = { - x: ax + t1 * dx, - y: ay + t1 * dy - }; - return line; - }; - } - var d3_geo_clipExtentMAX = 1e9; - d3.geo.clipExtent = function() { - var x0, y0, x1, y1, stream, clip, clipExtent = { - stream: function(output) { - if (stream) stream.valid = false; - stream = clip(output); - stream.valid = true; - return stream; - }, - extent: function(_) { - if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; - clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]); - if (stream) stream.valid = false, stream = null; - return clipExtent; - } - }; - return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]); - }; - function d3_geo_clipExtent(x0, y0, x1, y1) { - return function(listener) { - var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring; - var clip = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - listener = bufferListener; - segments = []; - polygon = []; - clean = true; - }, - polygonEnd: function() { - listener = listener_; - segments = d3.merge(segments); - var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length; - if (inside || visible) { - listener.polygonStart(); - if (inside) { - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - } - if (visible) { - d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener); - } - listener.polygonEnd(); - } - segments = polygon = ring = null; - } - }; - function insidePolygon(p) { - var wn = 0, n = polygon.length, y = p[1]; - for (var i = 0; i < n; ++i) { - for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) { - b = v[j]; - if (a[1] <= y) { - if (b[1] > y && isLeft(a, b, p) > 0) ++wn; - } else { - if (b[1] <= y && isLeft(a, b, p) < 0) --wn; - } - a = b; - } - } - return wn !== 0; - } - function isLeft(a, b, c) { - return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]); - } - function interpolate(from, to, direction, listener) { - var a = 0, a1 = 0; - if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) { - do { - listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); - } while ((a = (a + direction + 4) % 4) !== a1); - } else { - listener.point(to[0], to[1]); - } - } - function pointVisible(x, y) { - return x0 <= x && x <= x1 && y0 <= y && y <= y1; - } - function point(x, y) { - if (pointVisible(x, y)) listener.point(x, y); - } - var x__, y__, v__, x_, y_, v_, first, clean; - function lineStart() { - clip.point = linePoint; - if (polygon) polygon.push(ring = []); - first = true; - v_ = false; - x_ = y_ = NaN; - } - function lineEnd() { - if (segments) { - linePoint(x__, y__); - if (v__ && v_) bufferListener.rejoin(); - segments.push(bufferListener.buffer()); - } - clip.point = point; - if (v_) listener.lineEnd(); - } - function linePoint(x, y) { - x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x)); - y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y)); - var v = pointVisible(x, y); - if (polygon) ring.push([ x, y ]); - if (first) { - x__ = x, y__ = y, v__ = v; - first = false; - if (v) { - listener.lineStart(); - listener.point(x, y); - } - } else { - if (v && v_) listener.point(x, y); else { - var l = { - a: { - x: x_, - y: y_ - }, - b: { - x: x, - y: y - } - }; - if (clipLine(l)) { - if (!v_) { - listener.lineStart(); - listener.point(l.a.x, l.a.y); - } - listener.point(l.b.x, l.b.y); - if (!v) listener.lineEnd(); - clean = false; - } else if (v) { - listener.lineStart(); - listener.point(x, y); - clean = false; - } - } - } - x_ = x, y_ = y, v_ = v; - } - return clip; - }; - function corner(p, direction) { - return abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2; - } - function compare(a, b) { - return comparePoints(a.x, b.x); - } - function comparePoints(a, b) { - var ca = corner(a, 1), cb = corner(b, 1); - return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0]; - } - } - function d3_geo_compose(a, b) { - function compose(x, y) { - return x = a(x, y), b(x[0], x[1]); - } - if (a.invert && b.invert) compose.invert = function(x, y) { - return x = b.invert(x, y), x && a.invert(x[0], x[1]); - }; - return compose; - } - function d3_geo_conic(projectAt) { - var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1); - p.parallels = function(_) { - if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ]; - return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180); - }; - return p; - } - function d3_geo_conicEqualArea(φ0, φ1) { - var sinφ0 = Math.sin(φ0), n = (sinφ0 + Math.sin(φ1)) / 2, C = 1 + sinφ0 * (2 * n - sinφ0), ρ0 = Math.sqrt(C) / n; - function forward(λ, φ) { - var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n; - return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ]; - } - forward.invert = function(x, y) { - var ρ0_y = ρ0 - y; - return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ]; - }; - return forward; - } - (d3.geo.conicEqualArea = function() { - return d3_geo_conic(d3_geo_conicEqualArea); - }).raw = d3_geo_conicEqualArea; - d3.geo.albers = function() { - return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070); - }; - d3.geo.albersUsa = function() { - var lower48 = d3.geo.albers(); - var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]); - var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]); - var point, pointStream = { - point: function(x, y) { - point = [ x, y ]; - } - }, lower48Point, alaskaPoint, hawaiiPoint; - function albersUsa(coordinates) { - var x = coordinates[0], y = coordinates[1]; - point = null; - (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y); - return point; - } - albersUsa.invert = function(coordinates) { - var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k; - return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates); - }; - albersUsa.stream = function(stream) { - var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream); - return { - point: function(x, y) { - lower48Stream.point(x, y); - alaskaStream.point(x, y); - hawaiiStream.point(x, y); - }, - sphere: function() { - lower48Stream.sphere(); - alaskaStream.sphere(); - hawaiiStream.sphere(); - }, - lineStart: function() { - lower48Stream.lineStart(); - alaskaStream.lineStart(); - hawaiiStream.lineStart(); - }, - lineEnd: function() { - lower48Stream.lineEnd(); - alaskaStream.lineEnd(); - hawaiiStream.lineEnd(); - }, - polygonStart: function() { - lower48Stream.polygonStart(); - alaskaStream.polygonStart(); - hawaiiStream.polygonStart(); - }, - polygonEnd: function() { - lower48Stream.polygonEnd(); - alaskaStream.polygonEnd(); - hawaiiStream.polygonEnd(); - } - }; - }; - albersUsa.precision = function(_) { - if (!arguments.length) return lower48.precision(); - lower48.precision(_); - alaska.precision(_); - hawaii.precision(_); - return albersUsa; - }; - albersUsa.scale = function(_) { - if (!arguments.length) return lower48.scale(); - lower48.scale(_); - alaska.scale(_ * .35); - hawaii.scale(_); - return albersUsa.translate(lower48.translate()); - }; - albersUsa.translate = function(_) { - if (!arguments.length) return lower48.translate(); - var k = lower48.scale(), x = +_[0], y = +_[1]; - lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point; - alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + ε, y + .12 * k + ε ], [ x - .214 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; - hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + ε, y + .166 * k + ε ], [ x - .115 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; - return albersUsa; - }; - return albersUsa.scale(1070); - }; - var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = { - point: d3_noop, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: function() { - d3_geo_pathAreaPolygon = 0; - d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart; - }, - polygonEnd: function() { - d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop; - d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2); - } - }; - function d3_geo_pathAreaRingStart() { - var x00, y00, x0, y0; - d3_geo_pathArea.point = function(x, y) { - d3_geo_pathArea.point = nextPoint; - x00 = x0 = x, y00 = y0 = y; - }; - function nextPoint(x, y) { - d3_geo_pathAreaPolygon += y0 * x - x0 * y; - x0 = x, y0 = y; - } - d3_geo_pathArea.lineEnd = function() { - nextPoint(x00, y00); - }; - } - var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1; - var d3_geo_pathBounds = { - point: d3_geo_pathBoundsPoint, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: d3_noop, - polygonEnd: d3_noop - }; - function d3_geo_pathBoundsPoint(x, y) { - if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x; - if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x; - if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y; - if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y; - } - function d3_geo_pathBuffer() { - var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = []; - var stream = { - point: point, - lineStart: function() { - stream.point = pointLineStart; - }, - lineEnd: lineEnd, - polygonStart: function() { - stream.lineEnd = lineEndPolygon; - }, - polygonEnd: function() { - stream.lineEnd = lineEnd; - stream.point = point; - }, - pointRadius: function(_) { - pointCircle = d3_geo_pathBufferCircle(_); - return stream; - }, - result: function() { - if (buffer.length) { - var result = buffer.join(""); - buffer = []; - return result; - } - } - }; - function point(x, y) { - buffer.push("M", x, ",", y, pointCircle); - } - function pointLineStart(x, y) { - buffer.push("M", x, ",", y); - stream.point = pointLine; - } - function pointLine(x, y) { - buffer.push("L", x, ",", y); - } - function lineEnd() { - stream.point = point; - } - function lineEndPolygon() { - buffer.push("Z"); - } - return stream; - } - function d3_geo_pathBufferCircle(radius) { - return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z"; - } - var d3_geo_pathCentroid = { - point: d3_geo_pathCentroidPoint, - lineStart: d3_geo_pathCentroidLineStart, - lineEnd: d3_geo_pathCentroidLineEnd, - polygonStart: function() { - d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart; - }, - polygonEnd: function() { - d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; - d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart; - d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd; - } - }; - function d3_geo_pathCentroidPoint(x, y) { - d3_geo_centroidX0 += x; - d3_geo_centroidY0 += y; - ++d3_geo_centroidZ0; - } - function d3_geo_pathCentroidLineStart() { - var x0, y0; - d3_geo_pathCentroid.point = function(x, y) { - d3_geo_pathCentroid.point = nextPoint; - d3_geo_pathCentroidPoint(x0 = x, y0 = y); - }; - function nextPoint(x, y) { - var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); - d3_geo_centroidX1 += z * (x0 + x) / 2; - d3_geo_centroidY1 += z * (y0 + y) / 2; - d3_geo_centroidZ1 += z; - d3_geo_pathCentroidPoint(x0 = x, y0 = y); - } - } - function d3_geo_pathCentroidLineEnd() { - d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; - } - function d3_geo_pathCentroidRingStart() { - var x00, y00, x0, y0; - d3_geo_pathCentroid.point = function(x, y) { - d3_geo_pathCentroid.point = nextPoint; - d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y); - }; - function nextPoint(x, y) { - var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); - d3_geo_centroidX1 += z * (x0 + x) / 2; - d3_geo_centroidY1 += z * (y0 + y) / 2; - d3_geo_centroidZ1 += z; - z = y0 * x - x0 * y; - d3_geo_centroidX2 += z * (x0 + x); - d3_geo_centroidY2 += z * (y0 + y); - d3_geo_centroidZ2 += z * 3; - d3_geo_pathCentroidPoint(x0 = x, y0 = y); - } - d3_geo_pathCentroid.lineEnd = function() { - nextPoint(x00, y00); - }; - } - function d3_geo_pathContext(context) { - var pointRadius = 4.5; - var stream = { - point: point, - lineStart: function() { - stream.point = pointLineStart; - }, - lineEnd: lineEnd, - polygonStart: function() { - stream.lineEnd = lineEndPolygon; - }, - polygonEnd: function() { - stream.lineEnd = lineEnd; - stream.point = point; - }, - pointRadius: function(_) { - pointRadius = _; - return stream; - }, - result: d3_noop - }; - function point(x, y) { - context.moveTo(x, y); - context.arc(x, y, pointRadius, 0, τ); - } - function pointLineStart(x, y) { - context.moveTo(x, y); - stream.point = pointLine; - } - function pointLine(x, y) { - context.lineTo(x, y); - } - function lineEnd() { - stream.point = point; - } - function lineEndPolygon() { - context.closePath(); - } - return stream; - } - function d3_geo_resample(project) { - var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16; - function resample(stream) { - return (maxDepth ? resampleRecursive : resampleNone)(stream); - } - function resampleNone(stream) { - return d3_geo_transformPoint(stream, function(x, y) { - x = project(x, y); - stream.point(x[0], x[1]); - }); - } - function resampleRecursive(stream) { - var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0; - var resample = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - stream.polygonStart(); - resample.lineStart = ringStart; - }, - polygonEnd: function() { - stream.polygonEnd(); - resample.lineStart = lineStart; - } - }; - function point(x, y) { - x = project(x, y); - stream.point(x[0], x[1]); - } - function lineStart() { - x0 = NaN; - resample.point = linePoint; - stream.lineStart(); - } - function linePoint(λ, φ) { - var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ); - resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); - stream.point(x0, y0); - } - function lineEnd() { - resample.point = point; - stream.lineEnd(); - } - function ringStart() { - lineStart(); - resample.point = ringPoint; - resample.lineEnd = ringEnd; - } - function ringPoint(λ, φ) { - linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; - resample.point = linePoint; - } - function ringEnd() { - resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream); - resample.lineEnd = lineEnd; - lineEnd(); - } - return resample; - } - function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) { - var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy; - if (d2 > 4 * δ2 && depth--) { - var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), φ2 = Math.asin(c /= m), λ2 = abs(abs(c) - 1) < ε || abs(λ0 - λ1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, φ2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2; - if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { - resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream); - stream.point(x2, y2); - resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream); - } - } - } - resample.precision = function(_) { - if (!arguments.length) return Math.sqrt(δ2); - maxDepth = (δ2 = _ * _) > 0 && 16; - return resample; - }; - return resample; - } - d3.geo.path = function() { - var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream; - function path(object) { - if (object) { - if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments)); - if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream); - d3.geo.stream(object, cacheStream); - } - return contextStream.result(); - } - path.area = function(object) { - d3_geo_pathAreaSum = 0; - d3.geo.stream(object, projectStream(d3_geo_pathArea)); - return d3_geo_pathAreaSum; - }; - path.centroid = function(object) { - d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; - d3.geo.stream(object, projectStream(d3_geo_pathCentroid)); - return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ]; - }; - path.bounds = function(object) { - d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity); - d3.geo.stream(object, projectStream(d3_geo_pathBounds)); - return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ]; - }; - path.projection = function(_) { - if (!arguments.length) return projection; - projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity; - return reset(); - }; - path.context = function(_) { - if (!arguments.length) return context; - contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_); - if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius); - return reset(); - }; - path.pointRadius = function(_) { - if (!arguments.length) return pointRadius; - pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_); - return path; - }; - function reset() { - cacheStream = null; - return path; - } - return path.projection(d3.geo.albersUsa()).context(null); - }; - function d3_geo_pathProjectStream(project) { - var resample = d3_geo_resample(function(x, y) { - return project([ x * d3_degrees, y * d3_degrees ]); - }); - return function(stream) { - return d3_geo_projectionRadians(resample(stream)); - }; - } - d3.geo.transform = function(methods) { - return { - stream: function(stream) { - var transform = new d3_geo_transform(stream); - for (var k in methods) transform[k] = methods[k]; - return transform; - } - }; - }; - function d3_geo_transform(stream) { - this.stream = stream; - } - d3_geo_transform.prototype = { - point: function(x, y) { - this.stream.point(x, y); - }, - sphere: function() { - this.stream.sphere(); - }, - lineStart: function() { - this.stream.lineStart(); - }, - lineEnd: function() { - this.stream.lineEnd(); - }, - polygonStart: function() { - this.stream.polygonStart(); - }, - polygonEnd: function() { - this.stream.polygonEnd(); - } - }; - function d3_geo_transformPoint(stream, point) { - return { - point: point, - sphere: function() { - stream.sphere(); - }, - lineStart: function() { - stream.lineStart(); - }, - lineEnd: function() { - stream.lineEnd(); - }, - polygonStart: function() { - stream.polygonStart(); - }, - polygonEnd: function() { - stream.polygonEnd(); - } - }; - } - d3.geo.projection = d3_geo_projection; - d3.geo.projectionMutator = d3_geo_projectionMutator; - function d3_geo_projection(project) { - return d3_geo_projectionMutator(function() { - return project; - })(); - } - function d3_geo_projectionMutator(projectAt) { - var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) { - x = project(x, y); - return [ x[0] * k + δx, δy - x[1] * k ]; - }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream; - function projection(point) { - point = projectRotate(point[0] * d3_radians, point[1] * d3_radians); - return [ point[0] * k + δx, δy - point[1] * k ]; - } - function invert(point) { - point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k); - return point && [ point[0] * d3_degrees, point[1] * d3_degrees ]; - } - projection.stream = function(output) { - if (stream) stream.valid = false; - stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output)))); - stream.valid = true; - return stream; - }; - projection.clipAngle = function(_) { - if (!arguments.length) return clipAngle; - preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); - return invalidate(); - }; - projection.clipExtent = function(_) { - if (!arguments.length) return clipExtent; - clipExtent = _; - postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity; - return invalidate(); - }; - projection.scale = function(_) { - if (!arguments.length) return k; - k = +_; - return reset(); - }; - projection.translate = function(_) { - if (!arguments.length) return [ x, y ]; - x = +_[0]; - y = +_[1]; - return reset(); - }; - projection.center = function(_) { - if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ]; - λ = _[0] % 360 * d3_radians; - φ = _[1] % 360 * d3_radians; - return reset(); - }; - projection.rotate = function(_) { - if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ]; - δλ = _[0] % 360 * d3_radians; - δφ = _[1] % 360 * d3_radians; - δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0; - return reset(); - }; - d3.rebind(projection, projectResample, "precision"); - function reset() { - projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project); - var center = project(λ, φ); - δx = x - center[0] * k; - δy = y + center[1] * k; - return invalidate(); - } - function invalidate() { - if (stream) stream.valid = false, stream = null; - return projection; - } - return function() { - project = projectAt.apply(this, arguments); - projection.invert = project.invert && invert; - return reset(); - }; - } - function d3_geo_projectionRadians(stream) { - return d3_geo_transformPoint(stream, function(x, y) { - stream.point(x * d3_radians, y * d3_radians); - }); - } - function d3_geo_equirectangular(λ, φ) { - return [ λ, φ ]; - } - (d3.geo.equirectangular = function() { - return d3_geo_projection(d3_geo_equirectangular); - }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular; - d3.geo.rotation = function(rotate) { - rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0); - function forward(coordinates) { - coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians); - return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; - } - forward.invert = function(coordinates) { - coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians); - return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; - }; - return forward; - }; - function d3_geo_identityRotation(λ, φ) { - return [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ]; - } - d3_geo_identityRotation.invert = d3_geo_equirectangular; - function d3_geo_rotation(δλ, δφ, δγ) { - return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_identityRotation; - } - function d3_geo_forwardRotationλ(δλ) { - return function(λ, φ) { - return λ += δλ, [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ]; - }; - } - function d3_geo_rotationλ(δλ) { - var rotation = d3_geo_forwardRotationλ(δλ); - rotation.invert = d3_geo_forwardRotationλ(-δλ); - return rotation; - } - function d3_geo_rotationφγ(δφ, δγ) { - var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ); - function rotation(λ, φ) { - var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ; - return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ]; - } - rotation.invert = function(λ, φ) { - var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ; - return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ]; - }; - return rotation; - } - d3.geo.circle = function() { - var origin = [ 0, 0 ], angle, precision = 6, interpolate; - function circle() { - var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = []; - interpolate(null, null, 1, { - point: function(x, y) { - ring.push(x = rotate(x, y)); - x[0] *= d3_degrees, x[1] *= d3_degrees; - } - }); - return { - type: "Polygon", - coordinates: [ ring ] - }; - } - circle.origin = function(x) { - if (!arguments.length) return origin; - origin = x; - return circle; - }; - circle.angle = function(x) { - if (!arguments.length) return angle; - interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians); - return circle; - }; - circle.precision = function(_) { - if (!arguments.length) return precision; - interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians); - return circle; - }; - return circle.angle(90); - }; - function d3_geo_circleInterpolate(radius, precision) { - var cr = Math.cos(radius), sr = Math.sin(radius); - return function(from, to, direction, listener) { - var step = direction * precision; - if (from != null) { - from = d3_geo_circleAngle(cr, from); - to = d3_geo_circleAngle(cr, to); - if (direction > 0 ? from < to : from > to) from += direction * τ; - } else { - from = radius + direction * τ; - to = radius - .5 * step; - } - for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) { - listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]); - } - }; - } - function d3_geo_circleAngle(cr, point) { - var a = d3_geo_cartesian(point); - a[0] -= cr; - d3_geo_cartesianNormalize(a); - var angle = d3_acos(-a[1]); - return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI); - } - d3.geo.distance = function(a, b) { - var Δλ = (b[0] - a[0]) * d3_radians, φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), t; - return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ); - }; - d3.geo.graticule = function() { - var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5; - function graticule() { - return { - type: "MultiLineString", - coordinates: lines() - }; - } - function lines() { - return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) { - return abs(x % DX) > ε; - }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) { - return abs(y % DY) > ε; - }).map(y)); - } - graticule.lines = function() { - return lines().map(function(coordinates) { - return { - type: "LineString", - coordinates: coordinates - }; - }); - }; - graticule.outline = function() { - return { - type: "Polygon", - coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ] - }; - }; - graticule.extent = function(_) { - if (!arguments.length) return graticule.minorExtent(); - return graticule.majorExtent(_).minorExtent(_); - }; - graticule.majorExtent = function(_) { - if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ]; - X0 = +_[0][0], X1 = +_[1][0]; - Y0 = +_[0][1], Y1 = +_[1][1]; - if (X0 > X1) _ = X0, X0 = X1, X1 = _; - if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _; - return graticule.precision(precision); - }; - graticule.minorExtent = function(_) { - if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; - x0 = +_[0][0], x1 = +_[1][0]; - y0 = +_[0][1], y1 = +_[1][1]; - if (x0 > x1) _ = x0, x0 = x1, x1 = _; - if (y0 > y1) _ = y0, y0 = y1, y1 = _; - return graticule.precision(precision); - }; - graticule.step = function(_) { - if (!arguments.length) return graticule.minorStep(); - return graticule.majorStep(_).minorStep(_); - }; - graticule.majorStep = function(_) { - if (!arguments.length) return [ DX, DY ]; - DX = +_[0], DY = +_[1]; - return graticule; - }; - graticule.minorStep = function(_) { - if (!arguments.length) return [ dx, dy ]; - dx = +_[0], dy = +_[1]; - return graticule; - }; - graticule.precision = function(_) { - if (!arguments.length) return precision; - precision = +_; - x = d3_geo_graticuleX(y0, y1, 90); - y = d3_geo_graticuleY(x0, x1, precision); - X = d3_geo_graticuleX(Y0, Y1, 90); - Y = d3_geo_graticuleY(X0, X1, precision); - return graticule; - }; - return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]); - }; - function d3_geo_graticuleX(y0, y1, dy) { - var y = d3.range(y0, y1 - ε, dy).concat(y1); - return function(x) { - return y.map(function(y) { - return [ x, y ]; - }); - }; - } - function d3_geo_graticuleY(x0, x1, dx) { - var x = d3.range(x0, x1 - ε, dx).concat(x1); - return function(y) { - return x.map(function(x) { - return [ x, y ]; - }); - }; - } - function d3_source(d) { - return d.source; - } - function d3_target(d) { - return d.target; - } - d3.geo.greatArc = function() { - var source = d3_source, source_, target = d3_target, target_; - function greatArc() { - return { - type: "LineString", - coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ] - }; - } - greatArc.distance = function() { - return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments)); - }; - greatArc.source = function(_) { - if (!arguments.length) return source; - source = _, source_ = typeof _ === "function" ? null : _; - return greatArc; - }; - greatArc.target = function(_) { - if (!arguments.length) return target; - target = _, target_ = typeof _ === "function" ? null : _; - return greatArc; - }; - greatArc.precision = function() { - return arguments.length ? greatArc : 0; - }; - return greatArc; - }; - d3.geo.interpolate = function(source, target) { - return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians); - }; - function d3_geo_interpolate(x0, y0, x1, y1) { - var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d); - var interpolate = d ? function(t) { - var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; - return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ]; - } : function() { - return [ x0 * d3_degrees, y0 * d3_degrees ]; - }; - interpolate.distance = d; - return interpolate; - } - d3.geo.length = function(object) { - d3_geo_lengthSum = 0; - d3.geo.stream(object, d3_geo_length); - return d3_geo_lengthSum; - }; - var d3_geo_lengthSum; - var d3_geo_length = { - sphere: d3_noop, - point: d3_noop, - lineStart: d3_geo_lengthLineStart, - lineEnd: d3_noop, - polygonStart: d3_noop, - polygonEnd: d3_noop - }; - function d3_geo_lengthLineStart() { - var λ0, sinφ0, cosφ0; - d3_geo_length.point = function(λ, φ) { - λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ); - d3_geo_length.point = nextPoint; - }; - d3_geo_length.lineEnd = function() { - d3_geo_length.point = d3_geo_length.lineEnd = d3_noop; - }; - function nextPoint(λ, φ) { - var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t); - d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ); - λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ; - } - } - function d3_geo_azimuthal(scale, angle) { - function azimuthal(λ, φ) { - var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ); - return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ]; - } - azimuthal.invert = function(x, y) { - var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c); - return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ]; - }; - return azimuthal; - } - var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) { - return Math.sqrt(2 / (1 + cosλcosφ)); - }, function(ρ) { - return 2 * Math.asin(ρ / 2); - }); - (d3.geo.azimuthalEqualArea = function() { - return d3_geo_projection(d3_geo_azimuthalEqualArea); - }).raw = d3_geo_azimuthalEqualArea; - var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) { - var c = Math.acos(cosλcosφ); - return c && c / Math.sin(c); - }, d3_identity); - (d3.geo.azimuthalEquidistant = function() { - return d3_geo_projection(d3_geo_azimuthalEquidistant); - }).raw = d3_geo_azimuthalEquidistant; - function d3_geo_conicConformal(φ0, φ1) { - var cosφ0 = Math.cos(φ0), t = function(φ) { - return Math.tan(π / 4 + φ / 2); - }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n; - if (!n) return d3_geo_mercator; - function forward(λ, φ) { - var ρ = abs(abs(φ) - halfπ) < ε ? 0 : F / Math.pow(t(φ), n); - return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ]; - } - forward.invert = function(x, y) { - var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y); - return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ ]; - }; - return forward; - } - (d3.geo.conicConformal = function() { - return d3_geo_conic(d3_geo_conicConformal); - }).raw = d3_geo_conicConformal; - function d3_geo_conicEquidistant(φ0, φ1) { - var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0; - if (abs(n) < ε) return d3_geo_equirectangular; - function forward(λ, φ) { - var ρ = G - φ; - return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ]; - } - forward.invert = function(x, y) { - var ρ0_y = G - y; - return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ]; - }; - return forward; - } - (d3.geo.conicEquidistant = function() { - return d3_geo_conic(d3_geo_conicEquidistant); - }).raw = d3_geo_conicEquidistant; - var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) { - return 1 / cosλcosφ; - }, Math.atan); - (d3.geo.gnomonic = function() { - return d3_geo_projection(d3_geo_gnomonic); - }).raw = d3_geo_gnomonic; - function d3_geo_mercator(λ, φ) { - return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ]; - } - d3_geo_mercator.invert = function(x, y) { - return [ x, 2 * Math.atan(Math.exp(y)) - halfπ ]; - }; - function d3_geo_mercatorProjection(project) { - var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto; - m.scale = function() { - var v = scale.apply(m, arguments); - return v === m ? clipAuto ? m.clipExtent(null) : m : v; - }; - m.translate = function() { - var v = translate.apply(m, arguments); - return v === m ? clipAuto ? m.clipExtent(null) : m : v; - }; - m.clipExtent = function(_) { - var v = clipExtent.apply(m, arguments); - if (v === m) { - if (clipAuto = _ == null) { - var k = π * scale(), t = translate(); - clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]); - } - } else if (clipAuto) { - v = null; - } - return v; - }; - return m.clipExtent(null); - } - (d3.geo.mercator = function() { - return d3_geo_mercatorProjection(d3_geo_mercator); - }).raw = d3_geo_mercator; - var d3_geo_orthographic = d3_geo_azimuthal(function() { - return 1; - }, Math.asin); - (d3.geo.orthographic = function() { - return d3_geo_projection(d3_geo_orthographic); - }).raw = d3_geo_orthographic; - var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) { - return 1 / (1 + cosλcosφ); - }, function(ρ) { - return 2 * Math.atan(ρ); - }); - (d3.geo.stereographic = function() { - return d3_geo_projection(d3_geo_stereographic); - }).raw = d3_geo_stereographic; - function d3_geo_transverseMercator(λ, φ) { - return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ]; - } - d3_geo_transverseMercator.invert = function(x, y) { - return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ]; - }; - (d3.geo.transverseMercator = function() { - var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate; - projection.center = function(_) { - return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ -_[1], _[0] ]); - }; - projection.rotate = function(_) { - return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), - [ _[0], _[1], _[2] - 90 ]); - }; - return projection.rotate([ 0, 0 ]); - }).raw = d3_geo_transverseMercator; - d3.geom = {}; - function d3_geom_pointX(d) { - return d[0]; - } - function d3_geom_pointY(d) { - return d[1]; - } - d3.geom.hull = function(vertices) { - var x = d3_geom_pointX, y = d3_geom_pointY; - if (arguments.length) return hull(vertices); - function hull(data) { - if (data.length < 3) return []; - var fx = d3_functor(x), fy = d3_functor(y), n = data.length, vertices, plen = n - 1, points = [], stack = [], d, i, j, h = 0, x1, y1, x2, y2, u, v, a, sp; - if (fx === d3_geom_pointX && y === d3_geom_pointY) vertices = data; else for (i = 0, - vertices = []; i < n; ++i) { - vertices.push([ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]); - } - for (i = 1; i < n; ++i) { - if (vertices[i][1] < vertices[h][1] || vertices[i][1] == vertices[h][1] && vertices[i][0] < vertices[h][0]) h = i; - } - for (i = 0; i < n; ++i) { - if (i === h) continue; - y1 = vertices[i][1] - vertices[h][1]; - x1 = vertices[i][0] - vertices[h][0]; - points.push({ - angle: Math.atan2(y1, x1), - index: i - }); - } - points.sort(function(a, b) { - return a.angle - b.angle; - }); - a = points[0].angle; - v = points[0].index; - u = 0; - for (i = 1; i < plen; ++i) { - j = points[i].index; - if (a == points[i].angle) { - x1 = vertices[v][0] - vertices[h][0]; - y1 = vertices[v][1] - vertices[h][1]; - x2 = vertices[j][0] - vertices[h][0]; - y2 = vertices[j][1] - vertices[h][1]; - if (x1 * x1 + y1 * y1 >= x2 * x2 + y2 * y2) { - points[i].index = -1; - continue; - } else { - points[u].index = -1; - } - } - a = points[i].angle; - u = i; - v = j; - } - stack.push(h); - for (i = 0, j = 0; i < 2; ++j) { - if (points[j].index > -1) { - stack.push(points[j].index); - i++; - } - } - sp = stack.length; - for (;j < plen; ++j) { - if (points[j].index < 0) continue; - while (!d3_geom_hullCCW(stack[sp - 2], stack[sp - 1], points[j].index, vertices)) { - --sp; - } - stack[sp++] = points[j].index; - } - var poly = []; - for (i = sp - 1; i >= 0; --i) poly.push(data[stack[i]]); - return poly; - } - hull.x = function(_) { - return arguments.length ? (x = _, hull) : x; - }; - hull.y = function(_) { - return arguments.length ? (y = _, hull) : y; - }; - return hull; - }; - function d3_geom_hullCCW(i1, i2, i3, v) { - var t, a, b, c, d, e, f; - t = v[i1]; - a = t[0]; - b = t[1]; - t = v[i2]; - c = t[0]; - d = t[1]; - t = v[i3]; - e = t[0]; - f = t[1]; - return (f - b) * (c - a) - (d - b) * (e - a) > 0; - } - d3.geom.polygon = function(coordinates) { - d3_subclass(coordinates, d3_geom_polygonPrototype); - return coordinates; - }; - var d3_geom_polygonPrototype = d3.geom.polygon.prototype = []; - d3_geom_polygonPrototype.area = function() { - var i = -1, n = this.length, a, b = this[n - 1], area = 0; - while (++i < n) { - a = b; - b = this[i]; - area += a[1] * b[0] - a[0] * b[1]; - } - return area * .5; - }; - d3_geom_polygonPrototype.centroid = function(k) { - var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c; - if (!arguments.length) k = -1 / (6 * this.area()); - while (++i < n) { - a = b; - b = this[i]; - c = a[0] * b[1] - b[0] * a[1]; - x += (a[0] + b[0]) * c; - y += (a[1] + b[1]) * c; - } - return [ x * k, y * k ]; - }; - d3_geom_polygonPrototype.clip = function(subject) { - var input, closed = d3_geom_polygonClosed(subject), i = -1, n = this.length - d3_geom_polygonClosed(this), j, m, a = this[n - 1], b, c, d; - while (++i < n) { - input = subject.slice(); - subject.length = 0; - b = this[i]; - c = input[(m = input.length - closed) - 1]; - j = -1; - while (++j < m) { - d = input[j]; - if (d3_geom_polygonInside(d, a, b)) { - if (!d3_geom_polygonInside(c, a, b)) { - subject.push(d3_geom_polygonIntersect(c, d, a, b)); - } - subject.push(d); - } else if (d3_geom_polygonInside(c, a, b)) { - subject.push(d3_geom_polygonIntersect(c, d, a, b)); - } - c = d; - } - if (closed) subject.push(subject[0]); - a = b; - } - return subject; - }; - function d3_geom_polygonInside(p, a, b) { - return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); - } - function d3_geom_polygonIntersect(c, d, a, b) { - var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21); - return [ x1 + ua * x21, y1 + ua * y21 ]; - } - function d3_geom_polygonClosed(coordinates) { - var a = coordinates[0], b = coordinates[coordinates.length - 1]; - return !(a[0] - b[0] || a[1] - b[1]); - } - var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = []; - function d3_geom_voronoiBeach() { - d3_geom_voronoiRedBlackNode(this); - this.edge = this.site = this.circle = null; - } - function d3_geom_voronoiCreateBeach(site) { - var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach(); - beach.site = site; - return beach; - } - function d3_geom_voronoiDetachBeach(beach) { - d3_geom_voronoiDetachCircle(beach); - d3_geom_voronoiBeaches.remove(beach); - d3_geom_voronoiBeachPool.push(beach); - d3_geom_voronoiRedBlackNode(beach); - } - function d3_geom_voronoiRemoveBeach(beach) { - var circle = beach.circle, x = circle.x, y = circle.cy, vertex = { - x: x, - y: y - }, previous = beach.P, next = beach.N, disappearing = [ beach ]; - d3_geom_voronoiDetachBeach(beach); - var lArc = previous; - while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) { - previous = lArc.P; - disappearing.unshift(lArc); - d3_geom_voronoiDetachBeach(lArc); - lArc = previous; - } - disappearing.unshift(lArc); - d3_geom_voronoiDetachCircle(lArc); - var rArc = next; - while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) { - next = rArc.N; - disappearing.push(rArc); - d3_geom_voronoiDetachBeach(rArc); - rArc = next; - } - disappearing.push(rArc); - d3_geom_voronoiDetachCircle(rArc); - var nArcs = disappearing.length, iArc; - for (iArc = 1; iArc < nArcs; ++iArc) { - rArc = disappearing[iArc]; - lArc = disappearing[iArc - 1]; - d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex); - } - lArc = disappearing[0]; - rArc = disappearing[nArcs - 1]; - rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex); - d3_geom_voronoiAttachCircle(lArc); - d3_geom_voronoiAttachCircle(rArc); - } - function d3_geom_voronoiAddBeach(site) { - var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._; - while (node) { - dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x; - if (dxl > ε) node = node.L; else { - dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix); - if (dxr > ε) { - if (!node.R) { - lArc = node; - break; - } - node = node.R; - } else { - if (dxl > -ε) { - lArc = node.P; - rArc = node; - } else if (dxr > -ε) { - lArc = node; - rArc = node.N; - } else { - lArc = rArc = node; - } - break; - } - } - } - var newArc = d3_geom_voronoiCreateBeach(site); - d3_geom_voronoiBeaches.insert(lArc, newArc); - if (!lArc && !rArc) return; - if (lArc === rArc) { - d3_geom_voronoiDetachCircle(lArc); - rArc = d3_geom_voronoiCreateBeach(lArc.site); - d3_geom_voronoiBeaches.insert(newArc, rArc); - newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); - d3_geom_voronoiAttachCircle(lArc); - d3_geom_voronoiAttachCircle(rArc); - return; - } - if (!rArc) { - newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); - return; - } - d3_geom_voronoiDetachCircle(lArc); - d3_geom_voronoiDetachCircle(rArc); - var lSite = lArc.site, ax = lSite.x, ay = lSite.y, bx = site.x - ax, by = site.y - ay, rSite = rArc.site, cx = rSite.x - ax, cy = rSite.y - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = { - x: (cy * hb - by * hc) / d + ax, - y: (bx * hc - cx * hb) / d + ay - }; - d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex); - newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex); - rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex); - d3_geom_voronoiAttachCircle(lArc); - d3_geom_voronoiAttachCircle(rArc); - } - function d3_geom_voronoiLeftBreakPoint(arc, directrix) { - var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix; - if (!pby2) return rfocx; - var lArc = arc.P; - if (!lArc) return -Infinity; - site = lArc.site; - var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix; - if (!plby2) return lfocx; - var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2; - if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx; - return (rfocx + lfocx) / 2; - } - function d3_geom_voronoiRightBreakPoint(arc, directrix) { - var rArc = arc.N; - if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix); - var site = arc.site; - return site.y === directrix ? site.x : Infinity; - } - function d3_geom_voronoiCell(site) { - this.site = site; - this.edges = []; - } - d3_geom_voronoiCell.prototype.prepare = function() { - var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge; - while (iHalfEdge--) { - edge = halfEdges[iHalfEdge].edge; - if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1); - } - halfEdges.sort(d3_geom_voronoiHalfEdgeOrder); - return halfEdges.length; - }; - function d3_geom_voronoiCloseCells(extent) { - var x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], x2, y2, x3, y3, cells = d3_geom_voronoiCells, iCell = cells.length, cell, iHalfEdge, halfEdges, nHalfEdges, start, end; - while (iCell--) { - cell = cells[iCell]; - if (!cell || !cell.prepare()) continue; - halfEdges = cell.edges; - nHalfEdges = halfEdges.length; - iHalfEdge = 0; - while (iHalfEdge < nHalfEdges) { - end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y; - start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y; - if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) { - halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? { - x: x0, - y: abs(x2 - x0) < ε ? y2 : y1 - } : abs(y3 - y1) < ε && x1 - x3 > ε ? { - x: abs(y2 - y1) < ε ? x2 : x1, - y: y1 - } : abs(x3 - x1) < ε && y3 - y0 > ε ? { - x: x1, - y: abs(x2 - x1) < ε ? y2 : y0 - } : abs(y3 - y0) < ε && x3 - x0 > ε ? { - x: abs(y2 - y0) < ε ? x2 : x0, - y: y0 - } : null), cell.site, null)); - ++nHalfEdges; - } - } - } - } - function d3_geom_voronoiHalfEdgeOrder(a, b) { - return b.angle - a.angle; - } - function d3_geom_voronoiCircle() { - d3_geom_voronoiRedBlackNode(this); - this.x = this.y = this.arc = this.site = this.cy = null; - } - function d3_geom_voronoiAttachCircle(arc) { - var lArc = arc.P, rArc = arc.N; - if (!lArc || !rArc) return; - var lSite = lArc.site, cSite = arc.site, rSite = rArc.site; - if (lSite === rSite) return; - var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by; - var d = 2 * (ax * cy - ay * cx); - if (d >= -ε2) return; - var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x = (cy * ha - ay * hc) / d, y = (ax * hc - cx * ha) / d, cy = y + by; - var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle(); - circle.arc = arc; - circle.site = cSite; - circle.x = x + bx; - circle.y = cy + Math.sqrt(x * x + y * y); - circle.cy = cy; - arc.circle = circle; - var before = null, node = d3_geom_voronoiCircles._; - while (node) { - if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) { - if (node.L) node = node.L; else { - before = node.P; - break; - } - } else { - if (node.R) node = node.R; else { - before = node; - break; - } - } - } - d3_geom_voronoiCircles.insert(before, circle); - if (!before) d3_geom_voronoiFirstCircle = circle; - } - function d3_geom_voronoiDetachCircle(arc) { - var circle = arc.circle; - if (circle) { - if (!circle.P) d3_geom_voronoiFirstCircle = circle.N; - d3_geom_voronoiCircles.remove(circle); - d3_geom_voronoiCirclePool.push(circle); - d3_geom_voronoiRedBlackNode(circle); - arc.circle = null; - } - } - function d3_geom_voronoiClipEdges(extent) { - var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e; - while (i--) { - e = edges[i]; - if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) { - e.a = e.b = null; - edges.splice(i, 1); - } - } - } - function d3_geom_voronoiConnectEdge(edge, extent) { - var vb = edge.b; - if (vb) return true; - var va = edge.a, x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], lSite = edge.l, rSite = edge.r, lx = lSite.x, ly = lSite.y, rx = rSite.x, ry = rSite.y, fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb; - if (ry === ly) { - if (fx < x0 || fx >= x1) return; - if (lx > rx) { - if (!va) va = { - x: fx, - y: y0 - }; else if (va.y >= y1) return; - vb = { - x: fx, - y: y1 - }; - } else { - if (!va) va = { - x: fx, - y: y1 - }; else if (va.y < y0) return; - vb = { - x: fx, - y: y0 - }; - } - } else { - fm = (lx - rx) / (ry - ly); - fb = fy - fm * fx; - if (fm < -1 || fm > 1) { - if (lx > rx) { - if (!va) va = { - x: (y0 - fb) / fm, - y: y0 - }; else if (va.y >= y1) return; - vb = { - x: (y1 - fb) / fm, - y: y1 - }; - } else { - if (!va) va = { - x: (y1 - fb) / fm, - y: y1 - }; else if (va.y < y0) return; - vb = { - x: (y0 - fb) / fm, - y: y0 - }; - } - } else { - if (ly < ry) { - if (!va) va = { - x: x0, - y: fm * x0 + fb - }; else if (va.x >= x1) return; - vb = { - x: x1, - y: fm * x1 + fb - }; - } else { - if (!va) va = { - x: x1, - y: fm * x1 + fb - }; else if (va.x < x0) return; - vb = { - x: x0, - y: fm * x0 + fb - }; - } - } - } - edge.a = va; - edge.b = vb; - return true; - } - function d3_geom_voronoiEdge(lSite, rSite) { - this.l = lSite; - this.r = rSite; - this.a = this.b = null; - } - function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) { - var edge = new d3_geom_voronoiEdge(lSite, rSite); - d3_geom_voronoiEdges.push(edge); - if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va); - if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb); - d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite)); - d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite)); - return edge; - } - function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) { - var edge = new d3_geom_voronoiEdge(lSite, null); - edge.a = va; - edge.b = vb; - d3_geom_voronoiEdges.push(edge); - return edge; - } - function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) { - if (!edge.a && !edge.b) { - edge.a = vertex; - edge.l = lSite; - edge.r = rSite; - } else if (edge.l === rSite) { - edge.b = vertex; - } else { - edge.a = vertex; - } - } - function d3_geom_voronoiHalfEdge(edge, lSite, rSite) { - var va = edge.a, vb = edge.b; - this.edge = edge; - this.site = lSite; - this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) : Math.atan2(va.x - vb.x, vb.y - va.y); - } - d3_geom_voronoiHalfEdge.prototype = { - start: function() { - return this.edge.l === this.site ? this.edge.a : this.edge.b; - }, - end: function() { - return this.edge.l === this.site ? this.edge.b : this.edge.a; - } - }; - function d3_geom_voronoiRedBlackTree() { - this._ = null; - } - function d3_geom_voronoiRedBlackNode(node) { - node.U = node.C = node.L = node.R = node.P = node.N = null; - } - d3_geom_voronoiRedBlackTree.prototype = { - insert: function(after, node) { - var parent, grandpa, uncle; - if (after) { - node.P = after; - node.N = after.N; - if (after.N) after.N.P = node; - after.N = node; - if (after.R) { - after = after.R; - while (after.L) after = after.L; - after.L = node; - } else { - after.R = node; - } - parent = after; - } else if (this._) { - after = d3_geom_voronoiRedBlackFirst(this._); - node.P = null; - node.N = after; - after.P = after.L = node; - parent = after; - } else { - node.P = node.N = null; - this._ = node; - parent = null; - } - node.L = node.R = null; - node.U = parent; - node.C = true; - after = node; - while (parent && parent.C) { - grandpa = parent.U; - if (parent === grandpa.L) { - uncle = grandpa.R; - if (uncle && uncle.C) { - parent.C = uncle.C = false; - grandpa.C = true; - after = grandpa; - } else { - if (after === parent.R) { - d3_geom_voronoiRedBlackRotateLeft(this, parent); - after = parent; - parent = after.U; - } - parent.C = false; - grandpa.C = true; - d3_geom_voronoiRedBlackRotateRight(this, grandpa); - } - } else { - uncle = grandpa.L; - if (uncle && uncle.C) { - parent.C = uncle.C = false; - grandpa.C = true; - after = grandpa; - } else { - if (after === parent.L) { - d3_geom_voronoiRedBlackRotateRight(this, parent); - after = parent; - parent = after.U; - } - parent.C = false; - grandpa.C = true; - d3_geom_voronoiRedBlackRotateLeft(this, grandpa); - } - } - parent = after.U; - } - this._.C = false; - }, - remove: function(node) { - if (node.N) node.N.P = node.P; - if (node.P) node.P.N = node.N; - node.N = node.P = null; - var parent = node.U, sibling, left = node.L, right = node.R, next, red; - if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right); - if (parent) { - if (parent.L === node) parent.L = next; else parent.R = next; - } else { - this._ = next; - } - if (left && right) { - red = next.C; - next.C = node.C; - next.L = left; - left.U = next; - if (next !== right) { - parent = next.U; - next.U = node.U; - node = next.R; - parent.L = node; - next.R = right; - right.U = next; - } else { - next.U = parent; - parent = next; - node = next.R; - } - } else { - red = node.C; - node = next; - } - if (node) node.U = parent; - if (red) return; - if (node && node.C) { - node.C = false; - return; - } - do { - if (node === this._) break; - if (node === parent.L) { - sibling = parent.R; - if (sibling.C) { - sibling.C = false; - parent.C = true; - d3_geom_voronoiRedBlackRotateLeft(this, parent); - sibling = parent.R; - } - if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { - if (!sibling.R || !sibling.R.C) { - sibling.L.C = false; - sibling.C = true; - d3_geom_voronoiRedBlackRotateRight(this, sibling); - sibling = parent.R; - } - sibling.C = parent.C; - parent.C = sibling.R.C = false; - d3_geom_voronoiRedBlackRotateLeft(this, parent); - node = this._; - break; - } - } else { - sibling = parent.L; - if (sibling.C) { - sibling.C = false; - parent.C = true; - d3_geom_voronoiRedBlackRotateRight(this, parent); - sibling = parent.L; - } - if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { - if (!sibling.L || !sibling.L.C) { - sibling.R.C = false; - sibling.C = true; - d3_geom_voronoiRedBlackRotateLeft(this, sibling); - sibling = parent.L; - } - sibling.C = parent.C; - parent.C = sibling.L.C = false; - d3_geom_voronoiRedBlackRotateRight(this, parent); - node = this._; - break; - } - } - sibling.C = true; - node = parent; - parent = parent.U; - } while (!node.C); - if (node) node.C = false; - } - }; - function d3_geom_voronoiRedBlackRotateLeft(tree, node) { - var p = node, q = node.R, parent = p.U; - if (parent) { - if (parent.L === p) parent.L = q; else parent.R = q; - } else { - tree._ = q; - } - q.U = parent; - p.U = q; - p.R = q.L; - if (p.R) p.R.U = p; - q.L = p; - } - function d3_geom_voronoiRedBlackRotateRight(tree, node) { - var p = node, q = node.L, parent = p.U; - if (parent) { - if (parent.L === p) parent.L = q; else parent.R = q; - } else { - tree._ = q; - } - q.U = parent; - p.U = q; - p.L = q.R; - if (p.L) p.L.U = p; - q.R = p; - } - function d3_geom_voronoiRedBlackFirst(node) { - while (node.L) node = node.L; - return node; - } - function d3_geom_voronoi(sites, bbox) { - var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle; - d3_geom_voronoiEdges = []; - d3_geom_voronoiCells = new Array(sites.length); - d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree(); - d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree(); - while (true) { - circle = d3_geom_voronoiFirstCircle; - if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) { - if (site.x !== x0 || site.y !== y0) { - d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site); - d3_geom_voronoiAddBeach(site); - x0 = site.x, y0 = site.y; - } - site = sites.pop(); - } else if (circle) { - d3_geom_voronoiRemoveBeach(circle.arc); - } else { - break; - } - } - if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox); - var diagram = { - cells: d3_geom_voronoiCells, - edges: d3_geom_voronoiEdges - }; - d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null; - return diagram; - } - function d3_geom_voronoiVertexOrder(a, b) { - return b.y - a.y || b.x - a.x; - } - d3.geom.voronoi = function(points) { - var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent; - if (points) return voronoi(points); - function voronoi(data) { - var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1]; - d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) { - var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) { - var s = e.start(); - return [ s.x, s.y ]; - }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : []; - polygon.point = data[i]; - }); - return polygons; - } - function sites(data) { - return data.map(function(d, i) { - return { - x: Math.round(fx(d, i) / ε) * ε, - y: Math.round(fy(d, i) / ε) * ε, - i: i - }; - }); - } - voronoi.links = function(data) { - return d3_geom_voronoi(sites(data)).edges.filter(function(edge) { - return edge.l && edge.r; - }).map(function(edge) { - return { - source: data[edge.l.i], - target: data[edge.r.i] - }; - }); - }; - voronoi.triangles = function(data) { - var triangles = []; - d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) { - var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, e0, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l; - while (++j < m) { - e0 = e1; - s0 = s1; - e1 = edges[j].edge; - s1 = e1.l === site ? e1.r : e1.l; - if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) { - triangles.push([ data[i], data[s0.i], data[s1.i] ]); - } - } - }); - return triangles; - }; - voronoi.x = function(_) { - return arguments.length ? (fx = d3_functor(x = _), voronoi) : x; - }; - voronoi.y = function(_) { - return arguments.length ? (fy = d3_functor(y = _), voronoi) : y; - }; - voronoi.clipExtent = function(_) { - if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent; - clipExtent = _ == null ? d3_geom_voronoiClipExtent : _; - return voronoi; - }; - voronoi.size = function(_) { - if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1]; - return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]); - }; - return voronoi; - }; - var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ]; - function d3_geom_voronoiTriangleArea(a, b, c) { - return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y); - } - d3.geom.delaunay = function(vertices) { - return d3.geom.voronoi().triangles(vertices); - }; - d3.geom.quadtree = function(points, x1, y1, x2, y2) { - var x = d3_geom_pointX, y = d3_geom_pointY, compat; - if (compat = arguments.length) { - x = d3_geom_quadtreeCompatX; - y = d3_geom_quadtreeCompatY; - if (compat === 3) { - y2 = y1; - x2 = x1; - y1 = x1 = 0; - } - return quadtree(points); - } - function quadtree(data) { - var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_; - if (x1 != null) { - x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2; - } else { - x2_ = y2_ = -(x1_ = y1_ = Infinity); - xs = [], ys = []; - n = data.length; - if (compat) for (i = 0; i < n; ++i) { - d = data[i]; - if (d.x < x1_) x1_ = d.x; - if (d.y < y1_) y1_ = d.y; - if (d.x > x2_) x2_ = d.x; - if (d.y > y2_) y2_ = d.y; - xs.push(d.x); - ys.push(d.y); - } else for (i = 0; i < n; ++i) { - var x_ = +fx(d = data[i], i), y_ = +fy(d, i); - if (x_ < x1_) x1_ = x_; - if (y_ < y1_) y1_ = y_; - if (x_ > x2_) x2_ = x_; - if (y_ > y2_) y2_ = y_; - xs.push(x_); - ys.push(y_); - } - } - var dx = x2_ - x1_, dy = y2_ - y1_; - if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy; - function insert(n, d, x, y, x1, y1, x2, y2) { - if (isNaN(x) || isNaN(y)) return; - if (n.leaf) { - var nx = n.x, ny = n.y; - if (nx != null) { - if (abs(nx - x) + abs(ny - y) < .01) { - insertChild(n, d, x, y, x1, y1, x2, y2); - } else { - var nPoint = n.point; - n.x = n.y = n.point = null; - insertChild(n, nPoint, nx, ny, x1, y1, x2, y2); - insertChild(n, d, x, y, x1, y1, x2, y2); - } - } else { - n.x = x, n.y = y, n.point = d; - } - } else { - insertChild(n, d, x, y, x1, y1, x2, y2); - } - } - function insertChild(n, d, x, y, x1, y1, x2, y2) { - var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, right = x >= sx, bottom = y >= sy, i = (bottom << 1) + right; - n.leaf = false; - n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); - if (right) x1 = sx; else x2 = sx; - if (bottom) y1 = sy; else y2 = sy; - insert(n, d, x, y, x1, y1, x2, y2); - } - var root = d3_geom_quadtreeNode(); - root.add = function(d) { - insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_); - }; - root.visit = function(f) { - d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_); - }; - i = -1; - if (x1 == null) { - while (++i < n) { - insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_); - } - --i; - } else data.forEach(root.add); - xs = ys = data = d = null; - return root; - } - quadtree.x = function(_) { - return arguments.length ? (x = _, quadtree) : x; - }; - quadtree.y = function(_) { - return arguments.length ? (y = _, quadtree) : y; - }; - quadtree.extent = function(_) { - if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ]; - if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], - y2 = +_[1][1]; - return quadtree; - }; - quadtree.size = function(_) { - if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ]; - if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1]; - return quadtree; - }; - return quadtree; - }; - function d3_geom_quadtreeCompatX(d) { - return d.x; - } - function d3_geom_quadtreeCompatY(d) { - return d.y; - } - function d3_geom_quadtreeNode() { - return { - leaf: true, - nodes: [], - point: null, - x: null, - y: null - }; - } - function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) { - if (!f(node, x1, y1, x2, y2)) { - var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes; - if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy); - if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy); - if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2); - if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); - } - } - d3.interpolateRgb = d3_interpolateRgb; - function d3_interpolateRgb(a, b) { - a = d3.rgb(a); - b = d3.rgb(b); - var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab; - return function(t) { - return "#" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t)); - }; - } - d3.interpolateObject = d3_interpolateObject; - function d3_interpolateObject(a, b) { - var i = {}, c = {}, k; - for (k in a) { - if (k in b) { - i[k] = d3_interpolate(a[k], b[k]); - } else { - c[k] = a[k]; - } - } - for (k in b) { - if (!(k in a)) { - c[k] = b[k]; - } - } - return function(t) { - for (k in i) c[k] = i[k](t); - return c; - }; - } - d3.interpolateNumber = d3_interpolateNumber; - function d3_interpolateNumber(a, b) { - b -= a = +a; - return function(t) { - return a + b * t; - }; - } - d3.interpolateString = d3_interpolateString; - function d3_interpolateString(a, b) { - var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o; - a = a + "", b = b + ""; - d3_interpolate_number.lastIndex = 0; - for (i = 0; m = d3_interpolate_number.exec(b); ++i) { - if (m.index) s.push(b.substring(s0, s1 = m.index)); - q.push({ - i: s.length, - x: m[0] - }); - s.push(null); - s0 = d3_interpolate_number.lastIndex; - } - if (s0 < b.length) s.push(b.substring(s0)); - for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) { - o = q[i]; - if (o.x == m[0]) { - if (o.i) { - if (s[o.i + 1] == null) { - s[o.i - 1] += o.x; - s.splice(o.i, 1); - for (j = i + 1; j < n; ++j) q[j].i--; - } else { - s[o.i - 1] += o.x + s[o.i + 1]; - s.splice(o.i, 2); - for (j = i + 1; j < n; ++j) q[j].i -= 2; - } - } else { - if (s[o.i + 1] == null) { - s[o.i] = o.x; - } else { - s[o.i] = o.x + s[o.i + 1]; - s.splice(o.i + 1, 1); - for (j = i + 1; j < n; ++j) q[j].i--; - } - } - q.splice(i, 1); - n--; - i--; - } else { - o.x = d3_interpolateNumber(parseFloat(m[0]), parseFloat(o.x)); - } - } - while (i < n) { - o = q.pop(); - if (s[o.i + 1] == null) { - s[o.i] = o.x; - } else { - s[o.i] = o.x + s[o.i + 1]; - s.splice(o.i + 1, 1); - } - n--; - } - if (s.length === 1) { - return s[0] == null ? (o = q[0].x, function(t) { - return o(t) + ""; - }) : function() { - return b; - }; - } - return function(t) { - for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t); - return s.join(""); - }; - } - var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g; - d3.interpolate = d3_interpolate; - function d3_interpolate(a, b) { - var i = d3.interpolators.length, f; - while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ; - return f; - } - d3.interpolators = [ function(a, b) { - var t = typeof b; - return (t === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_Color ? d3_interpolateRgb : t === "object" ? Array.isArray(b) ? d3_interpolateArray : d3_interpolateObject : d3_interpolateNumber)(a, b); - } ]; - d3.interpolateArray = d3_interpolateArray; - function d3_interpolateArray(a, b) { - var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i; - for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i])); - for (;i < na; ++i) c[i] = a[i]; - for (;i < nb; ++i) c[i] = b[i]; - return function(t) { - for (i = 0; i < n0; ++i) c[i] = x[i](t); - return c; - }; - } - var d3_ease_default = function() { - return d3_identity; - }; - var d3_ease = d3.map({ - linear: d3_ease_default, - poly: d3_ease_poly, - quad: function() { - return d3_ease_quad; - }, - cubic: function() { - return d3_ease_cubic; - }, - sin: function() { - return d3_ease_sin; - }, - exp: function() { - return d3_ease_exp; - }, - circle: function() { - return d3_ease_circle; - }, - elastic: d3_ease_elastic, - back: d3_ease_back, - bounce: function() { - return d3_ease_bounce; - } - }); - var d3_ease_mode = d3.map({ - "in": d3_identity, - out: d3_ease_reverse, - "in-out": d3_ease_reflect, - "out-in": function(f) { - return d3_ease_reflect(d3_ease_reverse(f)); - } - }); - d3.ease = function(name) { - var i = name.indexOf("-"), t = i >= 0 ? name.substring(0, i) : name, m = i >= 0 ? name.substring(i + 1) : "in"; - t = d3_ease.get(t) || d3_ease_default; - m = d3_ease_mode.get(m) || d3_identity; - return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1)))); - }; - function d3_ease_clamp(f) { - return function(t) { - return t <= 0 ? 0 : t >= 1 ? 1 : f(t); - }; - } - function d3_ease_reverse(f) { - return function(t) { - return 1 - f(1 - t); - }; - } - function d3_ease_reflect(f) { - return function(t) { - return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t)); - }; - } - function d3_ease_quad(t) { - return t * t; - } - function d3_ease_cubic(t) { - return t * t * t; - } - function d3_ease_cubicInOut(t) { - if (t <= 0) return 0; - if (t >= 1) return 1; - var t2 = t * t, t3 = t2 * t; - return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75); - } - function d3_ease_poly(e) { - return function(t) { - return Math.pow(t, e); - }; - } - function d3_ease_sin(t) { - return 1 - Math.cos(t * halfπ); - } - function d3_ease_exp(t) { - return Math.pow(2, 10 * (t - 1)); - } - function d3_ease_circle(t) { - return 1 - Math.sqrt(1 - t * t); - } - function d3_ease_elastic(a, p) { - var s; - if (arguments.length < 2) p = .45; - if (arguments.length) s = p / τ * Math.asin(1 / a); else a = 1, s = p / 4; - return function(t) { - return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p); - }; - } - function d3_ease_back(s) { - if (!s) s = 1.70158; - return function(t) { - return t * t * ((s + 1) * t - s); - }; - } - function d3_ease_bounce(t) { - return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375; - } - d3.interpolateHcl = d3_interpolateHcl; - function d3_interpolateHcl(a, b) { - a = d3.hcl(a); - b = d3.hcl(b); - var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al; - if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac; - if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; - return function(t) { - return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; - }; - } - d3.interpolateHsl = d3_interpolateHsl; - function d3_interpolateHsl(a, b) { - a = d3.hsl(a); - b = d3.hsl(b); - var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al; - if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as; - if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; - return function(t) { - return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + ""; - }; - } - d3.interpolateLab = d3_interpolateLab; - function d3_interpolateLab(a, b) { - a = d3.lab(a); - b = d3.lab(b); - var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab; - return function(t) { - return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; - }; - } - d3.interpolateRound = d3_interpolateRound; - function d3_interpolateRound(a, b) { - b -= a; - return function(t) { - return Math.round(a + b * t); - }; - } - d3.transform = function(string) { - var g = d3_document.createElementNS(d3.ns.prefix.svg, "g"); - return (d3.transform = function(string) { - if (string != null) { - g.setAttribute("transform", string); - var t = g.transform.baseVal.consolidate(); - } - return new d3_transform(t ? t.matrix : d3_transformIdentity); - })(string); - }; - function d3_transform(m) { - var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0; - if (r0[0] * r1[1] < r1[0] * r0[1]) { - r0[0] *= -1; - r0[1] *= -1; - kx *= -1; - kz *= -1; - } - this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees; - this.translate = [ m.e, m.f ]; - this.scale = [ kx, ky ]; - this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0; - } - d3_transform.prototype.toString = function() { - return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")"; - }; - function d3_transformDot(a, b) { - return a[0] * b[0] + a[1] * b[1]; - } - function d3_transformNormalize(a) { - var k = Math.sqrt(d3_transformDot(a, a)); - if (k) { - a[0] /= k; - a[1] /= k; - } - return k; - } - function d3_transformCombine(a, b, k) { - a[0] += k * b[0]; - a[1] += k * b[1]; - return a; - } - var d3_transformIdentity = { - a: 1, - b: 0, - c: 0, - d: 1, - e: 0, - f: 0 - }; - d3.interpolateTransform = d3_interpolateTransform; - function d3_interpolateTransform(a, b) { - var s = [], q = [], n, A = d3.transform(a), B = d3.transform(b), ta = A.translate, tb = B.translate, ra = A.rotate, rb = B.rotate, wa = A.skew, wb = B.skew, ka = A.scale, kb = B.scale; - if (ta[0] != tb[0] || ta[1] != tb[1]) { - s.push("translate(", null, ",", null, ")"); - q.push({ - i: 1, - x: d3_interpolateNumber(ta[0], tb[0]) - }, { - i: 3, - x: d3_interpolateNumber(ta[1], tb[1]) - }); - } else if (tb[0] || tb[1]) { - s.push("translate(" + tb + ")"); - } else { - s.push(""); - } - if (ra != rb) { - if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; - q.push({ - i: s.push(s.pop() + "rotate(", null, ")") - 2, - x: d3_interpolateNumber(ra, rb) - }); - } else if (rb) { - s.push(s.pop() + "rotate(" + rb + ")"); - } - if (wa != wb) { - q.push({ - i: s.push(s.pop() + "skewX(", null, ")") - 2, - x: d3_interpolateNumber(wa, wb) - }); - } else if (wb) { - s.push(s.pop() + "skewX(" + wb + ")"); - } - if (ka[0] != kb[0] || ka[1] != kb[1]) { - n = s.push(s.pop() + "scale(", null, ",", null, ")"); - q.push({ - i: n - 4, - x: d3_interpolateNumber(ka[0], kb[0]) - }, { - i: n - 2, - x: d3_interpolateNumber(ka[1], kb[1]) - }); - } else if (kb[0] != 1 || kb[1] != 1) { - s.push(s.pop() + "scale(" + kb + ")"); - } - n = q.length; - return function(t) { - var i = -1, o; - while (++i < n) s[(o = q[i]).i] = o.x(t); - return s.join(""); - }; - } - function d3_uninterpolateNumber(a, b) { - b = b - (a = +a) ? 1 / (b - a) : 0; - return function(x) { - return (x - a) * b; - }; - } - function d3_uninterpolateClamp(a, b) { - b = b - (a = +a) ? 1 / (b - a) : 0; - return function(x) { - return Math.max(0, Math.min(1, (x - a) * b)); - }; - } - d3.layout = {}; - d3.layout.bundle = function() { - return function(links) { - var paths = [], i = -1, n = links.length; - while (++i < n) paths.push(d3_layout_bundlePath(links[i])); - return paths; - }; - }; - function d3_layout_bundlePath(link) { - var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ]; - while (start !== lca) { - start = start.parent; - points.push(start); - } - var k = points.length; - while (end !== lca) { - points.splice(k, 0, end); - end = end.parent; - } - return points; - } - function d3_layout_bundleAncestors(node) { - var ancestors = [], parent = node.parent; - while (parent != null) { - ancestors.push(node); - node = parent; - parent = parent.parent; - } - ancestors.push(node); - return ancestors; - } - function d3_layout_bundleLeastCommonAncestor(a, b) { - if (a === b) return a; - var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null; - while (aNode === bNode) { - sharedNode = aNode; - aNode = aNodes.pop(); - bNode = bNodes.pop(); - } - return sharedNode; - } - d3.layout.chord = function() { - var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords; - function relayout() { - var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j; - chords = []; - groups = []; - k = 0, i = -1; - while (++i < n) { - x = 0, j = -1; - while (++j < n) { - x += matrix[i][j]; - } - groupSums.push(x); - subgroupIndex.push(d3.range(n)); - k += x; - } - if (sortGroups) { - groupIndex.sort(function(a, b) { - return sortGroups(groupSums[a], groupSums[b]); - }); - } - if (sortSubgroups) { - subgroupIndex.forEach(function(d, i) { - d.sort(function(a, b) { - return sortSubgroups(matrix[i][a], matrix[i][b]); - }); - }); - } - k = (τ - padding * n) / k; - x = 0, i = -1; - while (++i < n) { - x0 = x, j = -1; - while (++j < n) { - var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k; - subgroups[di + "-" + dj] = { - index: di, - subindex: dj, - startAngle: a0, - endAngle: a1, - value: v - }; - } - groups[di] = { - index: di, - startAngle: x0, - endAngle: x, - value: (x - x0) / k - }; - x += padding; - } - i = -1; - while (++i < n) { - j = i - 1; - while (++j < n) { - var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i]; - if (source.value || target.value) { - chords.push(source.value < target.value ? { - source: target, - target: source - } : { - source: source, - target: target - }); - } - } - } - if (sortChords) resort(); - } - function resort() { - chords.sort(function(a, b) { - return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2); - }); - } - chord.matrix = function(x) { - if (!arguments.length) return matrix; - n = (matrix = x) && matrix.length; - chords = groups = null; - return chord; - }; - chord.padding = function(x) { - if (!arguments.length) return padding; - padding = x; - chords = groups = null; - return chord; - }; - chord.sortGroups = function(x) { - if (!arguments.length) return sortGroups; - sortGroups = x; - chords = groups = null; - return chord; - }; - chord.sortSubgroups = function(x) { - if (!arguments.length) return sortSubgroups; - sortSubgroups = x; - chords = null; - return chord; - }; - chord.sortChords = function(x) { - if (!arguments.length) return sortChords; - sortChords = x; - if (chords) resort(); - return chord; - }; - chord.chords = function() { - if (!chords) relayout(); - return chords; - }; - chord.groups = function() { - if (!groups) relayout(); - return groups; - }; - return chord; - }; - d3.layout.force = function() { - var force = {}, event = d3.dispatch("start", "tick", "end"), size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, gravity = .1, theta = .8, nodes = [], links = [], distances, strengths, charges; - function repulse(node) { - return function(quad, x1, _, x2) { - if (quad.point !== node) { - var dx = quad.cx - node.x, dy = quad.cy - node.y, dn = 1 / Math.sqrt(dx * dx + dy * dy); - if ((x2 - x1) * dn < theta) { - var k = quad.charge * dn * dn; - node.px -= dx * k; - node.py -= dy * k; - return true; - } - if (quad.point && isFinite(dn)) { - var k = quad.pointCharge * dn * dn; - node.px -= dx * k; - node.py -= dy * k; - } - } - return !quad.charge; - }; - } - force.tick = function() { - if ((alpha *= .99) < .005) { - event.end({ - type: "end", - alpha: alpha = 0 - }); - return true; - } - var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y; - for (i = 0; i < m; ++i) { - o = links[i]; - s = o.source; - t = o.target; - x = t.x - s.x; - y = t.y - s.y; - if (l = x * x + y * y) { - l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; - x *= l; - y *= l; - t.x -= x * (k = s.weight / (t.weight + s.weight)); - t.y -= y * k; - s.x += x * (k = 1 - k); - s.y += y * k; - } - } - if (k = alpha * gravity) { - x = size[0] / 2; - y = size[1] / 2; - i = -1; - if (k) while (++i < n) { - o = nodes[i]; - o.x += (x - o.x) * k; - o.y += (y - o.y) * k; - } - } - if (charge) { - d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges); - i = -1; - while (++i < n) { - if (!(o = nodes[i]).fixed) { - q.visit(repulse(o)); - } - } - } - i = -1; - while (++i < n) { - o = nodes[i]; - if (o.fixed) { - o.x = o.px; - o.y = o.py; - } else { - o.x -= (o.px - (o.px = o.x)) * friction; - o.y -= (o.py - (o.py = o.y)) * friction; - } - } - event.tick({ - type: "tick", - alpha: alpha - }); - }; - force.nodes = function(x) { - if (!arguments.length) return nodes; - nodes = x; - return force; - }; - force.links = function(x) { - if (!arguments.length) return links; - links = x; - return force; - }; - force.size = function(x) { - if (!arguments.length) return size; - size = x; - return force; - }; - force.linkDistance = function(x) { - if (!arguments.length) return linkDistance; - linkDistance = typeof x === "function" ? x : +x; - return force; - }; - force.distance = force.linkDistance; - force.linkStrength = function(x) { - if (!arguments.length) return linkStrength; - linkStrength = typeof x === "function" ? x : +x; - return force; - }; - force.friction = function(x) { - if (!arguments.length) return friction; - friction = +x; - return force; - }; - force.charge = function(x) { - if (!arguments.length) return charge; - charge = typeof x === "function" ? x : +x; - return force; - }; - force.gravity = function(x) { - if (!arguments.length) return gravity; - gravity = +x; - return force; - }; - force.theta = function(x) { - if (!arguments.length) return theta; - theta = +x; - return force; - }; - force.alpha = function(x) { - if (!arguments.length) return alpha; - x = +x; - if (alpha) { - if (x > 0) alpha = x; else alpha = 0; - } else if (x > 0) { - event.start({ - type: "start", - alpha: alpha = x - }); - d3.timer(force.tick); - } - return force; - }; - force.start = function() { - var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o; - for (i = 0; i < n; ++i) { - (o = nodes[i]).index = i; - o.weight = 0; - } - for (i = 0; i < m; ++i) { - o = links[i]; - if (typeof o.source == "number") o.source = nodes[o.source]; - if (typeof o.target == "number") o.target = nodes[o.target]; - ++o.source.weight; - ++o.target.weight; - } - for (i = 0; i < n; ++i) { - o = nodes[i]; - if (isNaN(o.x)) o.x = position("x", w); - if (isNaN(o.y)) o.y = position("y", h); - if (isNaN(o.px)) o.px = o.x; - if (isNaN(o.py)) o.py = o.y; - } - distances = []; - if (typeof linkDistance === "function") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance; - strengths = []; - if (typeof linkStrength === "function") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength; - charges = []; - if (typeof charge === "function") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge; - function position(dimension, size) { - if (!neighbors) { - neighbors = new Array(n); - for (j = 0; j < n; ++j) { - neighbors[j] = []; - } - for (j = 0; j < m; ++j) { - var o = links[j]; - neighbors[o.source.index].push(o.target); - neighbors[o.target.index].push(o.source); - } - } - var candidates = neighbors[i], j = -1, m = candidates.length, x; - while (++j < m) if (!isNaN(x = candidates[j][dimension])) return x; - return Math.random() * size; - } - return force.resume(); - }; - force.resume = function() { - return force.alpha(.1); - }; - force.stop = function() { - return force.alpha(0); - }; - force.drag = function() { - if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart.force", d3_layout_forceDragstart).on("drag.force", dragmove).on("dragend.force", d3_layout_forceDragend); - if (!arguments.length) return drag; - this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag); - }; - function dragmove(d) { - d.px = d3.event.x, d.py = d3.event.y; - force.resume(); - } - return d3.rebind(force, event, "on"); - }; - function d3_layout_forceDragstart(d) { - d.fixed |= 2; - } - function d3_layout_forceDragend(d) { - d.fixed &= ~6; - } - function d3_layout_forceMouseover(d) { - d.fixed |= 4; - d.px = d.x, d.py = d.y; - } - function d3_layout_forceMouseout(d) { - d.fixed &= ~4; - } - function d3_layout_forceAccumulate(quad, alpha, charges) { - var cx = 0, cy = 0; - quad.charge = 0; - if (!quad.leaf) { - var nodes = quad.nodes, n = nodes.length, i = -1, c; - while (++i < n) { - c = nodes[i]; - if (c == null) continue; - d3_layout_forceAccumulate(c, alpha, charges); - quad.charge += c.charge; - cx += c.charge * c.cx; - cy += c.charge * c.cy; - } - } - if (quad.point) { - if (!quad.leaf) { - quad.point.x += Math.random() - .5; - quad.point.y += Math.random() - .5; - } - var k = alpha * charges[quad.point.index]; - quad.charge += quad.pointCharge = k; - cx += k * quad.point.x; - cy += k * quad.point.y; - } - quad.cx = cx / quad.charge; - quad.cy = cy / quad.charge; - } - var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1; - d3.layout.hierarchy = function() { - var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; - function recurse(node, depth, nodes) { - var childs = children.call(hierarchy, node, depth); - node.depth = depth; - nodes.push(node); - if (childs && (n = childs.length)) { - var i = -1, n, c = node.children = new Array(n), v = 0, j = depth + 1, d; - while (++i < n) { - d = c[i] = recurse(childs[i], j, nodes); - d.parent = node; - v += d.value; - } - if (sort) c.sort(sort); - if (value) node.value = v; - } else { - delete node.children; - if (value) { - node.value = +value.call(hierarchy, node, depth) || 0; - } - } - return node; - } - function revalue(node, depth) { - var children = node.children, v = 0; - if (children && (n = children.length)) { - var i = -1, n, j = depth + 1; - while (++i < n) v += revalue(children[i], j); - } else if (value) { - v = +value.call(hierarchy, node, depth) || 0; - } - if (value) node.value = v; - return v; - } - function hierarchy(d) { - var nodes = []; - recurse(d, 0, nodes); - return nodes; - } - hierarchy.sort = function(x) { - if (!arguments.length) return sort; - sort = x; - return hierarchy; - }; - hierarchy.children = function(x) { - if (!arguments.length) return children; - children = x; - return hierarchy; - }; - hierarchy.value = function(x) { - if (!arguments.length) return value; - value = x; - return hierarchy; - }; - hierarchy.revalue = function(root) { - revalue(root, 0); - return root; - }; - return hierarchy; - }; - function d3_layout_hierarchyRebind(object, hierarchy) { - d3.rebind(object, hierarchy, "sort", "children", "value"); - object.nodes = object; - object.links = d3_layout_hierarchyLinks; - return object; - } - function d3_layout_hierarchyChildren(d) { - return d.children; - } - function d3_layout_hierarchyValue(d) { - return d.value; - } - function d3_layout_hierarchySort(a, b) { - return b.value - a.value; - } - function d3_layout_hierarchyLinks(nodes) { - return d3.merge(nodes.map(function(parent) { - return (parent.children || []).map(function(child) { - return { - source: parent, - target: child - }; - }); - })); - } - d3.layout.partition = function() { - var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ]; - function position(node, x, dx, dy) { - var children = node.children; - node.x = x; - node.y = node.depth * dy; - node.dx = dx; - node.dy = dy; - if (children && (n = children.length)) { - var i = -1, n, c, d; - dx = node.value ? dx / node.value : 0; - while (++i < n) { - position(c = children[i], x, d = c.value * dx, dy); - x += d; - } - } - } - function depth(node) { - var children = node.children, d = 0; - if (children && (n = children.length)) { - var i = -1, n; - while (++i < n) d = Math.max(d, depth(children[i])); - } - return 1 + d; - } - function partition(d, i) { - var nodes = hierarchy.call(this, d, i); - position(nodes[0], 0, size[0], size[1] / depth(nodes[0])); - return nodes; - } - partition.size = function(x) { - if (!arguments.length) return size; - size = x; - return partition; - }; - return d3_layout_hierarchyRebind(partition, hierarchy); - }; - d3.layout.pie = function() { - var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ; - function pie(data) { - var values = data.map(function(d, i) { - return +value.call(pie, d, i); - }); - var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle); - var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a) / d3.sum(values); - var index = d3.range(data.length); - if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) { - return values[j] - values[i]; - } : function(i, j) { - return sort(data[i], data[j]); - }); - var arcs = []; - index.forEach(function(i) { - var d; - arcs[i] = { - data: data[i], - value: d = values[i], - startAngle: a, - endAngle: a += d * k - }; - }); - return arcs; - } - pie.value = function(x) { - if (!arguments.length) return value; - value = x; - return pie; - }; - pie.sort = function(x) { - if (!arguments.length) return sort; - sort = x; - return pie; - }; - pie.startAngle = function(x) { - if (!arguments.length) return startAngle; - startAngle = x; - return pie; - }; - pie.endAngle = function(x) { - if (!arguments.length) return endAngle; - endAngle = x; - return pie; - }; - return pie; - }; - var d3_layout_pieSortByValue = {}; - d3.layout.stack = function() { - var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; - function stack(data, index) { - var series = data.map(function(d, i) { - return values.call(stack, d, i); - }); - var points = series.map(function(d) { - return d.map(function(v, i) { - return [ x.call(stack, v, i), y.call(stack, v, i) ]; - }); - }); - var orders = order.call(stack, points, index); - series = d3.permute(series, orders); - points = d3.permute(points, orders); - var offsets = offset.call(stack, points, index); - var n = series.length, m = series[0].length, i, j, o; - for (j = 0; j < m; ++j) { - out.call(stack, series[0][j], o = offsets[j], points[0][j][1]); - for (i = 1; i < n; ++i) { - out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]); - } - } - return data; - } - stack.values = function(x) { - if (!arguments.length) return values; - values = x; - return stack; - }; - stack.order = function(x) { - if (!arguments.length) return order; - order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault; - return stack; - }; - stack.offset = function(x) { - if (!arguments.length) return offset; - offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero; - return stack; - }; - stack.x = function(z) { - if (!arguments.length) return x; - x = z; - return stack; - }; - stack.y = function(z) { - if (!arguments.length) return y; - y = z; - return stack; - }; - stack.out = function(z) { - if (!arguments.length) return out; - out = z; - return stack; - }; - return stack; - }; - function d3_layout_stackX(d) { - return d.x; - } - function d3_layout_stackY(d) { - return d.y; - } - function d3_layout_stackOut(d, y0, y) { - d.y0 = y0; - d.y = y; - } - var d3_layout_stackOrders = d3.map({ - "inside-out": function(data) { - var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) { - return max[a] - max[b]; - }), top = 0, bottom = 0, tops = [], bottoms = []; - for (i = 0; i < n; ++i) { - j = index[i]; - if (top < bottom) { - top += sums[j]; - tops.push(j); - } else { - bottom += sums[j]; - bottoms.push(j); - } - } - return bottoms.reverse().concat(tops); - }, - reverse: function(data) { - return d3.range(data.length).reverse(); - }, - "default": d3_layout_stackOrderDefault - }); - var d3_layout_stackOffsets = d3.map({ - silhouette: function(data) { - var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = []; - for (j = 0; j < m; ++j) { - for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; - if (o > max) max = o; - sums.push(o); - } - for (j = 0; j < m; ++j) { - y0[j] = (max - sums[j]) / 2; - } - return y0; - }, - wiggle: function(data) { - var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = []; - y0[0] = o = o0 = 0; - for (j = 1; j < m; ++j) { - for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1]; - for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) { - for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) { - s3 += (data[k][j][1] - data[k][j - 1][1]) / dx; - } - s2 += s3 * data[i][j][1]; - } - y0[j] = o -= s1 ? s2 / s1 * dx : 0; - if (o < o0) o0 = o; - } - for (j = 0; j < m; ++j) y0[j] -= o0; - return y0; - }, - expand: function(data) { - var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = []; - for (j = 0; j < m; ++j) { - for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; - if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k; - } - for (j = 0; j < m; ++j) y0[j] = 0; - return y0; - }, - zero: d3_layout_stackOffsetZero - }); - function d3_layout_stackOrderDefault(data) { - return d3.range(data.length); - } - function d3_layout_stackOffsetZero(data) { - var j = -1, m = data[0].length, y0 = []; - while (++j < m) y0[j] = 0; - return y0; - } - function d3_layout_stackMaxIndex(array) { - var i = 1, j = 0, v = array[0][1], k, n = array.length; - for (;i < n; ++i) { - if ((k = array[i][1]) > v) { - j = i; - v = k; - } - } - return j; - } - function d3_layout_stackReduceSum(d) { - return d.reduce(d3_layout_stackSum, 0); - } - function d3_layout_stackSum(p, d) { - return p + d[1]; - } - d3.layout.histogram = function() { - var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges; - function histogram(data, i) { - var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x; - while (++i < m) { - bin = bins[i] = []; - bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); - bin.y = 0; - } - if (m > 0) { - i = -1; - while (++i < n) { - x = values[i]; - if (x >= range[0] && x <= range[1]) { - bin = bins[d3.bisect(thresholds, x, 1, m) - 1]; - bin.y += k; - bin.push(data[i]); - } - } - } - return bins; - } - histogram.value = function(x) { - if (!arguments.length) return valuer; - valuer = x; - return histogram; - }; - histogram.range = function(x) { - if (!arguments.length) return ranger; - ranger = d3_functor(x); - return histogram; - }; - histogram.bins = function(x) { - if (!arguments.length) return binner; - binner = typeof x === "number" ? function(range) { - return d3_layout_histogramBinFixed(range, x); - } : d3_functor(x); - return histogram; - }; - histogram.frequency = function(x) { - if (!arguments.length) return frequency; - frequency = !!x; - return histogram; - }; - return histogram; - }; - function d3_layout_histogramBinSturges(range, values) { - return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1)); - } - function d3_layout_histogramBinFixed(range, n) { - var x = -1, b = +range[0], m = (range[1] - b) / n, f = []; - while (++x <= n) f[x] = m * x + b; - return f; - } - function d3_layout_histogramRange(values) { - return [ d3.min(values), d3.max(values) ]; - } - d3.layout.tree = function() { - var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; - function tree(d, i) { - var nodes = hierarchy.call(this, d, i), root = nodes[0]; - function firstWalk(node, previousSibling) { - var children = node.children, layout = node._tree; - if (children && (n = children.length)) { - var n, firstChild = children[0], previousChild, ancestor = firstChild, child, i = -1; - while (++i < n) { - child = children[i]; - firstWalk(child, previousChild); - ancestor = apportion(child, previousChild, ancestor); - previousChild = child; - } - d3_layout_treeShift(node); - var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim); - if (previousSibling) { - layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); - layout.mod = layout.prelim - midpoint; - } else { - layout.prelim = midpoint; - } - } else { - if (previousSibling) { - layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); - } - } - } - function secondWalk(node, x) { - node.x = node._tree.prelim + x; - var children = node.children; - if (children && (n = children.length)) { - var i = -1, n; - x += node._tree.mod; - while (++i < n) { - secondWalk(children[i], x); - } - } - } - function apportion(node, previousSibling, ancestor) { - if (previousSibling) { - var vip = node, vop = node, vim = previousSibling, vom = node.parent.children[0], sip = vip._tree.mod, sop = vop._tree.mod, sim = vim._tree.mod, som = vom._tree.mod, shift; - while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) { - vom = d3_layout_treeLeft(vom); - vop = d3_layout_treeRight(vop); - vop._tree.ancestor = node; - shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip); - if (shift > 0) { - d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift); - sip += shift; - sop += shift; - } - sim += vim._tree.mod; - sip += vip._tree.mod; - som += vom._tree.mod; - sop += vop._tree.mod; - } - if (vim && !d3_layout_treeRight(vop)) { - vop._tree.thread = vim; - vop._tree.mod += sim - sop; - } - if (vip && !d3_layout_treeLeft(vom)) { - vom._tree.thread = vip; - vom._tree.mod += sip - som; - ancestor = node; - } - } - return ancestor; - } - d3_layout_treeVisitAfter(root, function(node, previousSibling) { - node._tree = { - ancestor: node, - prelim: 0, - mod: 0, - change: 0, - shift: 0, - number: previousSibling ? previousSibling._tree.number + 1 : 0 - }; - }); - firstWalk(root); - secondWalk(root, -root._tree.prelim); - var left = d3_layout_treeSearch(root, d3_layout_treeLeftmost), right = d3_layout_treeSearch(root, d3_layout_treeRightmost), deep = d3_layout_treeSearch(root, d3_layout_treeDeepest), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2, y1 = deep.depth || 1; - d3_layout_treeVisitAfter(root, nodeSize ? function(node) { - node.x *= size[0]; - node.y = node.depth * size[1]; - delete node._tree; - } : function(node) { - node.x = (node.x - x0) / (x1 - x0) * size[0]; - node.y = node.depth / y1 * size[1]; - delete node._tree; - }); - return nodes; - } - tree.separation = function(x) { - if (!arguments.length) return separation; - separation = x; - return tree; - }; - tree.size = function(x) { - if (!arguments.length) return nodeSize ? null : size; - nodeSize = (size = x) == null; - return tree; - }; - tree.nodeSize = function(x) { - if (!arguments.length) return nodeSize ? size : null; - nodeSize = (size = x) != null; - return tree; - }; - return d3_layout_hierarchyRebind(tree, hierarchy); - }; - function d3_layout_treeSeparation(a, b) { - return a.parent == b.parent ? 1 : 2; - } - function d3_layout_treeLeft(node) { - var children = node.children; - return children && children.length ? children[0] : node._tree.thread; - } - function d3_layout_treeRight(node) { - var children = node.children, n; - return children && (n = children.length) ? children[n - 1] : node._tree.thread; - } - function d3_layout_treeSearch(node, compare) { - var children = node.children; - if (children && (n = children.length)) { - var child, n, i = -1; - while (++i < n) { - if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) { - node = child; - } - } - } - return node; - } - function d3_layout_treeRightmost(a, b) { - return a.x - b.x; - } - function d3_layout_treeLeftmost(a, b) { - return b.x - a.x; - } - function d3_layout_treeDeepest(a, b) { - return a.depth - b.depth; - } - function d3_layout_treeVisitAfter(node, callback) { - function visit(node, previousSibling) { - var children = node.children; - if (children && (n = children.length)) { - var child, previousChild = null, i = -1, n; - while (++i < n) { - child = children[i]; - visit(child, previousChild); - previousChild = child; - } - } - callback(node, previousSibling); - } - visit(node, null); - } - function d3_layout_treeShift(node) { - var shift = 0, change = 0, children = node.children, i = children.length, child; - while (--i >= 0) { - child = children[i]._tree; - child.prelim += shift; - child.mod += shift; - shift += child.shift + (change += child.change); - } - } - function d3_layout_treeMove(ancestor, node, shift) { - ancestor = ancestor._tree; - node = node._tree; - var change = shift / (node.number - ancestor.number); - ancestor.change += change; - node.change -= change; - node.shift += shift; - node.prelim += shift; - node.mod += shift; - } - function d3_layout_treeAncestor(vim, node, ancestor) { - return vim._tree.ancestor.parent == node.parent ? vim._tree.ancestor : ancestor; - } - d3.layout.pack = function() { - var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius; - function pack(d, i) { - var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === "function" ? radius : function() { - return radius; - }; - root.x = root.y = 0; - d3_layout_treeVisitAfter(root, function(d) { - d.r = +r(d.value); - }); - d3_layout_treeVisitAfter(root, d3_layout_packSiblings); - if (padding) { - var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2; - d3_layout_treeVisitAfter(root, function(d) { - d.r += dr; - }); - d3_layout_treeVisitAfter(root, d3_layout_packSiblings); - d3_layout_treeVisitAfter(root, function(d) { - d.r -= dr; - }); - } - d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h)); - return nodes; - } - pack.size = function(_) { - if (!arguments.length) return size; - size = _; - return pack; - }; - pack.radius = function(_) { - if (!arguments.length) return radius; - radius = _ == null || typeof _ === "function" ? _ : +_; - return pack; - }; - pack.padding = function(_) { - if (!arguments.length) return padding; - padding = +_; - return pack; - }; - return d3_layout_hierarchyRebind(pack, hierarchy); - }; - function d3_layout_packSort(a, b) { - return a.value - b.value; - } - function d3_layout_packInsert(a, b) { - var c = a._pack_next; - a._pack_next = b; - b._pack_prev = a; - b._pack_next = c; - c._pack_prev = b; - } - function d3_layout_packSplice(a, b) { - a._pack_next = b; - b._pack_prev = a; - } - function d3_layout_packIntersects(a, b) { - var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r; - return .999 * dr * dr > dx * dx + dy * dy; - } - function d3_layout_packSiblings(node) { - if (!(nodes = node.children) || !(n = nodes.length)) return; - var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n; - function bound(node) { - xMin = Math.min(node.x - node.r, xMin); - xMax = Math.max(node.x + node.r, xMax); - yMin = Math.min(node.y - node.r, yMin); - yMax = Math.max(node.y + node.r, yMax); - } - nodes.forEach(d3_layout_packLink); - a = nodes[0]; - a.x = -a.r; - a.y = 0; - bound(a); - if (n > 1) { - b = nodes[1]; - b.x = b.r; - b.y = 0; - bound(b); - if (n > 2) { - c = nodes[2]; - d3_layout_packPlace(a, b, c); - bound(c); - d3_layout_packInsert(a, c); - a._pack_prev = c; - d3_layout_packInsert(c, b); - b = a._pack_next; - for (i = 3; i < n; i++) { - d3_layout_packPlace(a, b, c = nodes[i]); - var isect = 0, s1 = 1, s2 = 1; - for (j = b._pack_next; j !== b; j = j._pack_next, s1++) { - if (d3_layout_packIntersects(j, c)) { - isect = 1; - break; - } - } - if (isect == 1) { - for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { - if (d3_layout_packIntersects(k, c)) { - break; - } - } - } - if (isect) { - if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b); - i--; - } else { - d3_layout_packInsert(a, c); - b = c; - bound(c); - } - } - } - } - var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0; - for (i = 0; i < n; i++) { - c = nodes[i]; - c.x -= cx; - c.y -= cy; - cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y)); - } - node.r = cr; - nodes.forEach(d3_layout_packUnlink); - } - function d3_layout_packLink(node) { - node._pack_next = node._pack_prev = node; - } - function d3_layout_packUnlink(node) { - delete node._pack_next; - delete node._pack_prev; - } - function d3_layout_packTransform(node, x, y, k) { - var children = node.children; - node.x = x += k * node.x; - node.y = y += k * node.y; - node.r *= k; - if (children) { - var i = -1, n = children.length; - while (++i < n) d3_layout_packTransform(children[i], x, y, k); - } - } - function d3_layout_packPlace(a, b, c) { - var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y; - if (db && (dx || dy)) { - var da = b.r + c.r, dc = dx * dx + dy * dy; - da *= da; - db *= db; - var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); - c.x = a.x + x * dx + y * dy; - c.y = a.y + x * dy - y * dx; - } else { - c.x = a.x + db; - c.y = a.y; - } - } - d3.layout.cluster = function() { - var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; - function cluster(d, i) { - var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0; - d3_layout_treeVisitAfter(root, function(node) { - var children = node.children; - if (children && children.length) { - node.x = d3_layout_clusterX(children); - node.y = d3_layout_clusterY(children); - } else { - node.x = previousNode ? x += separation(node, previousNode) : 0; - node.y = 0; - previousNode = node; - } - }); - var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2; - d3_layout_treeVisitAfter(root, nodeSize ? function(node) { - node.x = (node.x - root.x) * size[0]; - node.y = (root.y - node.y) * size[1]; - } : function(node) { - node.x = (node.x - x0) / (x1 - x0) * size[0]; - node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1]; - }); - return nodes; - } - cluster.separation = function(x) { - if (!arguments.length) return separation; - separation = x; - return cluster; - }; - cluster.size = function(x) { - if (!arguments.length) return nodeSize ? null : size; - nodeSize = (size = x) == null; - return cluster; - }; - cluster.nodeSize = function(x) { - if (!arguments.length) return nodeSize ? size : null; - nodeSize = (size = x) != null; - return cluster; - }; - return d3_layout_hierarchyRebind(cluster, hierarchy); - }; - function d3_layout_clusterY(children) { - return 1 + d3.max(children, function(child) { - return child.y; - }); - } - function d3_layout_clusterX(children) { - return children.reduce(function(x, child) { - return x + child.x; - }, 0) / children.length; - } - function d3_layout_clusterLeft(node) { - var children = node.children; - return children && children.length ? d3_layout_clusterLeft(children[0]) : node; - } - function d3_layout_clusterRight(node) { - var children = node.children, n; - return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node; - } - d3.layout.treemap = function() { - var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = "squarify", ratio = .5 * (1 + Math.sqrt(5)); - function scale(children, k) { - var i = -1, n = children.length, child, area; - while (++i < n) { - area = (child = children[i]).value * (k < 0 ? 0 : k); - child.area = isNaN(area) || area <= 0 ? 0 : area; - } - } - function squarify(node) { - var children = node.children; - if (children && children.length) { - var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" ? rect.dy : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n; - scale(remaining, rect.dx * rect.dy / node.value); - row.area = 0; - while ((n = remaining.length) > 0) { - row.push(child = remaining[n - 1]); - row.area += child.area; - if (mode !== "squarify" || (score = worst(row, u)) <= best) { - remaining.pop(); - best = score; - } else { - row.area -= row.pop().area; - position(row, u, rect, false); - u = Math.min(rect.dx, rect.dy); - row.length = row.area = 0; - best = Infinity; - } - } - if (row.length) { - position(row, u, rect, true); - row.length = row.area = 0; - } - children.forEach(squarify); - } - } - function stickify(node) { - var children = node.children; - if (children && children.length) { - var rect = pad(node), remaining = children.slice(), child, row = []; - scale(remaining, rect.dx * rect.dy / node.value); - row.area = 0; - while (child = remaining.pop()) { - row.push(child); - row.area += child.area; - if (child.z != null) { - position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length); - row.length = row.area = 0; - } - } - children.forEach(stickify); - } - } - function worst(row, u) { - var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length; - while (++i < n) { - if (!(r = row[i].area)) continue; - if (r < rmin) rmin = r; - if (r > rmax) rmax = r; - } - s *= s; - u *= u; - return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity; - } - function position(row, u, rect, flush) { - var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o; - if (u == rect.dx) { - if (flush || v > rect.dy) v = rect.dy; - while (++i < n) { - o = row[i]; - o.x = x; - o.y = y; - o.dy = v; - x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0); - } - o.z = true; - o.dx += rect.x + rect.dx - x; - rect.y += v; - rect.dy -= v; - } else { - if (flush || v > rect.dx) v = rect.dx; - while (++i < n) { - o = row[i]; - o.x = x; - o.y = y; - o.dx = v; - y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0); - } - o.z = false; - o.dy += rect.y + rect.dy - y; - rect.x += v; - rect.dx -= v; - } - } - function treemap(d) { - var nodes = stickies || hierarchy(d), root = nodes[0]; - root.x = 0; - root.y = 0; - root.dx = size[0]; - root.dy = size[1]; - if (stickies) hierarchy.revalue(root); - scale([ root ], root.dx * root.dy / root.value); - (stickies ? stickify : squarify)(root); - if (sticky) stickies = nodes; - return nodes; - } - treemap.size = function(x) { - if (!arguments.length) return size; - size = x; - return treemap; - }; - treemap.padding = function(x) { - if (!arguments.length) return padding; - function padFunction(node) { - var p = x.call(treemap, node, node.depth); - return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p); - } - function padConstant(node) { - return d3_layout_treemapPad(node, x); - } - var type; - pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ], - padConstant) : padConstant; - return treemap; - }; - treemap.round = function(x) { - if (!arguments.length) return round != Number; - round = x ? Math.round : Number; - return treemap; - }; - treemap.sticky = function(x) { - if (!arguments.length) return sticky; - sticky = x; - stickies = null; - return treemap; - }; - treemap.ratio = function(x) { - if (!arguments.length) return ratio; - ratio = x; - return treemap; - }; - treemap.mode = function(x) { - if (!arguments.length) return mode; - mode = x + ""; - return treemap; - }; - return d3_layout_hierarchyRebind(treemap, hierarchy); - }; - function d3_layout_treemapPadNull(node) { - return { - x: node.x, - y: node.y, - dx: node.dx, - dy: node.dy - }; - } - function d3_layout_treemapPad(node, padding) { - var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2]; - if (dx < 0) { - x += dx / 2; - dx = 0; - } - if (dy < 0) { - y += dy / 2; - dy = 0; - } - return { - x: x, - y: y, - dx: dx, - dy: dy - }; - } - d3.random = { - normal: function(µ, σ) { - var n = arguments.length; - if (n < 2) σ = 1; - if (n < 1) µ = 0; - return function() { - var x, y, r; - do { - x = Math.random() * 2 - 1; - y = Math.random() * 2 - 1; - r = x * x + y * y; - } while (!r || r > 1); - return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r); - }; - }, - logNormal: function() { - var random = d3.random.normal.apply(d3, arguments); - return function() { - return Math.exp(random()); - }; - }, - bates: function(m) { - var random = d3.random.irwinHall(m); - return function() { - return random() / m; - }; - }, - irwinHall: function(m) { - return function() { - for (var s = 0, j = 0; j < m; j++) s += Math.random(); - return s; - }; - } - }; - d3.scale = {}; - function d3_scaleExtent(domain) { - var start = domain[0], stop = domain[domain.length - 1]; - return start < stop ? [ start, stop ] : [ stop, start ]; - } - function d3_scaleRange(scale) { - return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range()); - } - function d3_scale_bilinear(domain, range, uninterpolate, interpolate) { - var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]); - return function(x) { - return i(u(x)); - }; - } - function d3_scale_nice(domain, nice) { - var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx; - if (x1 < x0) { - dx = i0, i0 = i1, i1 = dx; - dx = x0, x0 = x1, x1 = dx; - } - domain[i0] = nice.floor(x0); - domain[i1] = nice.ceil(x1); - return domain; - } - function d3_scale_niceStep(step) { - return step ? { - floor: function(x) { - return Math.floor(x / step) * step; - }, - ceil: function(x) { - return Math.ceil(x / step) * step; - } - } : d3_scale_niceIdentity; - } - var d3_scale_niceIdentity = { - floor: d3_identity, - ceil: d3_identity - }; - function d3_scale_polylinear(domain, range, uninterpolate, interpolate) { - var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1; - if (domain[k] < domain[0]) { - domain = domain.slice().reverse(); - range = range.slice().reverse(); - } - while (++j <= k) { - u.push(uninterpolate(domain[j - 1], domain[j])); - i.push(interpolate(range[j - 1], range[j])); - } - return function(x) { - var j = d3.bisect(domain, x, 1, k) - 1; - return i[j](u[j](x)); - }; - } - d3.scale.linear = function() { - return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false); - }; - function d3_scale_linear(domain, range, interpolate, clamp) { - var output, input; - function rescale() { - var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber; - output = linear(domain, range, uninterpolate, interpolate); - input = linear(range, domain, uninterpolate, d3_interpolate); - return scale; - } - function scale(x) { - return output(x); - } - scale.invert = function(y) { - return input(y); - }; - scale.domain = function(x) { - if (!arguments.length) return domain; - domain = x.map(Number); - return rescale(); - }; - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - return rescale(); - }; - scale.rangeRound = function(x) { - return scale.range(x).interpolate(d3_interpolateRound); - }; - scale.clamp = function(x) { - if (!arguments.length) return clamp; - clamp = x; - return rescale(); - }; - scale.interpolate = function(x) { - if (!arguments.length) return interpolate; - interpolate = x; - return rescale(); - }; - scale.ticks = function(m) { - return d3_scale_linearTicks(domain, m); - }; - scale.tickFormat = function(m, format) { - return d3_scale_linearTickFormat(domain, m, format); - }; - scale.nice = function(m) { - d3_scale_linearNice(domain, m); - return rescale(); - }; - scale.copy = function() { - return d3_scale_linear(domain, range, interpolate, clamp); - }; - return rescale(); - } - function d3_scale_linearRebind(scale, linear) { - return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); - } - function d3_scale_linearNice(domain, m) { - return d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2])); - } - function d3_scale_linearTickRange(domain, m) { - if (m == null) m = 10; - var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step; - if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; - extent[0] = Math.ceil(extent[0] / step) * step; - extent[1] = Math.floor(extent[1] / step) * step + step * .5; - extent[2] = step; - return extent; - } - function d3_scale_linearTicks(domain, m) { - return d3.range.apply(d3, d3_scale_linearTickRange(domain, m)); - } - function d3_scale_linearTickFormat(domain, m, format) { - var range = d3_scale_linearTickRange(domain, m); - return d3.format(format ? format.replace(d3_format_re, function(a, b, c, d, e, f, g, h, i, j) { - return [ b, c, d, e, f, g, h, i || "." + d3_scale_linearFormatPrecision(j, range), j ].join(""); - }) : ",." + d3_scale_linearPrecision(range[2]) + "f"); - } - var d3_scale_linearFormatSignificant = { - s: 1, - g: 1, - p: 1, - r: 1, - e: 1 - }; - function d3_scale_linearPrecision(value) { - return -Math.floor(Math.log(value) / Math.LN10 + .01); - } - function d3_scale_linearFormatPrecision(type, range) { - var p = d3_scale_linearPrecision(range[2]); - return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(Math.abs(range[0]), Math.abs(range[1])))) + +(type !== "e") : p - (type === "%") * 2; - } - d3.scale.log = function() { - return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]); - }; - function d3_scale_log(linear, base, positive, domain) { - function log(x) { - return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base); - } - function pow(x) { - return positive ? Math.pow(base, x) : -Math.pow(base, -x); - } - function scale(x) { - return linear(log(x)); - } - scale.invert = function(x) { - return pow(linear.invert(x)); - }; - scale.domain = function(x) { - if (!arguments.length) return domain; - positive = x[0] >= 0; - linear.domain((domain = x.map(Number)).map(log)); - return scale; - }; - scale.base = function(_) { - if (!arguments.length) return base; - base = +_; - linear.domain(domain.map(log)); - return scale; - }; - scale.nice = function() { - var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative); - linear.domain(niced); - domain = niced.map(pow); - return scale; - }; - scale.ticks = function() { - var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base; - if (isFinite(j - i)) { - if (positive) { - for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k); - ticks.push(pow(i)); - } else { - ticks.push(pow(i)); - for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k); - } - for (i = 0; ticks[i] < u; i++) {} - for (j = ticks.length; ticks[j - 1] > v; j--) {} - ticks = ticks.slice(i, j); - } - return ticks; - }; - scale.tickFormat = function(n, format) { - if (!arguments.length) return d3_scale_logFormat; - if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format); - var k = Math.max(.1, n / scale.ticks().length), f = positive ? (e = 1e-12, Math.ceil) : (e = -1e-12, - Math.floor), e; - return function(d) { - return d / pow(f(log(d) + e)) <= k ? format(d) : ""; - }; - }; - scale.copy = function() { - return d3_scale_log(linear.copy(), base, positive, domain); - }; - return d3_scale_linearRebind(scale, linear); - } - var d3_scale_logFormat = d3.format(".0e"), d3_scale_logNiceNegative = { - floor: function(x) { - return -Math.ceil(-x); - }, - ceil: function(x) { - return -Math.floor(-x); - } - }; - d3.scale.pow = function() { - return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]); - }; - function d3_scale_pow(linear, exponent, domain) { - var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent); - function scale(x) { - return linear(powp(x)); - } - scale.invert = function(x) { - return powb(linear.invert(x)); - }; - scale.domain = function(x) { - if (!arguments.length) return domain; - linear.domain((domain = x.map(Number)).map(powp)); - return scale; - }; - scale.ticks = function(m) { - return d3_scale_linearTicks(domain, m); - }; - scale.tickFormat = function(m, format) { - return d3_scale_linearTickFormat(domain, m, format); - }; - scale.nice = function(m) { - return scale.domain(d3_scale_linearNice(domain, m)); - }; - scale.exponent = function(x) { - if (!arguments.length) return exponent; - powp = d3_scale_powPow(exponent = x); - powb = d3_scale_powPow(1 / exponent); - linear.domain(domain.map(powp)); - return scale; - }; - scale.copy = function() { - return d3_scale_pow(linear.copy(), exponent, domain); - }; - return d3_scale_linearRebind(scale, linear); - } - function d3_scale_powPow(e) { - return function(x) { - return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e); - }; - } - d3.scale.sqrt = function() { - return d3.scale.pow().exponent(.5); - }; - d3.scale.ordinal = function() { - return d3_scale_ordinal([], { - t: "range", - a: [ [] ] - }); - }; - function d3_scale_ordinal(domain, ranger) { - var index, range, rangeBand; - function scale(x) { - return range[((index.get(x) || ranger.t === "range" && index.set(x, domain.push(x))) - 1) % range.length]; - } - function steps(start, step) { - return d3.range(domain.length).map(function(i) { - return start + step * i; - }); - } - scale.domain = function(x) { - if (!arguments.length) return domain; - domain = []; - index = new d3_Map(); - var i = -1, n = x.length, xi; - while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi)); - return scale[ranger.t].apply(scale, ranger.a); - }; - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - rangeBand = 0; - ranger = { - t: "range", - a: arguments - }; - return scale; - }; - scale.rangePoints = function(x, padding) { - if (arguments.length < 2) padding = 0; - var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding); - range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step); - rangeBand = 0; - ranger = { - t: "rangePoints", - a: arguments - }; - return scale; - }; - scale.rangeBands = function(x, padding, outerPadding) { - if (arguments.length < 2) padding = 0; - if (arguments.length < 3) outerPadding = padding; - var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding); - range = steps(start + step * outerPadding, step); - if (reverse) range.reverse(); - rangeBand = step * (1 - padding); - ranger = { - t: "rangeBands", - a: arguments - }; - return scale; - }; - scale.rangeRoundBands = function(x, padding, outerPadding) { - if (arguments.length < 2) padding = 0; - if (arguments.length < 3) outerPadding = padding; - var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)), error = stop - start - (domain.length - padding) * step; - range = steps(start + Math.round(error / 2), step); - if (reverse) range.reverse(); - rangeBand = Math.round(step * (1 - padding)); - ranger = { - t: "rangeRoundBands", - a: arguments - }; - return scale; - }; - scale.rangeBand = function() { - return rangeBand; - }; - scale.rangeExtent = function() { - return d3_scaleExtent(ranger.a[0]); - }; - scale.copy = function() { - return d3_scale_ordinal(domain, ranger); - }; - return scale.domain(domain); - } - d3.scale.category10 = function() { - return d3.scale.ordinal().range(d3_category10); - }; - d3.scale.category20 = function() { - return d3.scale.ordinal().range(d3_category20); - }; - d3.scale.category20b = function() { - return d3.scale.ordinal().range(d3_category20b); - }; - d3.scale.category20c = function() { - return d3.scale.ordinal().range(d3_category20c); - }; - var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString); - var d3_category20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbString); - var d3_category20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbString); - var d3_category20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbString); - d3.scale.quantile = function() { - return d3_scale_quantile([], []); - }; - function d3_scale_quantile(domain, range) { - var thresholds; - function rescale() { - var k = 0, q = range.length; - thresholds = []; - while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q); - return scale; - } - function scale(x) { - if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)]; - } - scale.domain = function(x) { - if (!arguments.length) return domain; - domain = x.filter(function(d) { - return !isNaN(d); - }).sort(d3.ascending); - return rescale(); - }; - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - return rescale(); - }; - scale.quantiles = function() { - return thresholds; - }; - scale.invertExtent = function(y) { - y = range.indexOf(y); - return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ]; - }; - scale.copy = function() { - return d3_scale_quantile(domain, range); - }; - return rescale(); - } - d3.scale.quantize = function() { - return d3_scale_quantize(0, 1, [ 0, 1 ]); - }; - function d3_scale_quantize(x0, x1, range) { - var kx, i; - function scale(x) { - return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))]; - } - function rescale() { - kx = range.length / (x1 - x0); - i = range.length - 1; - return scale; - } - scale.domain = function(x) { - if (!arguments.length) return [ x0, x1 ]; - x0 = +x[0]; - x1 = +x[x.length - 1]; - return rescale(); - }; - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - return rescale(); - }; - scale.invertExtent = function(y) { - y = range.indexOf(y); - y = y < 0 ? NaN : y / kx + x0; - return [ y, y + 1 / kx ]; - }; - scale.copy = function() { - return d3_scale_quantize(x0, x1, range); - }; - return rescale(); - } - d3.scale.threshold = function() { - return d3_scale_threshold([ .5 ], [ 0, 1 ]); - }; - function d3_scale_threshold(domain, range) { - function scale(x) { - if (x <= x) return range[d3.bisect(domain, x)]; - } - scale.domain = function(_) { - if (!arguments.length) return domain; - domain = _; - return scale; - }; - scale.range = function(_) { - if (!arguments.length) return range; - range = _; - return scale; - }; - scale.invertExtent = function(y) { - y = range.indexOf(y); - return [ domain[y - 1], domain[y] ]; - }; - scale.copy = function() { - return d3_scale_threshold(domain, range); - }; - return scale; - } - d3.scale.identity = function() { - return d3_scale_identity([ 0, 1 ]); - }; - function d3_scale_identity(domain) { - function identity(x) { - return +x; - } - identity.invert = identity; - identity.domain = identity.range = function(x) { - if (!arguments.length) return domain; - domain = x.map(identity); - return identity; - }; - identity.ticks = function(m) { - return d3_scale_linearTicks(domain, m); - }; - identity.tickFormat = function(m, format) { - return d3_scale_linearTickFormat(domain, m, format); - }; - identity.copy = function() { - return d3_scale_identity(domain); - }; - return identity; - } - d3.svg = {}; - d3.svg.arc = function() { - var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; - function arc() { - var r0 = innerRadius.apply(this, arguments), r1 = outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset, a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset, da = (a1 < a0 && (da = a0, - a0 = a1, a1 = da), a1 - a0), df = da < π ? "0" : "1", c0 = Math.cos(a0), s0 = Math.sin(a0), c1 = Math.cos(a1), s1 = Math.sin(a1); - return da >= d3_svg_arcMax ? r0 ? "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "M0," + r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + -r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + r0 + "Z" : "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "Z" : r0 ? "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L" + r0 * c1 + "," + r0 * s1 + "A" + r0 + "," + r0 + " 0 " + df + ",0 " + r0 * c0 + "," + r0 * s0 + "Z" : "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L0,0" + "Z"; - } - arc.innerRadius = function(v) { - if (!arguments.length) return innerRadius; - innerRadius = d3_functor(v); - return arc; - }; - arc.outerRadius = function(v) { - if (!arguments.length) return outerRadius; - outerRadius = d3_functor(v); - return arc; - }; - arc.startAngle = function(v) { - if (!arguments.length) return startAngle; - startAngle = d3_functor(v); - return arc; - }; - arc.endAngle = function(v) { - if (!arguments.length) return endAngle; - endAngle = d3_functor(v); - return arc; - }; - arc.centroid = function() { - var r = (innerRadius.apply(this, arguments) + outerRadius.apply(this, arguments)) / 2, a = (startAngle.apply(this, arguments) + endAngle.apply(this, arguments)) / 2 + d3_svg_arcOffset; - return [ Math.cos(a) * r, Math.sin(a) * r ]; - }; - return arc; - }; - var d3_svg_arcOffset = -halfπ, d3_svg_arcMax = τ - ε; - function d3_svg_arcInnerRadius(d) { - return d.innerRadius; - } - function d3_svg_arcOuterRadius(d) { - return d.outerRadius; - } - function d3_svg_arcStartAngle(d) { - return d.startAngle; - } - function d3_svg_arcEndAngle(d) { - return d.endAngle; - } - function d3_svg_line(projection) { - var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; - function line(data) { - var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y); - function segment() { - segments.push("M", interpolate(projection(points), tension)); - } - while (++i < n) { - if (defined.call(this, d = data[i], i)) { - points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]); - } else if (points.length) { - segment(); - points = []; - } - } - if (points.length) segment(); - return segments.length ? segments.join("") : null; - } - line.x = function(_) { - if (!arguments.length) return x; - x = _; - return line; - }; - line.y = function(_) { - if (!arguments.length) return y; - y = _; - return line; - }; - line.defined = function(_) { - if (!arguments.length) return defined; - defined = _; - return line; - }; - line.interpolate = function(_) { - if (!arguments.length) return interpolateKey; - if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; - return line; - }; - line.tension = function(_) { - if (!arguments.length) return tension; - tension = _; - return line; - }; - return line; - } - d3.svg.line = function() { - return d3_svg_line(d3_identity); - }; - var d3_svg_lineInterpolators = d3.map({ - linear: d3_svg_lineLinear, - "linear-closed": d3_svg_lineLinearClosed, - step: d3_svg_lineStep, - "step-before": d3_svg_lineStepBefore, - "step-after": d3_svg_lineStepAfter, - basis: d3_svg_lineBasis, - "basis-open": d3_svg_lineBasisOpen, - "basis-closed": d3_svg_lineBasisClosed, - bundle: d3_svg_lineBundle, - cardinal: d3_svg_lineCardinal, - "cardinal-open": d3_svg_lineCardinalOpen, - "cardinal-closed": d3_svg_lineCardinalClosed, - monotone: d3_svg_lineMonotone - }); - d3_svg_lineInterpolators.forEach(function(key, value) { - value.key = key; - value.closed = /-closed$/.test(key); - }); - function d3_svg_lineLinear(points) { - return points.join("L"); - } - function d3_svg_lineLinearClosed(points) { - return d3_svg_lineLinear(points) + "Z"; - } - function d3_svg_lineStep(points) { - var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; - while (++i < n) path.push("H", (p[0] + (p = points[i])[0]) / 2, "V", p[1]); - if (n > 1) path.push("H", p[0]); - return path.join(""); - } - function d3_svg_lineStepBefore(points) { - var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; - while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]); - return path.join(""); - } - function d3_svg_lineStepAfter(points) { - var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; - while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]); - return path.join(""); - } - function d3_svg_lineCardinalOpen(points, tension) { - return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), d3_svg_lineCardinalTangents(points, tension)); - } - function d3_svg_lineCardinalClosed(points, tension) { - return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), - points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension)); - } - function d3_svg_lineCardinal(points, tension) { - return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension)); - } - function d3_svg_lineHermite(points, tangents) { - if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) { - return d3_svg_lineLinear(points); - } - var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1; - if (quad) { - path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1]; - p0 = points[1]; - pi = 2; - } - if (tangents.length > 1) { - t = tangents[1]; - p = points[pi]; - pi++; - path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; - for (var i = 2; i < tangents.length; i++, pi++) { - p = points[pi]; - t = tangents[i]; - path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; - } - } - if (quad) { - var lp = points[pi]; - path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1]; - } - return path; - } - function d3_svg_lineCardinalTangents(points, tension) { - var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length; - while (++i < n) { - p0 = p1; - p1 = p2; - p2 = points[i]; - tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]); - } - return tangents; - } - function d3_svg_lineBasis(points) { - if (points.length < 3) return d3_svg_lineLinear(points); - var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, ",", y0, "L", d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; - points.push(points[n - 1]); - while (++i <= n) { - pi = points[i]; - px.shift(); - px.push(pi[0]); - py.shift(); - py.push(pi[1]); - d3_svg_lineBasisBezier(path, px, py); - } - points.pop(); - path.push("L", pi); - return path.join(""); - } - function d3_svg_lineBasisOpen(points) { - if (points.length < 4) return d3_svg_lineLinear(points); - var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ]; - while (++i < 3) { - pi = points[i]; - px.push(pi[0]); - py.push(pi[1]); - } - path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)); - --i; - while (++i < n) { - pi = points[i]; - px.shift(); - px.push(pi[0]); - py.shift(); - py.push(pi[1]); - d3_svg_lineBasisBezier(path, px, py); - } - return path.join(""); - } - function d3_svg_lineBasisClosed(points) { - var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = []; - while (++i < 4) { - pi = points[i % n]; - px.push(pi[0]); - py.push(pi[1]); - } - path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; - --i; - while (++i < m) { - pi = points[i % n]; - px.shift(); - px.push(pi[0]); - py.shift(); - py.push(pi[1]); - d3_svg_lineBasisBezier(path, px, py); - } - return path.join(""); - } - function d3_svg_lineBundle(points, tension) { - var n = points.length - 1; - if (n) { - var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t; - while (++i <= n) { - p = points[i]; - t = i / n; - p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx); - p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy); - } - } - return d3_svg_lineBasis(points); - } - function d3_svg_lineDot4(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; - } - var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ]; - function d3_svg_lineBasisBezier(path, x, y) { - path.push("C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y)); - } - function d3_svg_lineSlope(p0, p1) { - return (p1[1] - p0[1]) / (p1[0] - p0[0]); - } - function d3_svg_lineFiniteDifferences(points) { - var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1); - while (++i < j) { - m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2; - } - m[i] = d; - return m; - } - function d3_svg_lineMonotoneTangents(points) { - var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1; - while (++i < j) { - d = d3_svg_lineSlope(points[i], points[i + 1]); - if (abs(d) < ε) { - m[i] = m[i + 1] = 0; - } else { - a = m[i] / d; - b = m[i + 1] / d; - s = a * a + b * b; - if (s > 9) { - s = d * 3 / Math.sqrt(s); - m[i] = s * a; - m[i + 1] = s * b; - } - } - } - i = -1; - while (++i <= j) { - s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i])); - tangents.push([ s || 0, m[i] * s || 0 ]); - } - return tangents; - } - function d3_svg_lineMonotone(points) { - return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points)); - } - d3.svg.line.radial = function() { - var line = d3_svg_line(d3_svg_lineRadial); - line.radius = line.x, delete line.x; - line.angle = line.y, delete line.y; - return line; - }; - function d3_svg_lineRadial(points) { - var point, i = -1, n = points.length, r, a; - while (++i < n) { - point = points[i]; - r = point[0]; - a = point[1] + d3_svg_arcOffset; - point[0] = r * Math.cos(a); - point[1] = r * Math.sin(a); - } - return points; - } - function d3_svg_area(projection) { - var x0 = d3_geom_pointX, x1 = d3_geom_pointX, y0 = 0, y1 = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7; - function area(data) { - var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() { - return x; - } : d3_functor(x1), fy1 = y0 === y1 ? function() { - return y; - } : d3_functor(y1), x, y; - function segment() { - segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z"); - } - while (++i < n) { - if (defined.call(this, d = data[i], i)) { - points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]); - points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]); - } else if (points0.length) { - segment(); - points0 = []; - points1 = []; - } - } - if (points0.length) segment(); - return segments.length ? segments.join("") : null; - } - area.x = function(_) { - if (!arguments.length) return x1; - x0 = x1 = _; - return area; - }; - area.x0 = function(_) { - if (!arguments.length) return x0; - x0 = _; - return area; - }; - area.x1 = function(_) { - if (!arguments.length) return x1; - x1 = _; - return area; - }; - area.y = function(_) { - if (!arguments.length) return y1; - y0 = y1 = _; - return area; - }; - area.y0 = function(_) { - if (!arguments.length) return y0; - y0 = _; - return area; - }; - area.y1 = function(_) { - if (!arguments.length) return y1; - y1 = _; - return area; - }; - area.defined = function(_) { - if (!arguments.length) return defined; - defined = _; - return area; - }; - area.interpolate = function(_) { - if (!arguments.length) return interpolateKey; - if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; - interpolateReverse = interpolate.reverse || interpolate; - L = interpolate.closed ? "M" : "L"; - return area; - }; - area.tension = function(_) { - if (!arguments.length) return tension; - tension = _; - return area; - }; - return area; - } - d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter; - d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore; - d3.svg.area = function() { - return d3_svg_area(d3_identity); - }; - d3.svg.area.radial = function() { - var area = d3_svg_area(d3_svg_lineRadial); - area.radius = area.x, delete area.x; - area.innerRadius = area.x0, delete area.x0; - area.outerRadius = area.x1, delete area.x1; - area.angle = area.y, delete area.y; - area.startAngle = area.y0, delete area.y0; - area.endAngle = area.y1, delete area.y1; - return area; - }; - d3.svg.chord = function() { - var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; - function chord(d, i) { - var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i); - return "M" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + "Z"; - } - function subgroup(self, f, d, i) { - var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) + d3_svg_arcOffset, a1 = endAngle.call(self, subgroup, i) + d3_svg_arcOffset; - return { - r: r, - a0: a0, - a1: a1, - p0: [ r * Math.cos(a0), r * Math.sin(a0) ], - p1: [ r * Math.cos(a1), r * Math.sin(a1) ] - }; - } - function equals(a, b) { - return a.a0 == b.a0 && a.a1 == b.a1; - } - function arc(r, p, a) { - return "A" + r + "," + r + " 0 " + +(a > π) + ",1 " + p; - } - function curve(r0, p0, r1, p1) { - return "Q 0,0 " + p1; - } - chord.radius = function(v) { - if (!arguments.length) return radius; - radius = d3_functor(v); - return chord; - }; - chord.source = function(v) { - if (!arguments.length) return source; - source = d3_functor(v); - return chord; - }; - chord.target = function(v) { - if (!arguments.length) return target; - target = d3_functor(v); - return chord; - }; - chord.startAngle = function(v) { - if (!arguments.length) return startAngle; - startAngle = d3_functor(v); - return chord; - }; - chord.endAngle = function(v) { - if (!arguments.length) return endAngle; - endAngle = d3_functor(v); - return chord; - }; - return chord; - }; - function d3_svg_chordRadius(d) { - return d.radius; - } - d3.svg.diagonal = function() { - var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection; - function diagonal(d, i) { - var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, { - x: p0.x, - y: m - }, { - x: p3.x, - y: m - }, p3 ]; - p = p.map(projection); - return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3]; - } - diagonal.source = function(x) { - if (!arguments.length) return source; - source = d3_functor(x); - return diagonal; - }; - diagonal.target = function(x) { - if (!arguments.length) return target; - target = d3_functor(x); - return diagonal; - }; - diagonal.projection = function(x) { - if (!arguments.length) return projection; - projection = x; - return diagonal; - }; - return diagonal; - }; - function d3_svg_diagonalProjection(d) { - return [ d.x, d.y ]; - } - d3.svg.diagonal.radial = function() { - var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection; - diagonal.projection = function(x) { - return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection; - }; - return diagonal; - }; - function d3_svg_diagonalRadialProjection(projection) { - return function() { - var d = projection.apply(this, arguments), r = d[0], a = d[1] + d3_svg_arcOffset; - return [ r * Math.cos(a), r * Math.sin(a) ]; - }; - } - d3.svg.symbol = function() { - var type = d3_svg_symbolType, size = d3_svg_symbolSize; - function symbol(d, i) { - return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i)); - } - symbol.type = function(x) { - if (!arguments.length) return type; - type = d3_functor(x); - return symbol; - }; - symbol.size = function(x) { - if (!arguments.length) return size; - size = d3_functor(x); - return symbol; - }; - return symbol; - }; - function d3_svg_symbolSize() { - return 64; - } - function d3_svg_symbolType() { - return "circle"; - } - function d3_svg_symbolCircle(size) { - var r = Math.sqrt(size / π); - return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z"; - } - var d3_svg_symbols = d3.map({ - circle: d3_svg_symbolCircle, - cross: function(size) { - var r = Math.sqrt(size / 5) / 2; - return "M" + -3 * r + "," + -r + "H" + -r + "V" + -3 * r + "H" + r + "V" + -r + "H" + 3 * r + "V" + r + "H" + r + "V" + 3 * r + "H" + -r + "V" + r + "H" + -3 * r + "Z"; - }, - diamond: function(size) { - var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30; - return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z"; - }, - square: function(size) { - var r = Math.sqrt(size) / 2; - return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z"; - }, - "triangle-down": function(size) { - var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; - return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z"; - }, - "triangle-up": function(size) { - var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; - return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z"; - } - }); - d3.svg.symbolTypes = d3_svg_symbols.keys(); - var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians); - function d3_transition(groups, id) { - d3_subclass(groups, d3_transitionPrototype); - groups.id = id; - return groups; - } - var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit; - d3_transitionPrototype.call = d3_selectionPrototype.call; - d3_transitionPrototype.empty = d3_selectionPrototype.empty; - d3_transitionPrototype.node = d3_selectionPrototype.node; - d3_transitionPrototype.size = d3_selectionPrototype.size; - d3.transition = function(selection) { - return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition(); - }; - d3.transition.prototype = d3_transitionPrototype; - d3_transitionPrototype.select = function(selector) { - var id = this.id, subgroups = [], subgroup, subnode, node; - selector = d3_selection_selector(selector); - for (var j = -1, m = this.length; ++j < m; ) { - subgroups.push(subgroup = []); - for (var group = this[j], i = -1, n = group.length; ++i < n; ) { - if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) { - if ("__data__" in node) subnode.__data__ = node.__data__; - d3_transitionNode(subnode, i, id, node.__transition__[id]); - subgroup.push(subnode); - } else { - subgroup.push(null); - } - } - } - return d3_transition(subgroups, id); - }; - d3_transitionPrototype.selectAll = function(selector) { - var id = this.id, subgroups = [], subgroup, subnodes, node, subnode, transition; - selector = d3_selection_selectorAll(selector); - for (var j = -1, m = this.length; ++j < m; ) { - for (var group = this[j], i = -1, n = group.length; ++i < n; ) { - if (node = group[i]) { - transition = node.__transition__[id]; - subnodes = selector.call(node, node.__data__, i, j); - subgroups.push(subgroup = []); - for (var k = -1, o = subnodes.length; ++k < o; ) { - if (subnode = subnodes[k]) d3_transitionNode(subnode, k, id, transition); - subgroup.push(subnode); - } - } - } - } - return d3_transition(subgroups, id); - }; - d3_transitionPrototype.filter = function(filter) { - var subgroups = [], subgroup, group, node; - if (typeof filter !== "function") filter = d3_selection_filter(filter); - for (var j = 0, m = this.length; j < m; j++) { - subgroups.push(subgroup = []); - for (var group = this[j], i = 0, n = group.length; i < n; i++) { - if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { - subgroup.push(node); - } - } - } - return d3_transition(subgroups, this.id); - }; - d3_transitionPrototype.tween = function(name, tween) { - var id = this.id; - if (arguments.length < 2) return this.node().__transition__[id].tween.get(name); - return d3_selection_each(this, tween == null ? function(node) { - node.__transition__[id].tween.remove(name); - } : function(node) { - node.__transition__[id].tween.set(name, tween); - }); - }; - function d3_transition_tween(groups, name, value, tween) { - var id = groups.id; - return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) { - node.__transition__[id].tween.set(name, tween(value.call(node, node.__data__, i, j))); - } : (value = tween(value), function(node) { - node.__transition__[id].tween.set(name, value); - })); - } - d3_transitionPrototype.attr = function(nameNS, value) { - if (arguments.length < 2) { - for (value in nameNS) this.attr(value, nameNS[value]); - return this; - } - var interpolate = nameNS == "transform" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS); - function attrNull() { - this.removeAttribute(name); - } - function attrNullNS() { - this.removeAttributeNS(name.space, name.local); - } - function attrTween(b) { - return b == null ? attrNull : (b += "", function() { - var a = this.getAttribute(name), i; - return a !== b && (i = interpolate(a, b), function(t) { - this.setAttribute(name, i(t)); - }); - }); - } - function attrTweenNS(b) { - return b == null ? attrNullNS : (b += "", function() { - var a = this.getAttributeNS(name.space, name.local), i; - return a !== b && (i = interpolate(a, b), function(t) { - this.setAttributeNS(name.space, name.local, i(t)); - }); - }); - } - return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween); - }; - d3_transitionPrototype.attrTween = function(nameNS, tween) { - var name = d3.ns.qualify(nameNS); - function attrTween(d, i) { - var f = tween.call(this, d, i, this.getAttribute(name)); - return f && function(t) { - this.setAttribute(name, f(t)); - }; - } - function attrTweenNS(d, i) { - var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); - return f && function(t) { - this.setAttributeNS(name.space, name.local, f(t)); - }; - } - return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); - }; - d3_transitionPrototype.style = function(name, value, priority) { - var n = arguments.length; - if (n < 3) { - if (typeof name !== "string") { - if (n < 2) value = ""; - for (priority in name) this.style(priority, name[priority], value); - return this; - } - priority = ""; - } - function styleNull() { - this.style.removeProperty(name); - } - function styleString(b) { - return b == null ? styleNull : (b += "", function() { - var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i; - return a !== b && (i = d3_interpolate(a, b), function(t) { - this.style.setProperty(name, i(t), priority); - }); - }); - } - return d3_transition_tween(this, "style." + name, value, styleString); - }; - d3_transitionPrototype.styleTween = function(name, tween, priority) { - if (arguments.length < 3) priority = ""; - function styleTween(d, i) { - var f = tween.call(this, d, i, d3_window.getComputedStyle(this, null).getPropertyValue(name)); - return f && function(t) { - this.style.setProperty(name, f(t), priority); - }; - } - return this.tween("style." + name, styleTween); - }; - d3_transitionPrototype.text = function(value) { - return d3_transition_tween(this, "text", value, d3_transition_text); - }; - function d3_transition_text(b) { - if (b == null) b = ""; - return function() { - this.textContent = b; - }; - } - d3_transitionPrototype.remove = function() { - return this.each("end.transition", function() { - var p; - if (this.__transition__.count < 2 && (p = this.parentNode)) p.removeChild(this); - }); - }; - d3_transitionPrototype.ease = function(value) { - var id = this.id; - if (arguments.length < 1) return this.node().__transition__[id].ease; - if (typeof value !== "function") value = d3.ease.apply(d3, arguments); - return d3_selection_each(this, function(node) { - node.__transition__[id].ease = value; - }); - }; - d3_transitionPrototype.delay = function(value) { - var id = this.id; - return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { - node.__transition__[id].delay = +value.call(node, node.__data__, i, j); - } : (value = +value, function(node) { - node.__transition__[id].delay = value; - })); - }; - d3_transitionPrototype.duration = function(value) { - var id = this.id; - return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { - node.__transition__[id].duration = Math.max(1, value.call(node, node.__data__, i, j)); - } : (value = Math.max(1, value), function(node) { - node.__transition__[id].duration = value; - })); - }; - d3_transitionPrototype.each = function(type, listener) { - var id = this.id; - if (arguments.length < 2) { - var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId; - d3_transitionInheritId = id; - d3_selection_each(this, function(node, i, j) { - d3_transitionInherit = node.__transition__[id]; - type.call(node, node.__data__, i, j); - }); - d3_transitionInherit = inherit; - d3_transitionInheritId = inheritId; - } else { - d3_selection_each(this, function(node) { - var transition = node.__transition__[id]; - (transition.event || (transition.event = d3.dispatch("start", "end"))).on(type, listener); - }); - } - return this; - }; - d3_transitionPrototype.transition = function() { - var id0 = this.id, id1 = ++d3_transitionId, subgroups = [], subgroup, group, node, transition; - for (var j = 0, m = this.length; j < m; j++) { - subgroups.push(subgroup = []); - for (var group = this[j], i = 0, n = group.length; i < n; i++) { - if (node = group[i]) { - transition = Object.create(node.__transition__[id0]); - transition.delay += transition.duration; - d3_transitionNode(node, i, id1, transition); - } - subgroup.push(node); - } - } - return d3_transition(subgroups, id1); - }; - function d3_transitionNode(node, i, id, inherit) { - var lock = node.__transition__ || (node.__transition__ = { - active: 0, - count: 0 - }), transition = lock[id]; - if (!transition) { - var time = inherit.time; - transition = lock[id] = { - tween: new d3_Map(), - time: time, - ease: inherit.ease, - delay: inherit.delay, - duration: inherit.duration - }; - ++lock.count; - d3.timer(function(elapsed) { - var d = node.__data__, ease = transition.ease, delay = transition.delay, duration = transition.duration, timer = d3_timer_active, tweened = []; - timer.t = delay + time; - if (delay <= elapsed) return start(elapsed - delay); - timer.c = start; - function start(elapsed) { - if (lock.active > id) return stop(); - lock.active = id; - transition.event && transition.event.start.call(node, d, i); - transition.tween.forEach(function(key, value) { - if (value = value.call(node, d, i)) { - tweened.push(value); - } - }); - d3.timer(function() { - timer.c = tick(elapsed || 1) ? d3_true : tick; - return 1; - }, 0, time); - } - function tick(elapsed) { - if (lock.active !== id) return stop(); - var t = elapsed / duration, e = ease(t), n = tweened.length; - while (n > 0) { - tweened[--n].call(node, e); - } - if (t >= 1) { - transition.event && transition.event.end.call(node, d, i); - return stop(); - } - } - function stop() { - if (--lock.count) delete lock[id]; else delete node.__transition__; - return 1; - } - }, 0, time); - } - } - d3.svg.axis = function() { - var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_; - function axis(g) { - g.each(function() { - var g = d3.select(this); - var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy(); - var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform; - var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), - d3.transition(path)); - tickEnter.append("line"); - tickEnter.append("text"); - var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); - switch (orient) { - case "bottom": - { - tickTransform = d3_svg_axisX; - lineEnter.attr("y2", innerTickSize); - textEnter.attr("y", Math.max(innerTickSize, 0) + tickPadding); - lineUpdate.attr("x2", 0).attr("y2", innerTickSize); - textUpdate.attr("x", 0).attr("y", Math.max(innerTickSize, 0) + tickPadding); - text.attr("dy", ".71em").style("text-anchor", "middle"); - pathUpdate.attr("d", "M" + range[0] + "," + outerTickSize + "V0H" + range[1] + "V" + outerTickSize); - break; - } - - case "top": - { - tickTransform = d3_svg_axisX; - lineEnter.attr("y2", -innerTickSize); - textEnter.attr("y", -(Math.max(innerTickSize, 0) + tickPadding)); - lineUpdate.attr("x2", 0).attr("y2", -innerTickSize); - textUpdate.attr("x", 0).attr("y", -(Math.max(innerTickSize, 0) + tickPadding)); - text.attr("dy", "0em").style("text-anchor", "middle"); - pathUpdate.attr("d", "M" + range[0] + "," + -outerTickSize + "V0H" + range[1] + "V" + -outerTickSize); - break; - } - - case "left": - { - tickTransform = d3_svg_axisY; - lineEnter.attr("x2", -innerTickSize); - textEnter.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)); - lineUpdate.attr("x2", -innerTickSize).attr("y2", 0); - textUpdate.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)).attr("y", 0); - text.attr("dy", ".32em").style("text-anchor", "end"); - pathUpdate.attr("d", "M" + -outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + -outerTickSize); - break; - } - - case "right": - { - tickTransform = d3_svg_axisY; - lineEnter.attr("x2", innerTickSize); - textEnter.attr("x", Math.max(innerTickSize, 0) + tickPadding); - lineUpdate.attr("x2", innerTickSize).attr("y2", 0); - textUpdate.attr("x", Math.max(innerTickSize, 0) + tickPadding).attr("y", 0); - text.attr("dy", ".32em").style("text-anchor", "start"); - pathUpdate.attr("d", "M" + outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + outerTickSize); - break; - } - } - if (scale1.rangeBand) { - var x = scale1, dx = x.rangeBand() / 2; - scale0 = scale1 = function(d) { - return x(d) + dx; - }; - } else if (scale0.rangeBand) { - scale0 = scale1; - } else { - tickExit.call(tickTransform, scale1); - } - tickEnter.call(tickTransform, scale0); - tickUpdate.call(tickTransform, scale1); - }); - } - axis.scale = function(x) { - if (!arguments.length) return scale; - scale = x; - return axis; - }; - axis.orient = function(x) { - if (!arguments.length) return orient; - orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient; - return axis; - }; - axis.ticks = function() { - if (!arguments.length) return tickArguments_; - tickArguments_ = arguments; - return axis; - }; - axis.tickValues = function(x) { - if (!arguments.length) return tickValues; - tickValues = x; - return axis; - }; - axis.tickFormat = function(x) { - if (!arguments.length) return tickFormat_; - tickFormat_ = x; - return axis; - }; - axis.tickSize = function(x) { - var n = arguments.length; - if (!n) return innerTickSize; - innerTickSize = +x; - outerTickSize = +arguments[n - 1]; - return axis; - }; - axis.innerTickSize = function(x) { - if (!arguments.length) return innerTickSize; - innerTickSize = +x; - return axis; - }; - axis.outerTickSize = function(x) { - if (!arguments.length) return outerTickSize; - outerTickSize = +x; - return axis; - }; - axis.tickPadding = function(x) { - if (!arguments.length) return tickPadding; - tickPadding = +x; - return axis; - }; - axis.tickSubdivide = function() { - return arguments.length && axis; - }; - return axis; - }; - var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = { - top: 1, - right: 1, - bottom: 1, - left: 1 - }; - function d3_svg_axisX(selection, x) { - selection.attr("transform", function(d) { - return "translate(" + x(d) + ",0)"; - }); - } - function d3_svg_axisY(selection, y) { - selection.attr("transform", function(d) { - return "translate(0," + y(d) + ")"; - }); - } - d3.svg.brush = function() { - var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0]; - function brush(g) { - g.each(function() { - var g = d3.select(this).style("pointer-events", "all").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart); - var background = g.selectAll(".background").data([ 0 ]); - background.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"); - g.selectAll(".extent").data([ 0 ]).enter().append("rect").attr("class", "extent").style("cursor", "move"); - var resize = g.selectAll(".resize").data(resizes, d3_identity); - resize.exit().remove(); - resize.enter().append("g").attr("class", function(d) { - return "resize " + d; - }).style("cursor", function(d) { - return d3_svg_brushCursor[d]; - }).append("rect").attr("x", function(d) { - return /[ew]$/.test(d) ? -3 : null; - }).attr("y", function(d) { - return /^[ns]/.test(d) ? -3 : null; - }).attr("width", 6).attr("height", 6).style("visibility", "hidden"); - resize.style("display", brush.empty() ? "none" : null); - var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range; - if (x) { - range = d3_scaleRange(x); - backgroundUpdate.attr("x", range[0]).attr("width", range[1] - range[0]); - redrawX(gUpdate); - } - if (y) { - range = d3_scaleRange(y); - backgroundUpdate.attr("y", range[0]).attr("height", range[1] - range[0]); - redrawY(gUpdate); - } - redraw(gUpdate); - }); - } - brush.event = function(g) { - g.each(function() { - var event_ = event.of(this, arguments), extent1 = { - x: xExtent, - y: yExtent, - i: xExtentDomain, - j: yExtentDomain - }, extent0 = this.__chart__ || extent1; - this.__chart__ = extent1; - if (d3_transitionInheritId) { - d3.select(this).transition().each("start.brush", function() { - xExtentDomain = extent0.i; - yExtentDomain = extent0.j; - xExtent = extent0.x; - yExtent = extent0.y; - event_({ - type: "brushstart" - }); - }).tween("brush:brush", function() { - var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y); - xExtentDomain = yExtentDomain = null; - return function(t) { - xExtent = extent1.x = xi(t); - yExtent = extent1.y = yi(t); - event_({ - type: "brush", - mode: "resize" - }); - }; - }).each("end.brush", function() { - xExtentDomain = extent1.i; - yExtentDomain = extent1.j; - event_({ - type: "brush", - mode: "resize" - }); - event_({ - type: "brushend" - }); - }); - } else { - event_({ - type: "brushstart" - }); - event_({ - type: "brush", - mode: "resize" - }); - event_({ - type: "brushend" - }); - } - }); - }; - function redraw(g) { - g.selectAll(".resize").attr("transform", function(d) { - return "translate(" + xExtent[+/e$/.test(d)] + "," + yExtent[+/^s/.test(d)] + ")"; - }); - } - function redrawX(g) { - g.select(".extent").attr("x", xExtent[0]); - g.selectAll(".extent,.n>rect,.s>rect").attr("width", xExtent[1] - xExtent[0]); - } - function redrawY(g) { - g.select(".extent").attr("y", yExtent[0]); - g.selectAll(".extent,.e>rect,.w>rect").attr("height", yExtent[1] - yExtent[0]); - } - function brushstart() { - var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed("extent"), dragRestore = d3_event_dragSuppress(), center, origin = d3.mouse(target), offset; - var w = d3.select(d3_window).on("keydown.brush", keydown).on("keyup.brush", keyup); - if (d3.event.changedTouches) { - w.on("touchmove.brush", brushmove).on("touchend.brush", brushend); - } else { - w.on("mousemove.brush", brushmove).on("mouseup.brush", brushend); - } - g.interrupt().selectAll("*").interrupt(); - if (dragging) { - origin[0] = xExtent[0] - origin[0]; - origin[1] = yExtent[0] - origin[1]; - } else if (resizing) { - var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing); - offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ]; - origin[0] = xExtent[ex]; - origin[1] = yExtent[ey]; - } else if (d3.event.altKey) center = origin.slice(); - g.style("pointer-events", "none").selectAll(".resize").style("display", null); - d3.select("body").style("cursor", eventTarget.style("cursor")); - event_({ - type: "brushstart" - }); - brushmove(); - function keydown() { - if (d3.event.keyCode == 32) { - if (!dragging) { - center = null; - origin[0] -= xExtent[1]; - origin[1] -= yExtent[1]; - dragging = 2; - } - d3_eventPreventDefault(); - } - } - function keyup() { - if (d3.event.keyCode == 32 && dragging == 2) { - origin[0] += xExtent[1]; - origin[1] += yExtent[1]; - dragging = 0; - d3_eventPreventDefault(); - } - } - function brushmove() { - var point = d3.mouse(target), moved = false; - if (offset) { - point[0] += offset[0]; - point[1] += offset[1]; - } - if (!dragging) { - if (d3.event.altKey) { - if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ]; - origin[0] = xExtent[+(point[0] < center[0])]; - origin[1] = yExtent[+(point[1] < center[1])]; - } else center = null; - } - if (resizingX && move1(point, x, 0)) { - redrawX(g); - moved = true; - } - if (resizingY && move1(point, y, 1)) { - redrawY(g); - moved = true; - } - if (moved) { - redraw(g); - event_({ - type: "brush", - mode: dragging ? "move" : "resize" - }); - } - } - function move1(point, scale, i) { - var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], extent = i ? yExtent : xExtent, size = extent[1] - extent[0], min, max; - if (dragging) { - r0 -= position; - r1 -= size + position; - } - min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i]; - if (dragging) { - max = (min += position) + size; - } else { - if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min)); - if (position < min) { - max = min; - min = position; - } else { - max = position; - } - } - if (extent[0] != min || extent[1] != max) { - if (i) yExtentDomain = null; else xExtentDomain = null; - extent[0] = min; - extent[1] = max; - return true; - } - } - function brushend() { - brushmove(); - g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null); - d3.select("body").style("cursor", null); - w.on("mousemove.brush", null).on("mouseup.brush", null).on("touchmove.brush", null).on("touchend.brush", null).on("keydown.brush", null).on("keyup.brush", null); - dragRestore(); - event_({ - type: "brushend" - }); - } - } - brush.x = function(z) { - if (!arguments.length) return x; - x = z; - resizes = d3_svg_brushResizes[!x << 1 | !y]; - return brush; - }; - brush.y = function(z) { - if (!arguments.length) return y; - y = z; - resizes = d3_svg_brushResizes[!x << 1 | !y]; - return brush; - }; - brush.clamp = function(z) { - if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null; - if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z; - return brush; - }; - brush.extent = function(z) { - var x0, x1, y0, y1, t; - if (!arguments.length) { - if (x) { - if (xExtentDomain) { - x0 = xExtentDomain[0], x1 = xExtentDomain[1]; - } else { - x0 = xExtent[0], x1 = xExtent[1]; - if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1); - if (x1 < x0) t = x0, x0 = x1, x1 = t; - } - } - if (y) { - if (yExtentDomain) { - y0 = yExtentDomain[0], y1 = yExtentDomain[1]; - } else { - y0 = yExtent[0], y1 = yExtent[1]; - if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1); - if (y1 < y0) t = y0, y0 = y1, y1 = t; - } - } - return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ]; - } - if (x) { - x0 = z[0], x1 = z[1]; - if (y) x0 = x0[0], x1 = x1[0]; - xExtentDomain = [ x0, x1 ]; - if (x.invert) x0 = x(x0), x1 = x(x1); - if (x1 < x0) t = x0, x0 = x1, x1 = t; - if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ]; - } - if (y) { - y0 = z[0], y1 = z[1]; - if (x) y0 = y0[1], y1 = y1[1]; - yExtentDomain = [ y0, y1 ]; - if (y.invert) y0 = y(y0), y1 = y(y1); - if (y1 < y0) t = y0, y0 = y1, y1 = t; - if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ]; - } - return brush; - }; - brush.clear = function() { - if (!brush.empty()) { - xExtent = [ 0, 0 ], yExtent = [ 0, 0 ]; - xExtentDomain = yExtentDomain = null; - } - return brush; - }; - brush.empty = function() { - return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1]; - }; - return d3.rebind(brush, event, "on"); - }; - var d3_svg_brushCursor = { - n: "ns-resize", - e: "ew-resize", - s: "ns-resize", - w: "ew-resize", - nw: "nwse-resize", - ne: "nesw-resize", - se: "nwse-resize", - sw: "nesw-resize" - }; - var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ]; - var d3_time = d3.time = {}, d3_date = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; - function d3_date_utc() { - this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); - } - d3_date_utc.prototype = { - getDate: function() { - return this._.getUTCDate(); - }, - getDay: function() { - return this._.getUTCDay(); - }, - getFullYear: function() { - return this._.getUTCFullYear(); - }, - getHours: function() { - return this._.getUTCHours(); - }, - getMilliseconds: function() { - return this._.getUTCMilliseconds(); - }, - getMinutes: function() { - return this._.getUTCMinutes(); - }, - getMonth: function() { - return this._.getUTCMonth(); - }, - getSeconds: function() { - return this._.getUTCSeconds(); - }, - getTime: function() { - return this._.getTime(); - }, - getTimezoneOffset: function() { - return 0; - }, - valueOf: function() { - return this._.valueOf(); - }, - setDate: function() { - d3_time_prototype.setUTCDate.apply(this._, arguments); - }, - setDay: function() { - d3_time_prototype.setUTCDay.apply(this._, arguments); - }, - setFullYear: function() { - d3_time_prototype.setUTCFullYear.apply(this._, arguments); - }, - setHours: function() { - d3_time_prototype.setUTCHours.apply(this._, arguments); - }, - setMilliseconds: function() { - d3_time_prototype.setUTCMilliseconds.apply(this._, arguments); - }, - setMinutes: function() { - d3_time_prototype.setUTCMinutes.apply(this._, arguments); - }, - setMonth: function() { - d3_time_prototype.setUTCMonth.apply(this._, arguments); - }, - setSeconds: function() { - d3_time_prototype.setUTCSeconds.apply(this._, arguments); - }, - setTime: function() { - d3_time_prototype.setTime.apply(this._, arguments); - } - }; - var d3_time_prototype = Date.prototype; - var d3_time_formatDateTime = "%a %b %e %X %Y", d3_time_formatDate = "%m/%d/%Y", d3_time_formatTime = "%H:%M:%S"; - var d3_time_days = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], d3_time_dayAbbreviations = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], d3_time_months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], d3_time_monthAbbreviations = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; - function d3_time_interval(local, step, number) { - function round(date) { - var d0 = local(date), d1 = offset(d0, 1); - return date - d0 < d1 - date ? d0 : d1; - } - function ceil(date) { - step(date = local(new d3_date(date - 1)), 1); - return date; - } - function offset(date, k) { - step(date = new d3_date(+date), k); - return date; - } - function range(t0, t1, dt) { - var time = ceil(t0), times = []; - if (dt > 1) { - while (time < t1) { - if (!(number(time) % dt)) times.push(new Date(+time)); - step(time, 1); - } - } else { - while (time < t1) times.push(new Date(+time)), step(time, 1); - } - return times; - } - function range_utc(t0, t1, dt) { - try { - d3_date = d3_date_utc; - var utc = new d3_date_utc(); - utc._ = t0; - return range(utc, t1, dt); - } finally { - d3_date = Date; - } - } - local.floor = local; - local.round = round; - local.ceil = ceil; - local.offset = offset; - local.range = range; - var utc = local.utc = d3_time_interval_utc(local); - utc.floor = utc; - utc.round = d3_time_interval_utc(round); - utc.ceil = d3_time_interval_utc(ceil); - utc.offset = d3_time_interval_utc(offset); - utc.range = range_utc; - return local; - } - function d3_time_interval_utc(method) { - return function(date, k) { - try { - d3_date = d3_date_utc; - var utc = new d3_date_utc(); - utc._ = date; - return method(utc, k)._; - } finally { - d3_date = Date; - } - }; - } - d3_time.year = d3_time_interval(function(date) { - date = d3_time.day(date); - date.setMonth(0, 1); - return date; - }, function(date, offset) { - date.setFullYear(date.getFullYear() + offset); - }, function(date) { - return date.getFullYear(); - }); - d3_time.years = d3_time.year.range; - d3_time.years.utc = d3_time.year.utc.range; - d3_time.day = d3_time_interval(function(date) { - var day = new d3_date(2e3, 0); - day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); - return day; - }, function(date, offset) { - date.setDate(date.getDate() + offset); - }, function(date) { - return date.getDate() - 1; - }); - d3_time.days = d3_time.day.range; - d3_time.days.utc = d3_time.day.utc.range; - d3_time.dayOfYear = function(date) { - var year = d3_time.year(date); - return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); - }; - d3_time_daySymbols.forEach(function(day, i) { - day = day.toLowerCase(); - i = 7 - i; - var interval = d3_time[day] = d3_time_interval(function(date) { - (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7); - return date; - }, function(date, offset) { - date.setDate(date.getDate() + Math.floor(offset) * 7); - }, function(date) { - var day = d3_time.year(date).getDay(); - return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i); - }); - d3_time[day + "s"] = interval.range; - d3_time[day + "s"].utc = interval.utc.range; - d3_time[day + "OfYear"] = function(date) { - var day = d3_time.year(date).getDay(); - return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7); - }; - }); - d3_time.week = d3_time.sunday; - d3_time.weeks = d3_time.sunday.range; - d3_time.weeks.utc = d3_time.sunday.utc.range; - d3_time.weekOfYear = d3_time.sundayOfYear; - d3_time.format = d3_time_format; - function d3_time_format(template) { - var n = template.length; - function format(date) { - var string = [], i = -1, j = 0, c, p, f; - while (++i < n) { - if (template.charCodeAt(i) === 37) { - string.push(template.substring(j, i)); - if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i); - if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p); - string.push(c); - j = i + 1; - } - } - string.push(template.substring(j, i)); - return string.join(""); - } - format.parse = function(string) { - var d = { - y: 1900, - m: 0, - d: 1, - H: 0, - M: 0, - S: 0, - L: 0, - Z: null - }, i = d3_time_parse(d, template, string, 0); - if (i != string.length) return null; - if ("p" in d) d.H = d.H % 12 + d.p * 12; - var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)(); - if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("w" in d && ("W" in d || "U" in d)) { - date.setFullYear(d.y, 0, 1); - date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7); - } else date.setFullYear(d.y, d.m, d.d); - date.setHours(d.H + Math.floor(d.Z / 100), d.M + d.Z % 100, d.S, d.L); - return localZ ? date._ : date; - }; - format.toString = function() { - return template; - }; - return format; - } - function d3_time_parse(date, template, string, j) { - var c, p, t, i = 0, n = template.length, m = string.length; - while (i < n) { - if (j >= m) return -1; - c = template.charCodeAt(i++); - if (c === 37) { - t = template.charAt(i++); - p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t]; - if (!p || (j = p(date, string, j)) < 0) return -1; - } else if (c != string.charCodeAt(j++)) { - return -1; - } - } - return j; - } - function d3_time_formatRe(names) { - return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); - } - function d3_time_formatLookup(names) { - var map = new d3_Map(), i = -1, n = names.length; - while (++i < n) map.set(names[i].toLowerCase(), i); - return map; - } - function d3_time_formatPad(value, fill, width) { - var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length; - return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); - } - var d3_time_dayRe = d3_time_formatRe(d3_time_days), d3_time_dayLookup = d3_time_formatLookup(d3_time_days), d3_time_dayAbbrevRe = d3_time_formatRe(d3_time_dayAbbreviations), d3_time_dayAbbrevLookup = d3_time_formatLookup(d3_time_dayAbbreviations), d3_time_monthRe = d3_time_formatRe(d3_time_months), d3_time_monthLookup = d3_time_formatLookup(d3_time_months), d3_time_monthAbbrevRe = d3_time_formatRe(d3_time_monthAbbreviations), d3_time_monthAbbrevLookup = d3_time_formatLookup(d3_time_monthAbbreviations), d3_time_percentRe = /^%/; - var d3_time_formatPads = { - "-": "", - _: " ", - "0": "0" - }; - var d3_time_formats = { - a: function(d) { - return d3_time_dayAbbreviations[d.getDay()]; - }, - A: function(d) { - return d3_time_days[d.getDay()]; - }, - b: function(d) { - return d3_time_monthAbbreviations[d.getMonth()]; - }, - B: function(d) { - return d3_time_months[d.getMonth()]; - }, - c: d3_time_format(d3_time_formatDateTime), - d: function(d, p) { - return d3_time_formatPad(d.getDate(), p, 2); - }, - e: function(d, p) { - return d3_time_formatPad(d.getDate(), p, 2); - }, - H: function(d, p) { - return d3_time_formatPad(d.getHours(), p, 2); - }, - I: function(d, p) { - return d3_time_formatPad(d.getHours() % 12 || 12, p, 2); - }, - j: function(d, p) { - return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3); - }, - L: function(d, p) { - return d3_time_formatPad(d.getMilliseconds(), p, 3); - }, - m: function(d, p) { - return d3_time_formatPad(d.getMonth() + 1, p, 2); - }, - M: function(d, p) { - return d3_time_formatPad(d.getMinutes(), p, 2); - }, - p: function(d) { - return d.getHours() >= 12 ? "PM" : "AM"; - }, - S: function(d, p) { - return d3_time_formatPad(d.getSeconds(), p, 2); - }, - U: function(d, p) { - return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2); - }, - w: function(d) { - return d.getDay(); - }, - W: function(d, p) { - return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2); - }, - x: d3_time_format(d3_time_formatDate), - X: d3_time_format(d3_time_formatTime), - y: function(d, p) { - return d3_time_formatPad(d.getFullYear() % 100, p, 2); - }, - Y: function(d, p) { - return d3_time_formatPad(d.getFullYear() % 1e4, p, 4); - }, - Z: d3_time_zone, - "%": function() { - return "%"; - } - }; - var d3_time_parsers = { - a: d3_time_parseWeekdayAbbrev, - A: d3_time_parseWeekday, - b: d3_time_parseMonthAbbrev, - B: d3_time_parseMonth, - c: d3_time_parseLocaleFull, - d: d3_time_parseDay, - e: d3_time_parseDay, - H: d3_time_parseHour24, - I: d3_time_parseHour24, - j: d3_time_parseDayOfYear, - L: d3_time_parseMilliseconds, - m: d3_time_parseMonthNumber, - M: d3_time_parseMinutes, - p: d3_time_parseAmPm, - S: d3_time_parseSeconds, - U: d3_time_parseWeekNumberSunday, - w: d3_time_parseWeekdayNumber, - W: d3_time_parseWeekNumberMonday, - x: d3_time_parseLocaleDate, - X: d3_time_parseLocaleTime, - y: d3_time_parseYear, - Y: d3_time_parseFullYear, - Z: d3_time_parseZone, - "%": d3_time_parseLiteralPercent - }; - function d3_time_parseWeekdayAbbrev(date, string, i) { - d3_time_dayAbbrevRe.lastIndex = 0; - var n = d3_time_dayAbbrevRe.exec(string.substring(i)); - return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function d3_time_parseWeekday(date, string, i) { - d3_time_dayRe.lastIndex = 0; - var n = d3_time_dayRe.exec(string.substring(i)); - return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function d3_time_parseWeekdayNumber(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 1)); - return n ? (date.w = +n[0], i + n[0].length) : -1; - } - function d3_time_parseWeekNumberSunday(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i)); - return n ? (date.U = +n[0], i + n[0].length) : -1; - } - function d3_time_parseWeekNumberMonday(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i)); - return n ? (date.W = +n[0], i + n[0].length) : -1; - } - function d3_time_parseMonthAbbrev(date, string, i) { - d3_time_monthAbbrevRe.lastIndex = 0; - var n = d3_time_monthAbbrevRe.exec(string.substring(i)); - return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function d3_time_parseMonth(date, string, i) { - d3_time_monthRe.lastIndex = 0; - var n = d3_time_monthRe.exec(string.substring(i)); - return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function d3_time_parseLocaleFull(date, string, i) { - return d3_time_parse(date, d3_time_formats.c.toString(), string, i); - } - function d3_time_parseLocaleDate(date, string, i) { - return d3_time_parse(date, d3_time_formats.x.toString(), string, i); - } - function d3_time_parseLocaleTime(date, string, i) { - return d3_time_parse(date, d3_time_formats.X.toString(), string, i); - } - function d3_time_parseFullYear(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 4)); - return n ? (date.y = +n[0], i + n[0].length) : -1; - } - function d3_time_parseYear(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1; - } - function d3_time_parseZone(date, string, i) { - return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5)) ? (date.Z = +string, - i + 5) : -1; - } - function d3_time_expandYear(d) { - return d + (d > 68 ? 1900 : 2e3); - } - function d3_time_parseMonthNumber(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.m = n[0] - 1, i + n[0].length) : -1; - } - function d3_time_parseDay(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.d = +n[0], i + n[0].length) : -1; - } - function d3_time_parseDayOfYear(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 3)); - return n ? (date.j = +n[0], i + n[0].length) : -1; - } - function d3_time_parseHour24(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.H = +n[0], i + n[0].length) : -1; - } - function d3_time_parseMinutes(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.M = +n[0], i + n[0].length) : -1; - } - function d3_time_parseSeconds(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); - return n ? (date.S = +n[0], i + n[0].length) : -1; - } - function d3_time_parseMilliseconds(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 3)); - return n ? (date.L = +n[0], i + n[0].length) : -1; - } - var d3_time_numberRe = /^\s*\d+/; - function d3_time_parseAmPm(date, string, i) { - var n = d3_time_amPmLookup.get(string.substring(i, i += 2).toLowerCase()); - return n == null ? -1 : (date.p = n, i); - } - var d3_time_amPmLookup = d3.map({ - am: 0, - pm: 1 - }); - function d3_time_zone(d) { - var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = ~~(abs(z) / 60), zm = abs(z) % 60; - return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2); - } - function d3_time_parseLiteralPercent(date, string, i) { - d3_time_percentRe.lastIndex = 0; - var n = d3_time_percentRe.exec(string.substring(i, i + 1)); - return n ? i + n[0].length : -1; - } - d3_time_format.utc = d3_time_formatUtc; - function d3_time_formatUtc(template) { - var local = d3_time_format(template); - function format(date) { - try { - d3_date = d3_date_utc; - var utc = new d3_date(); - utc._ = date; - return local(utc); - } finally { - d3_date = Date; - } - } - format.parse = function(string) { - try { - d3_date = d3_date_utc; - var date = local.parse(string); - return date && date._; - } finally { - d3_date = Date; - } - }; - format.toString = local.toString; - return format; - } - var d3_time_formatIso = d3_time_formatUtc("%Y-%m-%dT%H:%M:%S.%LZ"); - d3_time_format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso; - function d3_time_formatIsoNative(date) { - return date.toISOString(); - } - d3_time_formatIsoNative.parse = function(string) { - var date = new Date(string); - return isNaN(date) ? null : date; - }; - d3_time_formatIsoNative.toString = d3_time_formatIso.toString; - d3_time.second = d3_time_interval(function(date) { - return new d3_date(Math.floor(date / 1e3) * 1e3); - }, function(date, offset) { - date.setTime(date.getTime() + Math.floor(offset) * 1e3); - }, function(date) { - return date.getSeconds(); - }); - d3_time.seconds = d3_time.second.range; - d3_time.seconds.utc = d3_time.second.utc.range; - d3_time.minute = d3_time_interval(function(date) { - return new d3_date(Math.floor(date / 6e4) * 6e4); - }, function(date, offset) { - date.setTime(date.getTime() + Math.floor(offset) * 6e4); - }, function(date) { - return date.getMinutes(); - }); - d3_time.minutes = d3_time.minute.range; - d3_time.minutes.utc = d3_time.minute.utc.range; - d3_time.hour = d3_time_interval(function(date) { - var timezone = date.getTimezoneOffset() / 60; - return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5); - }, function(date, offset) { - date.setTime(date.getTime() + Math.floor(offset) * 36e5); - }, function(date) { - return date.getHours(); - }); - d3_time.hours = d3_time.hour.range; - d3_time.hours.utc = d3_time.hour.utc.range; - d3_time.month = d3_time_interval(function(date) { - date = d3_time.day(date); - date.setDate(1); - return date; - }, function(date, offset) { - date.setMonth(date.getMonth() + offset); - }, function(date) { - return date.getMonth(); - }); - d3_time.months = d3_time.month.range; - d3_time.months.utc = d3_time.month.utc.range; - function d3_time_scale(linear, methods, format) { - function scale(x) { - return linear(x); - } - scale.invert = function(x) { - return d3_time_scaleDate(linear.invert(x)); - }; - scale.domain = function(x) { - if (!arguments.length) return linear.domain().map(d3_time_scaleDate); - linear.domain(x); - return scale; - }; - function tickMethod(extent, count) { - var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target); - return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) { - return d / 31536e6; - }), count)[2] ] : !i ? [ d3_time_scaleMilliseconds, d3_scale_linearTickRange(extent, count)[2] ] : methods[target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target ? i - 1 : i]; - } - scale.nice = function(interval, skip) { - var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" && tickMethod(extent, interval); - if (method) interval = method[0], skip = method[1]; - function skipped(date) { - return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length; - } - return scale.domain(d3_scale_nice(domain, skip > 1 ? { - floor: function(date) { - while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1); - return date; - }, - ceil: function(date) { - while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1); - return date; - } - } : interval)); - }; - scale.ticks = function(interval, skip) { - var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" ? tickMethod(extent, interval) : !interval.range && [ { - range: interval - }, skip ]; - if (method) interval = method[0], skip = method[1]; - return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip); - }; - scale.tickFormat = function() { - return format; - }; - scale.copy = function() { - return d3_time_scale(linear.copy(), methods, format); - }; - return d3_scale_linearRebind(scale, linear); - } - function d3_time_scaleDate(t) { - return new Date(t); - } - function d3_time_scaleFormat(formats) { - return function(date) { - var i = formats.length - 1, f = formats[i]; - while (!f[1](date)) f = formats[--i]; - return f[0](date); - }; - } - var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ]; - var d3_time_scaleLocalMethods = [ [ d3_time.second, 1 ], [ d3_time.second, 5 ], [ d3_time.second, 15 ], [ d3_time.second, 30 ], [ d3_time.minute, 1 ], [ d3_time.minute, 5 ], [ d3_time.minute, 15 ], [ d3_time.minute, 30 ], [ d3_time.hour, 1 ], [ d3_time.hour, 3 ], [ d3_time.hour, 6 ], [ d3_time.hour, 12 ], [ d3_time.day, 1 ], [ d3_time.day, 2 ], [ d3_time.week, 1 ], [ d3_time.month, 1 ], [ d3_time.month, 3 ], [ d3_time.year, 1 ] ]; - var d3_time_scaleLocalFormats = [ [ d3_time_format("%Y"), d3_true ], [ d3_time_format("%B"), function(d) { - return d.getMonth(); - } ], [ d3_time_format("%b %d"), function(d) { - return d.getDate() != 1; - } ], [ d3_time_format("%a %d"), function(d) { - return d.getDay() && d.getDate() != 1; - } ], [ d3_time_format("%I %p"), function(d) { - return d.getHours(); - } ], [ d3_time_format("%I:%M"), function(d) { - return d.getMinutes(); - } ], [ d3_time_format(":%S"), function(d) { - return d.getSeconds(); - } ], [ d3_time_format(".%L"), function(d) { - return d.getMilliseconds(); - } ] ]; - var d3_time_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats); - d3_time_scaleLocalMethods.year = d3_time.year; - d3_time.scale = function() { - return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat); - }; - var d3_time_scaleMilliseconds = { - range: function(start, stop, step) { - return d3.range(+start, +stop, step).map(d3_time_scaleDate); - }, - floor: d3_identity, - ceil: d3_identity - }; - var d3_time_scaleUTCMethods = d3_time_scaleLocalMethods.map(function(m) { - return [ m[0].utc, m[1] ]; - }); - var d3_time_scaleUTCFormats = [ [ d3_time_formatUtc("%Y"), d3_true ], [ d3_time_formatUtc("%B"), function(d) { - return d.getUTCMonth(); - } ], [ d3_time_formatUtc("%b %d"), function(d) { - return d.getUTCDate() != 1; - } ], [ d3_time_formatUtc("%a %d"), function(d) { - return d.getUTCDay() && d.getUTCDate() != 1; - } ], [ d3_time_formatUtc("%I %p"), function(d) { - return d.getUTCHours(); - } ], [ d3_time_formatUtc("%I:%M"), function(d) { - return d.getUTCMinutes(); - } ], [ d3_time_formatUtc(":%S"), function(d) { - return d.getUTCSeconds(); - } ], [ d3_time_formatUtc(".%L"), function(d) { - return d.getUTCMilliseconds(); - } ] ]; - var d3_time_scaleUTCFormat = d3_time_scaleFormat(d3_time_scaleUTCFormats); - d3_time_scaleUTCMethods.year = d3_time.year.utc; - d3_time.scale.utc = function() { - return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat); - }; - d3.text = d3_xhrType(function(request) { - return request.responseText; - }); - d3.json = function(url, callback) { - return d3_xhr(url, "application/json", d3_json, callback); - }; - function d3_json(request) { - return JSON.parse(request.responseText); - } - d3.html = function(url, callback) { - return d3_xhr(url, "text/html", d3_html, callback); - }; - function d3_html(request) { - var range = d3_document.createRange(); - range.selectNode(d3_document.body); - return range.createContextualFragment(request.responseText); - } - d3.xml = d3_xhrType(function(request) { - return request.responseXML; - }); - return d3; -}(); diff --git a/.atom/packages/editor-stats/node_modules/d3-browserify/package.json b/.atom/packages/editor-stats/node_modules/d3-browserify/package.json deleted file mode 100644 index 8d22329..0000000 --- a/.atom/packages/editor-stats/node_modules/d3-browserify/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "d3-browserify", - "version": "3.3.13", - "description": "A small, free JavaScript library for manipulating documents based on data.", - "keywords": [ - "dom", - "w3c", - "visualization", - "svg", - "animation", - "canvas" - ], - "homepage": "http://d3js.org", - "author": { - "name": "Mike Bostock", - "url": "http://bost.ocks.org/mike" - }, - "contributors": [ - { - "name": "Jason Davies", - "url": "http://jasondavies.com" - } - ], - "repository": { - "type": "git", - "url": "https://github.com/zcbenz/d3-browserify.git" - }, - "main": "d3.js", - "browserify": "d3.js", - "licenses": [ - { - "type": "BSD", - "url": "https://github.com/mbostock/d3/blob/master/LICENSE" - } - ], - "readme": "# d3-browserify\n\nD3 distribution that used for browserify-like environment.\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/zcbenz/d3-browserify/issues" - }, - "_id": "d3-browserify@3.3.13", - "dist": { - "shasum": "dc8384a2f78bf7c88c39bedd5dbfde95fecc1f2a" - }, - "_from": "d3-browserify@3.3.13", - "_resolved": "https://registry.npmjs.org/d3-browserify/-/d3-browserify-3.3.13.tgz" -} diff --git a/.atom/packages/editor-stats/node_modules/underscore-plus/LICENSE.md b/.atom/packages/editor-stats/node_modules/underscore-plus/LICENSE.md deleted file mode 100644 index 493db50..0000000 --- a/.atom/packages/editor-stats/node_modules/underscore-plus/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2013 GitHub Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/editor-stats/node_modules/underscore-plus/README.md b/.atom/packages/editor-stats/node_modules/underscore-plus/README.md deleted file mode 100644 index dd7b4c0..0000000 --- a/.atom/packages/editor-stats/node_modules/underscore-plus/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# underscore-plus [![Build Status](https://travis-ci.org/atom/underscore-plus.svg?branch=master)](https://travis-ci.org/atom/underscore-plus) - -Takes the great [underscore](http://underscorejs.org/) library and adds a few -more things. - -## Using - -```sh -npm install underscore-plus -``` - -```coffeescript -_ = require 'underscore-plus' # Has all underscore methods and more -``` diff --git a/.atom/packages/editor-stats/node_modules/underscore-plus/lib/underscore-plus.js b/.atom/packages/editor-stats/node_modules/underscore-plus/lib/underscore-plus.js deleted file mode 100644 index f4b7391..0000000 --- a/.atom/packages/editor-stats/node_modules/underscore-plus/lib/underscore-plus.js +++ /dev/null @@ -1,498 +0,0 @@ -(function() { - var isEqual, macModifierKeyMap, nonMacModifierKeyMap, plus, shiftKeyMap, _, - __slice = [].slice; - - _ = require('underscore'); - - macModifierKeyMap = { - cmd: '\u2318', - ctrl: '\u2303', - alt: '\u2325', - option: '\u2325', - shift: '\u21e7', - enter: '\u23ce', - left: '\u2190', - right: '\u2192', - up: '\u2191', - down: '\u2193' - }; - - nonMacModifierKeyMap = { - cmd: 'Cmd', - ctrl: 'Ctrl', - alt: 'Alt', - option: 'Alt', - shift: 'Shift', - enter: 'Enter', - left: 'Left', - right: 'Right', - up: 'Up', - down: 'Down' - }; - - shiftKeyMap = { - '~': '`', - '_': '-', - '+': '=', - '|': '\\', - '{': '[', - '}': ']', - ':': ';', - '"': '\'', - '<': ',', - '>': '.', - '?': '/' - }; - - plus = { - adviseBefore: function(object, methodName, advice) { - var original; - original = object[methodName]; - return object[methodName] = function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - if (advice.apply(this, args) !== false) { - return original.apply(this, args); - } - }; - }, - camelize: function(string) { - if (string) { - return string.replace(/[_-]+(\w)/g, function(m) { - return m[1].toUpperCase(); - }); - } else { - return ''; - } - }, - capitalize: function(word) { - if (!word) { - return ''; - } - if (word.toLowerCase() === 'github') { - return 'GitHub'; - } else { - return word[0].toUpperCase() + word.slice(1); - } - }, - compactObject: function(object) { - var key, newObject, value; - newObject = {}; - for (key in object) { - value = object[key]; - if (value != null) { - newObject[key] = value; - } - } - return newObject; - }, - dasherize: function(string) { - if (!string) { - return ''; - } - string = string[0].toLowerCase() + string.slice(1); - return string.replace(/([A-Z])|(_)/g, function(m, letter) { - if (letter) { - return "-" + letter.toLowerCase(); - } else { - return "-"; - } - }); - }, - deepClone: function(object) { - if (_.isArray(object)) { - return object.map(function(value) { - return plus.deepClone(value); - }); - } else if (_.isObject(object)) { - return plus.mapObject(object, (function(_this) { - return function(key, value) { - return [key, plus.deepClone(value)]; - }; - })(this)); - } else { - return object; - } - }, - deepExtend: function() { - var key, object, objects, result, value, _i, _len; - objects = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - result = {}; - for (_i = 0, _len = objects.length; _i < _len; _i++) { - object = objects[_i]; - for (key in object) { - value = object[key]; - if (_.isObject(value) && !_.isArray(value)) { - result[key] = plus.deepExtend(result[key], value); - } else { - if (result[key] == null) { - result[key] = value; - } - } - } - } - return result; - }, - deepContains: function(array, target) { - var object, _i, _len; - if (array == null) { - return false; - } - for (_i = 0, _len = array.length; _i < _len; _i++) { - object = array[_i]; - if (_.isEqual(object, target)) { - return true; - } - } - return false; - }, - endsWith: function(string, suffix) { - if (suffix == null) { - suffix = ''; - } - if (string) { - return string.indexOf(suffix, string.length - suffix.length) !== -1; - } else { - return false; - } - }, - escapeAttribute: function(string) { - if (string) { - return string.replace(/"/g, '"').replace(/\n/g, '').replace(/\\/g, '-'); - } else { - return ''; - } - }, - escapeRegExp: function(string) { - if (string) { - return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); - } else { - return ''; - } - }, - humanizeEventName: function(eventName, eventDoc) { - var event, namespace, namespaceDoc, _ref; - _ref = eventName.split(':'), namespace = _ref[0], event = _ref[1]; - if (event == null) { - return plus.undasherize(namespace); - } - namespaceDoc = plus.undasherize(namespace); - if (eventDoc == null) { - eventDoc = plus.undasherize(event); - } - return "" + namespaceDoc + ": " + eventDoc; - }, - humanizeKey: function(key, platform) { - var modifierKeyMap; - if (platform == null) { - platform = process.platform; - } - if (!key) { - return key; - } - modifierKeyMap = platform === 'darwin' ? macModifierKeyMap : nonMacModifierKeyMap; - if (modifierKeyMap[key]) { - return modifierKeyMap[key]; - } else if (key.length === 1 && (shiftKeyMap[key] != null)) { - return [modifierKeyMap.shift, shiftKeyMap[key]]; - } else if (key.length === 1 && key === key.toUpperCase() && key.toUpperCase() !== key.toLowerCase()) { - return [modifierKeyMap.shift, key.toUpperCase()]; - } else if (key.length === 1 || /f[0-9]{1,2}/.test(key)) { - return key.toUpperCase(); - } else { - if (platform === 'darwin') { - return key; - } else { - return plus.capitalize(key); - } - } - }, - humanizeKeystroke: function(keystroke, platform) { - var humanizedKeystrokes, index, key, keys, keystrokes, splitKeystroke, _i, _j, _len, _len1; - if (platform == null) { - platform = process.platform; - } - if (!keystroke) { - return keystroke; - } - keystrokes = keystroke.split(' '); - humanizedKeystrokes = []; - for (_i = 0, _len = keystrokes.length; _i < _len; _i++) { - keystroke = keystrokes[_i]; - keys = []; - splitKeystroke = keystroke.split('-'); - for (index = _j = 0, _len1 = splitKeystroke.length; _j < _len1; index = ++_j) { - key = splitKeystroke[index]; - if (key === '' && splitKeystroke[index - 1] === '') { - key = '-'; - } - if (key) { - keys.push(plus.humanizeKey(key, platform)); - } - } - keys = _.uniq(_.flatten(keys)); - if (platform === 'darwin') { - keys = keys.join(''); - } else { - keys = keys.join('+'); - } - humanizedKeystrokes.push(keys); - } - return humanizedKeystrokes.join(' '); - }, - isSubset: function(potentialSubset, potentialSuperset) { - return _.every(potentialSubset, function(element) { - return _.include(potentialSuperset, element); - }); - }, - losslessInvert: function(hash) { - var inverted, key, value; - inverted = {}; - for (key in hash) { - value = hash[key]; - if (inverted[value] == null) { - inverted[value] = []; - } - inverted[value].push(key); - } - return inverted; - }, - mapObject: function(object, iterator) { - var key, newObject, value, _ref; - newObject = {}; - for (key in object) { - value = object[key]; - _ref = iterator(key, value), key = _ref[0], value = _ref[1]; - newObject[key] = value; - } - return newObject; - }, - multiplyString: function(string, n) { - var finalString, i; - finalString = ""; - i = 0; - while (i < n) { - finalString += string; - i++; - } - return finalString; - }, - pluralize: function(count, singular, plural) { - if (count == null) { - count = 0; - } - if (plural == null) { - plural = singular + 's'; - } - if (count === 1) { - return "" + count + " " + singular; - } else { - return "" + count + " " + plural; - } - }, - remove: function(array, element) { - var index; - index = array.indexOf(element); - if (index >= 0) { - array.splice(index, 1); - } - return array; - }, - setValueForKeyPath: function(object, keyPath, value) { - var key, keys; - keys = keyPath.split('.'); - while (keys.length > 1) { - key = keys.shift(); - if (object[key] == null) { - object[key] = {}; - } - object = object[key]; - } - if (value != null) { - return object[keys.shift()] = value; - } else { - return delete object[keys.shift()]; - } - }, - hasKeyPath: function(object, keyPath) { - var key, keys, _i, _len; - keys = keyPath.split('.'); - for (_i = 0, _len = keys.length; _i < _len; _i++) { - key = keys[_i]; - if (!object.hasOwnProperty(key)) { - return false; - } - object = object[key]; - } - return true; - }, - spliceWithArray: function(originalArray, start, length, insertedArray, chunkSize) { - var chunkStart, _i, _ref, _results; - if (chunkSize == null) { - chunkSize = 100000; - } - if (insertedArray.length < chunkSize) { - return originalArray.splice.apply(originalArray, [start, length].concat(__slice.call(insertedArray))); - } else { - originalArray.splice(start, length); - _results = []; - for (chunkStart = _i = 0, _ref = insertedArray.length; chunkSize > 0 ? _i <= _ref : _i >= _ref; chunkStart = _i += chunkSize) { - _results.push(originalArray.splice.apply(originalArray, [start + chunkStart, 0].concat(__slice.call(insertedArray.slice(chunkStart, chunkStart + chunkSize))))); - } - return _results; - } - }, - sum: function(array) { - var elt, sum, _i, _len; - sum = 0; - for (_i = 0, _len = array.length; _i < _len; _i++) { - elt = array[_i]; - sum += elt; - } - return sum; - }, - uncamelcase: function(string) { - var result; - if (!string) { - return ''; - } - result = string.replace(/([A-Z])|_+/g, function(match, letter) { - if (letter == null) { - letter = ''; - } - return " " + letter; - }); - return plus.capitalize(result.trim()); - }, - undasherize: function(string) { - if (string) { - return string.split('-').map(plus.capitalize).join(' '); - } else { - return ''; - } - }, - underscore: function(string) { - if (!string) { - return ''; - } - string = string[0].toLowerCase() + string.slice(1); - return string.replace(/([A-Z])|-+/g, function(match, letter) { - if (letter == null) { - letter = ''; - } - return "_" + (letter.toLowerCase()); - }); - }, - valueForKeyPath: function(object, keyPath) { - var key, keys, _i, _len; - keys = keyPath.split('.'); - for (_i = 0, _len = keys.length; _i < _len; _i++) { - key = keys[_i]; - object = object[key]; - if (object == null) { - return; - } - } - return object; - }, - isEqual: function(a, b, aStack, bStack) { - if (_.isArray(aStack) && _.isArray(bStack)) { - return isEqual(a, b, aStack, bStack); - } else { - return isEqual(a, b); - } - }, - isEqualForProperties: function() { - var a, b, properties, property, _i, _len; - a = arguments[0], b = arguments[1], properties = 3 <= arguments.length ? __slice.call(arguments, 2) : []; - for (_i = 0, _len = properties.length; _i < _len; _i++) { - property = properties[_i]; - if (!_.isEqual(a[property], b[property])) { - return false; - } - } - return true; - } - }; - - isEqual = function(a, b, aStack, bStack) { - var aCtor, aCtorValid, aElement, aKeyCount, aValue, bCtor, bCtorValid, bKeyCount, bValue, equal, i, key, stackIndex, _i, _len; - if (aStack == null) { - aStack = []; - } - if (bStack == null) { - bStack = []; - } - if (a === b) { - return _.isEqual(a, b); - } - if (_.isFunction(a) || _.isFunction(b)) { - return _.isEqual(a, b); - } - stackIndex = aStack.length; - while (stackIndex--) { - if (aStack[stackIndex] === a) { - return bStack[stackIndex] === b; - } - } - aStack.push(a); - bStack.push(b); - equal = false; - if (_.isFunction(a != null ? a.isEqual : void 0)) { - equal = a.isEqual(b, aStack, bStack); - } else if (_.isFunction(b != null ? b.isEqual : void 0)) { - equal = b.isEqual(a, bStack, aStack); - } else if (_.isArray(a) && _.isArray(b) && a.length === b.length) { - equal = true; - for (i = _i = 0, _len = a.length; _i < _len; i = ++_i) { - aElement = a[i]; - if (!isEqual(aElement, b[i], aStack, bStack)) { - equal = false; - break; - } - } - } else if (_.isRegExp(a) && _.isRegExp(b)) { - equal = _.isEqual(a, b); - } else if (_.isObject(a) && _.isObject(b)) { - aCtor = a.constructor; - bCtor = b.constructor; - aCtorValid = _.isFunction(aCtor) && aCtor instanceof aCtor; - bCtorValid = _.isFunction(bCtor) && bCtor instanceof bCtor; - if (aCtor !== bCtor && !(aCtorValid && bCtorValid)) { - equal = false; - } else { - aKeyCount = 0; - equal = true; - for (key in a) { - aValue = a[key]; - if (!_.has(a, key)) { - continue; - } - aKeyCount++; - if (!(_.has(b, key) && isEqual(aValue, b[key], aStack, bStack))) { - equal = false; - break; - } - } - if (equal) { - bKeyCount = 0; - for (key in b) { - bValue = b[key]; - if (_.has(b, key)) { - bKeyCount++; - } - } - equal = aKeyCount === bKeyCount; - } - } - } else { - equal = _.isEqual(a, b); - } - aStack.pop(); - bStack.pop(); - return equal; - }; - - module.exports = _.extend({}, _, plus); - -}).call(this); diff --git a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/LICENSE b/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/LICENSE deleted file mode 100644 index 0d6b873..0000000 --- a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative -Reporters & Editors - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/README.md b/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/README.md deleted file mode 100644 index c2ba259..0000000 --- a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/README.md +++ /dev/null @@ -1,22 +0,0 @@ - __ - /\ \ __ - __ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____ - /\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\ - \ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\ - \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/ - \/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/ - \ \____/ - \/___/ - -Underscore.js is a utility-belt library for JavaScript that provides -support for the usual functional suspects (each, map, reduce, filter...) -without extending any core JavaScript objects. - -For Docs, License, Tests, and pre-packed downloads, see: -http://underscorejs.org - -Underscore is an open-sourced component of DocumentCloud: -https://github.com/documentcloud - -Many thanks to our contributors: -https://github.com/jashkenas/underscore/contributors diff --git a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/package.json b/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/package.json deleted file mode 100644 index b5c76f6..0000000 --- a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/package.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "underscore", - "description": "JavaScript's functional programming helper library.", - "homepage": "http://underscorejs.org", - "keywords": [ - "util", - "functional", - "server", - "client", - "browser" - ], - "author": { - "name": "Jeremy Ashkenas", - "email": "jeremy@documentcloud.org" - }, - "repository": { - "type": "git", - "url": "git://github.com/jashkenas/underscore.git" - }, - "main": "underscore.js", - "version": "1.6.0", - "devDependencies": { - "docco": "0.6.x", - "phantomjs": "1.9.0-1", - "uglify-js": "2.4.x" - }, - "scripts": { - "test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true", - "build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js", - "doc": "docco underscore.js" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://raw.github.com/jashkenas/underscore/master/LICENSE" - } - ], - "files": [ - "underscore.js", - "underscore-min.js", - "LICENSE" - ], - "readme": " __\n /\\ \\ __\n __ __ ___ \\_\\ \\ __ _ __ ____ ___ ___ _ __ __ /\\_\\ ____\n /\\ \\/\\ \\ /' _ `\\ /'_ \\ /'__`\\/\\ __\\/ ,__\\ / ___\\ / __`\\/\\ __\\/'__`\\ \\/\\ \\ /',__\\\n \\ \\ \\_\\ \\/\\ \\/\\ \\/\\ \\ \\ \\/\\ __/\\ \\ \\//\\__, `\\/\\ \\__//\\ \\ \\ \\ \\ \\//\\ __/ __ \\ \\ \\/\\__, `\\\n \\ \\____/\\ \\_\\ \\_\\ \\___,_\\ \\____\\\\ \\_\\\\/\\____/\\ \\____\\ \\____/\\ \\_\\\\ \\____\\/\\_\\ _\\ \\ \\/\\____/\n \\/___/ \\/_/\\/_/\\/__,_ /\\/____/ \\/_/ \\/___/ \\/____/\\/___/ \\/_/ \\/____/\\/_//\\ \\_\\ \\/___/\n \\ \\____/\n \\/___/\n\nUnderscore.js is a utility-belt library for JavaScript that provides\nsupport for the usual functional suspects (each, map, reduce, filter...)\nwithout extending any core JavaScript objects.\n\nFor Docs, License, Tests, and pre-packed downloads, see:\nhttp://underscorejs.org\n\nUnderscore is an open-sourced component of DocumentCloud:\nhttps://github.com/documentcloud\n\nMany thanks to our contributors:\nhttps://github.com/jashkenas/underscore/contributors\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/jashkenas/underscore/issues" - }, - "_id": "underscore@1.6.0", - "dist": { - "shasum": "17906c2176b40abe48079e304631c0311efbf8ab" - }, - "_from": "underscore@~1.6.0", - "_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" -} diff --git a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/underscore-min.js b/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/underscore-min.js deleted file mode 100644 index 3434d6c..0000000 --- a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/underscore-min.js +++ /dev/null @@ -1,6 +0,0 @@ -// Underscore.js 1.6.0 -// http://underscorejs.org -// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors -// Underscore may be freely distributed under the MIT license. -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?void(this._wrapped=n):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.6.0";var A=j.each=j.forEach=function(n,t,e){if(null==n)return n;if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return;return n};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var O="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},j.find=j.detect=function(n,t,r){var e;return k(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var k=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:k(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,j.property(t))},j.where=function(n,t){return j.filter(n,j.matches(t))},j.findWhere=function(n,t){return j.find(n,j.matches(t))},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);var e=-1/0,u=-1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;o>u&&(e=n,u=o)}),e},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);var e=1/0,u=1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;u>o&&(e=n,u=o)}),e},j.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=j.random(r++),e[r-1]=e[t],e[t]=n}),e},j.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=j.values(n)),n[j.random(n.length-1)]):j.shuffle(n).slice(0,Math.max(0,t))};var E=function(n){return null==n?j.identity:j.isFunction(n)?n:j.property(n)};j.sortBy=function(n,t,r){return t=E(t),j.pluck(j.map(n,function(n,e,u){return{value:n,index:e,criteria:t.call(r,n,e,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=E(r),A(t,function(i,a){var o=r.call(e,i,a,t);n(u,o,i)}),u}};j.groupBy=F(function(n,t,r){j.has(n,t)?n[t].push(r):n[t]=[r]}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=E(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])t?[]:o.call(n,0,t)},j.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},j.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},j.rest=j.tail=j.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},j.compact=function(n){return j.filter(n,j.identity)};var M=function(n,t,r){return t&&j.every(n,j.isArray)?c.apply(r,n):(A(n,function(n){j.isArray(n)||j.isArguments(n)?t?a.apply(r,n):M(n,t,r):r.push(n)}),r)};j.flatten=function(n,t){return M(n,t,[])},j.without=function(n){return j.difference(n,o.call(arguments,1))},j.partition=function(n,t){var r=[],e=[];return A(n,function(n){(t(n)?r:e).push(n)}),[r,e]},j.uniq=j.unique=function(n,t,r,e){j.isFunction(t)&&(e=r,r=t,t=!1);var u=r?j.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:j.contains(a,r))||(a.push(r),i.push(n[e]))}),i},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(n){var t=o.call(arguments,1);return j.filter(j.uniq(n),function(n){return j.every(t,function(t){return j.contains(t,n)})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===j&&(e[u]=arguments[r++]);for(;r=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u),e=u=null):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o,c=function(){var l=j.now()-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u),i=u=null))};return function(){i=this,u=arguments,a=j.now();var l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u),i=u=null),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return j.partial(t,n)},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=function(n){if(!j.isObject(n))return[];if(w)return w(n);var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o)&&"constructor"in n&&"constructor"in t)return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.constant=function(n){return function(){return n}},j.property=function(n){return function(t){return t[n]}},j.matches=function(n){return function(t){if(t===n)return!0;for(var r in n)if(n[r]!==t[r])return!1;return!0}},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},j.now=Date.now||function(){return(new Date).getTime()};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};T.unescape=j.invert(T.escape);var I={escape:new RegExp("["+j.keys(T.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(T.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(I[n],function(t){return T[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return j})}).call(this); -//# sourceMappingURL=underscore-min.map \ No newline at end of file diff --git a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/underscore.js b/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/underscore.js deleted file mode 100644 index 9a4cabe..0000000 --- a/.atom/packages/editor-stats/node_modules/underscore-plus/node_modules/underscore/underscore.js +++ /dev/null @@ -1,1343 +0,0 @@ -// Underscore.js 1.6.0 -// http://underscorejs.org -// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors -// Underscore may be freely distributed under the MIT license. - -(function() { - - // Baseline setup - // -------------- - - // Establish the root object, `window` in the browser, or `exports` on the server. - var root = this; - - // Save the previous value of the `_` variable. - var previousUnderscore = root._; - - // Establish the object that gets returned to break out of a loop iteration. - var breaker = {}; - - // Save bytes in the minified (but not gzipped) version: - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - - // Create quick reference variables for speed access to core prototypes. - var - push = ArrayProto.push, - slice = ArrayProto.slice, - concat = ArrayProto.concat, - toString = ObjProto.toString, - hasOwnProperty = ObjProto.hasOwnProperty; - - // All **ECMAScript 5** native function implementations that we hope to use - // are declared here. - var - nativeForEach = ArrayProto.forEach, - nativeMap = ArrayProto.map, - nativeReduce = ArrayProto.reduce, - nativeReduceRight = ArrayProto.reduceRight, - nativeFilter = ArrayProto.filter, - nativeEvery = ArrayProto.every, - nativeSome = ArrayProto.some, - nativeIndexOf = ArrayProto.indexOf, - nativeLastIndexOf = ArrayProto.lastIndexOf, - nativeIsArray = Array.isArray, - nativeKeys = Object.keys, - nativeBind = FuncProto.bind; - - // Create a safe reference to the Underscore object for use below. - var _ = function(obj) { - if (obj instanceof _) return obj; - if (!(this instanceof _)) return new _(obj); - this._wrapped = obj; - }; - - // Export the Underscore object for **Node.js**, with - // backwards-compatibility for the old `require()` API. If we're in - // the browser, add `_` as a global object via a string identifier, - // for Closure Compiler "advanced" mode. - if (typeof exports !== 'undefined') { - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = _; - } - exports._ = _; - } else { - root._ = _; - } - - // Current version. - _.VERSION = '1.6.0'; - - // Collection Functions - // -------------------- - - // The cornerstone, an `each` implementation, aka `forEach`. - // Handles objects with the built-in `forEach`, arrays, and raw objects. - // Delegates to **ECMAScript 5**'s native `forEach` if available. - var each = _.each = _.forEach = function(obj, iterator, context) { - if (obj == null) return obj; - if (nativeForEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, length = obj.length; i < length; i++) { - if (iterator.call(context, obj[i], i, obj) === breaker) return; - } - } else { - var keys = _.keys(obj); - for (var i = 0, length = keys.length; i < length; i++) { - if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; - } - } - return obj; - }; - - // Return the results of applying the iterator to each element. - // Delegates to **ECMAScript 5**'s native `map` if available. - _.map = _.collect = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); - each(obj, function(value, index, list) { - results.push(iterator.call(context, value, index, list)); - }); - return results; - }; - - var reduceError = 'Reduce of empty array with no initial value'; - - // **Reduce** builds up a single result from a list of values, aka `inject`, - // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. - _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduce && obj.reduce === nativeReduce) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); - } - each(obj, function(value, index, list) { - if (!initial) { - memo = value; - initial = true; - } else { - memo = iterator.call(context, memo, value, index, list); - } - }); - if (!initial) throw new TypeError(reduceError); - return memo; - }; - - // The right-associative version of reduce, also known as `foldr`. - // Delegates to **ECMAScript 5**'s native `reduceRight` if available. - _.reduceRight = _.foldr = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); - } - var length = obj.length; - if (length !== +length) { - var keys = _.keys(obj); - length = keys.length; - } - each(obj, function(value, index, list) { - index = keys ? keys[--length] : --length; - if (!initial) { - memo = obj[index]; - initial = true; - } else { - memo = iterator.call(context, memo, obj[index], index, list); - } - }); - if (!initial) throw new TypeError(reduceError); - return memo; - }; - - // Return the first value which passes a truth test. Aliased as `detect`. - _.find = _.detect = function(obj, predicate, context) { - var result; - any(obj, function(value, index, list) { - if (predicate.call(context, value, index, list)) { - result = value; - return true; - } - }); - return result; - }; - - // Return all the elements that pass a truth test. - // Delegates to **ECMAScript 5**'s native `filter` if available. - // Aliased as `select`. - _.filter = _.select = function(obj, predicate, context) { - var results = []; - if (obj == null) return results; - if (nativeFilter && obj.filter === nativeFilter) return obj.filter(predicate, context); - each(obj, function(value, index, list) { - if (predicate.call(context, value, index, list)) results.push(value); - }); - return results; - }; - - // Return all the elements for which a truth test fails. - _.reject = function(obj, predicate, context) { - return _.filter(obj, function(value, index, list) { - return !predicate.call(context, value, index, list); - }, context); - }; - - // Determine whether all of the elements match a truth test. - // Delegates to **ECMAScript 5**'s native `every` if available. - // Aliased as `all`. - _.every = _.all = function(obj, predicate, context) { - predicate || (predicate = _.identity); - var result = true; - if (obj == null) return result; - if (nativeEvery && obj.every === nativeEvery) return obj.every(predicate, context); - each(obj, function(value, index, list) { - if (!(result = result && predicate.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if at least one element in the object matches a truth test. - // Delegates to **ECMAScript 5**'s native `some` if available. - // Aliased as `any`. - var any = _.some = _.any = function(obj, predicate, context) { - predicate || (predicate = _.identity); - var result = false; - if (obj == null) return result; - if (nativeSome && obj.some === nativeSome) return obj.some(predicate, context); - each(obj, function(value, index, list) { - if (result || (result = predicate.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if the array or object contains a given value (using `===`). - // Aliased as `include`. - _.contains = _.include = function(obj, target) { - if (obj == null) return false; - if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - return any(obj, function(value) { - return value === target; - }); - }; - - // Invoke a method (with arguments) on every item in a collection. - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); - return _.map(obj, function(value) { - return (isFunc ? method : value[method]).apply(value, args); - }); - }; - - // Convenience version of a common use case of `map`: fetching a property. - _.pluck = function(obj, key) { - return _.map(obj, _.property(key)); - }; - - // Convenience version of a common use case of `filter`: selecting only objects - // containing specific `key:value` pairs. - _.where = function(obj, attrs) { - return _.filter(obj, _.matches(attrs)); - }; - - // Convenience version of a common use case of `find`: getting the first object - // containing specific `key:value` pairs. - _.findWhere = function(obj, attrs) { - return _.find(obj, _.matches(attrs)); - }; - - // Return the maximum element or (element-based computation). - // Can't optimize arrays of integers longer than 65,535 elements. - // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797) - _.max = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.max.apply(Math, obj); - } - var result = -Infinity, lastComputed = -Infinity; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - if (computed > lastComputed) { - result = value; - lastComputed = computed; - } - }); - return result; - }; - - // Return the minimum element (or element-based computation). - _.min = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.min.apply(Math, obj); - } - var result = Infinity, lastComputed = Infinity; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - if (computed < lastComputed) { - result = value; - lastComputed = computed; - } - }); - return result; - }; - - // Shuffle an array, using the modern version of the - // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). - _.shuffle = function(obj) { - var rand; - var index = 0; - var shuffled = []; - each(obj, function(value) { - rand = _.random(index++); - shuffled[index - 1] = shuffled[rand]; - shuffled[rand] = value; - }); - return shuffled; - }; - - // Sample **n** random values from a collection. - // If **n** is not specified, returns a single random element. - // The internal `guard` argument allows it to work with `map`. - _.sample = function(obj, n, guard) { - if (n == null || guard) { - if (obj.length !== +obj.length) obj = _.values(obj); - return obj[_.random(obj.length - 1)]; - } - return _.shuffle(obj).slice(0, Math.max(0, n)); - }; - - // An internal function to generate lookup iterators. - var lookupIterator = function(value) { - if (value == null) return _.identity; - if (_.isFunction(value)) return value; - return _.property(value); - }; - - // Sort the object's values by a criterion produced by an iterator. - _.sortBy = function(obj, iterator, context) { - iterator = lookupIterator(iterator); - return _.pluck(_.map(obj, function(value, index, list) { - return { - value: value, - index: index, - criteria: iterator.call(context, value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; - } - return left.index - right.index; - }), 'value'); - }; - - // An internal function used for aggregate "group by" operations. - var group = function(behavior) { - return function(obj, iterator, context) { - var result = {}; - iterator = lookupIterator(iterator); - each(obj, function(value, index) { - var key = iterator.call(context, value, index, obj); - behavior(result, key, value); - }); - return result; - }; - }; - - // Groups the object's values by a criterion. Pass either a string attribute - // to group by, or a function that returns the criterion. - _.groupBy = group(function(result, key, value) { - _.has(result, key) ? result[key].push(value) : result[key] = [value]; - }); - - // Indexes the object's values by a criterion, similar to `groupBy`, but for - // when you know that your index values will be unique. - _.indexBy = group(function(result, key, value) { - result[key] = value; - }); - - // Counts instances of an object that group by a certain criterion. Pass - // either a string attribute to count by, or a function that returns the - // criterion. - _.countBy = group(function(result, key) { - _.has(result, key) ? result[key]++ : result[key] = 1; - }); - - // Use a comparator function to figure out the smallest index at which - // an object should be inserted so as to maintain order. Uses binary search. - _.sortedIndex = function(array, obj, iterator, context) { - iterator = lookupIterator(iterator); - var value = iterator.call(context, obj); - var low = 0, high = array.length; - while (low < high) { - var mid = (low + high) >>> 1; - iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; - } - return low; - }; - - // Safely create a real, live array from anything iterable. - _.toArray = function(obj) { - if (!obj) return []; - if (_.isArray(obj)) return slice.call(obj); - if (obj.length === +obj.length) return _.map(obj, _.identity); - return _.values(obj); - }; - - // Return the number of elements in an object. - _.size = function(obj) { - if (obj == null) return 0; - return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; - }; - - // Array Functions - // --------------- - - // Get the first element of an array. Passing **n** will return the first N - // values in the array. Aliased as `head` and `take`. The **guard** check - // allows it to work with `_.map`. - _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; - if ((n == null) || guard) return array[0]; - if (n < 0) return []; - return slice.call(array, 0, n); - }; - - // Returns everything but the last entry of the array. Especially useful on - // the arguments object. Passing **n** will return all the values in - // the array, excluding the last N. The **guard** check allows it to work with - // `_.map`. - _.initial = function(array, n, guard) { - return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); - }; - - // Get the last element of an array. Passing **n** will return the last N - // values in the array. The **guard** check allows it to work with `_.map`. - _.last = function(array, n, guard) { - if (array == null) return void 0; - if ((n == null) || guard) return array[array.length - 1]; - return slice.call(array, Math.max(array.length - n, 0)); - }; - - // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. - // Especially useful on the arguments object. Passing an **n** will return - // the rest N values in the array. The **guard** - // check allows it to work with `_.map`. - _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, (n == null) || guard ? 1 : n); - }; - - // Trim out all falsy values from an array. - _.compact = function(array) { - return _.filter(array, _.identity); - }; - - // Internal implementation of a recursive `flatten` function. - var flatten = function(input, shallow, output) { - if (shallow && _.every(input, _.isArray)) { - return concat.apply(output, input); - } - each(input, function(value) { - if (_.isArray(value) || _.isArguments(value)) { - shallow ? push.apply(output, value) : flatten(value, shallow, output); - } else { - output.push(value); - } - }); - return output; - }; - - // Flatten out an array, either recursively (by default), or just one level. - _.flatten = function(array, shallow) { - return flatten(array, shallow, []); - }; - - // Return a version of the array that does not contain the specified value(s). - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - - // Split an array into two arrays: one whose elements all satisfy the given - // predicate, and one whose elements all do not satisfy the predicate. - _.partition = function(array, predicate) { - var pass = [], fail = []; - each(array, function(elem) { - (predicate(elem) ? pass : fail).push(elem); - }); - return [pass, fail]; - }; - - // Produce a duplicate-free version of the array. If the array has already - // been sorted, you have the option of using a faster algorithm. - // Aliased as `unique`. - _.uniq = _.unique = function(array, isSorted, iterator, context) { - if (_.isFunction(isSorted)) { - context = iterator; - iterator = isSorted; - isSorted = false; - } - var initial = iterator ? _.map(array, iterator, context) : array; - var results = []; - var seen = []; - each(initial, function(value, index) { - if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { - seen.push(value); - results.push(array[index]); - } - }); - return results; - }; - - // Produce an array that contains the union: each distinct element from all of - // the passed-in arrays. - _.union = function() { - return _.uniq(_.flatten(arguments, true)); - }; - - // Produce an array that contains every item shared between all the - // passed-in arrays. - _.intersection = function(array) { - var rest = slice.call(arguments, 1); - return _.filter(_.uniq(array), function(item) { - return _.every(rest, function(other) { - return _.contains(other, item); - }); - }); - }; - - // Take the difference between one array and a number of other arrays. - // Only the elements present in just the first array will remain. - _.difference = function(array) { - var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); - return _.filter(array, function(value){ return !_.contains(rest, value); }); - }; - - // Zip together multiple lists into a single array -- elements that share - // an index go together. - _.zip = function() { - var length = _.max(_.pluck(arguments, 'length').concat(0)); - var results = new Array(length); - for (var i = 0; i < length; i++) { - results[i] = _.pluck(arguments, '' + i); - } - return results; - }; - - // Converts lists into objects. Pass either a single array of `[key, value]` - // pairs, or two parallel arrays of the same length -- one of keys, and one of - // the corresponding values. - _.object = function(list, values) { - if (list == null) return {}; - var result = {}; - for (var i = 0, length = list.length; i < length; i++) { - if (values) { - result[list[i]] = values[i]; - } else { - result[list[i][0]] = list[i][1]; - } - } - return result; - }; - - // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), - // we need this function. Return the position of the first occurrence of an - // item in an array, or -1 if the item is not included in the array. - // Delegates to **ECMAScript 5**'s native `indexOf` if available. - // If the array is large and already in sort order, pass `true` - // for **isSorted** to use binary search. - _.indexOf = function(array, item, isSorted) { - if (array == null) return -1; - var i = 0, length = array.length; - if (isSorted) { - if (typeof isSorted == 'number') { - i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted); - } else { - i = _.sortedIndex(array, item); - return array[i] === item ? i : -1; - } - } - if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); - for (; i < length; i++) if (array[i] === item) return i; - return -1; - }; - - // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. - _.lastIndexOf = function(array, item, from) { - if (array == null) return -1; - var hasIndex = from != null; - if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { - return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); - } - var i = (hasIndex ? from : array.length); - while (i--) if (array[i] === item) return i; - return -1; - }; - - // Generate an integer Array containing an arithmetic progression. A port of - // the native Python `range()` function. See - // [the Python documentation](http://docs.python.org/library/functions.html#range). - _.range = function(start, stop, step) { - if (arguments.length <= 1) { - stop = start || 0; - start = 0; - } - step = arguments[2] || 1; - - var length = Math.max(Math.ceil((stop - start) / step), 0); - var idx = 0; - var range = new Array(length); - - while(idx < length) { - range[idx++] = start; - start += step; - } - - return range; - }; - - // Function (ahem) Functions - // ------------------ - - // Reusable constructor function for prototype setting. - var ctor = function(){}; - - // Create a function bound to a given object (assigning `this`, and arguments, - // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if - // available. - _.bind = function(func, context) { - var args, bound; - if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - if (!_.isFunction(func)) throw new TypeError; - args = slice.call(arguments, 2); - return bound = function() { - if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); - ctor.prototype = func.prototype; - var self = new ctor; - ctor.prototype = null; - var result = func.apply(self, args.concat(slice.call(arguments))); - if (Object(result) === result) return result; - return self; - }; - }; - - // Partially apply a function by creating a version that has had some of its - // arguments pre-filled, without changing its dynamic `this` context. _ acts - // as a placeholder, allowing any combination of arguments to be pre-filled. - _.partial = function(func) { - var boundArgs = slice.call(arguments, 1); - return function() { - var position = 0; - var args = boundArgs.slice(); - for (var i = 0, length = args.length; i < length; i++) { - if (args[i] === _) args[i] = arguments[position++]; - } - while (position < arguments.length) args.push(arguments[position++]); - return func.apply(this, args); - }; - }; - - // Bind a number of an object's methods to that object. Remaining arguments - // are the method names to be bound. Useful for ensuring that all callbacks - // defined on an object belong to it. - _.bindAll = function(obj) { - var funcs = slice.call(arguments, 1); - if (funcs.length === 0) throw new Error('bindAll must be passed function names'); - each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); - return obj; - }; - - // Memoize an expensive function by storing its results. - _.memoize = function(func, hasher) { - var memo = {}; - hasher || (hasher = _.identity); - return function() { - var key = hasher.apply(this, arguments); - return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); - }; - }; - - // Delays a function for the given number of milliseconds, and then calls - // it with the arguments supplied. - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function(){ return func.apply(null, args); }, wait); - }; - - // Defers a function, scheduling it to run after the current call stack has - // cleared. - _.defer = function(func) { - return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); - }; - - // Returns a function, that, when invoked, will only be triggered at most once - // during a given window of time. Normally, the throttled function will run - // as much as it can, without ever going more than once per `wait` duration; - // but if you'd like to disable the execution on the leading edge, pass - // `{leading: false}`. To disable execution on the trailing edge, ditto. - _.throttle = function(func, wait, options) { - var context, args, result; - var timeout = null; - var previous = 0; - options || (options = {}); - var later = function() { - previous = options.leading === false ? 0 : _.now(); - timeout = null; - result = func.apply(context, args); - context = args = null; - }; - return function() { - var now = _.now(); - if (!previous && options.leading === false) previous = now; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0) { - clearTimeout(timeout); - timeout = null; - previous = now; - result = func.apply(context, args); - context = args = null; - } else if (!timeout && options.trailing !== false) { - timeout = setTimeout(later, remaining); - } - return result; - }; - }; - - // Returns a function, that, as long as it continues to be invoked, will not - // be triggered. The function will be called after it stops being called for - // N milliseconds. If `immediate` is passed, trigger the function on the - // leading edge, instead of the trailing. - _.debounce = function(func, wait, immediate) { - var timeout, args, context, timestamp, result; - - var later = function() { - var last = _.now() - timestamp; - if (last < wait) { - timeout = setTimeout(later, wait - last); - } else { - timeout = null; - if (!immediate) { - result = func.apply(context, args); - context = args = null; - } - } - }; - - return function() { - context = this; - args = arguments; - timestamp = _.now(); - var callNow = immediate && !timeout; - if (!timeout) { - timeout = setTimeout(later, wait); - } - if (callNow) { - result = func.apply(context, args); - context = args = null; - } - - return result; - }; - }; - - // Returns a function that will be executed at most one time, no matter how - // often you call it. Useful for lazy initialization. - _.once = function(func) { - var ran = false, memo; - return function() { - if (ran) return memo; - ran = true; - memo = func.apply(this, arguments); - func = null; - return memo; - }; - }; - - // Returns the first function passed as an argument to the second, - // allowing you to adjust arguments, run code before and after, and - // conditionally execute the original function. - _.wrap = function(func, wrapper) { - return _.partial(wrapper, func); - }; - - // Returns a function that is the composition of a list of functions, each - // consuming the return value of the function that follows. - _.compose = function() { - var funcs = arguments; - return function() { - var args = arguments; - for (var i = funcs.length - 1; i >= 0; i--) { - args = [funcs[i].apply(this, args)]; - } - return args[0]; - }; - }; - - // Returns a function that will only be executed after being called N times. - _.after = function(times, func) { - return function() { - if (--times < 1) { - return func.apply(this, arguments); - } - }; - }; - - // Object Functions - // ---------------- - - // Retrieve the names of an object's properties. - // Delegates to **ECMAScript 5**'s native `Object.keys` - _.keys = function(obj) { - if (!_.isObject(obj)) return []; - if (nativeKeys) return nativeKeys(obj); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys.push(key); - return keys; - }; - - // Retrieve the values of an object's properties. - _.values = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var values = new Array(length); - for (var i = 0; i < length; i++) { - values[i] = obj[keys[i]]; - } - return values; - }; - - // Convert an object into a list of `[key, value]` pairs. - _.pairs = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var pairs = new Array(length); - for (var i = 0; i < length; i++) { - pairs[i] = [keys[i], obj[keys[i]]]; - } - return pairs; - }; - - // Invert the keys and values of an object. The values must be serializable. - _.invert = function(obj) { - var result = {}; - var keys = _.keys(obj); - for (var i = 0, length = keys.length; i < length; i++) { - result[obj[keys[i]]] = keys[i]; - } - return result; - }; - - // Return a sorted list of the function names available on the object. - // Aliased as `methods` - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); - } - return names.sort(); - }; - - // Extend a given object with all the properties in passed-in object(s). - _.extend = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - obj[prop] = source[prop]; - } - } - }); - return obj; - }; - - // Return a copy of the object only containing the whitelisted properties. - _.pick = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - each(keys, function(key) { - if (key in obj) copy[key] = obj[key]; - }); - return copy; - }; - - // Return a copy of the object without the blacklisted properties. - _.omit = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - for (var key in obj) { - if (!_.contains(keys, key)) copy[key] = obj[key]; - } - return copy; - }; - - // Fill in a given object with default properties. - _.defaults = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - if (obj[prop] === void 0) obj[prop] = source[prop]; - } - } - }); - return obj; - }; - - // Create a (shallow-cloned) duplicate of an object. - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - - // Invokes interceptor with the obj, and then returns obj. - // The primary purpose of this method is to "tap into" a method chain, in - // order to perform operations on intermediate results within the chain. - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - - // Internal recursive comparison function for `isEqual`. - var eq = function(a, b, aStack, bStack) { - // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). - if (a === b) return a !== 0 || 1 / a == 1 / b; - // A strict comparison is necessary because `null == undefined`. - if (a == null || b == null) return a === b; - // Unwrap any wrapped objects. - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - // Compare `[[Class]]` names. - var className = toString.call(a); - if (className != toString.call(b)) return false; - switch (className) { - // Strings, numbers, dates, and booleans are compared by value. - case '[object String]': - // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is - // equivalent to `new String("5")`. - return a == String(b); - case '[object Number]': - // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for - // other numeric values. - return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); - case '[object Date]': - case '[object Boolean]': - // Coerce dates and booleans to numeric primitive values. Dates are compared by their - // millisecond representations. Note that invalid dates with millisecond representations - // of `NaN` are not equivalent. - return +a == +b; - // RegExps are compared by their source patterns and flags. - case '[object RegExp]': - return a.source == b.source && - a.global == b.global && - a.multiline == b.multiline && - a.ignoreCase == b.ignoreCase; - } - if (typeof a != 'object' || typeof b != 'object') return false; - // Assume equality for cyclic structures. The algorithm for detecting cyclic - // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. - var length = aStack.length; - while (length--) { - // Linear search. Performance is inversely proportional to the number of - // unique nested structures. - if (aStack[length] == a) return bStack[length] == b; - } - // Objects with different constructors are not equivalent, but `Object`s - // from different frames are. - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && - _.isFunction(bCtor) && (bCtor instanceof bCtor)) - && ('constructor' in a && 'constructor' in b)) { - return false; - } - // Add the first object to the stack of traversed objects. - aStack.push(a); - bStack.push(b); - var size = 0, result = true; - // Recursively compare objects and arrays. - if (className == '[object Array]') { - // Compare array lengths to determine if a deep comparison is necessary. - size = a.length; - result = size == b.length; - if (result) { - // Deep compare the contents, ignoring non-numeric properties. - while (size--) { - if (!(result = eq(a[size], b[size], aStack, bStack))) break; - } - } - } else { - // Deep compare objects. - for (var key in a) { - if (_.has(a, key)) { - // Count the expected number of properties. - size++; - // Deep compare each member. - if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; - } - } - // Ensure that both objects contain the same number of properties. - if (result) { - for (key in b) { - if (_.has(b, key) && !(size--)) break; - } - result = !size; - } - } - // Remove the first object from the stack of traversed objects. - aStack.pop(); - bStack.pop(); - return result; - }; - - // Perform a deep comparison to check if two objects are equal. - _.isEqual = function(a, b) { - return eq(a, b, [], []); - }; - - // Is a given array, string, or object empty? - // An "empty" object has no enumerable own-properties. - _.isEmpty = function(obj) { - if (obj == null) return true; - if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; - for (var key in obj) if (_.has(obj, key)) return false; - return true; - }; - - // Is a given value a DOM element? - _.isElement = function(obj) { - return !!(obj && obj.nodeType === 1); - }; - - // Is a given value an array? - // Delegates to ECMA5's native Array.isArray - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) == '[object Array]'; - }; - - // Is a given variable an object? - _.isObject = function(obj) { - return obj === Object(obj); - }; - - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. - each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { - _['is' + name] = function(obj) { - return toString.call(obj) == '[object ' + name + ']'; - }; - }); - - // Define a fallback version of the method in browsers (ahem, IE), where - // there isn't any inspectable "Arguments" type. - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return !!(obj && _.has(obj, 'callee')); - }; - } - - // Optimize `isFunction` if appropriate. - if (typeof (/./) !== 'function') { - _.isFunction = function(obj) { - return typeof obj === 'function'; - }; - } - - // Is a given object a finite number? - _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); - }; - - // Is the given value `NaN`? (NaN is the only number which does not equal itself). - _.isNaN = function(obj) { - return _.isNumber(obj) && obj != +obj; - }; - - // Is a given value a boolean? - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; - }; - - // Is a given value equal to null? - _.isNull = function(obj) { - return obj === null; - }; - - // Is a given variable undefined? - _.isUndefined = function(obj) { - return obj === void 0; - }; - - // Shortcut function for checking if an object has a given property directly - // on itself (in other words, not on a prototype). - _.has = function(obj, key) { - return hasOwnProperty.call(obj, key); - }; - - // Utility Functions - // ----------------- - - // Run Underscore.js in *noConflict* mode, returning the `_` variable to its - // previous owner. Returns a reference to the Underscore object. - _.noConflict = function() { - root._ = previousUnderscore; - return this; - }; - - // Keep the identity function around for default iterators. - _.identity = function(value) { - return value; - }; - - _.constant = function(value) { - return function () { - return value; - }; - }; - - _.property = function(key) { - return function(obj) { - return obj[key]; - }; - }; - - // Returns a predicate for checking whether an object has a given set of `key:value` pairs. - _.matches = function(attrs) { - return function(obj) { - if (obj === attrs) return true; //avoid comparing an object to itself. - for (var key in attrs) { - if (attrs[key] !== obj[key]) - return false; - } - return true; - } - }; - - // Run a function **n** times. - _.times = function(n, iterator, context) { - var accum = Array(Math.max(0, n)); - for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); - return accum; - }; - - // Return a random integer between min and max (inclusive). - _.random = function(min, max) { - if (max == null) { - max = min; - min = 0; - } - return min + Math.floor(Math.random() * (max - min + 1)); - }; - - // A (possibly faster) way to get the current timestamp as an integer. - _.now = Date.now || function() { return new Date().getTime(); }; - - // List of HTML entities for escaping. - var entityMap = { - escape: { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' - } - }; - entityMap.unescape = _.invert(entityMap.escape); - - // Regexes containing the keys and values listed immediately above. - var entityRegexes = { - escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), - unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') - }; - - // Functions for escaping and unescaping strings to/from HTML interpolation. - _.each(['escape', 'unescape'], function(method) { - _[method] = function(string) { - if (string == null) return ''; - return ('' + string).replace(entityRegexes[method], function(match) { - return entityMap[method][match]; - }); - }; - }); - - // If the value of the named `property` is a function then invoke it with the - // `object` as context; otherwise, return it. - _.result = function(object, property) { - if (object == null) return void 0; - var value = object[property]; - return _.isFunction(value) ? value.call(object) : value; - }; - - // Add your own custom functions to the Underscore object. - _.mixin = function(obj) { - each(_.functions(obj), function(name) { - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [this._wrapped]; - push.apply(args, arguments); - return result.call(this, func.apply(_, args)); - }; - }); - }; - - // Generate a unique integer id (unique within the entire client session). - // Useful for temporary DOM ids. - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = ++idCounter + ''; - return prefix ? prefix + id : id; - }; - - // By default, Underscore uses ERB-style template delimiters, change the - // following template settings to use alternative delimiters. - _.templateSettings = { - evaluate : /<%([\s\S]+?)%>/g, - interpolate : /<%=([\s\S]+?)%>/g, - escape : /<%-([\s\S]+?)%>/g - }; - - // When customizing `templateSettings`, if you don't want to define an - // interpolation, evaluation or escaping regex, we need one that is - // guaranteed not to match. - var noMatch = /(.)^/; - - // Certain characters need to be escaped so that they can be put into a - // string literal. - var escapes = { - "'": "'", - '\\': '\\', - '\r': 'r', - '\n': 'n', - '\t': 't', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; - - // JavaScript micro-templating, similar to John Resig's implementation. - // Underscore templating handles arbitrary delimiters, preserves whitespace, - // and correctly escapes quotes within interpolated code. - _.template = function(text, data, settings) { - var render; - settings = _.defaults({}, settings, _.templateSettings); - - // Combine delimiters into one regular expression via alternation. - var matcher = new RegExp([ - (settings.escape || noMatch).source, - (settings.interpolate || noMatch).source, - (settings.evaluate || noMatch).source - ].join('|') + '|$', 'g'); - - // Compile the template source, escaping string literals appropriately. - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset) - .replace(escaper, function(match) { return '\\' + escapes[match]; }); - - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } - if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } - if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } - index = offset + match.length; - return match; - }); - source += "';\n"; - - // If a variable is not specified, place data values in local scope. - if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; - - source = "var __t,__p='',__j=Array.prototype.join," + - "print=function(){__p+=__j.call(arguments,'');};\n" + - source + "return __p;\n"; - - try { - render = new Function(settings.variable || 'obj', '_', source); - } catch (e) { - e.source = source; - throw e; - } - - if (data) return render(data, _); - var template = function(data) { - return render.call(this, data, _); - }; - - // Provide the compiled function source as a convenience for precompilation. - template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; - - return template; - }; - - // Add a "chain" function, which will delegate to the wrapper. - _.chain = function(obj) { - return _(obj).chain(); - }; - - // OOP - // --------------- - // If Underscore is called as a function, it returns a wrapped object that - // can be used OO-style. This wrapper holds altered versions of all the - // underscore functions. Wrapped objects may be chained. - - // Helper function to continue chaining intermediate results. - var result = function(obj) { - return this._chain ? _(obj).chain() : obj; - }; - - // Add all of the Underscore functions to the wrapper object. - _.mixin(_); - - // Add all mutator Array functions to the wrapper. - each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - var obj = this._wrapped; - method.apply(obj, arguments); - if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; - return result.call(this, obj); - }; - }); - - // Add all accessor Array functions to the wrapper. - each(['concat', 'join', 'slice'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - return result.call(this, method.apply(this._wrapped, arguments)); - }; - }); - - _.extend(_.prototype, { - - // Start chaining a wrapped Underscore object. - chain: function() { - this._chain = true; - return this; - }, - - // Extracts the result from a wrapped and chained object. - value: function() { - return this._wrapped; - } - - }); - - // AMD registration happens at the end for compatibility with AMD loaders - // that may not enforce next-turn semantics on modules. Even though general - // practice for AMD registration is to be anonymous, underscore registers - // as a named module because, like jQuery, it is a base library that is - // popular enough to be bundled in a third party lib, but not be part of - // an AMD load request. Those cases could generate an error when an - // anonymous define() is called outside of a loader request. - if (typeof define === 'function' && define.amd) { - define('underscore', [], function() { - return _; - }); - } -}).call(this); diff --git a/.atom/packages/editor-stats/node_modules/underscore-plus/package.json b/.atom/packages/editor-stats/node_modules/underscore-plus/package.json deleted file mode 100644 index d5ab709..0000000 --- a/.atom/packages/editor-stats/node_modules/underscore-plus/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "underscore-plus", - "version": "1.5.0", - "description": "Underscore plus additional utilities", - "licenses": [ - { - "type": "MIT", - "url": "http://github.com/atom/underscore-plus/raw/master/LICENSE.md" - } - ], - "main": "./lib/underscore-plus.js", - "scripts": { - "prepublish": "grunt clean coffee lint", - "test": "grunt test" - }, - "repository": { - "type": "git", - "url": "https://github.com/atom/underscore-plus.git" - }, - "bugs": { - "url": "https://github.com/atom/underscore-plus/issues" - }, - "homepage": "http://atom.github.io/underscore-plus", - "keywords": [ - "underscore" - ], - "dependencies": { - "underscore": "~1.6.0" - }, - "devDependencies": { - "jasmine-focused": "1.x", - "grunt-contrib-coffee": "~0.9.0", - "grunt-cli": "~0.1.8", - "grunt": "~0.4.1", - "grunt-shell": "~0.2.2", - "grunt-coffeelint": "0.0.6", - "temp": "~0.5.0", - "rimraf": "~2.1.4" - }, - "readme": "# underscore-plus [![Build Status](https://travis-ci.org/atom/underscore-plus.svg?branch=master)](https://travis-ci.org/atom/underscore-plus)\n\nTakes the great [underscore](http://underscorejs.org/) library and adds a few\nmore things.\n\n## Using\n\n```sh\nnpm install underscore-plus\n```\n\n```coffeescript\n_ = require 'underscore-plus' # Has all underscore methods and more\n```\n", - "readmeFilename": "README.md", - "_id": "underscore-plus@1.5.0", - "dist": { - "shasum": "69dece800bcf9317e0c09191644e4d7d2bc3325d" - }, - "_from": "underscore-plus@1.x", - "_resolved": "https://registry.npmjs.org/underscore-plus/-/underscore-plus-1.5.0.tgz" -} diff --git a/.atom/packages/editor-stats/package.json b/.atom/packages/editor-stats/package.json deleted file mode 100644 index 5674d4f..0000000 --- a/.atom/packages/editor-stats/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "editor-stats", - "version": "0.15.0", - "main": "./lib/editor-stats", - "description": "Display a graph of keyboard and mouse usage for the last 6 hours.", - "license": "MIT", - "dependencies": { - "d3-browserify": "3.3.13", - "underscore-plus": "1.x" - }, - "repository": { - "type": "git", - "url": "https://github.com/atom/editor-stats" - }, - "engines": { - "atom": "*" - }, - "readme": "# Editor Stats package [![Build Status](https://travis-ci.org/atom/editor-stats.svg?branch=master)](https://travis-ci.org/atom/editor-stats)\n\nView a graph of your mouse and keyboard activity for the last 6 hours.\n\nThe blue bar indicates the time of greatest activity.\n\nUse `cmd-alt-s` to open and close the graph.\n\n![](https://f.cloud.github.com/assets/671378/2262223/843b1172-9e57-11e3-9c60-8d28d542f39c.png)\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/atom/editor-stats/issues" - }, - "homepage": "https://github.com/atom/editor-stats", - "_id": "editor-stats@0.15.0", - "dist": { - "shasum": "452609309c2e9670a97d4a6b52494bff4736b003" - }, - "_resolved": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114614-7476-78u8m0\\package.tgz", - "_from": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114614-7476-78u8m0\\package.tgz" -} diff --git a/.atom/packages/editor-stats/spec/editor-stats-spec.coffee b/.atom/packages/editor-stats/spec/editor-stats-spec.coffee deleted file mode 100644 index 76e187d..0000000 --- a/.atom/packages/editor-stats/spec/editor-stats-spec.coffee +++ /dev/null @@ -1,39 +0,0 @@ -_ = require 'underscore-plus' -{$, WorkspaceView} = require 'atom' - -describe "EditorStats", -> - [editorStats] = [] - - simulateKeyUp = (key) -> - e = $.Event "keydown", keyCode: key.charCodeAt(0) - atom.workspaceView.trigger(e) - - simulateClick = -> - e = $.Event "mouseup" - atom.workspaceView.trigger(e) - - beforeEach -> - atom.workspaceView = new WorkspaceView - atom.workspaceView.openSync('sample.js') - - waitsForPromise -> - atom.packages.activatePackage('editor-stats').then (pack) -> - editorStats = pack.mainModule.stats - - describe "when a keyup event is triggered", -> - beforeEach -> - expect(_.values(editorStats.eventLog)).not.toContain 1 - expect(_.values(editorStats.eventLog)).not.toContain 2 - - it "records the number of times a keyup is triggered", -> - simulateKeyUp('a') - expect(_.values(editorStats.eventLog)).toContain 1 - simulateKeyUp('b') - expect(_.values(editorStats.eventLog)).toContain 2 - - describe "when a mouseup event is triggered", -> - it "records the number of times a mouseup is triggered", -> - simulateClick() - expect(_.values(editorStats.eventLog)).toContain 1 - simulateClick() - expect(_.values(editorStats.eventLog)).toContain 2 diff --git a/.atom/packages/editor-stats/stylesheets/editor-stats.less b/.atom/packages/editor-stats/stylesheets/editor-stats.less deleted file mode 100644 index 442d0bc..0000000 --- a/.atom/packages/editor-stats/stylesheets/editor-stats.less +++ /dev/null @@ -1,44 +0,0 @@ -.editor-stats-wrapper { - padding: 5px; - box-sizing: border-box; - border-top: 1px solid rgba(255, 255, 255, 0.05); -} - -.editor-stats { - height: 50px; - width: 100%; - background: #1d1f21; - border: 1px solid rgba(0, 0, 0, 0.3); - border-bottom: 1px solid rgba(255, 255, 255, 0.1); - border-right: 1px solid rgba(255, 255, 255, 0.1); - - .bar { - fill: rgba(255, 255, 255, 0.2); - shape-rendering: crispedges; - - &.max { - fill: rgba(0, 163, 255, 1); - } - } - - text { - font-size: 10px; - fill: rgba(255, 255, 255, 0.2); - font-family: Courier; - } - - .minor text { - display: none; - } - - line { - stroke: #ccc; - stroke-opacity: 0.05; - stroke-width: 1px; - shape-rendering: crispedges; - } - - path.domain { - display: none; - } -} diff --git a/.atom/packages/jellybeans-syntax/.npmignore b/.atom/packages/jellybeans-syntax/.npmignore deleted file mode 100644 index ade14b9..0000000 --- a/.atom/packages/jellybeans-syntax/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -npm-debug.log -node_modules diff --git a/.atom/packages/jellybeans-syntax/CHANGELOG.md b/.atom/packages/jellybeans-syntax/CHANGELOG.md deleted file mode 100644 index c3d858c..0000000 --- a/.atom/packages/jellybeans-syntax/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.1.0 - First Release -* Every feature added -* Every bug fixed diff --git a/.atom/packages/jellybeans-syntax/LICENSE.md b/.atom/packages/jellybeans-syntax/LICENSE.md deleted file mode 100644 index 7ce8c08..0000000 --- a/.atom/packages/jellybeans-syntax/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/jellybeans-syntax/README.md b/.atom/packages/jellybeans-syntax/README.md deleted file mode 100644 index 3135eb5..0000000 --- a/.atom/packages/jellybeans-syntax/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# jellybeans-syntax theme - -Jellybeans theme, inspired by Nanotech's jellybeans color scheme for vim, available [here](https://github.com/nanotech/jellybeans.vim) - -![Screenshot](https://github.com/Trevoke/jellybeans-syntax/wiki/images/screenshot.png) diff --git a/.atom/packages/jellybeans-syntax/index.less b/.atom/packages/jellybeans-syntax/index.less deleted file mode 100644 index d850961..0000000 --- a/.atom/packages/jellybeans-syntax/index.less +++ /dev/null @@ -1 +0,0 @@ -@import "./stylesheets/base.less"; diff --git a/.atom/packages/jellybeans-syntax/package.json b/.atom/packages/jellybeans-syntax/package.json deleted file mode 100644 index 6cc0d80..0000000 --- a/.atom/packages/jellybeans-syntax/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "jellybeans-syntax", - "theme": "syntax", - "version": "0.3.0", - "description": "A copy of nanotech's vim jellybeans color theme", - "repository": { - "type": "git", - "url": "https://github.com/trevoke/jellybeans-syntax" - }, - "license": "MIT", - "engines": { - "atom": ">0.50.0" - }, - "readme": "# jellybeans-syntax theme\n\nJellybeans theme, inspired by Nanotech's jellybeans color scheme for vim, available [here](https://github.com/nanotech/jellybeans.vim)\n\n![Screenshot](https://github.com/Trevoke/jellybeans-syntax/wiki/images/screenshot.png)\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/trevoke/jellybeans-syntax/issues" - }, - "homepage": "https://github.com/trevoke/jellybeans-syntax", - "_id": "jellybeans-syntax@0.3.0", - "dist": { - "shasum": "46b9df6dd0f645e0c3292c1db20ca66f0f8eae68" - }, - "_resolved": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114628-3028-1owzcen\\package.tgz", - "_from": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114628-3028-1owzcen\\package.tgz" -} diff --git a/.atom/packages/jellybeans-syntax/stylesheets/base.less b/.atom/packages/jellybeans-syntax/stylesheets/base.less deleted file mode 100644 index 2880c2e..0000000 --- a/.atom/packages/jellybeans-syntax/stylesheets/base.less +++ /dev/null @@ -1,320 +0,0 @@ -@import "syntax-variables"; - -.editor-colors { - background-color: @syntax-background-color; - color: @syntax-text-color; -} - -.editor { - background-color: @syntax-background-color; - color: @syntax-text-color; - - .wrap-guide { - background-color: @syntax-wrap-guide-color; - } - - .indent-guide { - color: @syntax-indent-guide-color; - } - - .invisible-character { - color: @syntax-invisible-character-color; - } - - .gutter { - background-color: @syntax-gutter-background-color; - color: @syntax-gutter-text-color; - - .line-number { - &.cursor-line { - background-color: @syntax-gutter-background-color-selected; - color: @syntax-gutter-text-color-selected; - } - - &.cursor-line-no-selection { - color: @syntax-gutter-text-color-selected; - } - } - } - - .gutter .line-number.folded, - .gutter .line-number:after, - .fold-marker:after { - color: @light-gray; - } - - .invisible { - color: @syntax-text-color; - } - - .cursor { - color: @syntax-cursor-color; - background-color: @syntax-cursor-color; - - } - - .selection .region { - background-color: @syntax-selection-color; - } -} - -.editor .search-results .marker .region { - background-color: transparent; - border: 1px solid @syntax-result-marker-color; -} - -.editor .search-results .marker.current-result .region { - border: 1px solid @syntax-result-marker-color-selected; -} - -.comment { - color: @solid-gray; -} - -.entity { - &.name.type { - color: @light-orange; - } - - &.other.inherited-class { - color: @green; - } -} - -.keyword { - color: @dark-blue; - - &.control { - color: @dark-blue; - } - - &.operator { - color: @syntax-text-color; - } - - &.other.special-method { - color: @blue; - } - - &.other.unit { - color: @orange; - } -} - -.storage { - color: @purple; -} - -.constant { - color: @orange; - - &.character.escape { - color: @magenta; - } - - &.numeric { - color: @orange; - } - - &.other.color { - color: @cyan; - } - - &.other.symbol { - color: @darker-blue; - } -} - -.variable { - color: @cyan; - - &.interpolation { - color: darken(@red, 10%); - } - - &.parameter.function { - color: @syntax-text-color; - } -} - -.invalid.illegal { - background-color: @red; - color: @syntax-background-color; -} - -.string { - color: @green; - - - &.regexp { - color: @dark-magenta; - - .source.ruby.embedded { - color: @orange; - } - } - - &.other.link { - color: @red; - } -} - -.punctuation { - &.definition { - &.comment { - color: @solid-gray; - } - - &.variable { - color: @cyan; - } - - &.parameters { - color: @off-white; - } - - &.string, - &.array { - color: @dark-green; - } - - &.heading, - &.identity { - color: @blue; - } - - &.bold { - color: @light-orange; - font-style: bold; - } - - &.italic { - color: @purple; - font-style: italic; - } - } - - &.section.embedded { - color: darken(@red, 10%); - } - -} - -.support { - &.class { - color: @light-orange; - } - - &.function { - color: @cyan; - - &.any-method { - color: @blue; - } - } -} - -.entity { - &.name.function { - color: @yellow; - } - - &.name.class, &.name.type.class { - color: @light-orange; - } - - &.name.section { - color: @blue; - } - - &.name.tag { - color: @red; - text-decoration: underline; - } - - &.other.attribute-name { - color: @orange; - - &.id { - color: @blue; - } - } -} - -.meta { - &.class { - color: @light-orange; - } - - &.link { - color: @orange; - } - - &.require { - color: @blue; - } - - &.selector { - color: @purple; - } - - &.separator { - background-color: @gray; - color: @syntax-text-color; - } -} - -.none { - color: @syntax-text-color; -} - -.markup { - &.bold { - color: @orange; - font-style: bold; - } - - &.changed { - color: @purple; - } - - &.deleted { - color: @red; - } - - &.italic { - color: @purple; - font-style: italic; - } - - &.heading .punctuation.definition.heading { - color: @blue; - } - - &.inserted { - color: @green; - } - - &.list { - color: @red; - } - - &.quote { - color: @orange; - } - - &.raw.inline { - color: @green; - } -} - -.source.gfm .markup { - -webkit-font-smoothing: auto; - &.heading { - color: @green; - } -} - -.editor.mini .scroll-view { - padding-left: 1px; -} diff --git a/.atom/packages/jellybeans-syntax/stylesheets/colors.less b/.atom/packages/jellybeans-syntax/stylesheets/colors.less deleted file mode 100644 index 0704212..0000000 --- a/.atom/packages/jellybeans-syntax/stylesheets/colors.less +++ /dev/null @@ -1,30 +0,0 @@ -// These colors are specific to the theme. Do not use in a package! - -@cyan: #c6b6fe; -@purple: #b294bb; -@green: #99ad6a; -@dark-green: #556633; -@red: #de5577; -@orange: #eeeeee; -@light-orange: #f0c674; -@yellow: #fad07a; -@magenta: #a40063; -@dark-magenta: #dd0093; - -@background-color: #151515; -@text: #e8e8d3; -@black: #1c1c1c; //cursorLine, cursorColumn -@dark-cyan: #556779; //matchParen -@gray: #b0b8c0; //tabLine -@dark-gray: #9098a0; //tabLineFill -@white: #f0f0f0; // tabLineSel -@gray-brown: #606060; // pmenu -@off-white: #eeeeee; // pmenuSel -@brown: #404040; //highlight -@blue: #b0d0f0; //cursor -@darker-blue: #7597c6; -@dark-blue: #447799; -@light-brown: #605958; //linenumber -@light-gray: #ccc5c4; // cursorlinenumber -@solid-gray: #888888; // comment -@solid-light-gray: #c7c7c7; //todo diff --git a/.atom/packages/jellybeans-syntax/stylesheets/syntax-variables.less b/.atom/packages/jellybeans-syntax/stylesheets/syntax-variables.less deleted file mode 100644 index f4d2d10..0000000 --- a/.atom/packages/jellybeans-syntax/stylesheets/syntax-variables.less +++ /dev/null @@ -1,31 +0,0 @@ -@import "colors"; - -// This defines all syntax variables that syntax themes must implement when they -// include a syntax-variables.less file. - -// General colors -@syntax-text-color: @text; -@syntax-cursor-color: @blue; -@syntax-selection-color: #404040; -@syntax-background-color: @background-color; - -// Guide colors -@syntax-wrap-guide-color: lighten(@background-color, 10%); -@syntax-indent-guide-color: @dark-gray; -@syntax-invisible-character-color: @gray; - -// For find and replace markers -@syntax-result-marker-color: @light-gray; -@syntax-result-marker-color-selected: white; - -// Gutter colors -@syntax-gutter-text-color: @white; -@syntax-gutter-text-color-selected: @syntax-gutter-text-color; -@syntax-gutter-background-color: @dark-gray; -@syntax-gutter-background-color-selected: @gray; - -// For git diff info. i.e. in the gutter -@syntax-color-renamed: @blue; -@syntax-color-added: @green; -@syntax-color-modified: @orange; -@syntax-color-removed: @red; diff --git a/.atom/packages/language-erlang/README.md b/.atom/packages/language-erlang/README.md deleted file mode 100644 index ae9a2b2..0000000 --- a/.atom/packages/language-erlang/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# language-erlang package - -Erlang language support for Atom. - ------ - -Adds syntax highlighting and snippets to Erlang files in Atom. - -Copyright (c) 2014 [Jonathan Barronville](mailto:jonathan@belairlabs.com "jonathan@belairlabs.com") diff --git a/.atom/packages/language-erlang/grammars/erlang.cson b/.atom/packages/language-erlang/grammars/erlang.cson deleted file mode 100644 index c1ea5bc..0000000 --- a/.atom/packages/language-erlang/grammars/erlang.cson +++ /dev/null @@ -1,1305 +0,0 @@ -'comment': 'The recognition of function definitions and compiler directives (such as module, record and macro definitions) requires that each of the aforementioned constructs must be the first string inside a line (except for whitespace). Also, the function/module/record/macro names must be given unquoted. -- desp' -'fileTypes': [ - 'erl' - 'hrl' -] -'name': 'Erlang' -'patterns': [ - { - 'include': '#module-directive' - } - { - 'include': '#import-export-directive' - } - { - 'include': '#behaviour-directive' - } - { - 'include': '#record-directive' - } - { - 'include': '#define-directive' - } - { - 'include': '#macro-directive' - } - { - 'include': '#directive' - } - { - 'include': '#function' - } - { - 'include': '#everything-else' - } -] -'repository': - 'atom': - 'patterns': [ - { - 'begin': '(\')' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.symbol.begin.erlang' - 'end': '(\')' - 'endCaptures': - '1': - 'name': 'punctuation.definition.symbol.end.erlang' - 'name': 'constant.other.symbol.quoted.single.erlang' - 'patterns': [ - { - 'captures': - '1': - 'name': 'punctuation.definition.escape.erlang' - '3': - 'name': 'punctuation.definition.escape.erlang' - 'match': '(\\\\)([bdefnrstv\\\\\'"]|(\\^)[@-_]|[0-7]{1,3})' - 'name': 'constant.other.symbol.escape.erlang' - } - { - 'match': '\\\\\\^?.?' - 'name': 'invalid.illegal.atom.erlang' - } - ] - } - { - 'match': '[a-z][a-zA-Z\\d@_]*+' - 'name': 'constant.other.symbol.unquoted.erlang' - } - ] - 'behaviour-directive': - 'captures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.behaviour.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - '4': - 'name': 'entity.name.type.class.behaviour.definition.erlang' - '5': - 'name': 'punctuation.definition.parameters.end.erlang' - '6': - 'name': 'punctuation.section.directive.end.erlang' - 'match': '^\\s*+(-)\\s*+(behaviour)\\s*+(\\()\\s*+([a-z][a-zA-Z\\d@_]*+)\\s*+(\\))\\s*+(\\.)' - 'name': 'meta.directive.behaviour.erlang' - 'binary': - 'begin': '(<<)' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.binary.begin.erlang' - 'end': '(>>)' - 'endCaptures': - '1': - 'name': 'punctuation.definition.binary.end.erlang' - 'name': 'meta.structure.binary.erlang' - 'patterns': [ - { - 'captures': - '1': - 'name': 'punctuation.separator.binary.erlang' - '2': - 'name': 'punctuation.separator.value-size.erlang' - 'match': '(,)|(:)' - } - { - 'include': '#internal-type-specifiers' - } - { - 'include': '#everything-else' - } - ] - 'character': - 'patterns': [ - { - 'captures': - '1': - 'name': 'punctuation.definition.character.erlang' - '2': - 'name': 'constant.character.escape.erlang' - '3': - 'name': 'punctuation.definition.escape.erlang' - '5': - 'name': 'punctuation.definition.escape.erlang' - 'match': '(\\$)((\\\\)([bdefnrstv\\\\\'"]|(\\^)[@-_]|[0-7]{1,3}))' - 'name': 'constant.character.erlang' - } - { - 'match': '\\$\\\\\\^?.?' - 'name': 'invalid.illegal.character.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.definition.character.erlang' - 'match': '(\\$)\\S' - 'name': 'constant.character.erlang' - } - { - 'match': '\\$.?' - 'name': 'invalid.illegal.character.erlang' - } - ] - 'comment': - 'begin': '(^[ \\t]+)?(?=%)' - 'beginCaptures': - '1': - 'name': 'punctuation.whitespace.comment.leading.erlang' - 'end': '(?!\\G)' - 'patterns': [ - { - 'begin': '%' - 'beginCaptures': - '0': - 'name': 'punctuation.definition.comment.erlang' - 'end': '\\n' - 'name': 'comment.line.percentage.erlang' - } - ] - 'define-directive': - 'patterns': [ - { - 'begin': '^\\s*+(-)\\s*+(define)\\s*+(\\()\\s*+([a-zA-Z\\d@_]++)\\s*+(,)' - 'beginCaptures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.define.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - '4': - 'name': 'entity.name.function.macro.definition.erlang' - '5': - 'name': 'punctuation.separator.parameters.erlang' - 'end': '(\\))\\s*+(\\.)' - 'endCaptures': - '1': - 'name': 'punctuation.definition.parameters.end.erlang' - '2': - 'name': 'punctuation.section.directive.end.erlang' - 'name': 'meta.directive.define.erlang' - 'patterns': [ - { - 'include': '#everything-else' - } - ] - } - { - 'begin': '(?=^\\s*+-\\s*+define\\s*+\\(\\s*+[a-zA-Z\\d@_]++\\s*+\\()' - 'end': '(\\))\\s*+(\\.)' - 'endCaptures': - '1': - 'name': 'punctuation.definition.parameters.end.erlang' - '2': - 'name': 'punctuation.section.directive.end.erlang' - 'name': 'meta.directive.define.erlang' - 'patterns': [ - { - 'begin': '^\\s*+(-)\\s*+(define)\\s*+(\\()\\s*+([a-zA-Z\\d@_]++)\\s*+(\\()' - 'beginCaptures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.define.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - '4': - 'name': 'entity.name.function.macro.definition.erlang' - '5': - 'name': 'punctuation.definition.parameters.begin.erlang' - 'end': '(\\))\\s*(,)' - 'endCaptures': - '1': - 'name': 'punctuation.definition.parameters.end.erlang' - '2': - 'name': 'punctuation.separator.parameters.erlang' - 'patterns': [ - { - 'match': ',' - 'name': 'punctuation.separator.parameters.erlang' - } - { - 'include': '#everything-else' - } - ] - } - { - 'match': '\\|\\||\\||:|;|,|\\.|->' - 'name': 'punctuation.separator.define.erlang' - } - { - 'include': '#everything-else' - } - ] - } - ] - 'directive': - 'patterns': [ - { - 'begin': '^\\s*+(-)\\s*+([a-z][a-zA-Z\\d@_]*+)\\s*+(\\(?)' - 'beginCaptures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - 'end': '(\\)?)\\s*+(\\.)' - 'endCaptures': - '1': - 'name': 'punctuation.definition.parameters.end.erlang' - '2': - 'name': 'punctuation.section.directive.end.erlang' - 'name': 'meta.directive.erlang' - 'patterns': [ - { - 'include': '#everything-else' - } - ] - } - { - 'captures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.erlang' - '3': - 'name': 'punctuation.section.directive.end.erlang' - 'match': '^\\s*+(-)\\s*+([a-z][a-zA-Z\\d@_]*+)\\s*+(\\.)' - 'name': 'meta.directive.erlang' - } - ] - 'everything-else': - 'patterns': [ - { - 'include': '#comment' - } - { - 'include': '#record-usage' - } - { - 'include': '#macro-usage' - } - { - 'include': '#expression' - } - { - 'include': '#keyword' - } - { - 'include': '#textual-operator' - } - { - 'include': '#function-call' - } - { - 'include': '#tuple' - } - { - 'include': '#list' - } - { - 'include': '#binary' - } - { - 'include': '#parenthesized-expression' - } - { - 'include': '#character' - } - { - 'include': '#number' - } - { - 'include': '#atom' - } - { - 'include': '#string' - } - { - 'include': '#symbolic-operator' - } - { - 'include': '#variable' - } - ] - 'expression': - 'patterns': [ - { - 'begin': '\\b(if)\\b' - 'beginCaptures': - '1': - 'name': 'keyword.control.if.erlang' - 'end': '\\b(end)\\b' - 'endCaptures': - '1': - 'name': 'keyword.control.end.erlang' - 'name': 'meta.expression.if.erlang' - 'patterns': [ - { - 'include': '#internal-expression-punctuation' - } - { - 'include': '#everything-else' - } - ] - } - { - 'begin': '\\b(case)\\b' - 'beginCaptures': - '1': - 'name': 'keyword.control.case.erlang' - 'end': '\\b(end)\\b' - 'endCaptures': - '1': - 'name': 'keyword.control.end.erlang' - 'name': 'meta.expression.case.erlang' - 'patterns': [ - { - 'include': '#internal-expression-punctuation' - } - { - 'include': '#everything-else' - } - ] - } - { - 'begin': '\\b(receive)\\b' - 'beginCaptures': - '1': - 'name': 'keyword.control.receive.erlang' - 'end': '\\b(end)\\b' - 'endCaptures': - '1': - 'name': 'keyword.control.end.erlang' - 'name': 'meta.expression.receive.erlang' - 'patterns': [ - { - 'include': '#internal-expression-punctuation' - } - { - 'include': '#everything-else' - } - ] - } - { - 'captures': - '1': - 'name': 'keyword.control.fun.erlang' - '3': - 'name': 'entity.name.type.class.module.erlang' - '4': - 'name': 'punctuation.separator.module-function.erlang' - '5': - 'name': 'entity.name.function.erlang' - '6': - 'name': 'punctuation.separator.function-arity.erlang' - 'match': '\\b(fun)\\s*+(([a-z][a-zA-Z\\d@_]*+)\\s*+(:)\\s*+)?([a-z][a-zA-Z\\d@_]*+)\\s*(/)' - } - { - 'begin': '\\b(fun)\\b' - 'beginCaptures': - '1': - 'name': 'keyword.control.fun.erlang' - 'end': '\\b(end)\\b' - 'endCaptures': - '1': - 'name': 'keyword.control.end.erlang' - 'name': 'meta.expression.fun.erlang' - 'patterns': [ - { - 'begin': '(?=\\()' - 'end': '(;)|(?=\\bend\\b)' - 'endCaptures': - '1': - 'name': 'punctuation.separator.clauses.erlang' - 'patterns': [ - { - 'include': '#internal-function-parts' - } - ] - } - { - 'include': '#everything-else' - } - ] - } - { - 'begin': '\\b(try)\\b' - 'beginCaptures': - '1': - 'name': 'keyword.control.try.erlang' - 'end': '\\b(end)\\b' - 'endCaptures': - '1': - 'name': 'keyword.control.end.erlang' - 'name': 'meta.expression.try.erlang' - 'patterns': [ - { - 'include': '#internal-expression-punctuation' - } - { - 'include': '#everything-else' - } - ] - } - { - 'begin': '\\b(begin)\\b' - 'beginCaptures': - '1': - 'name': 'keyword.control.begin.erlang' - 'end': '\\b(end)\\b' - 'endCaptures': - '1': - 'name': 'keyword.control.end.erlang' - 'name': 'meta.expression.begin.erlang' - 'patterns': [ - { - 'include': '#internal-expression-punctuation' - } - { - 'include': '#everything-else' - } - ] - } - { - 'begin': '\\b(query)\\b' - 'beginCaptures': - '1': - 'name': 'keyword.control.query.erlang' - 'end': '\\b(end)\\b' - 'endCaptures': - '1': - 'name': 'keyword.control.end.erlang' - 'name': 'meta.expression.query.erlang' - 'patterns': [ - { - 'include': '#everything-else' - } - ] - } - ] - 'function': - 'begin': '^\\s*+([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(?=\\()' - 'beginCaptures': - '1': - 'name': 'entity.name.function.definition.erlang' - 'end': '(\\.)' - 'endCaptures': - '1': - 'name': 'punctuation.terminator.function.erlang' - 'name': 'meta.function.erlang' - 'patterns': [ - { - 'captures': - '1': - 'name': 'entity.name.function.erlang' - 'match': '^\\s*+([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(?=\\()' - } - { - 'begin': '(?=\\()' - 'end': '(;)|(?=\\.)' - 'endCaptures': - '1': - 'name': 'punctuation.separator.clauses.erlang' - 'patterns': [ - { - 'include': '#parenthesized-expression' - } - { - 'include': '#internal-function-parts' - } - ] - } - { - 'include': '#everything-else' - } - ] - 'function-call': - 'begin': '(?=([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(\\(|:\\s*+([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+\\())' - 'end': '(\\))' - 'endCaptures': - '1': - 'name': 'punctuation.definition.parameters.end.erlang' - 'name': 'meta.function-call.erlang' - 'patterns': [ - { - 'begin': '((erlang)\\s*+(:)\\s*+)?(is_atom|is_binary|is_constant|is_float|is_function|is_integer|is_list|is_number|is_pid|is_port|is_reference|is_tuple|is_record|abs|element|hd|length|node|round|self|size|tl|trunc)\\s*+(\\()' - 'beginCaptures': - '2': - 'name': 'entity.name.type.class.module.erlang' - '3': - 'name': 'punctuation.separator.module-function.erlang' - '4': - 'name': 'entity.name.function.guard.erlang' - '5': - 'name': 'punctuation.definition.parameters.begin.erlang' - 'end': '(?=\\))' - 'patterns': [ - { - 'match': ',' - 'name': 'punctuation.separator.parameters.erlang' - } - { - 'include': '#everything-else' - } - ] - } - { - 'begin': '(([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(:)\\s*+)?([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(\\()' - 'beginCaptures': - '2': - 'name': 'entity.name.type.class.module.erlang' - '3': - 'name': 'punctuation.separator.module-function.erlang' - '4': - 'name': 'entity.name.function.erlang' - '5': - 'name': 'punctuation.definition.parameters.begin.erlang' - 'end': '(?=\\))' - 'patterns': [ - { - 'match': ',' - 'name': 'punctuation.separator.parameters.erlang' - } - { - 'include': '#everything-else' - } - ] - } - ] - 'import-export-directive': - 'patterns': [ - { - 'begin': '^\\s*+(-)\\s*+(import)\\s*+(\\()\\s*+([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(,)' - 'beginCaptures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.import.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - '4': - 'name': 'entity.name.type.class.module.erlang' - '5': - 'name': 'punctuation.separator.parameters.erlang' - 'end': '(\\))\\s*+(\\.)' - 'endCaptures': - '1': - 'name': 'punctuation.definition.parameters.end.erlang' - '2': - 'name': 'punctuation.section.directive.end.erlang' - 'name': 'meta.directive.import.erlang' - 'patterns': [ - { - 'include': '#internal-function-list' - } - ] - } - { - 'begin': '^\\s*+(-)\\s*+(export)\\s*+(\\()' - 'beginCaptures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.export.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - 'end': '(\\))\\s*+(\\.)' - 'endCaptures': - '1': - 'name': 'punctuation.definition.parameters.end.erlang' - '2': - 'name': 'punctuation.section.directive.end.erlang' - 'name': 'meta.directive.export.erlang' - 'patterns': [ - { - 'include': '#internal-function-list' - } - ] - } - ] - 'internal-expression-punctuation': - 'captures': - '1': - 'name': 'punctuation.separator.clause-head-body.erlang' - '2': - 'name': 'punctuation.separator.clauses.erlang' - '3': - 'name': 'punctuation.separator.expressions.erlang' - 'match': '(->)|(;)|(,)' - 'internal-function-list': - 'begin': '(\\[)' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.list.begin.erlang' - 'end': '(\\])' - 'endCaptures': - '1': - 'name': 'punctuation.definition.list.end.erlang' - 'name': 'meta.structure.list.function.erlang' - 'patterns': [ - { - 'begin': '([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(/)' - 'beginCaptures': - '1': - 'name': 'entity.name.function.erlang' - '2': - 'name': 'punctuation.separator.function-arity.erlang' - 'end': '(,)|(?=\\])' - 'endCaptures': - '1': - 'name': 'punctuation.separator.list.erlang' - 'patterns': [ - { - 'include': '#everything-else' - } - ] - } - { - 'include': '#everything-else' - } - ] - 'internal-function-parts': - 'patterns': [ - { - 'begin': '(?=\\()' - 'end': '(->)' - 'endCaptures': - '1': - 'name': 'punctuation.separator.clause-head-body.erlang' - 'patterns': [ - { - 'begin': '(\\()' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.parameters.begin.erlang' - 'end': '(\\))' - 'endCaptures': - '1': - 'name': 'punctuation.definition.parameters.end.erlang' - 'patterns': [ - { - 'match': ',' - 'name': 'punctuation.separator.parameters.erlang' - } - { - 'include': '#everything-else' - } - ] - } - { - 'match': ',|;' - 'name': 'punctuation.separator.guards.erlang' - } - { - 'include': '#everything-else' - } - ] - } - { - 'match': ',' - 'name': 'punctuation.separator.expressions.erlang' - } - { - 'include': '#everything-else' - } - ] - 'internal-record-body': - 'begin': '(\\{)' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.class.record.begin.erlang' - 'end': '(?=\\})' - 'name': 'meta.structure.record.erlang' - 'patterns': [ - { - 'begin': '(([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')|(_))\\s*+(=|::)' - 'beginCaptures': - '2': - 'name': 'variable.other.field.erlang' - '3': - 'name': 'variable.language.omitted.field.erlang' - '4': - 'name': 'keyword.operator.assignment.erlang' - 'end': '(,)|(?=\\})' - 'endCaptures': - '1': - 'name': 'punctuation.separator.class.record.erlang' - 'patterns': [ - { - 'include': '#everything-else' - } - ] - } - { - 'captures': - '1': - 'name': 'variable.other.field.erlang' - '2': - 'name': 'punctuation.separator.class.record.erlang' - 'match': '([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(,)?' - } - { - 'include': '#everything-else' - } - ] - 'internal-type-specifiers': - 'begin': '(/)' - 'beginCaptures': - '1': - 'name': 'punctuation.separator.value-type.erlang' - 'end': '(?=,|:|>>)' - 'patterns': [ - { - 'captures': - '1': - 'name': 'storage.type.erlang' - '2': - 'name': 'storage.modifier.signedness.erlang' - '3': - 'name': 'storage.modifier.endianness.erlang' - '4': - 'name': 'storage.modifier.unit.erlang' - '5': - 'name': 'punctuation.separator.type-specifiers.erlang' - 'match': '(integer|float|binary|bytes|bitstring|bits)|(signed|unsigned)|(big|little|native)|(unit)|(-)' - } - ] - 'keyword': - 'match': '\\b(after|begin|case|catch|cond|end|fun|if|let|of|query|try|receive|when)\\b' - 'name': 'keyword.control.erlang' - 'list': - 'begin': '(\\[)' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.list.begin.erlang' - 'end': '(\\])' - 'endCaptures': - '1': - 'name': 'punctuation.definition.list.end.erlang' - 'name': 'meta.structure.list.erlang' - 'patterns': [ - { - 'match': '\\||\\|\\||,' - 'name': 'punctuation.separator.list.erlang' - } - { - 'include': '#everything-else' - } - ] - 'macro-directive': - 'patterns': [ - { - 'captures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.ifdef.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - '4': - 'name': 'entity.name.function.macro.erlang' - '5': - 'name': 'punctuation.definition.parameters.end.erlang' - '6': - 'name': 'punctuation.section.directive.end.erlang' - 'match': '^\\s*+(-)\\s*+(ifdef)\\s*+(\\()\\s*+([a-zA-z\\d@_]++)\\s*+(\\))\\s*+(\\.)' - 'name': 'meta.directive.ifdef.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.ifndef.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - '4': - 'name': 'entity.name.function.macro.erlang' - '5': - 'name': 'punctuation.definition.parameters.end.erlang' - '6': - 'name': 'punctuation.section.directive.end.erlang' - 'match': '^\\s*+(-)\\s*+(ifndef)\\s*+(\\()\\s*+([a-zA-z\\d@_]++)\\s*+(\\))\\s*+(\\.)' - 'name': 'meta.directive.ifndef.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.undef.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - '4': - 'name': 'entity.name.function.macro.erlang' - '5': - 'name': 'punctuation.definition.parameters.end.erlang' - '6': - 'name': 'punctuation.section.directive.end.erlang' - 'match': '^\\s*+(-)\\s*+(undef)\\s*+(\\()\\s*+([a-zA-z\\d@_]++)\\s*+(\\))\\s*+(\\.)' - 'name': 'meta.directive.undef.erlang' - } - ] - 'macro-usage': - 'captures': - '1': - 'name': 'keyword.operator.macro.erlang' - '2': - 'name': 'entity.name.function.macro.erlang' - 'match': '(\\?\\??)\\s*+([a-zA-Z\\d@_]++)' - 'name': 'meta.macro-usage.erlang' - 'module-directive': - 'captures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.module.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - '4': - 'name': 'entity.name.type.class.module.definition.erlang' - '5': - 'name': 'punctuation.definition.parameters.end.erlang' - '6': - 'name': 'punctuation.section.directive.end.erlang' - 'match': '^\\s*+(-)\\s*+(module)\\s*+(\\()\\s*+([a-z][a-zA-Z\\d@_]*+)\\s*+(\\))\\s*+(\\.)' - 'name': 'meta.directive.module.erlang' - 'number': - 'begin': '(?=\\d)' - 'end': '(?!\\d)' - 'patterns': [ - { - 'captures': - '1': - 'name': 'punctuation.separator.integer-float.erlang' - '2': - 'name': 'punctuation.separator.float-exponent.erlang' - 'match': '\\d++(\\.)\\d++([eE][\\+\\-]?\\d++)?' - 'name': 'constant.numeric.float.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '2(#)[0-1]++' - 'name': 'constant.numeric.integer.binary.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '3(#)[0-2]++' - 'name': 'constant.numeric.integer.base-3.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '4(#)[0-3]++' - 'name': 'constant.numeric.integer.base-4.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '5(#)[0-4]++' - 'name': 'constant.numeric.integer.base-5.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '6(#)[0-5]++' - 'name': 'constant.numeric.integer.base-6.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '7(#)[0-6]++' - 'name': 'constant.numeric.integer.base-7.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '8(#)[0-7]++' - 'name': 'constant.numeric.integer.octal.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '9(#)[0-8]++' - 'name': 'constant.numeric.integer.base-9.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '10(#)\\d++' - 'name': 'constant.numeric.integer.decimal.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '11(#)[\\daA]++' - 'name': 'constant.numeric.integer.base-11.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '12(#)[\\da-bA-B]++' - 'name': 'constant.numeric.integer.base-12.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '13(#)[\\da-cA-C]++' - 'name': 'constant.numeric.integer.base-13.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '14(#)[\\da-dA-D]++' - 'name': 'constant.numeric.integer.base-14.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '15(#)[\\da-eA-E]++' - 'name': 'constant.numeric.integer.base-15.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '16(#)\\h++' - 'name': 'constant.numeric.integer.hexadecimal.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '17(#)[\\da-gA-G]++' - 'name': 'constant.numeric.integer.base-17.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '18(#)[\\da-hA-H]++' - 'name': 'constant.numeric.integer.base-18.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '19(#)[\\da-iA-I]++' - 'name': 'constant.numeric.integer.base-19.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '20(#)[\\da-jA-J]++' - 'name': 'constant.numeric.integer.base-20.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '21(#)[\\da-kA-K]++' - 'name': 'constant.numeric.integer.base-21.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '22(#)[\\da-lA-L]++' - 'name': 'constant.numeric.integer.base-22.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '23(#)[\\da-mA-M]++' - 'name': 'constant.numeric.integer.base-23.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '24(#)[\\da-nA-N]++' - 'name': 'constant.numeric.integer.base-24.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '25(#)[\\da-oA-O]++' - 'name': 'constant.numeric.integer.base-25.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '26(#)[\\da-pA-P]++' - 'name': 'constant.numeric.integer.base-26.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '27(#)[\\da-qA-Q]++' - 'name': 'constant.numeric.integer.base-27.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '28(#)[\\da-rA-R]++' - 'name': 'constant.numeric.integer.base-28.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '29(#)[\\da-sA-S]++' - 'name': 'constant.numeric.integer.base-29.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '30(#)[\\da-tA-T]++' - 'name': 'constant.numeric.integer.base-30.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '31(#)[\\da-uA-U]++' - 'name': 'constant.numeric.integer.base-31.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '32(#)[\\da-vA-V]++' - 'name': 'constant.numeric.integer.base-32.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '33(#)[\\da-wA-W]++' - 'name': 'constant.numeric.integer.base-33.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '34(#)[\\da-xA-X]++' - 'name': 'constant.numeric.integer.base-34.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '35(#)[\\da-yA-Y]++' - 'name': 'constant.numeric.integer.base-35.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.separator.base-integer.erlang' - 'match': '36(#)[\\da-zA-Z]++' - 'name': 'constant.numeric.integer.base-36.erlang' - } - { - 'match': '\\d++#[\\da-zA-Z]++' - 'name': 'invalid.illegal.integer.erlang' - } - { - 'match': '\\d++' - 'name': 'constant.numeric.integer.decimal.erlang' - } - ] - 'parenthesized-expression': - 'begin': '(\\()' - 'beginCaptures': - '1': - 'name': 'punctuation.section.expression.begin.erlang' - 'end': '(\\))' - 'endCaptures': - '1': - 'name': 'punctuation.section.expression.end.erlang' - 'name': 'meta.expression.parenthesized' - 'patterns': [ - { - 'include': '#everything-else' - } - ] - 'record-directive': - 'begin': '^\\s*+(-)\\s*+(record)\\s*+(\\()\\s*+([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(,)' - 'beginCaptures': - '1': - 'name': 'punctuation.section.directive.begin.erlang' - '2': - 'name': 'keyword.control.directive.import.erlang' - '3': - 'name': 'punctuation.definition.parameters.begin.erlang' - '4': - 'name': 'entity.name.type.class.record.definition.erlang' - '5': - 'name': 'punctuation.separator.parameters.erlang' - 'end': '((\\}))\\s*+(\\))\\s*+(\\.)' - 'endCaptures': - '1': - 'name': 'meta.structure.record.erlang' - '2': - 'name': 'punctuation.definition.class.record.end.erlang' - '3': - 'name': 'punctuation.definition.parameters.end.erlang' - '4': - 'name': 'punctuation.section.directive.end.erlang' - 'name': 'meta.directive.record.erlang' - 'patterns': [ - { - 'include': '#internal-record-body' - } - ] - 'record-usage': - 'patterns': [ - { - 'captures': - '1': - 'name': 'keyword.operator.record.erlang' - '2': - 'name': 'entity.name.type.class.record.erlang' - '3': - 'name': 'punctuation.separator.record-field.erlang' - '4': - 'name': 'variable.other.field.erlang' - 'match': '(#)\\s*+([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')\\s*+(\\.)\\s*+([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')' - 'name': 'meta.record-usage.erlang' - } - { - 'begin': '(#)\\s*+([a-z][a-zA-Z\\d@_]*+|\'[^\']*+\')' - 'beginCaptures': - '1': - 'name': 'keyword.operator.record.erlang' - '2': - 'name': 'entity.name.type.class.record.erlang' - 'end': '((\\}))' - 'endCaptures': - '1': - 'name': 'meta.structure.record.erlang' - '2': - 'name': 'punctuation.definition.class.record.end.erlang' - 'name': 'meta.record-usage.erlang' - 'patterns': [ - { - 'include': '#internal-record-body' - } - ] - } - ] - 'string': - 'begin': '(")' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.string.begin.erlang' - 'end': '(")' - 'endCaptures': - '1': - 'name': 'punctuation.definition.string.end.erlang' - 'name': 'string.quoted.double.erlang' - 'patterns': [ - { - 'captures': - '1': - 'name': 'punctuation.definition.escape.erlang' - '3': - 'name': 'punctuation.definition.escape.erlang' - 'match': '(\\\\)([bdefnrstv\\\\\'"]|(\\^)[@-_]|[0-7]{1,3})' - 'name': 'constant.character.escape.erlang' - } - { - 'match': '\\\\\\^?.?' - 'name': 'invalid.illegal.string.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.definition.placeholder.erlang' - '3': - 'name': 'punctuation.separator.placeholder-parts.erlang' - '4': - 'name': 'punctuation.separator.placeholder-parts.erlang' - '6': - 'name': 'punctuation.separator.placeholder-parts.erlang' - '8': - 'name': 'punctuation.separator.placeholder-parts.erlang' - '10': - 'name': 'punctuation.separator.placeholder-parts.erlang' - '12': - 'name': 'punctuation.separator.placeholder-parts.erlang' - 'match': '(~)((\\-)?\\d++|(\\*))?((\\.)(\\d++|(\\*)))?((\\.)((\\*)|.))?[~cfegswpWPBX#bx\\+ni]' - 'name': 'constant.other.placeholder.erlang' - } - { - 'captures': - '1': - 'name': 'punctuation.definition.placeholder.erlang' - '2': - 'name': 'punctuation.separator.placeholder-parts.erlang' - 'match': '(~)(\\*)?(\\d++)?[~du\\-#fsacl]' - 'name': 'constant.other.placeholder.erlang' - } - { - 'match': '~.?' - 'name': 'invalid.illegal.string.erlang' - } - ] - 'symbolic-operator': - 'match': '\\+\\+|\\+|--|-|\\*|/=|/|=/=|=:=|==|=<|=|<-|<|>=|>|!|::' - 'name': 'keyword.operator.symbolic.erlang' - 'textual-operator': - 'match': '\\b(andalso|band|and|bxor|xor|bor|orelse|or|bnot|not|bsl|bsr|div|rem)\\b' - 'name': 'keyword.operator.textual.erlang' - 'tuple': - 'begin': '(\\{)' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.tuple.begin.erlang' - 'end': '(\\})' - 'endCaptures': - '1': - 'name': 'punctuation.definition.tuple.end.erlang' - 'name': 'meta.structure.tuple.erlang' - 'patterns': [ - { - 'match': ',' - 'name': 'punctuation.separator.tuple.erlang' - } - { - 'include': '#everything-else' - } - ] - 'variable': - 'captures': - '1': - 'name': 'variable.other.erlang' - '2': - 'name': 'variable.language.omitted.erlang' - 'match': '(_[a-zA-Z\\d@_]++|[A-Z][a-zA-Z\\d@_]*+)|(_)' -'scopeName': 'source.erlang' diff --git a/.atom/packages/language-erlang/grammars/html (erlang).cson b/.atom/packages/language-erlang/grammars/html (erlang).cson deleted file mode 100644 index 1cf502c..0000000 --- a/.atom/packages/language-erlang/grammars/html (erlang).cson +++ /dev/null @@ -1,53 +0,0 @@ -'fileTypes': [ - 'yaws' -] -'name': 'HTML (Erlang)' -'patterns': [ - { - 'begin': '(^\\s*)?(?=)' - 'beginCaptures': - '1': - 'name': 'punctuation.whitespace.embedded.leading.html' - 'contentName': 'meta.embedded.erlang' - 'end': '(?!\\G)(\\s*\\n)?' - 'endCaptures': - '1': - 'name': 'punctuation.whitespace.embedded.trailing.html' - 'patterns': [ - { - 'begin': '(<)(erl)(>)' - 'beginCaptures': - '0': - 'name': 'meta.tag.template.html' - '1': - 'name': 'punctuation.definition.tag.begin.html' - '2': - 'name': 'entity.name.tag.html' - '3': - 'name': 'punctuation.definition.tag.end.html' - 'contentName': 'source.erlang' - 'end': '(()' - 'endCaptures': - '0': - 'name': 'meta.tag.template.html' - '1': - 'name': 'punctuation.definition.tag.begin.html' - '2': - 'name': 'source.erlang' - '3': - 'name': 'entity.name.tag.html' - '4': - 'name': 'punctuation.definition.tag.end.html' - 'patterns': [ - { - 'include': 'source.erlang' - } - ] - } - ] - } - { - 'include': 'text.html.basic' - } -] -'scopeName': 'text.html.erlang.yaws' diff --git a/.atom/packages/language-erlang/package.json b/.atom/packages/language-erlang/package.json deleted file mode 100644 index fcd2060..0000000 --- a/.atom/packages/language-erlang/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "description": "Erlang language support for Atom.", - "engines": { - "atom": ">0.50.0" - }, - "license": "MIT", - "name": "language-erlang", - "repository": { - "type": "git", - "url": "https://github.com/jonathanmarvens/atom-language-erlang" - }, - "version": "2.0.0", - "readme": "# language-erlang package\n\nErlang language support for Atom.\n\n-----\n\nAdds syntax highlighting and snippets to Erlang files in Atom.\n\nCopyright (c) 2014 [Jonathan Barronville](mailto:jonathan@belairlabs.com \"jonathan@belairlabs.com\")\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/jonathanmarvens/atom-language-erlang/issues" - }, - "homepage": "https://github.com/jonathanmarvens/atom-language-erlang", - "_id": "language-erlang@2.0.0", - "dist": { - "shasum": "aebe014085be287bf333509480fd406934bc2477" - }, - "_resolved": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114628-1172-uyascq\\package.tgz", - "_from": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114628-1172-uyascq\\package.tgz" -} diff --git a/.atom/packages/language-erlang/scoped-properties/language-erlang.cson b/.atom/packages/language-erlang/scoped-properties/language-erlang.cson deleted file mode 100644 index 4fbb331..0000000 --- a/.atom/packages/language-erlang/scoped-properties/language-erlang.cson +++ /dev/null @@ -1,8 +0,0 @@ -'.source.erlang': - 'editor': - 'commentStart': '% ' - 'increaseIndentPattern': '^[^%]*(\\b(if|case|receive|after|fun|try|catch|begin|query)\\b(?!.*\\b(end)\\b.*))|(->(\\s*%.*)?$)' - 'decreaseIndentPattern': '^\\s*\\b(end)\\b' -'.text.html.erlang.yaws': - 'editor': - 'foldEndPattern': '(?x)\n\t\t(\n\t\t|^\\s*-->\n\t\t|(^|\\s)\\}\n\t\t)' diff --git a/.atom/packages/language-erlang/snippets/language-erlang.cson b/.atom/packages/language-erlang/snippets/language-erlang.cson deleted file mode 100644 index 0397b91..0000000 --- a/.atom/packages/language-erlang/snippets/language-erlang.cson +++ /dev/null @@ -1,49 +0,0 @@ -'.source.erlang': - 'Behaviour Directive': - 'prefix': 'beh' - 'body': '-behaviour (${1:behaviour}).' - 'Case Expression': - 'prefix': 'case' - 'body': 'case ${1:expression} of\n\t${2:pattern}${3: when ${4:guard}} ->\n\t\t${5:body}\nend' - 'Define Directive': - 'prefix': 'def' - 'body': '-define (${1:macro}${2: (${3:param})}, ${4:body}).' - 'Export All Directive': - 'prefix': 'expall' - 'body': '-compile(export_all).' - 'Export Directive': - 'prefix': 'exp' - 'body': '-export ([${1:function}/${2:arity}]).' - 'Fun Expression': - 'prefix': 'fun' - 'body': 'fun\n\t(${1:pattern})${2: when ${3:guard}} ->\n\t\t${4:body}\nend' - 'If Expression': - 'prefix': 'if' - 'body': 'if\n\t${1:guard} ->\n\t\t${2:body}\nend' - 'Ifdef Directive': - 'prefix': 'ifdef' - 'body': '-ifdef (${1:macro}).' - 'Ifndef Directive': - 'prefix': 'ifndef' - 'body': '-ifndef (${1:macro}).' - 'Import Directive': - 'prefix': 'imp' - 'body': '-import (${1:module}, [${2:function}/${3:arity}]).' - 'Include Directive': - 'prefix': 'inc' - 'body': '-include ("${1:file}").' - 'Module Directive': - 'prefix': 'mod' - 'body': '-module ($1).' - 'Receive Expression': - 'prefix': 'rcv' - 'body': 'receive\n${1:\t${2:pattern}${3: when ${4:guard}} ->\n\t\t${5:body}\n}${6:after\n\t${7:expression} ->\n\t\t${8:body}\n}end' - 'Record Directive': - 'prefix': 'rec' - 'body': '-record (${1:record}, {${2:field}${3: = ${4:value}}}).' - 'Try Expression': - 'prefix': 'try' - 'body': 'try${1: ${2:expression}${3: of\n\t${4:pattern}${5: when ${6:guard}} ->\n\t\t${7:body}}}\n${8:catch\n\t${9:pattern}${10: when ${11:guard}} ->\n\t\t${12:body}}\n${13:after\n\t${14:body}}\nend' - 'Undef Directive': - 'prefix': 'undef' - 'body': '-undef (${1:macro}).' diff --git a/.atom/packages/sort-lines/.npmignore b/.atom/packages/sort-lines/.npmignore deleted file mode 100644 index ade14b9..0000000 --- a/.atom/packages/sort-lines/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -npm-debug.log -node_modules diff --git a/.atom/packages/sort-lines/.travis.yml b/.atom/packages/sort-lines/.travis.yml deleted file mode 100644 index 31be69d..0000000 --- a/.atom/packages/sort-lines/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: objective-c - -notifications: - email: - on_success: never - on_failure: change - -script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh' diff --git a/.atom/packages/sort-lines/CONTRIBUTING.md b/.atom/packages/sort-lines/CONTRIBUTING.md deleted file mode 100644 index e70782f..0000000 --- a/.atom/packages/sort-lines/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -See the [Atom contributing guide](https://atom.io/docs/latest/contributing) diff --git a/.atom/packages/sort-lines/LICENSE.md b/.atom/packages/sort-lines/LICENSE.md deleted file mode 100644 index 4d231b4..0000000 --- a/.atom/packages/sort-lines/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 GitHub Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/sort-lines/README.md b/.atom/packages/sort-lines/README.md deleted file mode 100644 index 7e1cf16..0000000 --- a/.atom/packages/sort-lines/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Sort Lines Package [![Build Status](https://travis-ci.org/atom/sort-lines.svg?branch=master)](https://travis-ci.org/atom/sort-lines) - -Sorts your lines in Atom, never gets tired. - -![sort-lines-demo](https://f.cloud.github.com/assets/2988/1796891/85e69ff2-6a93-11e3-89ac-31927f604592.gif) diff --git a/.atom/packages/sort-lines/lib/range-finder.coffee b/.atom/packages/sort-lines/lib/range-finder.coffee deleted file mode 100644 index b4748be..0000000 --- a/.atom/packages/sort-lines/lib/range-finder.coffee +++ /dev/null @@ -1,40 +0,0 @@ -{Range} = require 'atom' - -module.exports = -class RangeFinder - # Public - @rangesFor: (editor) -> - new RangeFinder(editor).ranges() - - # Public - constructor: (@editor) -> - - # Public - ranges: -> - selectionRanges = @selectionRanges() - if selectionRanges.length is 0 - [@sortableRangeFrom(@sortableRangeForEntireBuffer())] - else - selectionRanges.map (selectionRange) => - @sortableRangeFrom(selectionRange) - - # Internal - selectionRanges: -> - @editor.getSelectedBufferRanges().filter (range) -> - not range.isEmpty() - - # Internal - sortableRangeForEntireBuffer: -> - @editor.getBuffer().getRange() - - # Internal - sortableRangeFrom: (selectionRange) -> - startRow = selectionRange.start.row - startCol = 0 - endRow = if selectionRange.end.column == 0 - selectionRange.end.row - 1 - else - selectionRange.end.row - endCol = @editor.lineLengthForBufferRow(endRow) - - new Range [startRow, startCol], [endRow, endCol] diff --git a/.atom/packages/sort-lines/lib/sort-lines.coffee b/.atom/packages/sort-lines/lib/sort-lines.coffee deleted file mode 100644 index d1d9301..0000000 --- a/.atom/packages/sort-lines/lib/sort-lines.coffee +++ /dev/null @@ -1,47 +0,0 @@ -RangeFinder = require './range-finder' - -module.exports = - activate: -> - atom.workspaceView.command 'sort-lines:sort', '.editor', -> - editor = atom.workspace.getActiveEditor() - sortLines(editor) - - atom.workspaceView.command 'sort-lines:reverse-sort', '.editor', -> - editor = atom.workspace.getActiveEditor() - sortLinesReversed(editor) - - atom.workspaceView.command 'sort-lines:unique', '.editor', -> - editor = atom.workspace.getActiveEditor() - uniqueLines(editor) - - atom.workspaceView.command 'sort-lines:case-insensitive-sort', '.editor', -> - editor = atom.workspaceView.getActivePaneItem() - sortLinesInsensitive(editor) - -sortLines = (editor) -> - sortableRanges = RangeFinder.rangesFor(editor) - sortableRanges.forEach (range) -> - textLines = editor.getTextInBufferRange(range).split("\n") - textLines.sort (a, b) -> a.localeCompare(b) - editor.setTextInBufferRange(range, textLines.join("\n")) - -sortLinesReversed = (editor) -> - sortableRanges = RangeFinder.rangesFor(editor) - sortableRanges.forEach (range) -> - textLines = editor.getTextInBufferRange(range).split("\n") - textLines.sort (a, b) -> b.localeCompare(a) - editor.setTextInBufferRange(range, textLines.join("\n")) - -uniqueLines = (editor) -> - sortableRanges = RangeFinder.rangesFor(editor) - sortableRanges.forEach (range) -> - textLines = editor.getTextInBufferRange(range).split("\n") - uniqued = textLines.filter (value, index, self) -> self.indexOf(value) == index - editor.setTextInBufferRange(range, uniqued.join("\n")) - -sortLinesInsensitive = (editor) -> - sortableRanges = RangeFinder.rangesFor(editor) - sortableRanges.forEach (range) -> - textLines = editor.getTextInBufferRange(range).split("\n") - textLines.sort (a, b) -> a.toLowerCase().localeCompare(b.toLowerCase()) - editor.setTextInBufferRange(range, textLines.join("\n")) diff --git a/.atom/packages/sort-lines/menus/sort-lines.cson b/.atom/packages/sort-lines/menus/sort-lines.cson deleted file mode 100644 index 0bca7b9..0000000 --- a/.atom/packages/sort-lines/menus/sort-lines.cson +++ /dev/null @@ -1,14 +0,0 @@ -'menu': [ - { - 'label': 'Edit' - 'submenu': [ - 'label': 'Lines' - 'submenu': [ - { 'label': 'Sort', 'command': 'sort-lines:sort' } - { 'label': 'Reverse Sort', 'command': 'sort-lines:reverse-sort' } - { 'label': 'Unique', 'command': 'sort-lines:unique' } - { 'label': 'Sort (Case Insentivive)', 'command': 'sort-lines:case-insensitive-sort' } - ] - ] - } -] diff --git a/.atom/packages/sort-lines/package.json b/.atom/packages/sort-lines/package.json deleted file mode 100644 index c290441..0000000 --- a/.atom/packages/sort-lines/package.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "sort-lines", - "main": "./lib/sort-lines", - "version": "0.6.0", - "description": "Sorts your lines. Never gets tired.", - "activationEvents": [ - "sort-lines:sort", - "sort-lines:reverse-sort", - "sort-lines:unique", - "sort-lines:case-insensitive-sort" - ], - "repository": { - "type": "git", - "url": "https://github.com/atom/sort-lines" - }, - "license": "MIT", - "engines": { - "atom": ">0.39.0" - }, - "dependencies": {}, - "readme": "# Sort Lines Package [![Build Status](https://travis-ci.org/atom/sort-lines.svg?branch=master)](https://travis-ci.org/atom/sort-lines)\n\nSorts your lines in Atom, never gets tired.\n\n![sort-lines-demo](https://f.cloud.github.com/assets/2988/1796891/85e69ff2-6a93-11e3-89ac-31927f604592.gif)\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/atom/sort-lines/issues" - }, - "homepage": "https://github.com/atom/sort-lines", - "_id": "sort-lines@0.6.0", - "dist": { - "shasum": "6ac7b38f8720c27c0eb20e532555f618d1017256" - }, - "_resolved": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114614-3900-113bedv\\package.tgz", - "_from": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114614-3900-113bedv\\package.tgz" -} diff --git a/.atom/packages/sort-lines/spec/sort-lines-spec.coffee b/.atom/packages/sort-lines/spec/sort-lines-spec.coffee deleted file mode 100644 index b962306..0000000 --- a/.atom/packages/sort-lines/spec/sort-lines-spec.coffee +++ /dev/null @@ -1,201 +0,0 @@ -{WorkspaceView} = require 'atom' - -describe "sorting lines", -> - [activationPromise, editor, editorView] = [] - - sortLines = (callback) -> - editorView.trigger "sort-lines:sort" - waitsForPromise -> activationPromise - runs(callback) - - sortLinesReversed = (callback) -> - editorView.trigger "sort-lines:reverse-sort" - waitsForPromise -> activationPromise - runs(callback) - - uniqueLines = (callback) -> - editorView.trigger "sort-lines:unique" - waitsForPromise -> activationPromise - runs(callback) - - sortLineCaseInsensitive = (callback) -> - editorView.trigger "sort-lines:case-insensitive-sort" - waitsForPromise -> activationPromise - runs(callback) - - beforeEach -> - atom.workspaceView = new WorkspaceView - atom.workspaceView.openSync() - - editorView = atom.workspaceView.getActiveView() - editor = editorView.getEditor() - - activationPromise = atom.packages.activatePackage('sort-lines') - - describe "when no lines are selected", -> - it "sorts all lines", -> - editor.setText """ - Hydrogen - Helium - Lithium - """ - editor.setCursorBufferPosition([0, 0]) - - sortLines -> - expect(editor.getText()).toBe """ - Helium - Hydrogen - Lithium - """ - - it "sorts all lines, ignoring the trailing new line", -> - editor.setText """ - Hydrogen - Helium - Lithium - - """ - editor.setCursorBufferPosition([0, 0]) - - sortLines -> - expect(editor.getText()).toBe """ - Helium - Hydrogen - Lithium - - """ - - describe "when entire lines are selected", -> - it "sorts the selected lines", -> - editor.setText """ - Hydrogen - Helium - Lithium - Beryllium - Boron - """ - editor.setSelectedBufferRange([[1,0], [4,0]]) - - sortLines -> - expect(editor.getText()).toBe """ - Hydrogen - Beryllium - Helium - Lithium - Boron - """ - - describe "when partial lines are selected", -> - it "sorts the selected lines", -> - editor.setText """ - Hydrogen - Helium - Lithium - Beryllium - Boron - """ - editor.setSelectedBufferRange([[1,3], [3,2]]) - - sortLines -> - expect(editor.getText()).toBe """ - Hydrogen - Beryllium - Helium - Lithium - Boron - """ - - describe "when there are multiple selection ranges", -> - it "sorts the lines in each selection range", -> - editor.setText """ - Hydrogen - Helium # selection 1 - Beryllium # selection 1 - Carbon - Fluorine # selection 2 - Aluminum # selection 2 - Gallium - Europium - """ - editor.addSelectionForBufferRange([[1, 0], [3, 0]]) - editor.addSelectionForBufferRange([[4, 0], [6, 0]]) - - sortLines -> - expect(editor.getText()).toBe """ - Hydrogen - Beryllium # selection 1 - Helium # selection 1 - Carbon - Aluminum # selection 2 - Fluorine # selection 2 - Gallium - Europium - """ - - describe "reversed sorting", -> - it "sorts all lines in reverse order", -> - editor.setText """ - Hydrogen - Helium - Lithium - """ - - editor.setCursorBufferPosition([0, 0]) - - sortLinesReversed -> - expect(editor.getText()).toBe """ - Lithium - Hydrogen - Helium - """ - - describe "uniqueing", -> - it "uniques all lines but does not change order", -> - editor.setText """ - Hydrogen - Hydrogen - Helium - Lithium - Hydrogen - Hydrogen - Helium - Lithium - Hydrogen - Hydrogen - Helium - Lithium - Hydrogen - Hydrogen - Helium - Lithium - """ - - editor.setCursorBufferPosition([0, 0]) - - uniqueLines -> - expect(editor.getText()).toBe """ - Hydrogen - Helium - Lithium - """ - - describe "case-insensitive sorting", -> - it "sorts all lines, ignoring case", -> - editor.setText """ - Hydrogen - lithium - helium - Helium - Lithium - """ - - editor.setCursorBufferPosition([0, 0]) - - sortLineCaseInsensitive -> - expect(editor.getText()).toBe """ - helium - Helium - Hydrogen - lithium - Lithium - """ diff --git a/.atom/packages/spacegray-mocha-ui/CONTRIBUTING.md b/.atom/packages/spacegray-mocha-ui/CONTRIBUTING.md deleted file mode 100644 index e70782f..0000000 --- a/.atom/packages/spacegray-mocha-ui/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -See the [Atom contributing guide](https://atom.io/docs/latest/contributing) diff --git a/.atom/packages/spacegray-mocha-ui/LICENSE.md b/.atom/packages/spacegray-mocha-ui/LICENSE.md deleted file mode 100644 index 4d231b4..0000000 --- a/.atom/packages/spacegray-mocha-ui/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 GitHub Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/spacegray-mocha-ui/README.md b/.atom/packages/spacegray-mocha-ui/README.md deleted file mode 100644 index 67a1b65..0000000 --- a/.atom/packages/spacegray-mocha-ui/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Spacegray Mocha UI theme - -Port of the [Spacegray](http://kkga.github.io/spacegray) Sublime Text theme to Atom. -UI Theme to match base16 Mocha Syntax (http://chriskempson.github.io/base16/#mocha). - -If these colors aren't to your liking, [check out my other packages!](https://atom.io/users/emilyemorehouse) -Or make a request. - - -Credit to [cannikin's original port](https://github.com/cannikin/spacegray-dark-ui). - -![screenshot](https://s3-us-west-2.amazonaws.com/emilyemorehouse/spacegraymocha) diff --git a/.atom/packages/spacegray-mocha-ui/index.less b/.atom/packages/spacegray-mocha-ui/index.less deleted file mode 100644 index bb6a1c0..0000000 --- a/.atom/packages/spacegray-mocha-ui/index.less +++ /dev/null @@ -1,20 +0,0 @@ -@import "stylesheets/atom"; -@import "stylesheets/buttons"; -@import "stylesheets/editor"; -@import "stylesheets/find-and-replace"; -@import "stylesheets/git"; -@import "stylesheets/lists"; -@import "stylesheets/messages"; -@import "stylesheets/nav"; -@import "stylesheets/overlays"; -@import "stylesheets/panels"; -@import "stylesheets/panes"; -@import "stylesheets/progress"; -@import "stylesheets/sites"; -@import "stylesheets/tabs"; -@import "stylesheets/text"; -@import "stylesheets/tips"; -@import "stylesheets/tooltips"; -@import "stylesheets/tree-view"; -@import "stylesheets/utilities"; -@import "stylesheets/zen"; diff --git a/.atom/packages/spacegray-mocha-ui/package.json b/.atom/packages/spacegray-mocha-ui/package.json deleted file mode 100644 index b3a3839..0000000 --- a/.atom/packages/spacegray-mocha-ui/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "spacegray-mocha-ui", - "theme": "ui", - "version": "0.1.0", - "description": "Port of the Spacegray Sublime Text theme to Atom. UI Theme to match base16 Mocha Syntax (http://chriskempson.github.io/base16/#mocha)", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/emilyemorehouse/spacegray-mocha-ui" - }, - "engines": { - "atom": ">0.50.0" - }, - "readme": "# Spacegray Mocha UI theme\n\nPort of the [Spacegray](http://kkga.github.io/spacegray) Sublime Text theme to Atom.\nUI Theme to match base16 Mocha Syntax (http://chriskempson.github.io/base16/#mocha). \n\nIf these colors aren't to your liking, [check out my other packages!](https://atom.io/users/emilyemorehouse)\nOr make a request.\n\n\nCredit to [cannikin's original port](https://github.com/cannikin/spacegray-dark-ui).\n\n![screenshot](https://s3-us-west-2.amazonaws.com/emilyemorehouse/spacegraymocha)\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/emilyemorehouse/spacegray-mocha-ui/issues" - }, - "homepage": "https://github.com/emilyemorehouse/spacegray-mocha-ui", - "_id": "spacegray-mocha-ui@0.1.0", - "dist": { - "shasum": "34c7b7fc289b0bbd4f993df6ceba4085ae5cc0e4" - }, - "_resolved": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114628-4572-1nzcviy\\package.tgz", - "_from": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114628-4572-1nzcviy\\package.tgz" -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/atom.less b/.atom/packages/spacegray-mocha-ui/stylesheets/atom.less deleted file mode 100644 index ea81f55..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/atom.less +++ /dev/null @@ -1,9 +0,0 @@ -@import "ui-variables"; - -* { - box-sizing: border-box; -} - -.workspace { - background-color: @app-background-color; -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/buttons.less b/.atom/packages/spacegray-mocha-ui/stylesheets/buttons.less deleted file mode 100644 index 8058d55..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/buttons.less +++ /dev/null @@ -1,55 +0,0 @@ -@import "ui-variables"; -@import "ui-mixins"; - -.btn-background (@color, @hover-color, @selected-color, @text-color) { - color: @text-color-subtle; - background-color: transparent; - transition: color 0.2s; - - &:hover, &:focus { - color: @text-color-subtle; - } - &.selected, - &.selected:hover { - color: @text-color-highlight; - &:hover { - - } - } -} - -.btn-variant (@color) { - @bg: darken(@color, 10%); - @hover: @color; - @selected: @color; - .btn-background(@bg, @hover, @selected, @text-color-highlight); -} - -.btn { - .btn-background(@button-background-color, @button-background-color-hover, @button-background-color-selected, @text-color); - &:active { - box-shadow: none; - -webkit-box-shadow: none; - } -} - -.btn.btn-primary { - .btn-variant(@background-color-info); -} -.btn.btn-info { - .btn-variant(@background-color-info); -} -.btn.btn-success { - .btn-variant(@background-color-success); -} -.btn.btn-warning { - .btn-variant(@background-color-warning); -} -.btn.btn-error { - .btn-variant(@background-color-error); -} - -.caret { - border-top: 5px solid #fff; - margin-top: -1px; -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/dropdowns.less b/.atom/packages/spacegray-mocha-ui/stylesheets/dropdowns.less deleted file mode 100644 index 410823a..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/dropdowns.less +++ /dev/null @@ -1,18 +0,0 @@ -@import "ui-variables"; -@import "ui-mixins"; -@import "octicon-mixins"; - -.dropdown-menu { - background-color: @overlay-background-color; - border-radius: @component-border-radius; - padding: 0; - - > li > a { - .text(normal); - } - - > li > a:hover { - .text(highlight); - background-color: @background-color-highlight; - } -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/editor.less b/.atom/packages/spacegray-mocha-ui/stylesheets/editor.less deleted file mode 100644 index f7140a8..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/editor.less +++ /dev/null @@ -1,35 +0,0 @@ -@import "ui-variables"; -@import "ui-mixins"; - -@-webkit-keyframes highlight { - from { background-color: rgba(100, 255, 100, 0.7); } - to { background-color: null; } -} - -.editor { - font-family: @font-family-code; - - &.mini { - color: @text-color-highlight; - background-color: @input-background-color; - border-radius: @component-border-radius; - padding-left: @component-padding/2; - .placeholder-text { - color: @text-color-subtle; - } - .cursor { border-color: #fff; } - .selection .region { background-color: lighten(@input-background-color, 10%); } - } - - &.editor-colors.mini.is-focused { - .selection .region { background-color: lighten(@app-background-color, 5%); } - transition: background-color 0.1s - } - - .highlighted.selection .region { - -webkit-animation-name: highlight; - -webkit-animation-duration: 1s; - -webkit-animation-iteration-count: 1; - } - -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/find-and-replace.less b/.atom/packages/spacegray-mocha-ui/stylesheets/find-and-replace.less deleted file mode 100644 index 5b1762f..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/find-and-replace.less +++ /dev/null @@ -1,15 +0,0 @@ -.btn-group-find, .btn-group-replace, .btn-group-replace-all { - .btn { - color: @0C; - &:hover { - color: @07; - } - } -} - -.project-find .highlight-info { - color: @0A; - background-color: @-00; - border-radius: 2px; - padding: 3px 1px; -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/git.less b/.atom/packages/spacegray-mocha-ui/stylesheets/git.less deleted file mode 100644 index cfdc73c..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/git.less +++ /dev/null @@ -1,9 +0,0 @@ -@import "ui-mixins"; -@import "ui-variables"; - -.status { .text(normal); } -.status-added { .text(info); } -.status-ignored { .text(subtle); } -.status-modified { .text(warning); } -.status-removed { .text(error); } -.status-renamed { .text(success); } diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/lists.less b/.atom/packages/spacegray-mocha-ui/stylesheets/lists.less deleted file mode 100644 index 9e19152..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/lists.less +++ /dev/null @@ -1,123 +0,0 @@ -@import "ui-variables"; -@import "ui-mixins"; -@import "octicon-mixins"; - -.list-group, .list-tree { - li:not(.list-nested-item), - li.list-nested-item > .list-item { - .text(normal); - } - - .generate-list-item-text-color(@class) { - li:not(.list-nested-item).text-@{class}, - li.list-nested-item.text-@{class} > .list-item { - .text(@class); - } - } - .generate-list-item-text-color(subtle); - .generate-list-item-text-color(info); - .generate-list-item-text-color(success); - .generate-list-item-text-color(warning); - .generate-list-item-text-color(error); - .generate-list-item-text-color(selected); - - .generate-list-item-status-color(@color, @status) { - li:not(.list-nested-item).status-@{status}, - li.list-nested-item.status-@{status} > .list-item { - color: @color; - } - } - - .generate-list-item-status-color(@text-color-subtle, ignored); - .generate-list-item-status-color(@text-color-added, added); - .generate-list-item-status-color(@text-color-renamed, renamed); - .generate-list-item-status-color(@text-color-modified, modified); - .generate-list-item-status-color(@text-color-removed, removed); - - li:not(.list-nested-item).selected, - li.list-nested-item.selected > .list-item { - .text(selected); - } -} - -.select-list ol.list-group, -&.select-list ol.list-group { - li.two-lines { - .secondary-line { color: @text-color-subtle; } - &.selected .secondary-line { - color: @text-color-subtle; - text-shadow: none; - } - } - - // We want to highlight the background of the list items because we dont - // know their size. - li.selected { - background-color: @background-color-selected; - &:before{ display: none; } - } - - &.mark-active{ - @active-icon-size: 14px; - - // pad in front of the text where the icon would be We'll pad the non- - // active items with a 'fake' icon so other classes can pad the item - // without worrying about the icon padding. - li:before { - content: ''; - background-color: transparent; - position: static; - display: inline-block; - left: auto; right: auto; - height: @active-icon-size; - width: @active-icon-size; - } - > li:not(.active):before { - margin-right: @component-icon-padding; - } - li.active { - .octicon(check, @active-icon-size); - &:before { - margin-right: @component-icon-padding; - color: @text-color-success; - } - } - } -} - -.select-list.popover-list { - background-color: @overlay-background-color; - padding: @component-padding/2; - border-radius: @component-border-radius; - border: 1px solid @overlay-border-color; - - .editor { - margin-bottom: @component-padding/2; - } - - .list-group li { - padding-left: @component-padding/2; - } -} - -.ui-sortable { - li { - line-height: 2.5; - } - - // For sortable lists in the settings view - li.ui-sortable-placeholder { - visibility: visible !important; - background-color: darken(@pane-item-background-color, 10%); - } -} - -li.ui-draggable-dragging, li.ui-sortable-helper { - line-height: @component-line-height; - height: @component-line-height; - border: 0; - border-radius: 0; - list-style: none; - padding: 0 @component-padding; - background: @background-color-highlight;; -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/messages.less b/.atom/packages/spacegray-mocha-ui/stylesheets/messages.less deleted file mode 100644 index 914737d..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/messages.less +++ /dev/null @@ -1,6 +0,0 @@ -@import "ui-variables"; - -ul.background-message { - font-weight: bold; - color: rgba(0, 0, 0, .2); -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/nav.less b/.atom/packages/spacegray-mocha-ui/stylesheets/nav.less deleted file mode 100644 index 2e50042..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/nav.less +++ /dev/null @@ -1,27 +0,0 @@ -@import "ui-variables"; - -.nav-tabs { - border-bottom: 1px solid @base-border-color; - li { - a, - &.active a { - border: none; - margin-right: 0px; - margin-bottom: 1px; - } - - a:hover, - &.active a, - &.active a:hover { - background-color: @background-color-highlight; - border: none; - color: @text-color-selected; - border-bottom-left-radius: 0px; - border-bottom-right-radius: 0px; - } - - &.active a { - background-color: @tab-background-color-active; - } - } -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/overlays.less b/.atom/packages/spacegray-mocha-ui/stylesheets/overlays.less deleted file mode 100644 index 50fc1c6..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/overlays.less +++ /dev/null @@ -1,38 +0,0 @@ -@import "ui-variables"; - -.overlay { - color: @text-color-subtle; - background-color: @overlay-background-color; - padding: @component-padding; - border-radius: @component-border-radius; - - .editor.mini { - margin-bottom: @component-padding; - } - - .select-list ol.list-group, - &.select-list ol.list-group { - - background-color: lighten(@overlay-background-color, 3%); - - li { - padding: @component-padding; - - &.two-lines { padding: @component-padding/2 @component-padding; } - - .status.icon { - float: right; - margin-left: @component-icon-padding; - &:before { - margin-right: 0; - } - } - - &.selected { - .status.icon { - color: @text-color-selected; - } - } - } - } -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/panels.less b/.atom/packages/spacegray-mocha-ui/stylesheets/panels.less deleted file mode 100644 index b202b10..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/panels.less +++ /dev/null @@ -1,44 +0,0 @@ -@import "ui-mixins"; -@import "ui-variables"; -@import "buttons"; - -.panel { - &.bordered { - border-radius: @component-border-radius; - } -} - -.tool-panel { - .text(normal); - position: relative; - - background-color: @tool-panel-background-color; -} - -.inset-panel { - position: relative; - background-color: @inset-panel-background-color; -} - -.is-blurred { - .tool-panel, - .inset-panel { - } -} - -.panel-heading { - .text(normal); - - background-color: transparent; - - .btn { - padding-left: 8px; - padding-right: 8px; - - @bg: lighten(@button-background-color, 10%); - @hover: lighten(@button-background-color-hover, 10%); - @selected: lighten(@button-background-color-selected, 10%); - @text: lighten(@text-color, 10%); - .btn-background(@bg, @hover, @selected, @text); - } -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/panes.less b/.atom/packages/spacegray-mocha-ui/stylesheets/panes.less deleted file mode 100644 index a9be0b8..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/panes.less +++ /dev/null @@ -1,63 +0,0 @@ -@import "ui-mixins"; -@import "ui-variables"; -@import "buttons"; - -.pane-item { - .panel { - border-color: fadeout(@inset-panel-border-color, 30%); - } -} - -.panes { - .pane { - background-color: @editor-background-color; - - .item-views .pane-item { - background-color: @editor-background-color; - font-family: @font-family-code; - font-size: @font-size; - } - - &:focus { - background-color: @app-background-color; - } - } - - .pane-row > * { - border-right: 1px solid @pane-item-border-color; - &:last-child { border-right: none; } - } - - .pane-column > * { - border-bottom: 1px solid @pane-item-border-color; - &:last-child { border-bottom: none; } - } -} - -.preview-pane { - .list-tree li.list-nested-item > .list-item { - color: @05; - } - - .list-tree li:not(.list-nested-item) { - color: @05; - } - - .highlight-info { - color: @05; - background-color: @00; - border: 1px solid @0A; - border-radius: 3px; - padding: 2px 1px; - } - .preview-count { - .highlight-info { - color: @0A; - background-color: @00; - border: none; - } - } - .results-view .line-number { - color: @09; - } -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/progress.less b/.atom/packages/spacegray-mocha-ui/stylesheets/progress.less deleted file mode 100644 index 38a60d1..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/progress.less +++ /dev/null @@ -1,76 +0,0 @@ -@import "ui-variables"; -@import "ui-mixins"; - -.loading-spinner(@size) { - width: @size; - height: @size; - display: block; - - background-image: url(images/octocat-spinner-128.gif); - background-repeat: no-repeat; - background-size: cover; - - &.inline-block { - display: inline-block; - } -} - -.loading-spinner-large { - .loading-spinner(64px); -} - -.loading-spinner-medium { - .loading-spinner(50px); -} - -.loading-spinner-small { - .loading-spinner(32px); -} - -.loading-spinner-tiny { - .loading-spinner(20px); -} - -// Much learning from: -// http://css-tricks.com/html5-progress-element/ - -@progress-height: 16px; -@progress-shine-gradient: -webkit-linear-gradient(top, rgba(255, 255, 255, .15), rgba(0, 0, 0, .15)); - -progress { - height: @progress-height; - -webkit-appearance: none; -} - -progress::-webkit-progress-bar { - height: @progress-height; - border-radius: @component-border-radius; - - background-color: #666; - - background-image: - -webkit-linear-gradient(-30deg, - transparent 33%, rgba(0, 0, 0, .1) 33%, - rgba(0,0, 0, .1) 66%, transparent 66%), - @progress-shine-gradient; - - border-radius: 2px; - background-size: 25px @progress-height, 100% 100%, 100% 100%; - -webkit-animation: animate-stripes 5s linear infinite; - animation: animate-stripes 5s linear infinite; -} - -progress::-webkit-progress-value { - border-radius: @component-border-radius; - background-image: @progress-shine-gradient; - background-color: @background-color-success; -} - -progress[value]::-webkit-progress-bar { - background-image: @progress-shine-gradient; - animation: none; -} - -@-webkit-keyframes animate-stripes { - 100% { background-position: 100px 0px; } -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/sites.less b/.atom/packages/spacegray-mocha-ui/stylesheets/sites.less deleted file mode 100644 index 5203347..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/sites.less +++ /dev/null @@ -1,14 +0,0 @@ -@import "ui-mixins"; -@import "ui-variables"; - -.ui-site(@num, @color) { - .ui-site-@{num} { - background-color: @color; - } -} - -.ui-site(1, @0B); -.ui-site(2, @0D); -.ui-site(3, @09); -.ui-site(4, @0E); -.ui-site(5, @0A); diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/tabs.less b/.atom/packages/spacegray-mocha-ui/stylesheets/tabs.less deleted file mode 100644 index a00a6ff..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/tabs.less +++ /dev/null @@ -1,109 +0,0 @@ -@import "ui-variables"; -@tab-radius: 3px; -@modified-icon-width: 8px; -@tab-skew: 30deg; -@tab-top-padding: 0; -@tab-bottom-border-height: 8px; -@tab-border: 1px solid @tab-border-color; -@tab-bar-bottom-border-color: #111; - -.tab-bar { - height: @tab-height + @tab-top-padding; - background: @tool-panel-background-color; - padding: 0 13px 0 10px; - box-sizing: border-box; - - &:after { - content: ""; - position: absolute; - bottom: 0; - height: @tab-bottom-border-height; - left: 0px; - width: 100%; - } - - .tab { - position: relative; - top: @tab-top-padding; - height: @tab-height; - line-height: @tab-height; - color: @text-color-subtle; - padding-left: 0; - margin-left: 15px; - transition: color .1s ease-in; - - &:before { - content: ''; - position: absolute; - top: 0; - left: -18px; - height: @tab-height; - width: 40px; - } - - .close-icon { - display: none; - transition: color 0.1s; - &:hover { - color: @text-color-error !important; - - } - } - - &.modified:not(:hover) .close-icon { - display: block; - top: @tab-height/2 - @modified-icon-width/2 + 1px; - right: 14px; - width: @modified-icon-width; - height: @modified-icon-width; - border-color: @text-color-info; - } - - &:first-child { - margin-left: 20px; - } - - &:hover { - .close-icon { - display: block; - } - } - } - - .tab.active { - z-index: 10; - line-height: @tab-height - 3px; - color: @text-color-highlight; - - .title{ - position: relative; - top: 1px; - } - - .close-icon { - line-height: @tab-height - 1px; - display: block; - } - - &, &:before { - background-color: @editor-background-color; - height: @tab-height; - } - - } - - .tab:hover { - color: @text-color-highlight; - } - - .tab.active:hover .close-icon { - color: @text-color-highlight; - } - - .placeholder { - height: @tab-height + @tab-top-padding + @tab-bottom-border-height; - &:after { - top: @tab-height + @tab-top-padding + @tab-bottom-border-height; - } - } -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/text.less b/.atom/packages/spacegray-mocha-ui/stylesheets/text.less deleted file mode 100644 index 895caf1..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/text.less +++ /dev/null @@ -1,81 +0,0 @@ -@import "ui-mixins"; -@import "ui-variables"; - -h1, -h2, -h3 { - line-height: 1em; - margin-bottom: 15px -} -h1 { font-size: 2em; } -h2 { font-size: 1.5em; } -h3 { font-size: 1.2em; } - -p { - line-height: 1.6; - margin-bottom: 15px; -} - -label { - font-weight: normal; -} - -pre { - box-shadow: none; - color: @text-color; - background: @inset-panel-background-color; - border-radius: @component-border-radius; - border: none; - margin: 0; -} - -code { - .text(highlight); - background: @background-color-highlight; - border-radius: @component-border-radius; -} - -.selected { .text(highlight); } - -.text-smaller { font-size: 0.9em; } - -.text-subtle { .text(subtle); } -.text-highlight { .text(highlight); } - -.text-error { .text(error); } -.text-info { - .text(info); - &:hover { color: @text-color-info; } -} -.text-warning { - .text(warning); - &:hover { color: @text-color-warning; } -} -.text-success { - .text(success); - &:hover { color: @text-color-success; } -} - -.highlight { - color: @text-color-highlight; - font-weight: bold; - text-shadow: none; - background-color: @background-color-highlight; - border-radius: @component-border-radius; - padding: 1px 3px; -} - -.highlight-color(@name, @color, @text-color) { - .highlight-@{name} { - color: lighten(saturate(@text-color, 0%), 30%); - font-weight: bold; - text-shadow: none; - background-color: fadeout(@color, 60%); - border-radius: @component-border-radius; - padding: 1px 3px; - } -} -.highlight-color(info, @background-color-info, @text-color-info); -.highlight-color(warning, @background-color-warning, @text-color-warning); -.highlight-color(error, @background-color-error, @text-color-error); -.highlight-color(success, @background-color-success, @text-color-success); diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/tips.less b/.atom/packages/spacegray-mocha-ui/stylesheets/tips.less deleted file mode 100644 index 0a1337c..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/tips.less +++ /dev/null @@ -1,3 +0,0 @@ -ul.background-message { - color: @text-color; -} \ No newline at end of file diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/tooltips.less b/.atom/packages/spacegray-mocha-ui/stylesheets/tooltips.less deleted file mode 100644 index 6cf9241..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/tooltips.less +++ /dev/null @@ -1,50 +0,0 @@ -@import "ui-variables"; - -.tooltip { - @tip-background-color: darken(@tool-panel-background-color, 10%); - @tip-text-color: @text-color; - white-space: nowrap; - - .keystroke { - font-family: Helvetica, Arial, sans-serif; - font-size: 12px; - color: lighten(@tip-text-color, 10%); - padding-left: 2px; - } - - &.in { opacity: 1; } - - .tooltip-inner { - line-height: 19px; - border-radius: @component-border-radius; - background-color: @tip-background-color; - color: @tip-text-color; - white-space: nowrap; - max-width: none; - } - - &.top .tooltip-arrow { - border-top-color: @tip-background-color; - } - &.top-left .tooltip-arrow { - border-top-color: @tip-background-color; - } - &.top-right .tooltip-arrow { - border-top-color: @tip-background-color; - } - &.right .tooltip-arrow { - border-right-color: @tip-background-color; - } - &.left .tooltip-arrow { - border-left-color: @tip-background-color; - } - &.bottom .tooltip-arrow { - border-bottom-color: @tip-background-color; - } - &.bottom-left .tooltip-arrow { - border-bottom-color: @tip-background-color; - } - &.bottom-right .tooltip-arrow { - border-bottom-color: @tip-background-color; - } -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/tree-view.less b/.atom/packages/spacegray-mocha-ui/stylesheets/tree-view.less deleted file mode 100644 index b026068..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/tree-view.less +++ /dev/null @@ -1,24 +0,0 @@ -@import "ui-variables"; - -.tree-view { - font-size: @font-size; - font-family: @font-family; - background-color: @tree-background-color; - - >.directory.entry.selected:before { - height: @tab-height; - } -} - -.focusable-panel { - opacity: 1; - - &:focus { - .selected > .name, - .selected > .name:before, - .selected > .list-item > .name, - .selected > .list-item > .name:before { - color: #fff !important; - } - } -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/ui-mixins.less b/.atom/packages/spacegray-mocha-ui/stylesheets/ui-mixins.less deleted file mode 100644 index 9895c6b..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/ui-mixins.less +++ /dev/null @@ -1,39 +0,0 @@ -@import "ui-variables"; - -// Pattern matching; ish is cray. -// http://lesscss.org/#-pattern-matching-and-guard-expressions -.text(normal) { - font-weight: normal; - color: @text-color; - text-shadow: none; -} -.text(subtle) { - font-weight: normal; - color: @text-color-subtle; - text-shadow: none; -} -.text(highlight) { - font-weight: normal; - color: @text-color-highlight; - text-shadow: 0 1px 0 rgba(0,0,0, .5); -} -.text(selected) { - .text(highlight) -} - -.text(info) { - color: @text-color-info; - text-shadow: none; -} -.text(success) { - color: @text-color-success; - text-shadow: none; -} -.text(warning) { - color: @text-color-warning; - text-shadow: none; -} -.text(error) { - color: @text-color-error; - text-shadow: none; -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/ui-variables.less b/.atom/packages/spacegray-mocha-ui/stylesheets/ui-variables.less deleted file mode 100644 index 7c87911..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/ui-variables.less +++ /dev/null @@ -1,114 +0,0 @@ -// Colors - -// Base16 - Mocha scheme -// http://chriskempson.github.io/base16/#mocha -@00: #3b3228; -@01: #534636; -@02: #645240; -@03: #7e705a; -@04: #b8afad; -@05: #d0c8c6; -@06: #e9e1dd; -@07: #f5eeeb; - -@08: #cb6077; // pink -@09: #d28b71; // orange -@0A: #f4bc87; // yellow -@0B: #beb55b; // green -@0C: #7bbda4; // teal -@0D: #8ab3b5; // blue -@0E: #a89bb9; // purple -@0F: #bb9584; // brown - -// darker browns -@-00: #1d1813; -@-01: #2c251e; - -@text-color: @03; -@text-color-subtle: @03; -@text-color-highlight: @06; -@text-color-selected: @05; - -@text-color-info: @0D; -@text-color-success: @0B; -@text-color-warning: @09; -@text-color-error: @08; - -@text-color-ignored: @text-color-subtle; -@text-color-added: @text-color-success; -@text-color-renamed: @text-color-info; -@text-color-modified: @text-color-warning; -@text-color-removed: @text-color-error; - -@app-background-color: @-00; - -@background-color-info: @0D; -@background-color-success: @0B; -@background-color-warning: @09; -@background-color-error: @08; -@background-color-highlight: rgba(255, 255, 255, 0.07); -@background-color-selected: @-00; - -@tree-background-color: @-01; -@editor-background-color: @00; - -@base-background-color: @-01; -@base-border-color: rgba(0, 0, 0, 0.5); - -@pane-item-background-color: @-01; -@pane-item-border-color: rgba(0, 0, 0, 0.5); - -@input-background-color: @-00; -@input-border-color: @base-border-color; - -@tool-panel-background-color: @-00; -@tool-panel-border-color: transparent; - -@inset-panel-background-color: @-00; -@inset-panel-border-color: @base-border-color; - -@panel-heading-background-color: @02; -@panel-heading-border-color: fadein(@base-border-color, 10%); - -@overlay-background-color: @-00; -@overlay-border-color: @background-color-highlight; - -@button-background-color: @-00; -@button-background-color-hover: @-00; -@button-background-color-selected: @-00; -@button-border-color: transparent; - -@tab-bar-background-color: @-00; -@tab-bar-border-color: transparent; -@tab-background-color: @-00; -@tab-background-color-active: @00; -@tab-border-color: transparent; - -@tree-view-background-color: @-00; -@tree-view-border-color: transparent; - -@ui-site-color-1: @0B; // green -@ui-site-color-2: @0D; // blue -@ui-site-color-3: @09; // orange -@ui-site-color-4: @0E; // purple -@ui-site-color-5: @0A; // yellow - -// Sizes - -@font-size: 11px; - -@disclosure-arrow-size: 10.5px; - -@component-padding: 10px; -@component-icon-padding: 5px; -@component-icon-size: 16px; -@component-line-height: 25px; -@component-border-radius: 2px; - -@tab-height: 30px; - - -// Other - -@font-family-code: 'Source Code Pro', 'Lucida Grande', 'Segoe UI', sans-serif; -@font-family: 'Lucida Grande', 'Segoe UI', sans-serif; diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/utilities.less b/.atom/packages/spacegray-mocha-ui/stylesheets/utilities.less deleted file mode 100644 index 14cb134..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/utilities.less +++ /dev/null @@ -1,17 +0,0 @@ -@import "ui-mixins"; -@import "ui-variables"; - -.key-binding { - display: inline-block; - line-height: 100%; - border-radius: @component-border-radius; - margin-left: @component-icon-padding; - font-family: Helvetica, Arial, sans-serif; - font-size: @font-size - 1px; - padding: @component-padding / 2; -} - -.badge { - .text(highlight); - background: @background-color-highlight; -} diff --git a/.atom/packages/spacegray-mocha-ui/stylesheets/zen.less b/.atom/packages/spacegray-mocha-ui/stylesheets/zen.less deleted file mode 100644 index eca874a..0000000 --- a/.atom/packages/spacegray-mocha-ui/stylesheets/zen.less +++ /dev/null @@ -1,7 +0,0 @@ -@import "ui-variables"; - -.zen { - .panes .pane { - background-color: @app-background-color; - } -} diff --git a/.atom/packages/vim-mode/.npmignore b/.atom/packages/vim-mode/.npmignore deleted file mode 100644 index 3c3629e..0000000 --- a/.atom/packages/vim-mode/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/.atom/packages/vim-mode/.travis.yml b/.atom/packages/vim-mode/.travis.yml deleted file mode 100644 index 31be69d..0000000 --- a/.atom/packages/vim-mode/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: objective-c - -notifications: - email: - on_success: never - on_failure: change - -script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh' diff --git a/.atom/packages/vim-mode/CHANGELOG.md b/.atom/packages/vim-mode/CHANGELOG.md deleted file mode 100644 index 32f4d14..0000000 --- a/.atom/packages/vim-mode/CHANGELOG.md +++ /dev/null @@ -1,159 +0,0 @@ -## HEAD -* Ctrl-c for command mode on mac only @sgtpepper43 -* Add css to status bar mode for optional custom styling @e-jigsaw -* Implement `-`, `+`, and `enter` @roryokane -* Fix problem undo'ing in insert mode @bhuga - -## 0.11.1 -* Fix interaction with autocomplete-plus @klorenz - -## 0.11.0 -* Fix `gg` and `G` in visual mode @cadwallion -* Implement `%` @carlosdcastillo -* Add ctags keybindings @tmm1 -* Fix tracking of marks when buffer changes @carlosdcastillo -* Fix off-by-one error for characterwise puts @carlosdcastillo -* Add support for undo and repeat to typing operations @bhuga -* Fix keybindings for some OSes @mcnicholls -* Fix visual `ngg` @tony612 -* Implement i{, i(, and i" @carlosdcastillo -* Fix off by one errors while selecting with j and k @fotanus -* Implement 'desired cursor column' behavior @iamjwc - -## 0.10.0 -* Fix E in visual mode @tony612 -* Implement `` @guanlun -* Fix broken behavior when enabling/disabling @cadwallion -* Enable search in visual mode @romankuznietsov -* Fix end-of-line movement @abijr -* Fix behavior of change current line `cc` in various corner cases. @jcurtis -* Fix some corner cases of `w` @abijr -* Don't hide cursor in visual mode @dyross - -## 0.9.0 - Lots of new features -* Enable arrow keys in visual mode @fholgado -* Additional bindings for split pane movement @zenhob -* Fix search on invalid regex @bhuga -* Add `s` alias to visual mode @tony612 -* Display current mode in the status bar @gblock0 -* Add marks (m, `, ') @danzimm -* Add operator-pending mode and a single text object (`iw`) @nathansobo, @jroes -* Add an option to start in insert mode @viveksjain -* Fix weird behavior when pasting at the end of a file @msvbg -* More fixes for corner cases in paste behavior @SKAhack -* Implement * and # @roman -* Implement ~ @badunk -* Implement t and T @udp - -## 0.8.1 - Small goodies -* Implement `ctrl-e` and `ctrl-y` @dougblack -* Implement `/`, `?`, `n` and `N` @bhuga -* Registers are now shared between tabs in a single atom window @bhuga -* Show cursor only in focused editor @tony612 -* Docs updated with new methods for entering insert mode @tednaleid -* Implement `r` @bhuga -* Fix `w` when on the last word of a file @dougblack -* Implement `=` @ciarand -* Implement `E` motion @tony612 -* Implement basic `ctrl-f` and `ctrl-b` support @ciarand -* Added `+`, `*` and `%` registers @cschneid -* Improved `^` movement when already at the first character @zenhob -* Fix off-by-one error for `15gg` @tony612 - -## 0.8.0 - Keep rocking -* API Fixes for Atom 0.62 @bhuga -* Add `$` and `^` to visual mode @spyc3r -* Add `0` to visual mode @ruedap -* Fix for yanking entire lines @chadkouse -* Add `X` operator @ruedap -* Add `W` and `B` motions @jcurtis -* Prevent cursor left at column 0 when switching to insert mode @adrianolaru -* Add pane switching shortcuts see #104 for details @dougblack -* Add `H`, `L` and `M` motions @dougblack - -## 0.7.2 - Full steam ahead -* Leaving insert mode always moves cursor left @joefiorini -* Implemented `I` command @dysfunction -* Restored `0` motion @jroes -* Implemented `}` motion to move to previous paragraph @zenhob -* Implement `gt` and `gT` to cycle through tabs @JosephKu -* Implement visual linewise mode @eoinkelly -* Properly clear selection when return to command mode @chadkouse - -## 0.7.1 - User improvements -* `ctrl-[` now activates command mode @ctbarna -* enter now moves down a line in command mode @ctbarna -* Documentation links now work on atom.io @michaeltwofish -* Backspace now moves back a space in command mode @Tarrant -* Fixed an issue where cursors wouldn't appear in the settings view. - -## 0.7.0 - Updates for release -* Update contributing guide -* Update package.json -* Require underscore-plus directly - -## 0.6.0 - Updates -* Implemented `.` operator, thanks to @bhuga -* Fix putting at the end of lines, thanks to @bhuga -* Compatibility with Atom 0.50.0 - -## 0.5.0 - Updates -* Switches apm db to buttant from iriscouch - -## 0.4.0 - Updates -* Compatibilty with Atom 26 - -## 0.3.0 - Visual and Collaborative -* Compatiblity with atom 0.21 -* Characterwise visual-mode! -* System copy and paste are now linked to the `*` -* Implement `A` operator -* Bugfixes concerning `b` and `P` - -## 0.2.3 - Not solo anymore - -* Major refactoring/cleanup/test speedup. -* Added `S` command. -* Added `C` operator. -* Proper undo/redo transactions for repeated commands. -* Enhance `G` to take line numbers. -* Added `Y` operator. -* Added `ctrl-c` to enter command mode. - -## 0.2.2 - -* Added `s` command. -* Added `e` motion. -* Fixed `cw` removing trailing whitepsace -* Fixed cursor position for `dd` when deleting blank lines - -## 0.2.1 - -* Added the `c` operator (thanks Yosef!) -* Cursor appears as block in command mode and blinks when inserting (thanks Corey!) -* Delete operations now save deleted text to the default buffer -* Implement `gg` and `G` motions -* Implement `P` operator -* Implement `o` and `O` commands - -## 0.2.0 - -* Added yank and put command with support for registers -* Added `$` and `^` motions -* Fixed repeats for commands and motions, ie `d2d` works as expected. -* Implemented `D` to delete through the end of the line. -* Implemented `>>` and `<<` indent and outdent commands. -* Implemented `J`. -* Implemented `a` to move cursor and enter insert mode. -* Add basic scrolling using `ctrl-u` and `ctrl-d`. -* Add basic undo/redo using `u` and `ctrl-r`. This needs to be improved so it - understands vim's semantics. - -## 0.1.0 - -* Nothing changed, used this as a test release to understand the - publishing flow. - -## 0.0.1 - -* Initial release, somewhat functional but missing many things. diff --git a/.atom/packages/vim-mode/CONTRIBUTING.md b/.atom/packages/vim-mode/CONTRIBUTING.md deleted file mode 100644 index 0fd0ad6..0000000 --- a/.atom/packages/vim-mode/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -See the [Atom contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md) diff --git a/.atom/packages/vim-mode/LICENSE.md b/.atom/packages/vim-mode/LICENSE.md deleted file mode 100644 index 4d231b4..0000000 --- a/.atom/packages/vim-mode/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 GitHub Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/vim-mode/MAINTAINERS.md b/.atom/packages/vim-mode/MAINTAINERS.md deleted file mode 100644 index fe31e61..0000000 --- a/.atom/packages/vim-mode/MAINTAINERS.md +++ /dev/null @@ -1,31 +0,0 @@ -## Maintainers Guide - -We'd like to foster an active community of mutual respect. With that as our -guiding principle, we strive to do the following: - -* Respond to issues/pulls in a timely manner. -* Encourage new contributors when possible. -* Maintain high code quality by ensuring all pull requests: - * Have clear concise code. - * Have passing specs. - * Have a proper note in the docs (if appropriate). - * Be made mergable by its creator (good feedback is hard enough). - * If a pull doesn't meet these standards, we should offer helpful actionable - advice to get it there. -* Add `CHANGELOG.md` entries for every pull merged. -* Publish new releases in a timely manner. -* Responsibly upgrade along with Atom core - * Tag the last compatible version with the correct Atom version before making a breaking change - * Merge finished pull requests before merging breaking changes -* Label issues clearly - * As either an `issue`, `enhancement` or `question`. - * The `question` label indicates that there's a question about current - functionality or future functionality. -* Label pull requests clearly - * As either an `issue` or `enhancement`. - * While being reviewed mark an additional `under-review` label if appropriate, - so the community knows the status. - * If a pull request requires changes by the creator an additional - `requires-changes` label is appropriate. - * Pulls that require core changes that aren't ready yet should be labeled - with an additional `blocked` label. diff --git a/.atom/packages/vim-mode/README.md b/.atom/packages/vim-mode/README.md deleted file mode 100644 index 9a85942..0000000 --- a/.atom/packages/vim-mode/README.md +++ /dev/null @@ -1,45 +0,0 @@ -## Vim Mode package [![Build Status](https://travis-ci.org/atom/vim-mode.svg?branch=master)](https://travis-ci.org/atom/vim-mode) - -Provides vim modal control for Atom, ideally blending the best of vim -and Atom. - -### Installing - -Use the Atom package manager, which can be found in the Settings view or -run `apm install vim-mode` from the command line. - -### Current Status - -Sizable portions of Vim's command mode work as you'd expect, including -many complex combinations. Even so, this package is far from finished (Vim -wasn't built in a day). - -Currently, vim-mode requires soft line wraps to be disabled, and has some issues -with international keyboard layouts. - -If there's a feature of Vim you're missing, it might just be that you use it -more often than other developers. Adding a feature can be quick and easy. Check -out the [closed pull requests](https://github.com/atom/vim-mode/pulls?direction=desc&page=1&sort=created&state=closed) -to see examples of community contributions. We're looking forward to yours, too. - -### Documentation - -* [Overview](https://github.com/atom/vim-mode/blob/master/docs/overview.md) -* [Motions](https://github.com/atom/vim-mode/blob/master/docs/motions.md) -* [Operators](https://github.com/atom/vim-mode/blob/master/docs/operators.md) -* [Windows](https://github.com/atom/vim-mode/blob/master/docs/windows.md) -* [Scrolling](https://github.com/atom/vim-mode/blob/master/docs/scrolling.md) - -### Development - -* Create a branch with your feature/fix. -* Add a spec (take inspiration from the ones that are already there). -* If you're adding a command be sure to update the appropriate file in - `docs/` -* Create a PR. - -When in doubt, open a PR earlier rather than later so that you can receive -feedback from the community. We want to get your fix or feature included as much -as you do. - -See [the contribution guide](https://github.com/atom/vim-mode/blob/master/CONTRIBUTING.md). diff --git a/.atom/packages/vim-mode/docs/motions.md b/.atom/packages/vim-mode/docs/motions.md deleted file mode 100644 index 9eaf533..0000000 --- a/.atom/packages/vim-mode/docs/motions.md +++ /dev/null @@ -1,29 +0,0 @@ -## Implemented Motions - -* [w](http://vimhelp.appspot.com/motion.txt.html#w) -* [W](http://vimhelp.appspot.com/motion.txt.html#W) -* [e](http://vimhelp.appspot.com/motion.txt.html#e) -* [E](http://vimhelp.appspot.com/motion.txt.html#E) -* [b](http://vimhelp.appspot.com/motion.txt.html#b) -* [B](http://vimhelp.appspot.com/motion.txt.html#B) -* [h](http://vimhelp.appspot.com/motion.txt.html#h) -* [j](http://vimhelp.appspot.com/motion.txt.html#j) -* [k](http://vimhelp.appspot.com/motion.txt.html#k) -* [l](http://vimhelp.appspot.com/motion.txt.html#l) -* [{](http://vimhelp.appspot.com/motion.txt.html#%7B) -* [}](http://vimhelp.appspot.com/motion.txt.html#%7D) -* [^](http://vimhelp.appspot.com/motion.txt.html#%5E) -* [$](http://vimhelp.appspot.com/motion.txt.html#%24) -* [0](http://vimhelp.appspot.com/motion.txt.html#0) -* [-](http://vimhelp.appspot.com/motion.txt.html#-) -* [+](http://vimhelp.appspot.com/motion.txt.html#+) -* [<enter>](http://vimhelp.appspot.com/motion.txt.html#) -* [gg](http://vimhelp.appspot.com/motion.txt.html#gg) -* [G](http://vimhelp.appspot.com/motion.txt.html#G) -* [gt](http://vimhelp.appspot.com/tabpage.txt.html#gt) -* [gT](http://vimhelp.appspot.com/tabpage.txt.html#gT) -* [H](http://vimhelp.appspot.com/motion.txt.html#H) -* [L](http://vimhelp.appspot.com/motion.txt.html#L) -* [M](http://vimhelp.appspot.com/motion.txt.html#M) -* ['[a-z][A-Z]](http://vimhelp.appspot.com/motion.txt.html#%27) -* [`[a-z][A-Z]](http://vimhelp.appspot.com/motion.txt.html#%27) diff --git a/.atom/packages/vim-mode/docs/operators.md b/.atom/packages/vim-mode/docs/operators.md deleted file mode 100644 index d4ee00c..0000000 --- a/.atom/packages/vim-mode/docs/operators.md +++ /dev/null @@ -1,38 +0,0 @@ -## Implemented Operators - -* [Delete](http://vimhelp.appspot.com/change.txt.html#deleting) - * `vwd` - works in visual mode - * `dw` - with a motion - * `3d2w` - with repeating operator and motion - * `dd` - linewise - * `d2d` - repeated linewise - * `D` - delete to the end of the line - * `X` - delete the character before the cursor -* [Change](http://vimhelp.appspot.com/change.txt.html#c) - * `vwc` - works in visual mode - * `cw` - deletes the next word and switches to insert mode. - * `cc` - linewise - * `c2c` - repeated linewise - * `C` - change to the end of the line -* [Yank](http://vimhelp.appspot.com/change.txt.html#yank) - * `vwy` - works in visual mode - * `yw` - with a motion - * `yy` - linewise - * `y2y` - repeated linewise - * `"ayy` - supports registers (only named a-h, pending more - advanced atom keymap support) - * `Y` - linewise -* Indent/Outdent/Auto-indent - * `vw>` - works in visual mode - * `>>` - indent current line one level - * `<<` - outdent current line one level - * `==` - auto-indents current line -* [Put](http://vimhelp.appspot.com/change.txt.html#p) - * `p` - default register - * `P` - pastes the default register before the current cursor. - * `"ap` - supports registers (only named a-h, pending more - advanced atom keymap support) -* [Join](http://vimhelp.appspot.com/change.txt.html#J) - * `J` - joins the current line with the immediately following line. -* [Mark](http://vimhelp.appspot.com/motion.txt.html#m) - * `m[a-z][A-Z]` - marks the current cursor position diff --git a/.atom/packages/vim-mode/docs/overview.md b/.atom/packages/vim-mode/docs/overview.md deleted file mode 100644 index 3ff1894..0000000 --- a/.atom/packages/vim-mode/docs/overview.md +++ /dev/null @@ -1,14 +0,0 @@ -## Overview - -* There are only currently two modes, command mode and insert mode. -* Motions have repeat support, `d3w` will delete three words. -* Insert mode can be entered using `i`, `I`, `a`, `A`, `o`, or `O`. -* Registers are a work in progress - * What Exists: - * `a-z` - Lowercase named registers - * `*`, `+` - System clipboard registers, although there's no distinction between the two currently. - * `%` - Current filename read-only register - * `_` - Blackhole register - * What Doesn't Exist: - * default buffer doesn't yet save on delete operations. - * `A-Z` - Appending via upper case registers diff --git a/.atom/packages/vim-mode/docs/scrolling.md b/.atom/packages/vim-mode/docs/scrolling.md deleted file mode 100644 index cd740f0..0000000 --- a/.atom/packages/vim-mode/docs/scrolling.md +++ /dev/null @@ -1,6 +0,0 @@ -## Implemented Scrolling Commands - -* [ctrl-e](http://vimhelp.appspot.com/scroll.txt.html#CTRL-E) -* [ctrl-y](http://vimhelp.appspot.com/scroll.txt.html#CTRL-Y) -* [ctrl-f](http://vimhelp.appspot.com/scroll.txt.html#CTRL-F) -* [ctrl-b](http://vimhelp.appspot.com/scroll.txt.html#CTRL-B) diff --git a/.atom/packages/vim-mode/docs/windows.md b/.atom/packages/vim-mode/docs/windows.md deleted file mode 100644 index 2c21485..0000000 --- a/.atom/packages/vim-mode/docs/windows.md +++ /dev/null @@ -1,12 +0,0 @@ -## Implemented Split Pane Commands - -* `ctrl-w h`/`ctrl-w left`/`ctrl-w ctrl-h` - focus pane on left -* `ctrl-w l`/`ctrl-w right`/`ctrl-w ctrl-l` - focus pane on right -* `ctrl-w k`/`ctrl-w up`/`ctrl-w ctrl-k` - focus pane above -* `ctrl-w j`/`ctrl-w down`/`ctrl-w ctrl-j` - focus pane below -* `ctrl-w w`/`ctrl-w ctrl-w` - focus next pane -* `ctrl-w p`/`ctrl-w ctrl-p` - focus previous pane -* `ctrl-w v`/`ctrl-w ctrl-v` - create vertical split -* `ctrl-w s`/`ctrl-w ctrl-s` - create horizontal split -* `ctrl-w c`/`ctrl-w ctrl-c`: close focused pane -* `ctrl-w q`/`ctrl-w ctrl-q` - close focused tab diff --git a/.atom/packages/vim-mode/keymaps/vim-mode.cson b/.atom/packages/vim-mode/keymaps/vim-mode.cson deleted file mode 100644 index f644625..0000000 --- a/.atom/packages/vim-mode/keymaps/vim-mode.cson +++ /dev/null @@ -1,184 +0,0 @@ -'.editor.vim-mode:not(.command-mode)': - 'escape': 'vim-mode:activate-command-mode' - 'ctrl-[': 'vim-mode:activate-command-mode' - -'.platform-darwin .editor.vim-mode:not(.command-mode)': - 'ctrl-c': 'vim-mode:activate-command-mode' - -'.editor.vim-mode:not(.insert-mode)': - 'h': 'vim-mode:move-left' - 'left': 'vim-mode:move-left' - 'backspace': 'core:move-left' - 'l': 'vim-mode:move-right' - 'space': 'vim-mode:move-right' - 'right': 'vim-mode:move-right' - 'k': 'vim-mode:move-up' - 'up': 'vim-mode:move-up' - 'j': 'vim-mode:move-down' - 'down': 'vim-mode:move-down' - - 'w': 'vim-mode:move-to-next-word' - 'W': 'vim-mode:move-to-next-whole-word' - 'e': 'vim-mode:move-to-end-of-word' - 'E': 'vim-mode:move-to-end-of-whole-word' - 'b': 'vim-mode:move-to-previous-word' - 'B': 'vim-mode:move-to-previous-whole-word' - '}': 'vim-mode:move-to-next-paragraph' - '{': 'vim-mode:move-to-previous-paragraph' - '0': 'vim-mode:move-to-beginning-of-line' - '^': 'vim-mode:move-to-first-character-of-line' - '$': 'vim-mode:move-to-last-character-of-line' - '-': 'vim-mode:move-to-first-character-of-line-up' - '+': 'vim-mode:move-to-first-character-of-line-down' - 'enter': 'vim-mode:move-to-first-character-of-line-down' - 'g g': 'vim-mode:move-to-start-of-file' - 'ctrl-u': 'core:page-up' - 'ctrl-b': 'core:page-up' - 'ctrl-d': 'core:page-down' - 'ctrl-f': 'core:page-down' - 'ctrl-e': 'vim-mode:scroll-down' - 'ctrl-y': 'vim-mode:scroll-up' - 'G': 'vim-mode:move-to-line' - 'H': 'vim-mode:move-to-top-of-screen' - 'L': 'vim-mode:move-to-bottom-of-screen' - 'M': 'vim-mode:move-to-middle-of-screen' - - 'd': 'vim-mode:delete' - 'D': 'vim-mode:delete-to-last-character-of-line' - 'c': 'vim-mode:change' - 'C': 'vim-mode:change-to-last-character-of-line' - 'S': 'vim-mode:substitute-line' - 'r': 'vim-mode:replace' - 'I': 'vim-mode:insert-at-beginning-of-line' - '>': 'vim-mode:indent' - '<': 'vim-mode:outdent' - '=': 'vim-mode:auto-indent' - 'J': 'vim-mode:join' - - 'y': 'vim-mode:yank' - 'Y': 'vim-mode:yank-line' - 'P': 'vim-mode:put-before' - 'p': 'vim-mode:put-after' - - 'ctrl-w ctrl-h': 'vim-mode:focus-pane-view-on-left' - 'ctrl-w h': 'vim-mode:focus-pane-view-on-left' - 'ctrl-w left': 'window:focus-pane-on-left' - 'ctrl-w ctrl-l': 'vim-mode:focus-pane-view-on-right' - 'ctrl-w l': 'vim-mode:focus-pane-view-on-right' - 'ctrl-w right': 'window:focus-pane-on-right' - 'ctrl-w ctrl-k': 'vim-mode:focus-pane-view-above' - 'ctrl-w k': 'vim-mode:focus-pane-view-above' - 'ctrl-w up': 'window:focus-pane-above' - 'ctrl-w ctrl-j': 'vim-mode:focus-pane-view-below' - 'ctrl-w j': 'vim-mode:focus-pane-view-below' - 'ctrl-w down': 'window:focus-pane-below' - 'ctrl-w ctrl-w': 'window:focus-next-pane' - 'ctrl-w w': 'window:focus-next-pane' - 'ctrl-w ctrl-p': 'vim-mode:focus-previous-pane-view' - 'ctrl-w p': 'window:focus-previous-pane' - 'ctrl-w ctrl-v': 'pane:split-right' - 'ctrl-w v': 'pane:split-right' - 'ctrl-w ctrl-s': 'pane:split-down' - 'ctrl-w s': 'pane:split-down' - 'ctrl-w ctrl-c': 'pane:close' - 'ctrl-w c': 'pane:close' - 'ctrl-w ctrl-q': 'core:close' - 'ctrl-w q': 'core:close' - 'g t': 'pane:show-next-item' - 'g T': 'pane:show-previous-item' - - 'm': 'vim-mode:mark' - '`': 'vim-mode:move-to-mark-literal' - '\'': 'vim-mode:move-to-mark' - - 'f': 'vim-mode:find' - 'F': 'vim-mode:find-backwards' - 't': 'vim-mode:till' - 'T': 'vim-mode:till-backwards' - - '/': 'vim-mode:search' - '?': 'vim-mode:reverse-search' - '*': 'vim-mode:search-current-word' - '#': 'vim-mode:reverse-search-current-word' - 'n': 'vim-mode:repeat-search' - 'N': 'vim-mode:repeat-search-backwards' - - '%': 'vim-mode:bracket-matching-motion' - - '1': 'vim-mode:repeat-prefix' - '2': 'vim-mode:repeat-prefix' - '3': 'vim-mode:repeat-prefix' - '4': 'vim-mode:repeat-prefix' - '5': 'vim-mode:repeat-prefix' - '6': 'vim-mode:repeat-prefix' - '7': 'vim-mode:repeat-prefix' - '8': 'vim-mode:repeat-prefix' - '9': 'vim-mode:repeat-prefix' - -'.editor.vim-mode.command-mode': - 'i': 'vim-mode:activate-insert-mode' - 'v': 'vim-mode:activate-characterwise-visual-mode' - 'V': 'vim-mode:activate-linewise-visual-mode' - 'ctrl-v': 'vim-mode:activate-blockwise-visual-mode' - 'escape': 'vim-mode:reset-command-mode' - 'ctrl-c': 'vim-mode:reset-command-mode' - 'ctrl-[': 'vim-mode:reset-command-mode' - - 'u': 'core:undo' - 'ctrl-r': 'core:redo' - - 'O': 'vim-mode:insert-above-with-newline' - 'o': 'vim-mode:insert-below-with-newline' - 'a': 'vim-mode:insert-after' - 'A': 'vim-mode:insert-after-end-of-line' - 'x': 'vim-mode:delete-right' - 'X': 'vim-mode:delete-left' - '~': 'vim-mode:toggle-case' - 's': 'vim-mode:substitute' - '.': 'vim-mode:repeat' - - 'ctrl-]': 'symbols-view:go-to-declaration' - 'ctrl-T': 'symbols-view:return-from-declaration' - - '" a': 'vim-mode:register-prefix' - '" b': 'vim-mode:register-prefix' - '" c': 'vim-mode:register-prefix' - '" d': 'vim-mode:register-prefix' - '" e': 'vim-mode:register-prefix' - '" f': 'vim-mode:register-prefix' - '" g': 'vim-mode:register-prefix' - '" h': 'vim-mode:register-prefix' - '" i': 'vim-mode:register-prefix' - '" j': 'vim-mode:register-prefix' - '" k': 'vim-mode:register-prefix' - '" l': 'vim-mode:register-prefix' - '" m': 'vim-mode:register-prefix' - '" n': 'vim-mode:register-prefix' - '" o': 'vim-mode:register-prefix' - '" p': 'vim-mode:register-prefix' - '" q': 'vim-mode:register-prefix' - '" r': 'vim-mode:register-prefix' - '" s': 'vim-mode:register-prefix' - '" t': 'vim-mode:register-prefix' - '" u': 'vim-mode:register-prefix' - '" v': 'vim-mode:register-prefix' - '" w': 'vim-mode:register-prefix' - '" x': 'vim-mode:register-prefix' - '" y': 'vim-mode:register-prefix' - '" z': 'vim-mode:register-prefix' - '" *': 'vim-mode:register-prefix' - '" +': 'vim-mode:register-prefix' - '" %': 'vim-mode:register-prefix' - '" _': 'vim-mode:register-prefix' - -'.editor.vim-mode.operator-pending-mode, .editor.vim-mode.visual-mode': - 'i w': 'vim-mode:select-inside-word' - 'i "': 'vim-mode:select-inside-double-quotes' - 'i \'': 'vim-mode:select-inside-single-quotes' - 'i {': 'vim-mode:select-inside-curly-brackets' - 'i <': 'vim-mode:select-inside-angle-brackets' - 'i (': 'vim-mode:select-inside-parentheses' - -'.editor.vim-mode.visual-mode': - 'x': 'vim-mode:delete' - 's': 'vim-mode:change' diff --git a/.atom/packages/vim-mode/lib/motions/find-motion.coffee b/.atom/packages/vim-mode/lib/motions/find-motion.coffee deleted file mode 100644 index b784c03..0000000 --- a/.atom/packages/vim-mode/lib/motions/find-motion.coffee +++ /dev/null @@ -1,53 +0,0 @@ -{MotionWithInput} = require './general-motions' -{ViewModel} = require '../view-models/view-model' -{Point, Range} = require 'atom' - -class Find extends MotionWithInput - constructor: (@editorView, @vimState) -> - super(@editorView, @vimState) - @viewModel = new ViewModel(@, class: 'find', singleChar: true, hidden: true) - @reversed = false - @offset = 0 - - match: (count) -> - currentPosition = @editorView.editor.getCursorBufferPosition() - line = @editorView.editor.lineForBufferRow(currentPosition.row) - if @reversed - index = currentPosition.column - for i in [0..count-1] - index = line.lastIndexOf(@input.characters, index-1) - if index != -1 - point = new Point(currentPosition.row, index+@offset) - return {} = - point: point - range: new Range(point, currentPosition) - else - index = currentPosition.column - for i in [0..count-1] - index = line.indexOf(@input.characters, index+1) - if index != -1 - point = new Point(currentPosition.row, index-@offset) - return {} = - point: point - range: new Range(currentPosition, point.translate([0,1])) - - reverse: -> - @reversed = !@reversed - @ - - execute: (count=1) -> - if (match = @match(count))? - @editorView.editor.setCursorBufferPosition(match.point) - - select: (count=1, {requireEOL}={}) -> - if (match = @match(count))? - @editorView.editor.setSelectedBufferRange(match.range) - return [true] - [false] - -class Till extends Find - constructor: (@editorView, @vimState) -> - super(@editorView, @vimState) - @offset = 1 - -module.exports = {Find, Till} diff --git a/.atom/packages/vim-mode/lib/motions/general-motions.coffee b/.atom/packages/vim-mode/lib/motions/general-motions.coffee deleted file mode 100644 index fd9ea05..0000000 --- a/.atom/packages/vim-mode/lib/motions/general-motions.coffee +++ /dev/null @@ -1,554 +0,0 @@ -_ = require 'underscore-plus' -{$$, Point, Range} = require 'atom' - -class MotionError - constructor: (@message) -> - @name = 'Motion Error' - -class Motion - constructor: (@editor, @vimState) -> - @vimState.desiredCursorColumn = null - - isComplete: -> true - isRecordable: -> false - inVisualMode: -> @vimState.mode == "visual" - -class CurrentSelection extends Motion - execute: (count=1) -> - _.times(count, -> true) - - select: (count=1) -> - _.times(count, -> true) - - isLinewise: -> @vimState.mode == 'visual' and @vimState.submode == 'linewise' - -# Public: Generic class for motions that require extra input -class MotionWithInput extends Motion - constructor: (@editorView, @vimState) -> - super(@editorView.editor, @vimState) - @complete = false - - isComplete: -> @complete - - canComposeWith: (operation) -> return operation.characters? - - compose: (input) -> - if not input.characters - throw new MotionError('Must compose with an Input') - @input = input - @complete = true - -class MoveLeft extends Motion - execute: (count=1) -> - _.times count, => - {row, column} = @editor.getCursorScreenPosition() - @editor.moveCursorLeft() if column > 0 - - select: (count=1) -> - _.times count, => - {row, column} = @editor.getCursorScreenPosition() - - if column > 0 - @editor.selectLeft() - true - else - false - -class MoveRight extends Motion - execute: (count=1) -> - _.times count, => - {row, column} = @editor.getCursorScreenPosition() - lastCharIndex = @editor.getBuffer().lineForRow(row).length - 1 - unless column >= lastCharIndex - @editor.moveCursorRight() - - select: (count=1) -> - _.times count, => - {start, end} = @editor.getSelectedBufferRange() - rowLength = @editor.getCursor().getCurrentBufferLine().length - - if end.column < rowLength - @editor.selectRight() - true - else - false - -class MoveVertically extends Motion - constructor: (@editor, @vimState) -> - # 'desiredCursorColumn' gets overwritten in the Motion constructor, - # so we need to re-set it after calling super. - column = @vimState.desiredCursorColumn - super(@editor, @vimState) - @vimState.desiredCursorColumn = column - - execute: (count=1) -> - {row, column} = @editor.getCursorBufferPosition() - - nextRow = @nextValidRow(count) - - if nextRow != row - nextLineLength = @editor.lineLengthForBufferRow(nextRow) - - # The 'nextColumn' the cursor should be in is the - # 'desiredCursorColumn', if it exists. If it does - # not, the current column should be used. - nextColumn = @vimState.desiredCursorColumn || column - - # Check to see if the 'nextColumn' position of - # cursor is greater than or equal to the length - # of the next line. - if nextColumn >= nextLineLength - # When the 'nextColumn' is greater than the - # length of the next line, we should move the - # cursor to the end of the next line and save - # 'nextColumn' in 'desiredCursorColumn'. - @editor.setCursorBufferPosition([nextRow, nextLineLength-1]) - @vimState.desiredCursorColumn = nextColumn - else - # When the 'nextColumn' is a valid spot to - # move into, in the next line, simply move - # there and unset 'desiredCursorColumn'. - @editor.setCursorBufferPosition([nextRow, nextColumn]) - @vimState.desiredCursorColumn = null - - # Internal: Finds the next valid row that can be moved - # to. This move takes folded lines into account when - # calculating the next valid row. - # - # count - The number of folded 'buffer' rows away from - # the current row. - # - # Returns an integer row index. - nextValidRow: (count) -> - {row, column} = @editor.getCursorBufferPosition() - - maxRow = @editor.getLastBufferRow() - minRow = 0 - - # For each count, add 1 'directionIncrement' to - # row. Folded rows count as a single row. - _.times count, => - if @editor.isFoldedAtBufferRow(row) - while @editor.isFoldedAtBufferRow(row) - row += @directionIncrement() - else - row += @directionIncrement() - - if row > maxRow - maxRow - else if row < minRow - minRow - else - row - -class MoveUp extends MoveVertically - # Internal: The direction to move the cursor. Use -1 - # for moving up, 1 for moving down. - # - # Returns -1 - directionIncrement: -> - -1 - - select: (count=1) -> - unless @inVisualMode() - @editor.moveCursorToBeginningOfLine() - @editor.moveCursorDown() - @editor.selectUp() - - _.times count, => - @editor.selectUp() - true - -class MoveDown extends MoveVertically - # Internal: The direction to move the cursor. Use -1 - # for moving up, 1 for moving down. - # - # Returns 1 - directionIncrement: -> - 1 - - select: (count=1) -> - @editor.selectLine() unless @inVisualMode() - _.times count, => - @editor.selectDown() - true - -class MoveToPreviousWord extends Motion - execute: (count=1) -> - _.times count, => - @editor.moveCursorToBeginningOfWord() - - select: (count=1) -> - _.times count, => - @editor.selectToBeginningOfWord() - true - -class MoveToPreviousWholeWord extends Motion - execute: (count=1) -> - _.times count, => - @editor.moveCursorToBeginningOfWord() - @editor.moveCursorToBeginningOfWord() while not @isWholeWord() and not @isBeginningOfFile() - - select: (count=1) -> - _.times count, => - @editor.selectToBeginningOfWord() - @editor.selectToBeginningOfWord() while not @isWholeWord() and not @isBeginningOfFile() - true - - isWholeWord: -> - char = @editor.getCursor().getCurrentWordPrefix().slice(-1) - char is ' ' or char is '\n' - - isBeginningOfFile: -> - cur = @editor.getCursorBufferPosition(); - not cur.row and not cur.column - -class MoveToNextWord extends Motion - execute: (count=1) -> - cursor = @editor.getCursor() - - _.times count, => - current = cursor.getBufferPosition() - next = cursor.getBeginningOfNextWordBufferPosition() - - return if @isEndOfFile() - - if cursor.isAtEndOfLine() - cursor.moveDown() - cursor.moveToBeginningOfLine() - cursor.skipLeadingWhitespace() - else if current.row is next.row and current.column is next.column - cursor.moveToEndOfWord() - else - cursor.moveToBeginningOfNextWord() - - # Options - # excludeWhitespace - if true, whitespace shouldn't be selected - select: (count=1, {excludeWhitespace}={}) -> - cursor = @editor.getCursor() - - _.times count, => - current = cursor.getBufferPosition() - next = cursor.getBeginningOfNextWordBufferPosition() - - if current.row != next.row or excludeWhitespace or current == next - @editor.selectToEndOfWord() - else - @editor.selectToBeginningOfNextWord() - - true - - isEndOfFile: -> - cur = @editor.getCursor().getBufferPosition() - eof = @editor.getEofBufferPosition() - cur.row is eof.row and cur.column is eof.column - -class MoveToNextWholeWord extends Motion - execute: (count=1) -> - _.times count, => - @editor.moveCursorToBeginningOfNextWord() - @editor.moveCursorToBeginningOfNextWord() while not @isWholeWord() and not @isEndOfFile() - - select: (count=1, {excludeWhitespace}={}) -> - cursor = @editor.getCursor() - - _.times count, => - current = cursor.getBufferPosition() - next = cursor.getBeginningOfNextWordBufferPosition(/[^\s]/) - - if current.row != next.row or excludeWhitespace - @editor.selectToEndOfWord() - else - @editor.selectToBeginningOfNextWord() - @editor.selectToBeginningOfNextWord() while not @isWholeWord() and not @isEndOfFile() - - true - - isWholeWord: -> - char = @editor.getCursor().getCurrentWordPrefix().slice(-1) - char is ' ' or char is '\n' - - isEndOfFile: -> - last = @editor.getEofBufferPosition() - cur = @editor.getCursorBufferPosition() - last.row is cur.row and last.column is cur.column - -class MoveToEndOfWord extends Motion - execute: (count=1) -> - cursor = @editor.getCursor() - _.times count, => - cursor.setBufferPosition(@nextBufferPosition(exclusive: true)) - - select: (count=1) -> - cursor = @editor.getCursor() - - _.times count, => - bufferPosition = @nextBufferPosition() - screenPosition = @editor.screenPositionForBufferPosition(bufferPosition) - @editor.selectToScreenPosition(screenPosition) - true - - # Private: Finds the end of the current word and stops on the last character - # - # exclusive - If true will stop on the last character of the word rather than - # the next character after the word. - # - # The reason this is implemented here is that Atom always stops on the - # character after the word which is only sometimes what vim means. - nextBufferPosition: ({exclusive}={})-> - cursor = @editor.getCursor() - current = cursor.getBufferPosition() - next = cursor.getEndOfCurrentWordBufferPosition() - next.column -= 1 if exclusive - - if exclusive and current.row == next.row and current.column == next.column - cursor.moveRight() - next = cursor.getEndOfCurrentWordBufferPosition() - next.column -= 1 - - next - -class MoveToEndOfWholeWord extends Motion - execute: (count=1) -> - cursor = @editor.getCursor() - _.times count, => - cursor.setBufferPosition(@nextBufferPosition(exclusive: true)) - - select: (count=1) -> - _.times count, => - bufferPosition = @nextBufferPosition() - screenPosition = @editor.screenPositionForBufferPosition(bufferPosition) - @editor.selectToScreenPosition(screenPosition) - true - - # Private: Finds the end of the current whole word and stops on the last character - # - # exclusive - If true will stop on the last character of the whole word rather - # than the next character after the word. - nextBufferPosition: ({exclusive}={})-> - # get next position and reset cursor's position - {row, column} = @editor.getCursorBufferPosition() - start = new Point(row, column + 1) - - scanRange = [start, @editor.getEofBufferPosition()] - position = @editor.getEofBufferPosition() - - @editor.scanInBufferRange /\S+/, scanRange, ({range, stop}) => - position = range.end - stop() - - position.column -= 1 if exclusive - position - -class MoveToNextParagraph extends Motion - execute: (count=1) -> - _.times count, => - @editor.setCursorScreenPosition(@nextPosition()) - - select: (count=1) -> - _.times count, => - @editor.selectToScreenPosition(@nextPosition()) - true - - # Private: Finds the beginning of the next paragraph - # - # If no paragraph is found, the end of the buffer is returned. - nextPosition: -> - start = @editor.getCursorBufferPosition() - scanRange = [start, @editor.getEofBufferPosition()] - - {row, column} = @editor.getEofBufferPosition() - position = new Point(row, column - 1) - - @editor.scanInBufferRange /^\n*$/g, scanRange, ({range, stop}) => - if !range.start.isEqual(start) - position = range.start - stop() - - @editor.screenPositionForBufferPosition(position) - -class MoveToPreviousParagraph extends Motion - execute: (count=1) -> - _.times count, => - @editor.setCursorScreenPosition(@previousPosition()) - - select: (count=1) -> - _.times count, => - @editor.selectToScreenPosition(@previousPosition()) - true - - # Private: Finds the beginning of the previous paragraph - # - # If no paragraph is found, the beginning of the buffer is returned. - previousPosition: -> - start = @editor.getCursorBufferPosition() - {row, column} = start - scanRange = [[row-1, column], [0,0]] - position = new Point(0, 0) - @editor.backwardsScanInBufferRange /^\n*$/g, scanRange, ({range, stop}) => - if !range.start.isEqual(new Point(0,0)) - position = range.start - stop() - @editor.screenPositionForBufferPosition(position) - -class MoveToLine extends Motion - isLinewise: -> true - - execute: (count) -> - @setCursorPosition(count) - @editor.getCursor().skipLeadingWhitespace() - - # Options - # requireEOL - if true, ensure an end of line character is always selected - select: (count=@editor.getLineCount(), {requireEOL}={}) -> - {row, column} = @editor.getCursorBufferPosition() - @editor.setSelectedBufferRange(@selectRows(row, row + (count - 1), requireEOL: requireEOL)) - - _.times count, -> - true - - # TODO: This is extracted from TextBuffer#deleteRows. Unfortunately - # there isn't a way to call this functionality without actually - # deleting at the same time. This should be extracted out within atom - # and the removed here. - selectRows: (start, end, {requireEOL}={}) => - startPoint = null - endPoint = null - buffer = @editor.getBuffer() - if end == buffer.getLastRow() - if start > 0 and requireEOL - startPoint = [start - 1, buffer.lineLengthForRow(start - 1)] - else - startPoint = [start, 0] - endPoint = [end, buffer.lineLengthForRow(end)] - else - startPoint = [start, 0] - endPoint = [end + 1, 0] - - new Range(startPoint, endPoint) - - setCursorPosition: (count) -> - @editor.setCursorBufferPosition([@getDestinationRow(count), 0]) - - getDestinationRow: (count) -> - if count? then count - 1 else (@editor.getLineCount() - 1) - -class MoveToScreenLine extends MoveToLine - constructor: (@editor, @vimState, @editorView, @scrolloff) -> - @scrolloff = 2 # atom default - super(@editor, @vimState) - - setCursorPosition: (count) -> - @editor.setCursorScreenPosition([@getDestinationRow(count), 0]) - -class MoveToBeginningOfLine extends Motion - execute: (count=1) -> - @editor.moveCursorToBeginningOfLine() - - select: (count=1) -> - _.times count, => - @editor.selectToBeginningOfLine() - true - -class MoveToFirstCharacterOfLine extends Motion - constructor:(@editor, @vimState) -> - @cursor = @editor.getCursor() - super(@editor, @vimState) - - execute: () -> - @editor.setCursorBufferPosition([@cursor.getBufferRow(), @getDestinationColumn()]) - - select: (count=1) -> - if @getDestinationColumn() isnt @cursor.getBufferColumn() - _.times count, => - @editor.selectToFirstCharacterOfLine() - true - - getDestinationColumn: -> - @editor.lineForBufferRow(@cursor.getBufferRow()).search(/\S/) - -class MoveToLastCharacterOfLine extends Motion - execute: (count=1) -> - # After moving to the end of the line, vertical motions - # should stay at the last column. - @vimState.desiredCursorColumn = Infinity - - _.times count, => - @editor.moveCursorToEndOfLine() - @editor.moveCursorLeft() unless @editor.getCursor().getBufferColumn() is 0 - - select: (count=1) -> - _.times count, => - @editor.selectToEndOfLine() - true - -class MoveToFirstCharacterOfLineUp extends Motion - execute: (count=1) -> - (new MoveUp(@editor, @vimState)).execute(count) - (new MoveToFirstCharacterOfLine(@editor, @vimState)).execute() - - select: (count=1) -> - (new MoveUp(@editor, @vimState)).select(count) - -class MoveToFirstCharacterOfLineDown extends Motion - execute: (count=1) -> - (new MoveDown(@editor, @vimState)).execute(count) - (new MoveToFirstCharacterOfLine(@editor, @vimState)).execute() - - select: (count=1) -> - (new MoveDown(@editor, @vimState)).select(count) - -class MoveToStartOfFile extends MoveToLine - isLinewise: -> @vimState.mode == 'visual' and @vimState.submode == 'linewise' - - getDestinationRow: (count=1) -> - count - 1 - - getDestinationColumn: (row) -> - if @isLinewise() then 0 else @editor.lineForBufferRow(row).search(/\S/) - - getStartingColumn: (column) -> - if @isLinewise() then column else column + 1 - - select: (count=1) -> - {row, column} = @editor.getCursorBufferPosition() - startingCol = @getStartingColumn(column) - destinationRow = @getDestinationRow(count) - destinationCol = @getDestinationColumn(destinationRow) - bufferRange = new Range([row, startingCol], [destinationRow, destinationCol]) - @editor.setSelectedBufferRange(bufferRange, reversed: true) - -class MoveToTopOfScreen extends MoveToScreenLine - getDestinationRow: (count=0) -> - firstScreenRow = @editorView.getFirstVisibleScreenRow() - if firstScreenRow > 0 - offset = Math.max(count - 1, @scrolloff) - else - offset = if count > 0 then count - 1 else count - firstScreenRow + offset - -class MoveToBottomOfScreen extends MoveToScreenLine - getDestinationRow: (count=0) -> - lastScreenRow = @editorView.getLastVisibleScreenRow() - lastRow = @editor.getBuffer().getLastRow() - if lastScreenRow != lastRow - offset = Math.max(count - 1, @scrolloff) - else - offset = if count > 0 then count - 1 else count - lastScreenRow - offset - -class MoveToMiddleOfScreen extends MoveToScreenLine - getDestinationRow: (count) -> - firstScreenRow = @editorView.getFirstVisibleScreenRow() - lastScreenRow = @editorView.getLastVisibleScreenRow() - height = lastScreenRow - firstScreenRow - Math.floor(firstScreenRow + (height / 2)) - -module.exports = { - Motion, MotionWithInput, CurrentSelection, MoveLeft, MoveRight, MoveUp, MoveDown, - MoveToPreviousWord, MoveToPreviousWholeWord, MoveToNextWord, MoveToNextWholeWord, - MoveToEndOfWord, MoveToNextParagraph, MoveToPreviousParagraph, MoveToLine, MoveToBeginningOfLine, - MoveToFirstCharacterOfLineUp, MoveToFirstCharacterOfLineDown, - MoveToFirstCharacterOfLine, MoveToLastCharacterOfLine, MoveToStartOfFile, MoveToTopOfScreen, - MoveToBottomOfScreen, MoveToMiddleOfScreen, MoveToEndOfWholeWord, MotionError -} diff --git a/.atom/packages/vim-mode/lib/motions/index.coffee b/.atom/packages/vim-mode/lib/motions/index.coffee deleted file mode 100644 index 0dfe9d9..0000000 --- a/.atom/packages/vim-mode/lib/motions/index.coffee +++ /dev/null @@ -1,13 +0,0 @@ -Motions = require './general-motions' -{Search, SearchCurrentWord, BracketMatchingMotion} = require './search-motion' -MoveToMark = require './move-to-mark-motion' -{Find, Till} = require './find-motion' - -Motions.Search = Search -Motions.SearchCurrentWord = SearchCurrentWord -Motions.BracketMatchingMotion = BracketMatchingMotion -Motions.MoveToMark = MoveToMark -Motions.Find = Find -Motions.Till = Till - -module.exports = Motions diff --git a/.atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee b/.atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee deleted file mode 100644 index f04c581..0000000 --- a/.atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee +++ /dev/null @@ -1,40 +0,0 @@ -{MotionWithInput} = require './general-motions' -{ViewModel} = require '../view-models/view-model' -{Point, Range} = require 'atom' - -module.exports = -class MoveToMark extends MotionWithInput - constructor: (@editorView, @vimState, @linewise=true) -> - super(@editorView, @vimState) - @viewModel = new ViewModel(@, class: 'move-to-mark', singleChar: true, hidden: true) - - isLinewise: -> @linewise - - execute: -> - markPosition = @vimState.getMark(@input.characters) - - if @input.characters == '`' # double '`' pressed - markPosition ?= [0, 0] # if markPosition not set, go to the beginning of the file - @vimState.setMark('`', @editorView.editor.getCursorBufferPosition()) - - @editor.setCursorBufferPosition(markPosition) if markPosition? - if @linewise - @editorView.trigger 'vim-mode:move-to-first-character-of-line' - - select: (count=1, {requireEOL}={}) -> - markPosition = @vimState.getMark(@input.characters) - return [false] unless markPosition? - currentPosition = @editor.getCursorBufferPosition() - selectionRange = null - if currentPosition.isGreaterThan(markPosition) - if @linewise - currentPosition = @editor.clipBufferPosition([currentPosition.row, Infinity]) - markPosition = new Point(markPosition.row, 0) - selectionRange = new Range(markPosition, currentPosition) - else - if @linewise - markPosition = @editor.clipBufferPosition([markPosition.row, Infinity]) - currentPosition = new Point(currentPosition.row, 0) - selectionRange = new Range(currentPosition, markPosition) - @editor.setSelectedBufferRange(selectionRange, requireEOL: requireEOL) - [true] diff --git a/.atom/packages/vim-mode/lib/motions/search-motion.coffee b/.atom/packages/vim-mode/lib/motions/search-motion.coffee deleted file mode 100644 index d40a5e8..0000000 --- a/.atom/packages/vim-mode/lib/motions/search-motion.coffee +++ /dev/null @@ -1,279 +0,0 @@ -_ = require 'underscore-plus' -{MotionWithInput} = require './general-motions' -SearchViewModel = require '../view-models/search-view-model' -{Input} = require '../view-models/view-model' -{$$, Point, Range} = require 'atom' - -class SearchBase extends MotionWithInput - @currentSearch: null - constructor: (@editorView, @vimState) -> - super(@editorView, @vimState) - Search.currentSearch = @ - @reverse = @initiallyReversed = false - - repeat: (opts = {}) => - reverse = opts.backwards - if @initiallyReversed and reverse - @reverse = false - else - @reverse = reverse or @initiallyReversed - @ - - reversed: => - @initiallyReversed = @reverse = true - @ - - execute: (count=1) -> - @scan() - @match count, (pos) => - @editor.setCursorBufferPosition(pos.range.start) - - select: (count=1) -> - @scan() - selectionStart = @getSelectionStart() - @match count, (pos) => - reversed = selectionStart.compare(pos.range.start) > 0 - @editor.setSelectedBufferRange([selectionStart, pos.range.start], {reversed}) - [true] - - getSelectionStart: -> - cur = @editor.getCursorBufferPosition() - {start, end} = @editor.getSelectedBufferRange() - if start.compare(cur) is 0 then end else start - - match: (count, callback) -> - pos = @matches[(count - 1) % @matches.length] - if pos? - callback(pos) - else - atom.beep() - - scan: -> - term = @input.characters - regexp = - try - new RegExp(term, 'g') - catch - new RegExp(_.escapeRegExp(term), 'g') - - cur = @editor.getCursorBufferPosition() - matchPoints = [] - iterator = (item) => - matchPointItem = - range: item.range - matchPoints.push(matchPointItem) - - @editor.scan(regexp, iterator) - - previous = _.filter matchPoints, (point) => - if @reverse - point.range.start.compare(cur) < 0 - else - point.range.start.compare(cur) <= 0 - - after = _.difference(matchPoints, previous) - after.push(previous...) - after = after.reverse() if @reverse - - @matches = after - -class Search extends SearchBase - constructor: (@editorView, @vimState) -> - super(@editorView, @vimState) - @viewModel = new SearchViewModel(@) - Search.currentSearch = @ - @reverse = @initiallyReversed = false - - compose: (input) -> - super(input) - @viewModel.value = @input.characters - -class SearchCurrentWord extends SearchBase - @keywordRegex: null - constructor: (@editorView, @vimState) -> - super(@editorView, @vimState) - Search.currentSearch = @ - @reverse = @initiallyReversed = false - - # FIXME: This must depend on the current language - defaultIsKeyword = "[@a-zA-Z0-9_\-]+" - userIsKeyword = atom.config.get('vim-mode.iskeyword') - @keywordRegex = new RegExp(userIsKeyword or defaultIsKeyword) - - @input = new Input(@getCurrentWordMatch()) - - getCurrentWord: (onRecursion=false) -> - cursor = @editor.getCursor() - wordRange = cursor.getCurrentWordBufferRange(wordRegex: @keywordRegex) - characters = @editor.getTextInBufferRange(wordRange) - - # We are not standing on top of a word, let's try to - # get to the next word and try again - if characters.length is 0 and not onRecursion - if @cursorIsOnEOF() - "" - else - cursor.moveToNextWordBoundary(wordRegex: @keywordRegex) - @getCurrentWord(true) - else - characters - - cursorIsOnEOF: -> - cursor = @editor.getCursor() - pos = cursor.getMoveNextWordBoundaryBufferPosition(wordRegex: @keywordRegex) - eofPos = @editor.getEofBufferPosition() - pos.row == eofPos.row && pos.column == eofPos.column - - getCurrentWordMatch: -> - characters = @getCurrentWord() - if characters.length > 0 - if /\W/.test(characters) then "#{characters}\\b" else "\\b#{characters}\\b" - else - characters - - isComplete: -> true - - execute: (count=1) -> - super(count) if @input.characters.length > 0 - - -class BracketMatchingMotion extends SearchBase - @keywordRegex: null - constructor: (@editorView, @vimState) -> - super(@editorView, @vimState) - Search.currentSearch = @ - @reverse = @initiallyReversed = false - @characters = [')','(','}','{',']','['] - @charactersMatching = ['(',')','{','}','[',']'] - @reverseSearch = [true,false,true,false,true,false] - - # FIXME: This must depend on the current language - @input = new Input(@getCurrentWordMatch()) - - getCurrentWord: (onRecursion=false) -> - cursor = @editor.getCursor() - tempPoint = cursor.getBufferPosition().toArray() - @character = @editor.getTextInBufferRange([cursor.getBufferPosition(),new Point(tempPoint[0],tempPoint[1] + 1)]) - @startUp = false; - index = @characters.indexOf(@character) - if index >= 0 - @matching = @charactersMatching[index] - @reverse = @reverseSearch[index] - else - @startUp = true - - @character - - getCurrentWordMatch: -> - characters = @getCurrentWord() - characters - - isComplete: -> true - - searchFor:(character) -> - term = character - regexp = - new RegExp(_.escapeRegExp(term), 'g') - - cur = @editor.getCursorBufferPosition() - matchPoints = [] - iterator = (item) => - matchPointItem = - range: item.range - matchPoints.push(matchPointItem) - - @editor.scan(regexp, iterator) - - previous = _.filter matchPoints, (point) => - if @reverse - point.range.start.compare(cur) < 0 - else - point.range.start.compare(cur) <= 0 - - if @reverse - after = [] - after.push(previous...) - after = after.reverse() - else - after = _.difference(matchPoints, previous) - - matches = after - matches - - select: (count=1) -> - @scan() - - cur = if @startUp then @startUpPos else @editor.getCursorBufferPosition() - - @match count, (pos) => - if @reverse - tempPoint = cur.toArray() - @editor.setSelectedBufferRange([pos.range.start, new Point(tempPoint[0],tempPoint[1] + 1)], {reversed: true}) - else - tempPoint = pos.range.start.toArray() - @editor.setSelectedBufferRange([ cur, new Point(tempPoint[0],tempPoint[1] + 1)], {reversed: true}) - [true] - - scan: -> - if @startUp - @startUpPos = @editor.getCursorBufferPosition() - min = -1 - iwin = -1 - for i in [0..@characters.length - 1] - matchesCharacter = @searchFor(@characters[i]) - if matchesCharacter.length > 0 - dst = matchesCharacter[0].range.start.toArray() - if @startUpPos.toArray()[0] == dst[0] and @startUpPos.toArray()[1] < dst[1] - if dst[1] < min or min == -1 - line = dst[0] - min = dst[1] - iwin = i - if iwin != -1 - @editor.setCursorBufferPosition(new Point(line,min)) - @character = @characters[iwin] - @matching = @charactersMatching[iwin] - @reverse = @reverseSearch[iwin] - - matchesCharacter = @searchFor(@character) - matchesMatching = @searchFor(@matching) - if matchesMatching.length == 0 - @matches = [] - else - charIndex = 0; - matchIndex = 0; - counter = 1; - winner = -1 - if @reverse - compVal = 1 - else - compVal = -1 - while counter > 0 - if matchIndex < matchesMatching.length and charIndex < matchesCharacter.length - if matchesCharacter[charIndex].range.compare(matchesMatching[matchIndex].range) == compVal - counter = counter + 1 - charIndex = charIndex + 1 - else - counter = counter - 1 - winner = matchIndex - matchIndex = matchIndex + 1 - else if matchIndex < matchesMatching.length - counter = counter - 1 - winner = matchIndex - matchIndex = matchIndex + 1 - else - break - - retVal = [] - if counter == 0 - retVal.push(matchesMatching[winner]) - @matches = retVal - - if @matches.length == 0 and @startUp - @editor.setCursorBufferPosition(@startUpPos) - - - - execute: (count=1) -> - super(count) if @input.characters.length > 0 - -module.exports = {Search, SearchCurrentWord,BracketMatchingMotion} diff --git a/.atom/packages/vim-mode/lib/operators/general-operators.coffee b/.atom/packages/vim-mode/lib/operators/general-operators.coffee deleted file mode 100644 index ee05a75..0000000 --- a/.atom/packages/vim-mode/lib/operators/general-operators.coffee +++ /dev/null @@ -1,210 +0,0 @@ -_ = require 'underscore-plus' -{$$, Range} = require 'atom' -{ViewModel} = require '../view-models/view-model' - -class OperatorError - constructor: (@message) -> - @name = 'Operator Error' - -class Operator - vimState: null - motion: null - complete: null - selectOptions: null - - # selectOptions - The options object to pass through to the motion when - # selecting. - constructor: (@editor, @vimState, {@selectOptions}={}) -> - @complete = false - - # Public: Determines when the command can be executed. - # - # Returns true if ready to execute and false otherwise. - isComplete: -> @complete - - # Public: Determines if this command should be recorded in the command - # history for repeats. - # - # Returns true if this command should be recorded. - isRecordable: -> true - - # Public: Marks this as ready to execute and saves the motion. - # - # motion - The motion used to select what to operate on. - # - # Returns nothing. - compose: (motion) -> - if not motion.select - throw new OperatorError('Must compose with a motion') - - @motion = motion - @complete = true - - canComposeWith: (operation) -> operation.select? - - # Protected: Wraps the function within an single undo step. - # - # fn - The function to wrap. - # - # Returns nothing. - undoTransaction: (fn) -> - @editor.getBuffer().transact(fn) - -# Public: Generic class for an operator that requires extra input -class OperatorWithInput extends Operator - constructor: (@editorView, @vimState) -> - @editor = @editorView.editor - @complete = false - - canComposeWith: (operation) -> operation.characters? - - compose: (input) -> - if not input.characters - throw new OperatorError('Must compose with an Input') - - @input = input - @complete = true - -# -# It deletes everything selected by the following motion. -# -class Delete extends Operator - allowEOL: null - - # allowEOL - Determines whether the cursor should be allowed to rest on the - # end of line character or not. - constructor: (@editor, @vimState, {@allowEOL, @selectOptions}={}) -> - @complete = false - @selectOptions ?= {} - @selectOptions.requireEOL ?= true - - # Public: Deletes the text selected by the given motion. - # - # count - The number of times to execute. - # - # Returns nothing. - execute: (count=1) -> - cursor = @editor.getCursor() - - if _.contains(@motion.select(count, @selectOptions), true) - validSelection = true - - if validSelection? - @editor.delete() - if !@allowEOL and cursor.isAtEndOfLine() and !@motion.isLinewise?() - @editor.moveCursorLeft() - - if @motion.isLinewise?() - @editor.setCursorScreenPosition([cursor.getScreenRow(), 0]) - - @vimState.activateCommandMode() -# -# It toggles the case of everything selected by the following motion -# -class ToggleCase extends Operator - - constructor: (@editor, @vimState, {@selectOptions}={}) -> @complete = true - - execute: (count=1) -> - pos = @editor.getCursorBufferPosition() - lastCharIndex = @editor.lineLengthForBufferRow(pos.row) - 1 - count = Math.min count, @editor.lineLengthForBufferRow(pos.row) - pos.column - - # Do nothing on an empty line - return if @editor.getBuffer().isRowBlank(pos.row) - - @undoTransaction => - _.times count, => - point = @editor.getCursorBufferPosition() - range = Range.fromPointWithDelta(point, 0, 1) - char = @editor.getTextInBufferRange(range) - - if char is char.toLowerCase() - @editor.setTextInBufferRange(range, char.toUpperCase()) - else - @editor.setTextInBufferRange(range, char.toLowerCase()) - - unless point.column >= lastCharIndex - @editor.moveCursorRight() - - @vimState.activateCommandMode() - -# -# It copies everything selected by the following motion. -# -class Yank extends Operator - register: '"' - - # Public: Copies the text selected by the given motion. - # - # count - The number of times to execute. - # - # Returns nothing. - execute: (count=1) -> - originalPosition = @editor.getCursorScreenPosition() - - if _.contains(@motion.select(count), true) - text = @editor.getSelection().getText() - else - text = '' - type = if @motion.isLinewise?() then 'linewise' else 'character' - - @vimState.setRegister(@register, {text, type}) - - if @motion.isLinewise?() - @editor.setCursorScreenPosition(originalPosition) - else - @editor.clearSelections() - - @vimState.activateCommandMode() - -# -# It combines the current line with the following line. -# -class Join extends Operator - constructor: (@editor, @vimState, {@selectOptions}={}) -> @complete = true - - # Public: Combines the current with the following lines - # - # count - The number of times to execute. - # - # Returns nothing. - execute: (count=1) -> - @undoTransaction => - _.times count, => - @editor.joinLines() - @vimState.activateCommandMode() - -# -# Repeat the last operation -# -class Repeat extends Operator - constructor: (@editor, @vimState, {@selectOptions}={}) -> @complete = true - - isRecordable: -> false - - execute: (count=1) -> - @undoTransaction => - _.times count, => - cmd = @vimState.history[0] - cmd?.execute() -# -# It creates a mark at the current cursor position -# -class Mark extends OperatorWithInput - constructor: (@editorView, @vimState, {@selectOptions}={}) -> - super(@editorView, @vimState) - @viewModel = new ViewModel(@, class: 'mark', singleChar: true, hidden: true) - - # Public: Creates the mark in the specified mark register (from user input) - # at the current position - # - # Returns nothing. - execute: () -> - @vimState.setMark(@input.characters, @editorView.editor.getCursorBufferPosition()) - @vimState.activateCommandMode() - -module.exports = { - Operator, OperatorWithInput, OperatorError, Delete, ToggleCase, - Yank, Join, Repeat, Mark -} diff --git a/.atom/packages/vim-mode/lib/operators/indent-operators.coffee b/.atom/packages/vim-mode/lib/operators/indent-operators.coffee deleted file mode 100644 index 08540cb..0000000 --- a/.atom/packages/vim-mode/lib/operators/indent-operators.coffee +++ /dev/null @@ -1,61 +0,0 @@ -{Operator} = require './general-operators' -# -# It indents everything selected by the following motion. -# -class Indent extends Operator - # Public: Indents the text selected by the given motion. - # - # count - The number of times to execute. - # - # Returns nothing. - execute: (count=1) -> - @indent(count) - @vimState.activateCommandMode() - - # Protected: Indents or outdents the text selected by the given motion. - # - # count - The number of times to execute. - # direction - Either 'indent' or 'outdent' - # - # Returns nothing. - indent: (count, direction='indent') -> - row = @editor.getCursorScreenRow() - - @motion.select(count) - if direction == 'indent' - @editor.indentSelectedRows() - else if direction == 'outdent' - @editor.outdentSelectedRows() - else if direction == 'auto' - @editor.autoIndentSelectedRows() - - @editor.setCursorScreenPosition([row, 0]) - @editor.moveCursorToFirstCharacterOfLine() - -# -# It outdents everything selected by the following motion. -# -class Outdent extends Indent - # Public: Indents the text selected by the given motion. - # - # count - The number of times to execute. - # - # Returns nothing. - execute: (count=1) -> - @indent(count, 'outdent') - @vimState.activateCommandMode() - -# -# It autoindents everything selected by the following motion. -# -class Autoindent extends Indent - # Public: Autoindents the text selected by the given motion. - # - # count - The number of times to execute. - # - # Returns nothing. - execute: (count=1) -> - @indent(count, 'auto') - @vimState.activateCommandMode() - -module.exports = {Indent, Outdent, Autoindent} diff --git a/.atom/packages/vim-mode/lib/operators/index.coffee b/.atom/packages/vim-mode/lib/operators/index.coffee deleted file mode 100644 index 95ef875..0000000 --- a/.atom/packages/vim-mode/lib/operators/index.coffee +++ /dev/null @@ -1,12 +0,0 @@ -_ = require 'underscore-plus' -IndentOperators = require './indent-operators' -Put = require './put-operator' -InputOperators = require './input' -Replace = require './replace-operator' -Operators = require './general-operators' - -Operators.Put = Put; -Operators.Replace = Replace; -_.extend(Operators, IndentOperators) -_.extend(Operators, InputOperators) -module.exports = Operators diff --git a/.atom/packages/vim-mode/lib/operators/input.coffee b/.atom/packages/vim-mode/lib/operators/input.coffee deleted file mode 100644 index 685651c..0000000 --- a/.atom/packages/vim-mode/lib/operators/input.coffee +++ /dev/null @@ -1,161 +0,0 @@ -{Operator, Delete} = require './general-operators' -_ = require 'underscore-plus' - -# The operation for text entered in input mode. Broadly speaking, input -# operators manage an undo transaction and set a @typingCompleted variable when -# it's done. When the input operation is completed, the typingCompleted variable -# tells the operation to repeat itself instead of enter insert mode. -class Insert extends Operator - standalone: true - - isComplete: -> @standalone || super - - confirmTransaction: (transaction) -> - bundler = new TransactionBundler(transaction) - @typedText = bundler.buildInsertText() - - execute: -> - if @typingCompleted - return unless @typedText? and @typedText.length > 0 - @undoTransaction => - @editor.getBuffer().insert(@editor.getCursorBufferPosition(), @typedText, true) - else - @vimState.activateInsertMode() - @typingCompleted = true - - inputOperator: -> true - -class InsertAfter extends Insert - execute: -> - @editor.moveCursorRight() unless @editor.getCursor().isAtEndOfLine() - super - -class InsertAboveWithNewline extends Insert - execute: (count=1) -> - @editor.beginTransaction() unless @typingCompleted - @editor.insertNewlineAbove() - @editor.getCursor().skipLeadingWhitespace() - - if @typingCompleted - # We'll have captured the inserted newline, but we want to do that - # over again by hand, or differing indentations will be wrong. - @typedText = @typedText.trimLeft() - return super - - @vimState.activateInsertMode(transactionStarted = true) - @typingCompleted = true - -class InsertBelowWithNewline extends Insert - execute: (count=1) -> - @editor.beginTransaction() unless @typingCompleted - @editor.insertNewlineBelow() - @editor.getCursor().skipLeadingWhitespace() - - if @typingCompleted - # We'll have captured the inserted newline, but we want to do that - # over again by hand, or differing indentations will be wrong. - @typedText = @typedText.trimLeft() - return super - - @vimState.activateInsertMode(transactionStarted = true) - @typingCompleted = true - -# -# Delete the following motion and enter insert mode to replace it. -# -class Change extends Insert - standalone: false - - # Public: Changes the text selected by the given motion. - # - # count - The number of times to execute. - # - # Returns nothing. - execute: (count=1) -> - # If we've typed, we're being repeated. If we're being repeated, - # undo transactions are already handled. - @editor.beginTransaction() unless @typingCompleted - operator = new Delete(@editor, @vimState, allowEOL: true, selectOptions: {excludeWhitespace: true}) - operator.compose(@motion) - - lastRow = @onLastRow() - onlyRow = @editor.getBuffer().getLineCount() is 1 - operator.execute(count) - if @motion.isLinewise?() and not onlyRow - if lastRow - @editor.insertNewlineBelow() - else - @editor.insertNewlineAbove() - - return super if @typingCompleted - - @vimState.activateInsertMode(transactionStarted = true) - @typingCompleted = true - - onLastRow: -> - {row, column} = @editor.getCursorBufferPosition() - row is @editor.getBuffer().getLastRow() - -class Substitute extends Insert - execute: (count=1) -> - @editor.beginTransaction() unless @typingCompleted - _.times count, => - @editor.selectRight() - @editor.delete() - - if @typingCompleted - @typedText = @typedText.trimLeft() - return super - - @vimState.activateInsertMode(transactionStarated = true) - @typingCompleted = true - -class SubstituteLine extends Insert - execute: (count=1) -> - @editor.beginTransaction() unless @typingCompleted - @editor.moveCursorToBeginningOfLine() - _.times count, => - @editor.selectDown() - @editor.delete() - @editor.insertNewlineAbove() - @editor.getCursor().skipLeadingWhitespace() - - if @typingCompleted - @typedText = @typedText.trimLeft() - return super - - @vimState.activateInsertMode(transactionStarated = true) - @typingCompleted = true - -# Takes a transaction and turns it into a string of what was typed. -# This class is an implementation detail of Insert -class TransactionBundler - constructor: (@transaction) -> - - buildInsertText: -> - return "" unless @transaction.patches - chars = [] - for patch in @transaction.patches - switch - when @isTypedChar(patch) then chars.push(@isTypedChar(patch)) - when @isBackspacedChar(patch) then chars.pop() - chars.join("") - - isTypedChar: (patch) -> - # Technically speaking, a typed char will be of length 1, but >= 1 - # happens to let us test with editor.setText, so we'll look the other way. - return false unless patch.newText?.length >= 1 and patch.oldText?.length == 0 - patch.newText - - isBackspacedChar: (patch) -> - patch.newText == "" and patch.oldText?.length == 1 - -module.exports = { - Insert, - InsertAfter, - InsertAboveWithNewline, - InsertBelowWithNewline, - Change, - Substitute, - SubstituteLine -} diff --git a/.atom/packages/vim-mode/lib/operators/put-operator.coffee b/.atom/packages/vim-mode/lib/operators/put-operator.coffee deleted file mode 100644 index 1328073..0000000 --- a/.atom/packages/vim-mode/lib/operators/put-operator.coffee +++ /dev/null @@ -1,69 +0,0 @@ -_ = require 'underscore-plus' -{Operator} = require './general-operators' - -module.exports = -# -# It pastes everything contained within the specifed register -# -class Put extends Operator - register: '"' - - constructor: (@editor, @vimState, {@location, @selectOptions}={}) -> - @location ?= 'after' - @complete = true - - # Public: Pastes the text in the given register. - # - # count - The number of times to execute. - # - # Returns nothing. - execute: (count=1) -> - {text, type} = @vimState.getRegister(@register) || {} - return unless text - - textToInsert = _.times(count, -> text).join('') - - # Clean up some corner cases on the last line of the file - if type == 'linewise' - textToInsert = textToInsert.replace(/\n$/, '') - if @location == 'after' and @onLastRow() - textToInsert = "\n#{textToInsert}" - else - textToInsert = "#{textToInsert}\n" - - if @location == 'after' - if type == 'linewise' - if @onLastRow() - @editor.moveCursorToEndOfLine() - - originalPosition = @editor.getCursorScreenPosition() - originalPosition.row += 1 - else - @editor.moveCursorDown() - else - unless @onLastColumn() - @editor.moveCursorRight() - - if type == 'linewise' and !originalPosition? - @editor.moveCursorToBeginningOfLine() - originalPosition = @editor.getCursorScreenPosition() - - @editor.insertText(textToInsert) - - if originalPosition? - @editor.setCursorScreenPosition(originalPosition) - @editor.moveCursorToFirstCharacterOfLine() - - @vimState.activateCommandMode() - if type != 'linewise' - @editor.moveCursorLeft() - - # Private: Helper to determine if the editor is currently on the last row. - # - # Returns true on the last row and false otherwise. - onLastRow: -> - {row, column} = @editor.getCursorBufferPosition() - row == @editor.getBuffer().getLastRow() - - onLastColumn: -> - @editor.getCursor().isAtEndOfLine() diff --git a/.atom/packages/vim-mode/lib/operators/replace-operator.coffee b/.atom/packages/vim-mode/lib/operators/replace-operator.coffee deleted file mode 100644 index 5a0d70c..0000000 --- a/.atom/packages/vim-mode/lib/operators/replace-operator.coffee +++ /dev/null @@ -1,29 +0,0 @@ -_ = require 'underscore-plus' -{OperatorWithInput} = require './general-operators' -{ViewModel} = require '../view-models/view-model' -{Range} = require 'atom' - -module.exports = -class Replace extends OperatorWithInput - constructor: (@editorView, @vimState, {@selectOptions}={}) -> - super(@editorView, @vimState) - @viewModel = new ViewModel(@, class: 'replace', hidden: true, singleChar: true) - - execute: (count=1) -> - pos = @editor.getCursorBufferPosition() - currentRowLength = @editor.lineLengthForBufferRow(pos.row) - - # Do nothing on an empty line - return unless currentRowLength > 0 - # Do nothing if asked to replace more characters than there are on a line - return unless currentRowLength - pos.column >= count - - @undoTransaction => - start = @editor.getCursorBufferPosition() - _.times count, => - point = @editor.getCursorBufferPosition() - @editor.setTextInBufferRange(Range.fromPointWithDelta(point, 0, 1), @input.characters) - @editor.moveCursorRight() - @editor.setCursorBufferPosition(start) - - @vimState.activateCommandMode() diff --git a/.atom/packages/vim-mode/lib/panes.coffee b/.atom/packages/vim-mode/lib/panes.coffee deleted file mode 100644 index cad6a7b..0000000 --- a/.atom/packages/vim-mode/lib/panes.coffee +++ /dev/null @@ -1,39 +0,0 @@ -class FocusAction - constructor: -> - isComplete: -> true - isRecordable: -> false - - focusCursor: -> - editor = atom.workspaceView.getActivePaneItem() - editorView = atom.workspaceView.getActiveView() - if editor? and editorView? - cursorPosition = editor.getCursorBufferPosition() - editorView.scrollToBufferPosition(cursorPosition) - -class FocusPaneViewOnLeft extends FocusAction - execute: -> - atom.workspaceView.focusPaneViewOnLeft() - @focusCursor() - -class FocusPaneViewOnRight extends FocusAction - execute: -> - atom.workspaceView.focusPaneViewOnRight() - @focusCursor() - -class FocusPaneViewAbove extends FocusAction - execute: -> - atom.workspaceView.focusPaneViewAbove() - @focusCursor() - -class FocusPaneViewBelow extends FocusAction - execute: -> - atom.workspaceView.focusPaneViewBelow() - @focusCursor() - -class FocusPreviousPaneView extends FocusAction - execute: -> - atom.workspaceView.focusPreviousPaneView() - @focusCursor() - -module.exports = { FocusPaneViewOnLeft, FocusPaneViewOnRight, - FocusPaneViewAbove, FocusPaneViewBelow, FocusPreviousPaneView } diff --git a/.atom/packages/vim-mode/lib/prefixes.coffee b/.atom/packages/vim-mode/lib/prefixes.coffee deleted file mode 100644 index d6f44ca..0000000 --- a/.atom/packages/vim-mode/lib/prefixes.coffee +++ /dev/null @@ -1,65 +0,0 @@ -class Prefix - complete: null - composedObject: null - - isComplete: -> @complete - - isRecordable: -> @composedObject.isRecordable() - - # Public: Marks this as complete upon receiving an object to compose with. - # - # composedObject - The next motion or operator. - # - # Returns nothing. - compose: (@composedObject) -> - @complete = true - - # Public: Executes the composed operator or motion. - # - # Returns nothing. - execute: -> - @composedObject.execute?(@count) - - # Public: Selects using the composed motion. - # - # Returns an array of booleans representing whether each selections' success. - select: -> - @composedObject.select?(@count) - -# -# Used to track the number of times either a motion or operator should -# be repeated. -# -class Repeat extends Prefix - count: null - - # count - The initial digit of the repeat sequence. - constructor: (@count) -> @complete = false - - # Public: Adds an additional digit to this repeat sequence. - # - # digit - A single digit, 0-9. - # - # Returns nothing. - addDigit: (digit) -> - @count = @count * 10 + digit - -# -# Used to track which register the following operator should operate on. -# -class Register extends Prefix - name: null - - # name - The single character name of the desired register - constructor: (@name) -> @complete = false - - # Public: Marks as complete and sets the operator's register if it accepts it. - # - # composedOperator - The operator this register pertains to. - # - # Returns nothing. - compose: (composedObject) -> - super(composedObject) - composedObject.register = @name if composedObject.register? - -module.exports = { Repeat, Register} diff --git a/.atom/packages/vim-mode/lib/scroll.coffee b/.atom/packages/vim-mode/lib/scroll.coffee deleted file mode 100644 index d192d3e..0000000 --- a/.atom/packages/vim-mode/lib/scroll.coffee +++ /dev/null @@ -1,37 +0,0 @@ -class Scroll - isComplete: -> true - isRecordable: -> false - constructor: (@editorView, @editor) -> - @scrolloff = 2 # atom default - -class ScrollDown extends Scroll - execute: (count=1) -> - @keepCursorOnScreen(count) - @scrollUp(count) - - keepCursorOnScreen: (count) -> - {row, column} = @editor.getCursorScreenPosition() - firstScreenRow = @editorView.getFirstVisibleScreenRow() + @scrolloff + 1 - if row - count <= firstScreenRow - @editor.setCursorScreenPosition([firstScreenRow + count, column]) - - scrollUp: (count) -> - lastScreenRow = @editorView.getLastVisibleScreenRow() - @scrolloff - @editorView.scrollToScreenPosition([lastScreenRow + count, 0]) - -class ScrollUp extends Scroll - execute: (count=1) -> - @keepCursorOnScreen(count) - @scrollDown(count) - - keepCursorOnScreen: (count) -> - {row, column} = @editor.getCursorScreenPosition() - lastScreenRow = @editorView.getLastVisibleScreenRow() - @scrolloff - 1 - if row + count >= lastScreenRow - @editor.setCursorScreenPosition([lastScreenRow - count, column]) - - scrollDown: (count) -> - firstScreenRow = @editorView.getFirstVisibleScreenRow() + @scrolloff - @editorView.scrollToScreenPosition([firstScreenRow - count, 0]) - -module.exports = { ScrollDown, ScrollUp } diff --git a/.atom/packages/vim-mode/lib/text-objects.coffee b/.atom/packages/vim-mode/lib/text-objects.coffee deleted file mode 100644 index 300b239..0000000 --- a/.atom/packages/vim-mode/lib/text-objects.coffee +++ /dev/null @@ -1,109 +0,0 @@ -class TextObject - constructor: (@editor, @state) -> - - isComplete: -> true - isRecordable: -> false - -class SelectInsideWord extends TextObject - select: -> - @editor.selectWord() - [true] - -# SelectInsideQuotes and the next class defined (SelectInsideBrackets) are -# almost-but-not-quite-repeated code. They are different because of the depth -# checks in the bracket matcher. - -class SelectInsideQuotes extends TextObject - constructor: (@editor, @char) -> - - findOpeningQuote: (pos) -> - pos = pos.copy() - while pos.row >= 0 - line = @editor.lineForBufferRow(pos.row) - pos.column = line.length - 1 if pos.column == -1 - while pos.column >= 0 - if line[pos.column] == @char - return pos if pos.column == 0 or line[pos.column - 1] != '\\' - -- pos.column - pos.column = -1 - -- pos.row - - findClosingQuote: (start) -> - end = start.copy() - escaping = false - - while end.row < @editor.getLineCount() - endLine = @editor.lineForBufferRow(end.row) - while end.column < endLine.length - if endLine[end.column] == '\\' - ++ end.column - else if endLine[end.column] == @char - @editor.expandSelectionsForward (selection) => - selection.cursor.setBufferPosition start - selection.selectToBufferPosition end - return {select:[true], end:end} - ++ end.column - end.column = 0 - ++ end.row - - {select:[false], end:end} - - select: -> - start = @findOpeningQuote(@editor.getCursorBufferPosition()) - return [false] unless start? - - ++ start.column # skip the opening quote - - {select,end} = @findClosingQuote(start) - select - -# SelectInsideBrackets and the previous class defined (SelectInsideQuotes) are -# almost-but-not-quite-repeated code. They are different because of the depth -# checks in the bracket matcher. - -class SelectInsideBrackets extends TextObject - constructor: (@editor, @beginChar, @endChar) -> - - findOpeningBracket: (pos) -> - pos = pos.copy() - depth = 0 - while pos.row >= 0 - line = @editor.lineForBufferRow(pos.row) - pos.column = line.length - 1 if pos.column == -1 - while pos.column >= 0 - switch line[pos.column] - when @endChar then ++ depth - when @beginChar - return pos if -- depth < 0 - -- pos.column - pos.column = -1 - -- pos.row - - findClosingBracket: (start) -> - end = start.copy() - depth = 0 - while end.row < @editor.getLineCount() - endLine = @editor.lineForBufferRow(end.row) - while end.column < endLine.length - switch endLine[end.column] - when @beginChar then ++ depth - when @endChar - if -- depth < 0 - @editor.expandSelectionsForward (selection) => - selection.cursor.setBufferPosition start - selection.selectToBufferPosition end - return {select:[true], end:end} - ++ end.column - end.column = 0 - ++ end.row - - {select:[false], end:end} - - select: -> - start = @findOpeningBracket(@editor.getCursorBufferPosition()) - return [false] unless start? - ++ start.column # skip the opening bracket - {select,end} = @findClosingBracket(start) - select - -module.exports = {TextObject, SelectInsideWord, SelectInsideQuotes, SelectInsideBrackets} diff --git a/.atom/packages/vim-mode/lib/utils.coffee b/.atom/packages/vim-mode/lib/utils.coffee deleted file mode 100644 index 22fd901..0000000 --- a/.atom/packages/vim-mode/lib/utils.coffee +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = - # Public: Determines if a string should be considered linewise or character - # - # text - The string to consider - # - # Returns 'linewise' if the string ends with a line return and 'character' - # otherwise. - copyType: (text) -> - if text.lastIndexOf("\n") == text.length - 1 - 'linewise' - else if text.lastIndexOf("\r") == text.length - 1 - 'linewise' - else - 'character' diff --git a/.atom/packages/vim-mode/lib/view-models/search-view-model.coffee b/.atom/packages/vim-mode/lib/view-models/search-view-model.coffee deleted file mode 100644 index 8602d69..0000000 --- a/.atom/packages/vim-mode/lib/view-models/search-view-model.coffee +++ /dev/null @@ -1,35 +0,0 @@ -_ = require 'underscore-plus' -{ViewModel} = require './view-model' - -module.exports = -class SearchViewModel extends ViewModel - constructor: (@searchMotion) -> - super(@searchMotion, class: 'search') - @historyIndex = -1 - - @view.editor.on('core:move-up', @increaseHistorySearch) - @view.editor.on('core:move-down', @decreaseHistorySearch) - - restoreHistory: (index) -> - @view.editor.setText(@history(index).value) - - history: (index) -> - @vimState.getSearchHistoryItem(index) - - increaseHistorySearch: => - if @history(@historyIndex + 1)? - @historyIndex += 1 - @restoreHistory(@historyIndex) - - decreaseHistorySearch: => - if @historyIndex <= 0 - # get us back to a clean slate - @historyIndex = -1 - @view.editor.setText('') - else - @historyIndex -= 1 - @restoreHistory(@historyIndex) - - confirm: (view) => - @vimState.pushSearchHistory(@) - super(view) diff --git a/.atom/packages/vim-mode/lib/view-models/view-model.coffee b/.atom/packages/vim-mode/lib/view-models/view-model.coffee deleted file mode 100644 index 69ad13c..0000000 --- a/.atom/packages/vim-mode/lib/view-models/view-model.coffee +++ /dev/null @@ -1,66 +0,0 @@ -VimCommandModeInputView = require './vim-command-mode-input-view' - -# Public: Base class for all view models; a view model -# is the model attached to a VimCommandModeInputView -# which is used when a given operator, motion -# needs extra keystroke. -# -# Ivars: -# -# @completionCommand - if set will automatically be triggered on the editorView -# when the `confirm` method is called on the view model -# -# @value - automatically set to the value of typed into the `VimCommandModeInputView` -# when the `confirm` method is called -# -class ViewModel - # Public: Override this in subclasses for custom initialization - # - # operator - An operator, motion, prefix, etc with `@editorView` and `@state` set - # - # opts - the options to be passed to `VimCommandModeInputView`. Possible options are: - # - # - class {String} - the class of the view to be added to the bottom of the screen - # - # - hidden {Boolean} - tells the view whether or not it should be hidden - # - # - singleChar {Boolean} - tells the view whether it should only listen for a single - # character or an entire string - constructor: (@operation, opts={}) -> - @editorView = @operation.editorView - @vimState = @operation.vimState - - @view = new VimCommandModeInputView(@, opts) - @editorView.editor.commandModeInputView = @view - # when the opStack is prematurely cleared we need to remove the view - @editorView.on 'vim-mode:compose-failure', => @view.remove() - - # Public: Overriding this isn't usually necessary in subclasses, this pushes another operation - # to the `opStack` in `vim-stack.coffee` which causes the opStack to collapse and - # call execute/select on the parent operation - # - # view - the `VimCommandModeInputView` that called this method - # - # Returns nothing. - confirm: (view) -> - @vimState.pushOperations(new Input(@view.value)) - - # Public: Overriding this isn't usually necessary in subclasses, this pushes an empty operation - # to the `opStack` in `vim-stack.coffee` which causes the opStack to collapse and - # call execute/select on the parent operation - # - # view - the `VimCommandModeInputView` that called this method - # - # Returns nothing. - cancel: (view) -> - if @vimState.isOperatorPending() - @vimState.pushOperations(new Input('')) - -class Input - constructor: (@characters) -> - isComplete: -> true - isRecordable: -> true - -module.exports = { - ViewModel, Input -} diff --git a/.atom/packages/vim-mode/lib/view-models/vim-command-mode-input-view.coffee b/.atom/packages/vim-mode/lib/view-models/vim-command-mode-input-view.coffee deleted file mode 100644 index 3f07efe..0000000 --- a/.atom/packages/vim-mode/lib/view-models/vim-command-mode-input-view.coffee +++ /dev/null @@ -1,72 +0,0 @@ -{View, EditorView} = require 'atom' - -module.exports = - -class VimCommandModeInputView extends View - @content: -> - @div class: 'command-mode-input', => - @div class: 'editor-container', outlet: 'editorContainer', => - @subview 'editor', new EditorView(mini: true) - - initialize: (@viewModel, opts = {})-> - @editor.setFontSize(atom.config.get('vim-mode.commandModeInputViewFontSize')) - - if opts.class? - @editorContainer.addClass opts.class - - if opts.hidden? - @editorContainer.addClass 'hidden-input' - - if opts.singleChar? - @singleChar = true - - unless atom.workspaceView? - # We're in test mode. Don't append to anything, just initialize. - @focus() - @handleEvents() - return - - statusBar = atom.workspaceView.find('.status-bar') - - if statusBar.length > 0 - @.insertBefore(statusBar) - else - atom.workspace.getActivePane().append(@) - - @focus() - @handleEvents() - - handleEvents: -> - if @singleChar? - @editor.find('input').on 'textInput', @autosubmit - @editor.on 'core:confirm', @confirm - @editor.on 'core:cancel', @cancel - @editor.find('input').on 'blur', @cancel - - stopHandlingEvents: -> - if @singleChar? - @editor.find('input').off 'textInput', @autosubmit - @editor.off 'core:confirm', @confirm - @editor.off 'core:cancel', @cancel - @editor.find('input').off 'blur', @cancel - - autosubmit: (event) => - @editor.setText(event.originalEvent.data) - @confirm() - - confirm: => - @value = @editor.getText() - @viewModel.confirm(@) - @remove() - - focus: => - @editorContainer.find('.editor').focus() - - cancel: (e) => - @viewModel.cancel(@) - @remove() - - remove: => - @stopHandlingEvents() - atom.workspaceView.focus() if atom.workspaceView? - super() diff --git a/.atom/packages/vim-mode/lib/vim-mode.coffee b/.atom/packages/vim-mode/lib/vim-mode.coffee deleted file mode 100644 index 69b1a6f..0000000 --- a/.atom/packages/vim-mode/lib/vim-mode.coffee +++ /dev/null @@ -1,24 +0,0 @@ -VimState = require './vim-state' - -module.exports = - configDefaults: - 'commandModeInputViewFontSize': 11 - 'startInInsertMode': false - - _initializeWorkspaceState: -> - atom.workspace.vimState ||= {} - atom.workspace.vimState.registers ||= {} - atom.workspace.vimState.searchHistory ||= [] - - activate: (state) -> - @_initializeWorkspaceState() - atom.workspaceView.eachEditorView (editorView) => - return unless editorView.attached - return if editorView.mini - - editorView.addClass('vim-mode') - editorView.vimState = new VimState(editorView) - - deactivate: -> - atom.workspaceView?.eachEditorView (editorView) => - editorView.off('.vim-mode') diff --git a/.atom/packages/vim-mode/lib/vim-state.coffee b/.atom/packages/vim-mode/lib/vim-state.coffee deleted file mode 100644 index a4129dd..0000000 --- a/.atom/packages/vim-mode/lib/vim-state.coffee +++ /dev/null @@ -1,520 +0,0 @@ -_ = require 'underscore-plus' -{$} = require 'atom' - -Operators = require './operators/index' -Prefixes = require './prefixes' -Motions = require './motions/index' - -TextObjects = require './text-objects' -Utils = require './utils' -Panes = require './panes' -Scroll = require './scroll' -{$$, Point, Range} = require 'atom' -Marker = require 'atom' - -module.exports = -class VimState - editor: null - opStack: null - mode: null - submode: null - - constructor: (@editorView) -> - @editor = @editorView.editor - @opStack = [] - @history = [] - @marks = {} - @desiredCursorColumn = null - params = {} - params.manager = this; - params.id = 0; - - @setupCommandMode() - @editorView.setInputEnabled?(false) - @registerInsertIntercept() - @registerInsertTransactionResets() - @registerUndoIntercept() - if atom.config.get 'vim-mode.startInInsertMode' - @activateInsertMode() - else - @activateCommandMode() - - atom.project.eachBuffer (buffer) => - @registerChangeHandler(buffer) - - # Private: Creates a handle to block insertion while in command mode. - # - # This is currently a bit of a hack. If a user is in command mode they - # won't be able to type in any of Atom's dialogs (such as the command - # palette). This also doesn't block non-printable characters such as - # backspace. - # - # There should probably be a better API on the editor to handle this - # but the requirements aren't clear yet, so this will have to suffice - # for now. - # - # Returns nothing. - registerInsertIntercept: -> - @editorView.preempt 'textInput', (e) => - return if $(e.currentTarget).hasClass('mini') - - if @mode == 'insert' - true - else - @clearOpStack() - false - - # Private: Intercept undo in insert mode. - # - # Undo in insert mode will blow up the previous transaction, but not - # put it into the redo stack anywhere correctly, as it hasn't been - # completed. As a workaround, we exit insert mode first and then - # bubble the event up - registerUndoIntercept: -> - @editorView.preempt 'core:undo', (e) => - return true unless @mode == 'insert' - @activateCommandMode() - return true - - # Private: Reset transactions on input for undo/redo/repeat on several - # core and vim-mode events - registerInsertTransactionResets: -> - events = [ 'core:move-up' - 'core:move-down' - 'core:move-right' - 'core:move-left' ] - @editorView.on events.join(' '), => - @resetInputTransactions() - - - # Private: Watches for any deletes on the current buffer and places it in the - # last deleted buffer. - # - # Returns nothing. - registerChangeHandler: (buffer) -> - buffer.on 'changed', ({newRange, newText, oldRange, oldText}) => - return unless @setRegister? - if newText == '' - @setRegister('"', text: oldText, type: Utils.copyType(oldText)) - - # Private: Creates the plugin's bindings - # - # Returns nothing. - setupCommandMode: -> - @registerCommands - 'activate-command-mode': => @activateCommandMode() - 'activate-linewise-visual-mode': => @activateVisualMode('linewise') - 'activate-characterwise-visual-mode': => @activateVisualMode('characterwise') - 'activate-blockwise-visual-mode': => @activateVisualMode('blockwise') - 'reset-command-mode': => @resetCommandMode() - 'repeat-prefix': (e) => @repeatPrefix(e) - - @registerOperationCommands - 'activate-insert-mode': => new Operators.Insert(@editor, @) - 'substitute': => new Operators.Substitute(@editor, @) - 'substitute-line': => new Operators.SubstituteLine(@editor, @) - 'insert-after': => new Operators.InsertAfter(@editor, @) - 'insert-after-end-of-line': => [new Motions.MoveToLastCharacterOfLine(@editor, @), new Operators.InsertAfter(@editor, @)] - 'insert-at-beginning-of-line': => [new Motions.MoveToFirstCharacterOfLine(@editor, @), new Operators.Insert(@editor, @)] - 'insert-above-with-newline': => new Operators.InsertAboveWithNewline(@editor, @) - 'insert-below-with-newline': => new Operators.InsertBelowWithNewline(@editor, @) - 'delete': => @linewiseAliasedOperator(Operators.Delete) - 'change': => @linewiseAliasedOperator(Operators.Change) - 'change-to-last-character-of-line': => [new Operators.Change(@editor, @), new Motions.MoveToLastCharacterOfLine(@editor, @)] - 'delete-right': => [new Operators.Delete(@editor, @), new Motions.MoveRight(@editor, @)] - 'delete-left': => [new Operators.Delete(@editor, @), new Motions.MoveLeft(@editor, @)] - 'delete-to-last-character-of-line': => [new Operators.Delete(@editor, @), new Motions.MoveToLastCharacterOfLine(@editor, @)] - 'toggle-case': => new Operators.ToggleCase(@editor, @) - 'yank': => @linewiseAliasedOperator(Operators.Yank) - 'yank-line': => [new Operators.Yank(@editor, @), new Motions.MoveToLine(@editor, @)] - 'put-before': => new Operators.Put(@editor, @, location: 'before') - 'put-after': => new Operators.Put(@editor, @, location: 'after') - 'join': => new Operators.Join(@editor, @) - 'indent': => @linewiseAliasedOperator(Operators.Indent) - 'outdent': => @linewiseAliasedOperator(Operators.Outdent) - 'auto-indent': => @linewiseAliasedOperator(Operators.Autoindent) - 'move-left': => new Motions.MoveLeft(@editor, @) - 'move-up': => new Motions.MoveUp(@editor, @) - 'move-down': => new Motions.MoveDown(@editor, @) - 'move-right': => new Motions.MoveRight(@editor, @) - 'move-to-next-word': => new Motions.MoveToNextWord(@editor, @) - 'move-to-next-whole-word': => new Motions.MoveToNextWholeWord(@editor, @) - 'move-to-end-of-word': => new Motions.MoveToEndOfWord(@editor, @) - 'move-to-end-of-whole-word': => new Motions.MoveToEndOfWholeWord(@editor, @) - 'move-to-previous-word': => new Motions.MoveToPreviousWord(@editor, @) - 'move-to-previous-whole-word': => new Motions.MoveToPreviousWholeWord(@editor, @) - 'move-to-next-paragraph': => new Motions.MoveToNextParagraph(@editor, @) - 'move-to-previous-paragraph': => new Motions.MoveToPreviousParagraph(@editor, @) - 'move-to-first-character-of-line': => new Motions.MoveToFirstCharacterOfLine(@editor, @) - 'move-to-last-character-of-line': => new Motions.MoveToLastCharacterOfLine(@editor, @) - 'move-to-beginning-of-line': (e) => @moveOrRepeat(e) - 'move-to-first-character-of-line-up': => new Motions.MoveToFirstCharacterOfLineUp(@editor, @) - 'move-to-first-character-of-line-down': => new Motions.MoveToFirstCharacterOfLineDown(@editor, @) - 'move-to-start-of-file': => new Motions.MoveToStartOfFile(@editor, @) - 'move-to-line': => new Motions.MoveToLine(@editor, @) - 'move-to-top-of-screen': => new Motions.MoveToTopOfScreen(@editor, @, @editorView) - 'move-to-bottom-of-screen': => new Motions.MoveToBottomOfScreen(@editor, @, @editorView) - 'move-to-middle-of-screen': => new Motions.MoveToMiddleOfScreen(@editor, @, @editorView) - 'scroll-down': => new Scroll.ScrollDown(@editorView, @editor) - 'scroll-up': => new Scroll.ScrollUp(@editorView, @editor) - 'select-inside-word': => new TextObjects.SelectInsideWord(@editor) - 'select-inside-double-quotes': => new TextObjects.SelectInsideQuotes(@editor, '"') - 'select-inside-single-quotes': => new TextObjects.SelectInsideQuotes(@editor, '\'') - 'select-inside-curly-brackets': => new TextObjects.SelectInsideBrackets(@editor, '{', '}') - 'select-inside-angle-brackets': => new TextObjects.SelectInsideBrackets(@editor, '<', '>') - 'select-inside-parentheses': => new TextObjects.SelectInsideBrackets(@editor, '(', ')') - 'register-prefix': (e) => @registerPrefix(e) - 'repeat': (e) => new Operators.Repeat(@editor, @) - 'repeat-search': (e) => currentSearch.repeat() if (currentSearch = Motions.Search.currentSearch)? - 'repeat-search-backwards': (e) => currentSearch.repeat(backwards: true) if (currentSearch = Motions.Search.currentSearch)? - 'focus-pane-view-on-left': => new Panes.FocusPaneViewOnLeft() - 'focus-pane-view-on-right': => new Panes.FocusPaneViewOnRight() - 'focus-pane-view-above': => new Panes.FocusPaneViewAbove() - 'focus-pane-view-below': => new Panes.FocusPaneViewBelow() - 'focus-previous-pane-view': => new Panes.FocusPreviousPaneView() - 'move-to-mark': (e) => new Motions.MoveToMark(@editorView, @) - 'move-to-mark-literal': (e) => new Motions.MoveToMark(@editorView, @, false) - 'mark': (e) => new Operators.Mark(@editorView, @) - 'find': (e) => new Motions.Find(@editorView, @) - 'find-backwards': (e) => new Motions.Find(@editorView, @).reverse() - 'till': (e) => new Motions.Till(@editorView, @) - 'till-backwards': (e) => new Motions.Till(@editorView, @).reverse() - 'replace': (e) => new Operators.Replace(@editorView, @) - 'search': (e) => new Motions.Search(@editorView, @) - 'reverse-search': (e) => (new Motions.Search(@editorView, @)).reversed() - 'search-current-word': (e) => new Motions.SearchCurrentWord(@editorView, @) - 'bracket-matching-motion': (e) => new Motions.BracketMatchingMotion(@editorView,@) - 'reverse-search-current-word': (e) => (new Motions.SearchCurrentWord(@editorView, @)).reversed() - - # Private: Register multiple command handlers via an {Object} that maps - # command names to command handler functions. - # - # Prefixes the given command names with 'vim-mode:' to reduce redundancy in - # the provided object. - registerCommands: (commands) -> - for commandName, fn of commands - do (fn) => - @editorView.command "vim-mode:#{commandName}.vim-mode", fn - - # Private: Register multiple Operators via an {Object} that - # maps command names to functions that return operations to push. - # - # Prefixes the given command names with 'vim-mode:' to reduce redundancy in - # the given object. - registerOperationCommands: (operationCommands) -> - commands = {} - for commandName, operationFn of operationCommands - do (operationFn) => - commands[commandName] = (event) => @pushOperations(operationFn(event)) - @registerCommands(commands) - - # Private: Push the given operations onto the operation stack, then process - # it. - pushOperations: (operations) -> - return unless operations? - operations = [operations] unless _.isArray(operations) - - for operation in operations - # Motions in visual mode perform their selections. - if @mode is 'visual' and (operation instanceof Motions.Motion or operation instanceof TextObjects.TextObject) - operation.execute = operation.select - - # if we have started an operation that responds to canComposeWith check if it can compose - # with the operation we're going to push onto the stack - if (topOp = @topOperation())? and topOp.canComposeWith? and not topOp.canComposeWith(operation) - @editorView.trigger 'vim-mode:compose-failure' - @resetCommandMode() - break - - @opStack.push(operation) - - # If we've received an operator in visual mode, mark the current - # selection as the motion to operate on. - if @mode is 'visual' and operation instanceof Operators.Operator - @opStack.push(new Motions.CurrentSelection(@editor, @)) - - @processOpStack() - - # Private: Removes all operations from the stack. - # - # Returns nothing. - clearOpStack: -> - @opStack = [] - - # Private: Processes the command if the last operation is complete. - # - # Returns nothing. - processOpStack: -> - unless @opStack.length > 0 - return - - unless @topOperation().isComplete() - if @mode is 'command' and @topOperation() instanceof Operators.Operator - @activateOperatorPendingMode() - return - - poppedOperation = @opStack.pop() - if @opStack.length - try - @topOperation().compose(poppedOperation) - @processOpStack() - catch e - ((e instanceof Operators.OperatorError) or (e instanceof Motions.MotionError)) and @resetCommandMode() or throw e - else - @history.unshift(poppedOperation) if poppedOperation.isRecordable() - poppedOperation.execute() - - # Private: Fetches the last operation. - # - # Returns the last operation. - topOperation: -> - _.last @opStack - - # Private: Fetches the value of a given register. - # - # name - The name of the register to fetch. - # - # Returns the value of the given register or undefined if it hasn't - # been set. - getRegister: (name) -> - if name in ['*', '+'] - text = atom.clipboard.read() - type = Utils.copyType(text) - {text, type} - else if name == '%' - text = @editor.getUri() - type = Utils.copyType(text) - {text, type} - else if name == "_" # Blackhole always returns nothing - text = '' - type = Utils.copyType(text) - {text, type} - else - atom.workspace.vimState.registers[name] - - # Private: Fetches the value of a given mark. - # - # name - The name of the mark to fetch. - # - # Returns the value of the given mark or undefined if it hasn't - # been set. - getMark: (name) -> - if @marks[name] - @marks[name].getBufferRange().start - else - undefined - - - # Private: Sets the value of a given register. - # - # name - The name of the register to fetch. - # value - The value to set the register to. - # - # Returns nothing. - setRegister: (name, value) -> - if name in ['*', '+'] - atom.clipboard.write(value.text) - else if name == '_' - # Blackhole register, nothing to do - else - atom.workspace.vimState.registers[name] = value - - # Private: Sets the value of a given mark. - # - # name - The name of the mark to fetch. - # pos {Point} - The value to set the mark to. - # - # Returns nothing. - setMark: (name, pos) -> - # check to make sure name is in [a-z] or is ` - if (charCode = name.charCodeAt(0)) >= 96 and charCode <= 122 - marker = @editor.markBufferRange(new Range(pos,pos),{invalidate:'never',persistent:false}) - @marks[name] = marker - - # Public: Append a search to the search history. - # - # Motions.Search - The confirmed search motion to append - # - # Returns nothing - pushSearchHistory: (search) -> - atom.workspace.vimState.searchHistory.unshift search - - # Public: Get the search history item at the given index. - # - # index - the index of the search history item - # - # Returns a search motion - getSearchHistoryItem: (index) -> - atom.workspace.vimState.searchHistory[index] - - resetInputTransactions: -> - return unless @mode == 'insert' && @history[0]?.inputOperator?() - @deactivateInsertMode() - @activateInsertMode() - - ############################################################################## - # Mode Switching - ############################################################################## - - # Private: Used to enable command mode. - # - # Returns nothing. - activateCommandMode: -> - @deactivateInsertMode() - @mode = 'command' - @submode = null - - if @editorView.is(".insert-mode") - cursor = @editor.getCursor() - cursor.moveLeft() unless cursor.isAtBeginningOfLine() - - @changeModeClass('command-mode') - - @clearOpStack() - @editor.clearSelections() - - @updateStatusBar() - - # Private: Used to enable insert mode. - # - # Returns nothing. - activateInsertMode: (transactionStarted = false)-> - @mode = 'insert' - @editorView.setInputEnabled?(true) - @editor.beginTransaction() unless transactionStarted - @submode = null - @changeModeClass('insert-mode') - @updateStatusBar() - - deactivateInsertMode: -> - return unless @mode == 'insert' - @editorView.setInputEnabled?(false) - @editor.commitTransaction() - transaction = _.last(@editor.buffer.history.undoStack) - item = @inputOperator(@history[0]) - if item? and transaction? - item.confirmTransaction(transaction) - - # Private: Get the input operator that needs to be told about about the - # typed undo transaction in a recently completed operation, if there - # is one. - inputOperator: (item) -> - return item unless item? - return item if item.inputOperator?() - return item.composedObject if item.composedObject?.inputOperator?() - - - # Private: Used to enable visual mode. - # - # type - One of 'characterwise', 'linewise' or 'blockwise' - # - # Returns nothing. - activateVisualMode: (type) -> - @deactivateInsertMode() - @mode = 'visual' - @submode = type - @changeModeClass('visual-mode') - - if @submode == 'linewise' - @editor.selectLine() - - @updateStatusBar() - - # Private: Used to enable operator-pending mode. - activateOperatorPendingMode: -> - @deactivateInsertMode() - @mode = 'operator-pending' - @submodule = null - @changeModeClass('operator-pending-mode') - - @updateStatusBar() - - changeModeClass: (targetMode) -> - for mode in ['command-mode', 'insert-mode', 'visual-mode', 'operator-pending-mode'] - if mode is targetMode - @editorView.addClass(mode) - else - @editorView.removeClass(mode) - - # Private: Resets the command mode back to it's initial state. - # - # Returns nothing. - resetCommandMode: -> - @activateCommandMode() - - # Private: A generic way to create a Register prefix based on the event. - # - # e - The event that triggered the Register prefix. - # - # Returns nothing. - registerPrefix: (e) -> - name = atom.keymap.keystrokeStringForEvent(e.originalEvent) - new Prefixes.Register(name) - - # Private: A generic way to create a Number prefix based on the event. - # - # e - The event that triggered the Number prefix. - # - # Returns nothing. - repeatPrefix: (e) -> - num = parseInt(atom.keymap.keystrokeStringForEvent(e.originalEvent)) - if @topOperation() instanceof Prefixes.Repeat - @topOperation().addDigit(num) - else - if num is 0 - e.abortKeyBinding() - else - @pushOperations(new Prefixes.Repeat(num)) - - # Private: Figure out whether or not we are in a repeat sequence or we just - # want to move to the beginning of the line. If we are within a repeat - # sequence, we pass control over to @repeatPrefix. - # - # e - The triggered event. - # - # Returns new motion or nothing. - moveOrRepeat: (e) -> - if @topOperation() instanceof Prefixes.Repeat - @repeatPrefix(e) - null - else - new Motions.MoveToBeginningOfLine(@editor, @) - - # Private: A generic way to handle Operators that can be repeated for - # their linewise form. - # - # constructor - The constructor of the operator. - # - # Returns nothing. - linewiseAliasedOperator: (constructor) -> - if @isOperatorPending(constructor) - new Motions.MoveToLine(@editor, @) - else - new constructor(@editor, @) - - # Private: Check if there is a pending operation of a certain type, or - # if there is any pending operation, if no type given. - # - # constructor - The constructor of the object type you're looking for. - # - isOperatorPending: (constructor) -> - if constructor? - for op in @opStack - return op if op instanceof constructor - false - else - @opStack.length > 0 - - updateStatusBar: -> - atom.packages.once 'activated', => - if !$('#status-bar-vim-mode').length - atom.workspaceView.statusBar?.prependRight("
Command
") - @updateStatusBar() - - @removeStatusBarClass() - switch @mode - when 'insert' then $('#status-bar-vim-mode').addClass('status-bar-vim-mode-insert').html("Insert") - when 'command' then $('#status-bar-vim-mode').addClass('status-bar-vim-mode-command').html("Command") - when 'visual' then $('#status-bar-vim-mode').addClass('status-bar-vim-mode-visual').html("Visual") - - removeStatusBarClass: -> $('#status-bar-vim-mode').removeClass('status-bar-vim-mode-insert status-bar-vim-mode-command status-bar-vim-mode-visual') diff --git a/.atom/packages/vim-mode/node_modules/underscore-plus/LICENSE.md b/.atom/packages/vim-mode/node_modules/underscore-plus/LICENSE.md deleted file mode 100644 index 493db50..0000000 --- a/.atom/packages/vim-mode/node_modules/underscore-plus/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2013 GitHub Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/vim-mode/node_modules/underscore-plus/README.md b/.atom/packages/vim-mode/node_modules/underscore-plus/README.md deleted file mode 100644 index dd7b4c0..0000000 --- a/.atom/packages/vim-mode/node_modules/underscore-plus/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# underscore-plus [![Build Status](https://travis-ci.org/atom/underscore-plus.svg?branch=master)](https://travis-ci.org/atom/underscore-plus) - -Takes the great [underscore](http://underscorejs.org/) library and adds a few -more things. - -## Using - -```sh -npm install underscore-plus -``` - -```coffeescript -_ = require 'underscore-plus' # Has all underscore methods and more -``` diff --git a/.atom/packages/vim-mode/node_modules/underscore-plus/lib/underscore-plus.js b/.atom/packages/vim-mode/node_modules/underscore-plus/lib/underscore-plus.js deleted file mode 100644 index f4b7391..0000000 --- a/.atom/packages/vim-mode/node_modules/underscore-plus/lib/underscore-plus.js +++ /dev/null @@ -1,498 +0,0 @@ -(function() { - var isEqual, macModifierKeyMap, nonMacModifierKeyMap, plus, shiftKeyMap, _, - __slice = [].slice; - - _ = require('underscore'); - - macModifierKeyMap = { - cmd: '\u2318', - ctrl: '\u2303', - alt: '\u2325', - option: '\u2325', - shift: '\u21e7', - enter: '\u23ce', - left: '\u2190', - right: '\u2192', - up: '\u2191', - down: '\u2193' - }; - - nonMacModifierKeyMap = { - cmd: 'Cmd', - ctrl: 'Ctrl', - alt: 'Alt', - option: 'Alt', - shift: 'Shift', - enter: 'Enter', - left: 'Left', - right: 'Right', - up: 'Up', - down: 'Down' - }; - - shiftKeyMap = { - '~': '`', - '_': '-', - '+': '=', - '|': '\\', - '{': '[', - '}': ']', - ':': ';', - '"': '\'', - '<': ',', - '>': '.', - '?': '/' - }; - - plus = { - adviseBefore: function(object, methodName, advice) { - var original; - original = object[methodName]; - return object[methodName] = function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - if (advice.apply(this, args) !== false) { - return original.apply(this, args); - } - }; - }, - camelize: function(string) { - if (string) { - return string.replace(/[_-]+(\w)/g, function(m) { - return m[1].toUpperCase(); - }); - } else { - return ''; - } - }, - capitalize: function(word) { - if (!word) { - return ''; - } - if (word.toLowerCase() === 'github') { - return 'GitHub'; - } else { - return word[0].toUpperCase() + word.slice(1); - } - }, - compactObject: function(object) { - var key, newObject, value; - newObject = {}; - for (key in object) { - value = object[key]; - if (value != null) { - newObject[key] = value; - } - } - return newObject; - }, - dasherize: function(string) { - if (!string) { - return ''; - } - string = string[0].toLowerCase() + string.slice(1); - return string.replace(/([A-Z])|(_)/g, function(m, letter) { - if (letter) { - return "-" + letter.toLowerCase(); - } else { - return "-"; - } - }); - }, - deepClone: function(object) { - if (_.isArray(object)) { - return object.map(function(value) { - return plus.deepClone(value); - }); - } else if (_.isObject(object)) { - return plus.mapObject(object, (function(_this) { - return function(key, value) { - return [key, plus.deepClone(value)]; - }; - })(this)); - } else { - return object; - } - }, - deepExtend: function() { - var key, object, objects, result, value, _i, _len; - objects = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - result = {}; - for (_i = 0, _len = objects.length; _i < _len; _i++) { - object = objects[_i]; - for (key in object) { - value = object[key]; - if (_.isObject(value) && !_.isArray(value)) { - result[key] = plus.deepExtend(result[key], value); - } else { - if (result[key] == null) { - result[key] = value; - } - } - } - } - return result; - }, - deepContains: function(array, target) { - var object, _i, _len; - if (array == null) { - return false; - } - for (_i = 0, _len = array.length; _i < _len; _i++) { - object = array[_i]; - if (_.isEqual(object, target)) { - return true; - } - } - return false; - }, - endsWith: function(string, suffix) { - if (suffix == null) { - suffix = ''; - } - if (string) { - return string.indexOf(suffix, string.length - suffix.length) !== -1; - } else { - return false; - } - }, - escapeAttribute: function(string) { - if (string) { - return string.replace(/"/g, '"').replace(/\n/g, '').replace(/\\/g, '-'); - } else { - return ''; - } - }, - escapeRegExp: function(string) { - if (string) { - return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); - } else { - return ''; - } - }, - humanizeEventName: function(eventName, eventDoc) { - var event, namespace, namespaceDoc, _ref; - _ref = eventName.split(':'), namespace = _ref[0], event = _ref[1]; - if (event == null) { - return plus.undasherize(namespace); - } - namespaceDoc = plus.undasherize(namespace); - if (eventDoc == null) { - eventDoc = plus.undasherize(event); - } - return "" + namespaceDoc + ": " + eventDoc; - }, - humanizeKey: function(key, platform) { - var modifierKeyMap; - if (platform == null) { - platform = process.platform; - } - if (!key) { - return key; - } - modifierKeyMap = platform === 'darwin' ? macModifierKeyMap : nonMacModifierKeyMap; - if (modifierKeyMap[key]) { - return modifierKeyMap[key]; - } else if (key.length === 1 && (shiftKeyMap[key] != null)) { - return [modifierKeyMap.shift, shiftKeyMap[key]]; - } else if (key.length === 1 && key === key.toUpperCase() && key.toUpperCase() !== key.toLowerCase()) { - return [modifierKeyMap.shift, key.toUpperCase()]; - } else if (key.length === 1 || /f[0-9]{1,2}/.test(key)) { - return key.toUpperCase(); - } else { - if (platform === 'darwin') { - return key; - } else { - return plus.capitalize(key); - } - } - }, - humanizeKeystroke: function(keystroke, platform) { - var humanizedKeystrokes, index, key, keys, keystrokes, splitKeystroke, _i, _j, _len, _len1; - if (platform == null) { - platform = process.platform; - } - if (!keystroke) { - return keystroke; - } - keystrokes = keystroke.split(' '); - humanizedKeystrokes = []; - for (_i = 0, _len = keystrokes.length; _i < _len; _i++) { - keystroke = keystrokes[_i]; - keys = []; - splitKeystroke = keystroke.split('-'); - for (index = _j = 0, _len1 = splitKeystroke.length; _j < _len1; index = ++_j) { - key = splitKeystroke[index]; - if (key === '' && splitKeystroke[index - 1] === '') { - key = '-'; - } - if (key) { - keys.push(plus.humanizeKey(key, platform)); - } - } - keys = _.uniq(_.flatten(keys)); - if (platform === 'darwin') { - keys = keys.join(''); - } else { - keys = keys.join('+'); - } - humanizedKeystrokes.push(keys); - } - return humanizedKeystrokes.join(' '); - }, - isSubset: function(potentialSubset, potentialSuperset) { - return _.every(potentialSubset, function(element) { - return _.include(potentialSuperset, element); - }); - }, - losslessInvert: function(hash) { - var inverted, key, value; - inverted = {}; - for (key in hash) { - value = hash[key]; - if (inverted[value] == null) { - inverted[value] = []; - } - inverted[value].push(key); - } - return inverted; - }, - mapObject: function(object, iterator) { - var key, newObject, value, _ref; - newObject = {}; - for (key in object) { - value = object[key]; - _ref = iterator(key, value), key = _ref[0], value = _ref[1]; - newObject[key] = value; - } - return newObject; - }, - multiplyString: function(string, n) { - var finalString, i; - finalString = ""; - i = 0; - while (i < n) { - finalString += string; - i++; - } - return finalString; - }, - pluralize: function(count, singular, plural) { - if (count == null) { - count = 0; - } - if (plural == null) { - plural = singular + 's'; - } - if (count === 1) { - return "" + count + " " + singular; - } else { - return "" + count + " " + plural; - } - }, - remove: function(array, element) { - var index; - index = array.indexOf(element); - if (index >= 0) { - array.splice(index, 1); - } - return array; - }, - setValueForKeyPath: function(object, keyPath, value) { - var key, keys; - keys = keyPath.split('.'); - while (keys.length > 1) { - key = keys.shift(); - if (object[key] == null) { - object[key] = {}; - } - object = object[key]; - } - if (value != null) { - return object[keys.shift()] = value; - } else { - return delete object[keys.shift()]; - } - }, - hasKeyPath: function(object, keyPath) { - var key, keys, _i, _len; - keys = keyPath.split('.'); - for (_i = 0, _len = keys.length; _i < _len; _i++) { - key = keys[_i]; - if (!object.hasOwnProperty(key)) { - return false; - } - object = object[key]; - } - return true; - }, - spliceWithArray: function(originalArray, start, length, insertedArray, chunkSize) { - var chunkStart, _i, _ref, _results; - if (chunkSize == null) { - chunkSize = 100000; - } - if (insertedArray.length < chunkSize) { - return originalArray.splice.apply(originalArray, [start, length].concat(__slice.call(insertedArray))); - } else { - originalArray.splice(start, length); - _results = []; - for (chunkStart = _i = 0, _ref = insertedArray.length; chunkSize > 0 ? _i <= _ref : _i >= _ref; chunkStart = _i += chunkSize) { - _results.push(originalArray.splice.apply(originalArray, [start + chunkStart, 0].concat(__slice.call(insertedArray.slice(chunkStart, chunkStart + chunkSize))))); - } - return _results; - } - }, - sum: function(array) { - var elt, sum, _i, _len; - sum = 0; - for (_i = 0, _len = array.length; _i < _len; _i++) { - elt = array[_i]; - sum += elt; - } - return sum; - }, - uncamelcase: function(string) { - var result; - if (!string) { - return ''; - } - result = string.replace(/([A-Z])|_+/g, function(match, letter) { - if (letter == null) { - letter = ''; - } - return " " + letter; - }); - return plus.capitalize(result.trim()); - }, - undasherize: function(string) { - if (string) { - return string.split('-').map(plus.capitalize).join(' '); - } else { - return ''; - } - }, - underscore: function(string) { - if (!string) { - return ''; - } - string = string[0].toLowerCase() + string.slice(1); - return string.replace(/([A-Z])|-+/g, function(match, letter) { - if (letter == null) { - letter = ''; - } - return "_" + (letter.toLowerCase()); - }); - }, - valueForKeyPath: function(object, keyPath) { - var key, keys, _i, _len; - keys = keyPath.split('.'); - for (_i = 0, _len = keys.length; _i < _len; _i++) { - key = keys[_i]; - object = object[key]; - if (object == null) { - return; - } - } - return object; - }, - isEqual: function(a, b, aStack, bStack) { - if (_.isArray(aStack) && _.isArray(bStack)) { - return isEqual(a, b, aStack, bStack); - } else { - return isEqual(a, b); - } - }, - isEqualForProperties: function() { - var a, b, properties, property, _i, _len; - a = arguments[0], b = arguments[1], properties = 3 <= arguments.length ? __slice.call(arguments, 2) : []; - for (_i = 0, _len = properties.length; _i < _len; _i++) { - property = properties[_i]; - if (!_.isEqual(a[property], b[property])) { - return false; - } - } - return true; - } - }; - - isEqual = function(a, b, aStack, bStack) { - var aCtor, aCtorValid, aElement, aKeyCount, aValue, bCtor, bCtorValid, bKeyCount, bValue, equal, i, key, stackIndex, _i, _len; - if (aStack == null) { - aStack = []; - } - if (bStack == null) { - bStack = []; - } - if (a === b) { - return _.isEqual(a, b); - } - if (_.isFunction(a) || _.isFunction(b)) { - return _.isEqual(a, b); - } - stackIndex = aStack.length; - while (stackIndex--) { - if (aStack[stackIndex] === a) { - return bStack[stackIndex] === b; - } - } - aStack.push(a); - bStack.push(b); - equal = false; - if (_.isFunction(a != null ? a.isEqual : void 0)) { - equal = a.isEqual(b, aStack, bStack); - } else if (_.isFunction(b != null ? b.isEqual : void 0)) { - equal = b.isEqual(a, bStack, aStack); - } else if (_.isArray(a) && _.isArray(b) && a.length === b.length) { - equal = true; - for (i = _i = 0, _len = a.length; _i < _len; i = ++_i) { - aElement = a[i]; - if (!isEqual(aElement, b[i], aStack, bStack)) { - equal = false; - break; - } - } - } else if (_.isRegExp(a) && _.isRegExp(b)) { - equal = _.isEqual(a, b); - } else if (_.isObject(a) && _.isObject(b)) { - aCtor = a.constructor; - bCtor = b.constructor; - aCtorValid = _.isFunction(aCtor) && aCtor instanceof aCtor; - bCtorValid = _.isFunction(bCtor) && bCtor instanceof bCtor; - if (aCtor !== bCtor && !(aCtorValid && bCtorValid)) { - equal = false; - } else { - aKeyCount = 0; - equal = true; - for (key in a) { - aValue = a[key]; - if (!_.has(a, key)) { - continue; - } - aKeyCount++; - if (!(_.has(b, key) && isEqual(aValue, b[key], aStack, bStack))) { - equal = false; - break; - } - } - if (equal) { - bKeyCount = 0; - for (key in b) { - bValue = b[key]; - if (_.has(b, key)) { - bKeyCount++; - } - } - equal = aKeyCount === bKeyCount; - } - } - } else { - equal = _.isEqual(a, b); - } - aStack.pop(); - bStack.pop(); - return equal; - }; - - module.exports = _.extend({}, _, plus); - -}).call(this); diff --git a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/LICENSE b/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/LICENSE deleted file mode 100644 index 0d6b873..0000000 --- a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative -Reporters & Editors - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/README.md b/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/README.md deleted file mode 100644 index c2ba259..0000000 --- a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/README.md +++ /dev/null @@ -1,22 +0,0 @@ - __ - /\ \ __ - __ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____ - /\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\ - \ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\ - \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/ - \/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/ - \ \____/ - \/___/ - -Underscore.js is a utility-belt library for JavaScript that provides -support for the usual functional suspects (each, map, reduce, filter...) -without extending any core JavaScript objects. - -For Docs, License, Tests, and pre-packed downloads, see: -http://underscorejs.org - -Underscore is an open-sourced component of DocumentCloud: -https://github.com/documentcloud - -Many thanks to our contributors: -https://github.com/jashkenas/underscore/contributors diff --git a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/package.json b/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/package.json deleted file mode 100644 index a121112..0000000 --- a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/package.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "underscore", - "description": "JavaScript's functional programming helper library.", - "homepage": "http://underscorejs.org", - "keywords": [ - "util", - "functional", - "server", - "client", - "browser" - ], - "author": { - "name": "Jeremy Ashkenas", - "email": "jeremy@documentcloud.org" - }, - "repository": { - "type": "git", - "url": "git://github.com/jashkenas/underscore.git" - }, - "main": "underscore.js", - "version": "1.6.0", - "devDependencies": { - "docco": "0.6.x", - "phantomjs": "1.9.0-1", - "uglify-js": "2.4.x" - }, - "scripts": { - "test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true", - "build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js", - "doc": "docco underscore.js" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://raw.github.com/jashkenas/underscore/master/LICENSE" - } - ], - "files": [ - "underscore.js", - "underscore-min.js", - "LICENSE" - ], - "readme": " __\n /\\ \\ __\n __ __ ___ \\_\\ \\ __ _ __ ____ ___ ___ _ __ __ /\\_\\ ____\n /\\ \\/\\ \\ /' _ `\\ /'_ \\ /'__`\\/\\ __\\/ ,__\\ / ___\\ / __`\\/\\ __\\/'__`\\ \\/\\ \\ /',__\\\n \\ \\ \\_\\ \\/\\ \\/\\ \\/\\ \\ \\ \\/\\ __/\\ \\ \\//\\__, `\\/\\ \\__//\\ \\ \\ \\ \\ \\//\\ __/ __ \\ \\ \\/\\__, `\\\n \\ \\____/\\ \\_\\ \\_\\ \\___,_\\ \\____\\\\ \\_\\\\/\\____/\\ \\____\\ \\____/\\ \\_\\\\ \\____\\/\\_\\ _\\ \\ \\/\\____/\n \\/___/ \\/_/\\/_/\\/__,_ /\\/____/ \\/_/ \\/___/ \\/____/\\/___/ \\/_/ \\/____/\\/_//\\ \\_\\ \\/___/\n \\ \\____/\n \\/___/\n\nUnderscore.js is a utility-belt library for JavaScript that provides\nsupport for the usual functional suspects (each, map, reduce, filter...)\nwithout extending any core JavaScript objects.\n\nFor Docs, License, Tests, and pre-packed downloads, see:\nhttp://underscorejs.org\n\nUnderscore is an open-sourced component of DocumentCloud:\nhttps://github.com/documentcloud\n\nMany thanks to our contributors:\nhttps://github.com/jashkenas/underscore/contributors\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/jashkenas/underscore/issues" - }, - "_id": "underscore@1.6.0", - "_from": "underscore@~1.6.0" -} diff --git a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/underscore-min.js b/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/underscore-min.js deleted file mode 100644 index 3434d6c..0000000 --- a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/underscore-min.js +++ /dev/null @@ -1,6 +0,0 @@ -// Underscore.js 1.6.0 -// http://underscorejs.org -// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors -// Underscore may be freely distributed under the MIT license. -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?void(this._wrapped=n):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.6.0";var A=j.each=j.forEach=function(n,t,e){if(null==n)return n;if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return;return n};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var O="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},j.find=j.detect=function(n,t,r){var e;return k(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var k=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:k(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,j.property(t))},j.where=function(n,t){return j.filter(n,j.matches(t))},j.findWhere=function(n,t){return j.find(n,j.matches(t))},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);var e=-1/0,u=-1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;o>u&&(e=n,u=o)}),e},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);var e=1/0,u=1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;u>o&&(e=n,u=o)}),e},j.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=j.random(r++),e[r-1]=e[t],e[t]=n}),e},j.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=j.values(n)),n[j.random(n.length-1)]):j.shuffle(n).slice(0,Math.max(0,t))};var E=function(n){return null==n?j.identity:j.isFunction(n)?n:j.property(n)};j.sortBy=function(n,t,r){return t=E(t),j.pluck(j.map(n,function(n,e,u){return{value:n,index:e,criteria:t.call(r,n,e,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=E(r),A(t,function(i,a){var o=r.call(e,i,a,t);n(u,o,i)}),u}};j.groupBy=F(function(n,t,r){j.has(n,t)?n[t].push(r):n[t]=[r]}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=E(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])t?[]:o.call(n,0,t)},j.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},j.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},j.rest=j.tail=j.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},j.compact=function(n){return j.filter(n,j.identity)};var M=function(n,t,r){return t&&j.every(n,j.isArray)?c.apply(r,n):(A(n,function(n){j.isArray(n)||j.isArguments(n)?t?a.apply(r,n):M(n,t,r):r.push(n)}),r)};j.flatten=function(n,t){return M(n,t,[])},j.without=function(n){return j.difference(n,o.call(arguments,1))},j.partition=function(n,t){var r=[],e=[];return A(n,function(n){(t(n)?r:e).push(n)}),[r,e]},j.uniq=j.unique=function(n,t,r,e){j.isFunction(t)&&(e=r,r=t,t=!1);var u=r?j.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:j.contains(a,r))||(a.push(r),i.push(n[e]))}),i},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(n){var t=o.call(arguments,1);return j.filter(j.uniq(n),function(n){return j.every(t,function(t){return j.contains(t,n)})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===j&&(e[u]=arguments[r++]);for(;r=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u),e=u=null):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o,c=function(){var l=j.now()-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u),i=u=null))};return function(){i=this,u=arguments,a=j.now();var l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u),i=u=null),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return j.partial(t,n)},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=function(n){if(!j.isObject(n))return[];if(w)return w(n);var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o)&&"constructor"in n&&"constructor"in t)return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.constant=function(n){return function(){return n}},j.property=function(n){return function(t){return t[n]}},j.matches=function(n){return function(t){if(t===n)return!0;for(var r in n)if(n[r]!==t[r])return!1;return!0}},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},j.now=Date.now||function(){return(new Date).getTime()};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};T.unescape=j.invert(T.escape);var I={escape:new RegExp("["+j.keys(T.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(T.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(I[n],function(t){return T[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return j})}).call(this); -//# sourceMappingURL=underscore-min.map \ No newline at end of file diff --git a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/underscore.js b/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/underscore.js deleted file mode 100644 index 9a4cabe..0000000 --- a/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/underscore.js +++ /dev/null @@ -1,1343 +0,0 @@ -// Underscore.js 1.6.0 -// http://underscorejs.org -// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors -// Underscore may be freely distributed under the MIT license. - -(function() { - - // Baseline setup - // -------------- - - // Establish the root object, `window` in the browser, or `exports` on the server. - var root = this; - - // Save the previous value of the `_` variable. - var previousUnderscore = root._; - - // Establish the object that gets returned to break out of a loop iteration. - var breaker = {}; - - // Save bytes in the minified (but not gzipped) version: - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - - // Create quick reference variables for speed access to core prototypes. - var - push = ArrayProto.push, - slice = ArrayProto.slice, - concat = ArrayProto.concat, - toString = ObjProto.toString, - hasOwnProperty = ObjProto.hasOwnProperty; - - // All **ECMAScript 5** native function implementations that we hope to use - // are declared here. - var - nativeForEach = ArrayProto.forEach, - nativeMap = ArrayProto.map, - nativeReduce = ArrayProto.reduce, - nativeReduceRight = ArrayProto.reduceRight, - nativeFilter = ArrayProto.filter, - nativeEvery = ArrayProto.every, - nativeSome = ArrayProto.some, - nativeIndexOf = ArrayProto.indexOf, - nativeLastIndexOf = ArrayProto.lastIndexOf, - nativeIsArray = Array.isArray, - nativeKeys = Object.keys, - nativeBind = FuncProto.bind; - - // Create a safe reference to the Underscore object for use below. - var _ = function(obj) { - if (obj instanceof _) return obj; - if (!(this instanceof _)) return new _(obj); - this._wrapped = obj; - }; - - // Export the Underscore object for **Node.js**, with - // backwards-compatibility for the old `require()` API. If we're in - // the browser, add `_` as a global object via a string identifier, - // for Closure Compiler "advanced" mode. - if (typeof exports !== 'undefined') { - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = _; - } - exports._ = _; - } else { - root._ = _; - } - - // Current version. - _.VERSION = '1.6.0'; - - // Collection Functions - // -------------------- - - // The cornerstone, an `each` implementation, aka `forEach`. - // Handles objects with the built-in `forEach`, arrays, and raw objects. - // Delegates to **ECMAScript 5**'s native `forEach` if available. - var each = _.each = _.forEach = function(obj, iterator, context) { - if (obj == null) return obj; - if (nativeForEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, length = obj.length; i < length; i++) { - if (iterator.call(context, obj[i], i, obj) === breaker) return; - } - } else { - var keys = _.keys(obj); - for (var i = 0, length = keys.length; i < length; i++) { - if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; - } - } - return obj; - }; - - // Return the results of applying the iterator to each element. - // Delegates to **ECMAScript 5**'s native `map` if available. - _.map = _.collect = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); - each(obj, function(value, index, list) { - results.push(iterator.call(context, value, index, list)); - }); - return results; - }; - - var reduceError = 'Reduce of empty array with no initial value'; - - // **Reduce** builds up a single result from a list of values, aka `inject`, - // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. - _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduce && obj.reduce === nativeReduce) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); - } - each(obj, function(value, index, list) { - if (!initial) { - memo = value; - initial = true; - } else { - memo = iterator.call(context, memo, value, index, list); - } - }); - if (!initial) throw new TypeError(reduceError); - return memo; - }; - - // The right-associative version of reduce, also known as `foldr`. - // Delegates to **ECMAScript 5**'s native `reduceRight` if available. - _.reduceRight = _.foldr = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); - } - var length = obj.length; - if (length !== +length) { - var keys = _.keys(obj); - length = keys.length; - } - each(obj, function(value, index, list) { - index = keys ? keys[--length] : --length; - if (!initial) { - memo = obj[index]; - initial = true; - } else { - memo = iterator.call(context, memo, obj[index], index, list); - } - }); - if (!initial) throw new TypeError(reduceError); - return memo; - }; - - // Return the first value which passes a truth test. Aliased as `detect`. - _.find = _.detect = function(obj, predicate, context) { - var result; - any(obj, function(value, index, list) { - if (predicate.call(context, value, index, list)) { - result = value; - return true; - } - }); - return result; - }; - - // Return all the elements that pass a truth test. - // Delegates to **ECMAScript 5**'s native `filter` if available. - // Aliased as `select`. - _.filter = _.select = function(obj, predicate, context) { - var results = []; - if (obj == null) return results; - if (nativeFilter && obj.filter === nativeFilter) return obj.filter(predicate, context); - each(obj, function(value, index, list) { - if (predicate.call(context, value, index, list)) results.push(value); - }); - return results; - }; - - // Return all the elements for which a truth test fails. - _.reject = function(obj, predicate, context) { - return _.filter(obj, function(value, index, list) { - return !predicate.call(context, value, index, list); - }, context); - }; - - // Determine whether all of the elements match a truth test. - // Delegates to **ECMAScript 5**'s native `every` if available. - // Aliased as `all`. - _.every = _.all = function(obj, predicate, context) { - predicate || (predicate = _.identity); - var result = true; - if (obj == null) return result; - if (nativeEvery && obj.every === nativeEvery) return obj.every(predicate, context); - each(obj, function(value, index, list) { - if (!(result = result && predicate.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if at least one element in the object matches a truth test. - // Delegates to **ECMAScript 5**'s native `some` if available. - // Aliased as `any`. - var any = _.some = _.any = function(obj, predicate, context) { - predicate || (predicate = _.identity); - var result = false; - if (obj == null) return result; - if (nativeSome && obj.some === nativeSome) return obj.some(predicate, context); - each(obj, function(value, index, list) { - if (result || (result = predicate.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if the array or object contains a given value (using `===`). - // Aliased as `include`. - _.contains = _.include = function(obj, target) { - if (obj == null) return false; - if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - return any(obj, function(value) { - return value === target; - }); - }; - - // Invoke a method (with arguments) on every item in a collection. - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); - return _.map(obj, function(value) { - return (isFunc ? method : value[method]).apply(value, args); - }); - }; - - // Convenience version of a common use case of `map`: fetching a property. - _.pluck = function(obj, key) { - return _.map(obj, _.property(key)); - }; - - // Convenience version of a common use case of `filter`: selecting only objects - // containing specific `key:value` pairs. - _.where = function(obj, attrs) { - return _.filter(obj, _.matches(attrs)); - }; - - // Convenience version of a common use case of `find`: getting the first object - // containing specific `key:value` pairs. - _.findWhere = function(obj, attrs) { - return _.find(obj, _.matches(attrs)); - }; - - // Return the maximum element or (element-based computation). - // Can't optimize arrays of integers longer than 65,535 elements. - // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797) - _.max = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.max.apply(Math, obj); - } - var result = -Infinity, lastComputed = -Infinity; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - if (computed > lastComputed) { - result = value; - lastComputed = computed; - } - }); - return result; - }; - - // Return the minimum element (or element-based computation). - _.min = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.min.apply(Math, obj); - } - var result = Infinity, lastComputed = Infinity; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - if (computed < lastComputed) { - result = value; - lastComputed = computed; - } - }); - return result; - }; - - // Shuffle an array, using the modern version of the - // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). - _.shuffle = function(obj) { - var rand; - var index = 0; - var shuffled = []; - each(obj, function(value) { - rand = _.random(index++); - shuffled[index - 1] = shuffled[rand]; - shuffled[rand] = value; - }); - return shuffled; - }; - - // Sample **n** random values from a collection. - // If **n** is not specified, returns a single random element. - // The internal `guard` argument allows it to work with `map`. - _.sample = function(obj, n, guard) { - if (n == null || guard) { - if (obj.length !== +obj.length) obj = _.values(obj); - return obj[_.random(obj.length - 1)]; - } - return _.shuffle(obj).slice(0, Math.max(0, n)); - }; - - // An internal function to generate lookup iterators. - var lookupIterator = function(value) { - if (value == null) return _.identity; - if (_.isFunction(value)) return value; - return _.property(value); - }; - - // Sort the object's values by a criterion produced by an iterator. - _.sortBy = function(obj, iterator, context) { - iterator = lookupIterator(iterator); - return _.pluck(_.map(obj, function(value, index, list) { - return { - value: value, - index: index, - criteria: iterator.call(context, value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; - } - return left.index - right.index; - }), 'value'); - }; - - // An internal function used for aggregate "group by" operations. - var group = function(behavior) { - return function(obj, iterator, context) { - var result = {}; - iterator = lookupIterator(iterator); - each(obj, function(value, index) { - var key = iterator.call(context, value, index, obj); - behavior(result, key, value); - }); - return result; - }; - }; - - // Groups the object's values by a criterion. Pass either a string attribute - // to group by, or a function that returns the criterion. - _.groupBy = group(function(result, key, value) { - _.has(result, key) ? result[key].push(value) : result[key] = [value]; - }); - - // Indexes the object's values by a criterion, similar to `groupBy`, but for - // when you know that your index values will be unique. - _.indexBy = group(function(result, key, value) { - result[key] = value; - }); - - // Counts instances of an object that group by a certain criterion. Pass - // either a string attribute to count by, or a function that returns the - // criterion. - _.countBy = group(function(result, key) { - _.has(result, key) ? result[key]++ : result[key] = 1; - }); - - // Use a comparator function to figure out the smallest index at which - // an object should be inserted so as to maintain order. Uses binary search. - _.sortedIndex = function(array, obj, iterator, context) { - iterator = lookupIterator(iterator); - var value = iterator.call(context, obj); - var low = 0, high = array.length; - while (low < high) { - var mid = (low + high) >>> 1; - iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; - } - return low; - }; - - // Safely create a real, live array from anything iterable. - _.toArray = function(obj) { - if (!obj) return []; - if (_.isArray(obj)) return slice.call(obj); - if (obj.length === +obj.length) return _.map(obj, _.identity); - return _.values(obj); - }; - - // Return the number of elements in an object. - _.size = function(obj) { - if (obj == null) return 0; - return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; - }; - - // Array Functions - // --------------- - - // Get the first element of an array. Passing **n** will return the first N - // values in the array. Aliased as `head` and `take`. The **guard** check - // allows it to work with `_.map`. - _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; - if ((n == null) || guard) return array[0]; - if (n < 0) return []; - return slice.call(array, 0, n); - }; - - // Returns everything but the last entry of the array. Especially useful on - // the arguments object. Passing **n** will return all the values in - // the array, excluding the last N. The **guard** check allows it to work with - // `_.map`. - _.initial = function(array, n, guard) { - return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); - }; - - // Get the last element of an array. Passing **n** will return the last N - // values in the array. The **guard** check allows it to work with `_.map`. - _.last = function(array, n, guard) { - if (array == null) return void 0; - if ((n == null) || guard) return array[array.length - 1]; - return slice.call(array, Math.max(array.length - n, 0)); - }; - - // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. - // Especially useful on the arguments object. Passing an **n** will return - // the rest N values in the array. The **guard** - // check allows it to work with `_.map`. - _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, (n == null) || guard ? 1 : n); - }; - - // Trim out all falsy values from an array. - _.compact = function(array) { - return _.filter(array, _.identity); - }; - - // Internal implementation of a recursive `flatten` function. - var flatten = function(input, shallow, output) { - if (shallow && _.every(input, _.isArray)) { - return concat.apply(output, input); - } - each(input, function(value) { - if (_.isArray(value) || _.isArguments(value)) { - shallow ? push.apply(output, value) : flatten(value, shallow, output); - } else { - output.push(value); - } - }); - return output; - }; - - // Flatten out an array, either recursively (by default), or just one level. - _.flatten = function(array, shallow) { - return flatten(array, shallow, []); - }; - - // Return a version of the array that does not contain the specified value(s). - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - - // Split an array into two arrays: one whose elements all satisfy the given - // predicate, and one whose elements all do not satisfy the predicate. - _.partition = function(array, predicate) { - var pass = [], fail = []; - each(array, function(elem) { - (predicate(elem) ? pass : fail).push(elem); - }); - return [pass, fail]; - }; - - // Produce a duplicate-free version of the array. If the array has already - // been sorted, you have the option of using a faster algorithm. - // Aliased as `unique`. - _.uniq = _.unique = function(array, isSorted, iterator, context) { - if (_.isFunction(isSorted)) { - context = iterator; - iterator = isSorted; - isSorted = false; - } - var initial = iterator ? _.map(array, iterator, context) : array; - var results = []; - var seen = []; - each(initial, function(value, index) { - if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { - seen.push(value); - results.push(array[index]); - } - }); - return results; - }; - - // Produce an array that contains the union: each distinct element from all of - // the passed-in arrays. - _.union = function() { - return _.uniq(_.flatten(arguments, true)); - }; - - // Produce an array that contains every item shared between all the - // passed-in arrays. - _.intersection = function(array) { - var rest = slice.call(arguments, 1); - return _.filter(_.uniq(array), function(item) { - return _.every(rest, function(other) { - return _.contains(other, item); - }); - }); - }; - - // Take the difference between one array and a number of other arrays. - // Only the elements present in just the first array will remain. - _.difference = function(array) { - var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); - return _.filter(array, function(value){ return !_.contains(rest, value); }); - }; - - // Zip together multiple lists into a single array -- elements that share - // an index go together. - _.zip = function() { - var length = _.max(_.pluck(arguments, 'length').concat(0)); - var results = new Array(length); - for (var i = 0; i < length; i++) { - results[i] = _.pluck(arguments, '' + i); - } - return results; - }; - - // Converts lists into objects. Pass either a single array of `[key, value]` - // pairs, or two parallel arrays of the same length -- one of keys, and one of - // the corresponding values. - _.object = function(list, values) { - if (list == null) return {}; - var result = {}; - for (var i = 0, length = list.length; i < length; i++) { - if (values) { - result[list[i]] = values[i]; - } else { - result[list[i][0]] = list[i][1]; - } - } - return result; - }; - - // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), - // we need this function. Return the position of the first occurrence of an - // item in an array, or -1 if the item is not included in the array. - // Delegates to **ECMAScript 5**'s native `indexOf` if available. - // If the array is large and already in sort order, pass `true` - // for **isSorted** to use binary search. - _.indexOf = function(array, item, isSorted) { - if (array == null) return -1; - var i = 0, length = array.length; - if (isSorted) { - if (typeof isSorted == 'number') { - i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted); - } else { - i = _.sortedIndex(array, item); - return array[i] === item ? i : -1; - } - } - if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); - for (; i < length; i++) if (array[i] === item) return i; - return -1; - }; - - // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. - _.lastIndexOf = function(array, item, from) { - if (array == null) return -1; - var hasIndex = from != null; - if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { - return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); - } - var i = (hasIndex ? from : array.length); - while (i--) if (array[i] === item) return i; - return -1; - }; - - // Generate an integer Array containing an arithmetic progression. A port of - // the native Python `range()` function. See - // [the Python documentation](http://docs.python.org/library/functions.html#range). - _.range = function(start, stop, step) { - if (arguments.length <= 1) { - stop = start || 0; - start = 0; - } - step = arguments[2] || 1; - - var length = Math.max(Math.ceil((stop - start) / step), 0); - var idx = 0; - var range = new Array(length); - - while(idx < length) { - range[idx++] = start; - start += step; - } - - return range; - }; - - // Function (ahem) Functions - // ------------------ - - // Reusable constructor function for prototype setting. - var ctor = function(){}; - - // Create a function bound to a given object (assigning `this`, and arguments, - // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if - // available. - _.bind = function(func, context) { - var args, bound; - if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - if (!_.isFunction(func)) throw new TypeError; - args = slice.call(arguments, 2); - return bound = function() { - if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); - ctor.prototype = func.prototype; - var self = new ctor; - ctor.prototype = null; - var result = func.apply(self, args.concat(slice.call(arguments))); - if (Object(result) === result) return result; - return self; - }; - }; - - // Partially apply a function by creating a version that has had some of its - // arguments pre-filled, without changing its dynamic `this` context. _ acts - // as a placeholder, allowing any combination of arguments to be pre-filled. - _.partial = function(func) { - var boundArgs = slice.call(arguments, 1); - return function() { - var position = 0; - var args = boundArgs.slice(); - for (var i = 0, length = args.length; i < length; i++) { - if (args[i] === _) args[i] = arguments[position++]; - } - while (position < arguments.length) args.push(arguments[position++]); - return func.apply(this, args); - }; - }; - - // Bind a number of an object's methods to that object. Remaining arguments - // are the method names to be bound. Useful for ensuring that all callbacks - // defined on an object belong to it. - _.bindAll = function(obj) { - var funcs = slice.call(arguments, 1); - if (funcs.length === 0) throw new Error('bindAll must be passed function names'); - each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); - return obj; - }; - - // Memoize an expensive function by storing its results. - _.memoize = function(func, hasher) { - var memo = {}; - hasher || (hasher = _.identity); - return function() { - var key = hasher.apply(this, arguments); - return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); - }; - }; - - // Delays a function for the given number of milliseconds, and then calls - // it with the arguments supplied. - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function(){ return func.apply(null, args); }, wait); - }; - - // Defers a function, scheduling it to run after the current call stack has - // cleared. - _.defer = function(func) { - return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); - }; - - // Returns a function, that, when invoked, will only be triggered at most once - // during a given window of time. Normally, the throttled function will run - // as much as it can, without ever going more than once per `wait` duration; - // but if you'd like to disable the execution on the leading edge, pass - // `{leading: false}`. To disable execution on the trailing edge, ditto. - _.throttle = function(func, wait, options) { - var context, args, result; - var timeout = null; - var previous = 0; - options || (options = {}); - var later = function() { - previous = options.leading === false ? 0 : _.now(); - timeout = null; - result = func.apply(context, args); - context = args = null; - }; - return function() { - var now = _.now(); - if (!previous && options.leading === false) previous = now; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0) { - clearTimeout(timeout); - timeout = null; - previous = now; - result = func.apply(context, args); - context = args = null; - } else if (!timeout && options.trailing !== false) { - timeout = setTimeout(later, remaining); - } - return result; - }; - }; - - // Returns a function, that, as long as it continues to be invoked, will not - // be triggered. The function will be called after it stops being called for - // N milliseconds. If `immediate` is passed, trigger the function on the - // leading edge, instead of the trailing. - _.debounce = function(func, wait, immediate) { - var timeout, args, context, timestamp, result; - - var later = function() { - var last = _.now() - timestamp; - if (last < wait) { - timeout = setTimeout(later, wait - last); - } else { - timeout = null; - if (!immediate) { - result = func.apply(context, args); - context = args = null; - } - } - }; - - return function() { - context = this; - args = arguments; - timestamp = _.now(); - var callNow = immediate && !timeout; - if (!timeout) { - timeout = setTimeout(later, wait); - } - if (callNow) { - result = func.apply(context, args); - context = args = null; - } - - return result; - }; - }; - - // Returns a function that will be executed at most one time, no matter how - // often you call it. Useful for lazy initialization. - _.once = function(func) { - var ran = false, memo; - return function() { - if (ran) return memo; - ran = true; - memo = func.apply(this, arguments); - func = null; - return memo; - }; - }; - - // Returns the first function passed as an argument to the second, - // allowing you to adjust arguments, run code before and after, and - // conditionally execute the original function. - _.wrap = function(func, wrapper) { - return _.partial(wrapper, func); - }; - - // Returns a function that is the composition of a list of functions, each - // consuming the return value of the function that follows. - _.compose = function() { - var funcs = arguments; - return function() { - var args = arguments; - for (var i = funcs.length - 1; i >= 0; i--) { - args = [funcs[i].apply(this, args)]; - } - return args[0]; - }; - }; - - // Returns a function that will only be executed after being called N times. - _.after = function(times, func) { - return function() { - if (--times < 1) { - return func.apply(this, arguments); - } - }; - }; - - // Object Functions - // ---------------- - - // Retrieve the names of an object's properties. - // Delegates to **ECMAScript 5**'s native `Object.keys` - _.keys = function(obj) { - if (!_.isObject(obj)) return []; - if (nativeKeys) return nativeKeys(obj); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys.push(key); - return keys; - }; - - // Retrieve the values of an object's properties. - _.values = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var values = new Array(length); - for (var i = 0; i < length; i++) { - values[i] = obj[keys[i]]; - } - return values; - }; - - // Convert an object into a list of `[key, value]` pairs. - _.pairs = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var pairs = new Array(length); - for (var i = 0; i < length; i++) { - pairs[i] = [keys[i], obj[keys[i]]]; - } - return pairs; - }; - - // Invert the keys and values of an object. The values must be serializable. - _.invert = function(obj) { - var result = {}; - var keys = _.keys(obj); - for (var i = 0, length = keys.length; i < length; i++) { - result[obj[keys[i]]] = keys[i]; - } - return result; - }; - - // Return a sorted list of the function names available on the object. - // Aliased as `methods` - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); - } - return names.sort(); - }; - - // Extend a given object with all the properties in passed-in object(s). - _.extend = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - obj[prop] = source[prop]; - } - } - }); - return obj; - }; - - // Return a copy of the object only containing the whitelisted properties. - _.pick = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - each(keys, function(key) { - if (key in obj) copy[key] = obj[key]; - }); - return copy; - }; - - // Return a copy of the object without the blacklisted properties. - _.omit = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - for (var key in obj) { - if (!_.contains(keys, key)) copy[key] = obj[key]; - } - return copy; - }; - - // Fill in a given object with default properties. - _.defaults = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - if (obj[prop] === void 0) obj[prop] = source[prop]; - } - } - }); - return obj; - }; - - // Create a (shallow-cloned) duplicate of an object. - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - - // Invokes interceptor with the obj, and then returns obj. - // The primary purpose of this method is to "tap into" a method chain, in - // order to perform operations on intermediate results within the chain. - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - - // Internal recursive comparison function for `isEqual`. - var eq = function(a, b, aStack, bStack) { - // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). - if (a === b) return a !== 0 || 1 / a == 1 / b; - // A strict comparison is necessary because `null == undefined`. - if (a == null || b == null) return a === b; - // Unwrap any wrapped objects. - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - // Compare `[[Class]]` names. - var className = toString.call(a); - if (className != toString.call(b)) return false; - switch (className) { - // Strings, numbers, dates, and booleans are compared by value. - case '[object String]': - // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is - // equivalent to `new String("5")`. - return a == String(b); - case '[object Number]': - // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for - // other numeric values. - return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); - case '[object Date]': - case '[object Boolean]': - // Coerce dates and booleans to numeric primitive values. Dates are compared by their - // millisecond representations. Note that invalid dates with millisecond representations - // of `NaN` are not equivalent. - return +a == +b; - // RegExps are compared by their source patterns and flags. - case '[object RegExp]': - return a.source == b.source && - a.global == b.global && - a.multiline == b.multiline && - a.ignoreCase == b.ignoreCase; - } - if (typeof a != 'object' || typeof b != 'object') return false; - // Assume equality for cyclic structures. The algorithm for detecting cyclic - // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. - var length = aStack.length; - while (length--) { - // Linear search. Performance is inversely proportional to the number of - // unique nested structures. - if (aStack[length] == a) return bStack[length] == b; - } - // Objects with different constructors are not equivalent, but `Object`s - // from different frames are. - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && - _.isFunction(bCtor) && (bCtor instanceof bCtor)) - && ('constructor' in a && 'constructor' in b)) { - return false; - } - // Add the first object to the stack of traversed objects. - aStack.push(a); - bStack.push(b); - var size = 0, result = true; - // Recursively compare objects and arrays. - if (className == '[object Array]') { - // Compare array lengths to determine if a deep comparison is necessary. - size = a.length; - result = size == b.length; - if (result) { - // Deep compare the contents, ignoring non-numeric properties. - while (size--) { - if (!(result = eq(a[size], b[size], aStack, bStack))) break; - } - } - } else { - // Deep compare objects. - for (var key in a) { - if (_.has(a, key)) { - // Count the expected number of properties. - size++; - // Deep compare each member. - if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; - } - } - // Ensure that both objects contain the same number of properties. - if (result) { - for (key in b) { - if (_.has(b, key) && !(size--)) break; - } - result = !size; - } - } - // Remove the first object from the stack of traversed objects. - aStack.pop(); - bStack.pop(); - return result; - }; - - // Perform a deep comparison to check if two objects are equal. - _.isEqual = function(a, b) { - return eq(a, b, [], []); - }; - - // Is a given array, string, or object empty? - // An "empty" object has no enumerable own-properties. - _.isEmpty = function(obj) { - if (obj == null) return true; - if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; - for (var key in obj) if (_.has(obj, key)) return false; - return true; - }; - - // Is a given value a DOM element? - _.isElement = function(obj) { - return !!(obj && obj.nodeType === 1); - }; - - // Is a given value an array? - // Delegates to ECMA5's native Array.isArray - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) == '[object Array]'; - }; - - // Is a given variable an object? - _.isObject = function(obj) { - return obj === Object(obj); - }; - - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. - each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { - _['is' + name] = function(obj) { - return toString.call(obj) == '[object ' + name + ']'; - }; - }); - - // Define a fallback version of the method in browsers (ahem, IE), where - // there isn't any inspectable "Arguments" type. - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return !!(obj && _.has(obj, 'callee')); - }; - } - - // Optimize `isFunction` if appropriate. - if (typeof (/./) !== 'function') { - _.isFunction = function(obj) { - return typeof obj === 'function'; - }; - } - - // Is a given object a finite number? - _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); - }; - - // Is the given value `NaN`? (NaN is the only number which does not equal itself). - _.isNaN = function(obj) { - return _.isNumber(obj) && obj != +obj; - }; - - // Is a given value a boolean? - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; - }; - - // Is a given value equal to null? - _.isNull = function(obj) { - return obj === null; - }; - - // Is a given variable undefined? - _.isUndefined = function(obj) { - return obj === void 0; - }; - - // Shortcut function for checking if an object has a given property directly - // on itself (in other words, not on a prototype). - _.has = function(obj, key) { - return hasOwnProperty.call(obj, key); - }; - - // Utility Functions - // ----------------- - - // Run Underscore.js in *noConflict* mode, returning the `_` variable to its - // previous owner. Returns a reference to the Underscore object. - _.noConflict = function() { - root._ = previousUnderscore; - return this; - }; - - // Keep the identity function around for default iterators. - _.identity = function(value) { - return value; - }; - - _.constant = function(value) { - return function () { - return value; - }; - }; - - _.property = function(key) { - return function(obj) { - return obj[key]; - }; - }; - - // Returns a predicate for checking whether an object has a given set of `key:value` pairs. - _.matches = function(attrs) { - return function(obj) { - if (obj === attrs) return true; //avoid comparing an object to itself. - for (var key in attrs) { - if (attrs[key] !== obj[key]) - return false; - } - return true; - } - }; - - // Run a function **n** times. - _.times = function(n, iterator, context) { - var accum = Array(Math.max(0, n)); - for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); - return accum; - }; - - // Return a random integer between min and max (inclusive). - _.random = function(min, max) { - if (max == null) { - max = min; - min = 0; - } - return min + Math.floor(Math.random() * (max - min + 1)); - }; - - // A (possibly faster) way to get the current timestamp as an integer. - _.now = Date.now || function() { return new Date().getTime(); }; - - // List of HTML entities for escaping. - var entityMap = { - escape: { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' - } - }; - entityMap.unescape = _.invert(entityMap.escape); - - // Regexes containing the keys and values listed immediately above. - var entityRegexes = { - escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), - unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') - }; - - // Functions for escaping and unescaping strings to/from HTML interpolation. - _.each(['escape', 'unescape'], function(method) { - _[method] = function(string) { - if (string == null) return ''; - return ('' + string).replace(entityRegexes[method], function(match) { - return entityMap[method][match]; - }); - }; - }); - - // If the value of the named `property` is a function then invoke it with the - // `object` as context; otherwise, return it. - _.result = function(object, property) { - if (object == null) return void 0; - var value = object[property]; - return _.isFunction(value) ? value.call(object) : value; - }; - - // Add your own custom functions to the Underscore object. - _.mixin = function(obj) { - each(_.functions(obj), function(name) { - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [this._wrapped]; - push.apply(args, arguments); - return result.call(this, func.apply(_, args)); - }; - }); - }; - - // Generate a unique integer id (unique within the entire client session). - // Useful for temporary DOM ids. - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = ++idCounter + ''; - return prefix ? prefix + id : id; - }; - - // By default, Underscore uses ERB-style template delimiters, change the - // following template settings to use alternative delimiters. - _.templateSettings = { - evaluate : /<%([\s\S]+?)%>/g, - interpolate : /<%=([\s\S]+?)%>/g, - escape : /<%-([\s\S]+?)%>/g - }; - - // When customizing `templateSettings`, if you don't want to define an - // interpolation, evaluation or escaping regex, we need one that is - // guaranteed not to match. - var noMatch = /(.)^/; - - // Certain characters need to be escaped so that they can be put into a - // string literal. - var escapes = { - "'": "'", - '\\': '\\', - '\r': 'r', - '\n': 'n', - '\t': 't', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; - - // JavaScript micro-templating, similar to John Resig's implementation. - // Underscore templating handles arbitrary delimiters, preserves whitespace, - // and correctly escapes quotes within interpolated code. - _.template = function(text, data, settings) { - var render; - settings = _.defaults({}, settings, _.templateSettings); - - // Combine delimiters into one regular expression via alternation. - var matcher = new RegExp([ - (settings.escape || noMatch).source, - (settings.interpolate || noMatch).source, - (settings.evaluate || noMatch).source - ].join('|') + '|$', 'g'); - - // Compile the template source, escaping string literals appropriately. - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset) - .replace(escaper, function(match) { return '\\' + escapes[match]; }); - - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } - if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } - if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } - index = offset + match.length; - return match; - }); - source += "';\n"; - - // If a variable is not specified, place data values in local scope. - if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; - - source = "var __t,__p='',__j=Array.prototype.join," + - "print=function(){__p+=__j.call(arguments,'');};\n" + - source + "return __p;\n"; - - try { - render = new Function(settings.variable || 'obj', '_', source); - } catch (e) { - e.source = source; - throw e; - } - - if (data) return render(data, _); - var template = function(data) { - return render.call(this, data, _); - }; - - // Provide the compiled function source as a convenience for precompilation. - template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; - - return template; - }; - - // Add a "chain" function, which will delegate to the wrapper. - _.chain = function(obj) { - return _(obj).chain(); - }; - - // OOP - // --------------- - // If Underscore is called as a function, it returns a wrapped object that - // can be used OO-style. This wrapper holds altered versions of all the - // underscore functions. Wrapped objects may be chained. - - // Helper function to continue chaining intermediate results. - var result = function(obj) { - return this._chain ? _(obj).chain() : obj; - }; - - // Add all of the Underscore functions to the wrapper object. - _.mixin(_); - - // Add all mutator Array functions to the wrapper. - each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - var obj = this._wrapped; - method.apply(obj, arguments); - if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; - return result.call(this, obj); - }; - }); - - // Add all accessor Array functions to the wrapper. - each(['concat', 'join', 'slice'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - return result.call(this, method.apply(this._wrapped, arguments)); - }; - }); - - _.extend(_.prototype, { - - // Start chaining a wrapped Underscore object. - chain: function() { - this._chain = true; - return this; - }, - - // Extracts the result from a wrapped and chained object. - value: function() { - return this._wrapped; - } - - }); - - // AMD registration happens at the end for compatibility with AMD loaders - // that may not enforce next-turn semantics on modules. Even though general - // practice for AMD registration is to be anonymous, underscore registers - // as a named module because, like jQuery, it is a base library that is - // popular enough to be bundled in a third party lib, but not be part of - // an AMD load request. Those cases could generate an error when an - // anonymous define() is called outside of a loader request. - if (typeof define === 'function' && define.amd) { - define('underscore', [], function() { - return _; - }); - } -}).call(this); diff --git a/.atom/packages/vim-mode/node_modules/underscore-plus/package.json b/.atom/packages/vim-mode/node_modules/underscore-plus/package.json deleted file mode 100644 index be3ae04..0000000 --- a/.atom/packages/vim-mode/node_modules/underscore-plus/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "underscore-plus", - "version": "1.5.0", - "description": "Underscore plus additional utilities", - "licenses": [ - { - "type": "MIT", - "url": "http://github.com/atom/underscore-plus/raw/master/LICENSE.md" - } - ], - "main": "./lib/underscore-plus.js", - "scripts": { - "prepublish": "grunt clean coffee lint", - "test": "grunt test" - }, - "repository": { - "type": "git", - "url": "https://github.com/atom/underscore-plus.git" - }, - "bugs": { - "url": "https://github.com/atom/underscore-plus/issues" - }, - "homepage": "http://atom.github.io/underscore-plus", - "keywords": [ - "underscore" - ], - "dependencies": { - "underscore": "~1.6.0" - }, - "devDependencies": { - "jasmine-focused": "1.x", - "grunt-contrib-coffee": "~0.9.0", - "grunt-cli": "~0.1.8", - "grunt": "~0.4.1", - "grunt-shell": "~0.2.2", - "grunt-coffeelint": "0.0.6", - "temp": "~0.5.0", - "rimraf": "~2.1.4" - }, - "readme": "# underscore-plus [![Build Status](https://travis-ci.org/atom/underscore-plus.svg?branch=master)](https://travis-ci.org/atom/underscore-plus)\n\nTakes the great [underscore](http://underscorejs.org/) library and adds a few\nmore things.\n\n## Using\n\n```sh\nnpm install underscore-plus\n```\n\n```coffeescript\n_ = require 'underscore-plus' # Has all underscore methods and more\n```\n", - "readmeFilename": "README.md", - "_id": "underscore-plus@1.5.0", - "_from": "underscore-plus@1.x" -} diff --git a/.atom/packages/vim-mode/package.json b/.atom/packages/vim-mode/package.json deleted file mode 100644 index 24728ed..0000000 --- a/.atom/packages/vim-mode/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "vim-mode", - "main": "./lib/vim-mode", - "version": "0.12.0", - "description": "Add vim modal control", - "license": "MIT", - "private": true, - "repository": { - "type": "git", - "url": "https://github.com/atom/vim-mode" - }, - "engines": { - "atom": ">0.99.0" - }, - "dependencies": { - "underscore-plus": "1.x" - }, - "readme": "## Vim Mode package [![Build Status](https://travis-ci.org/atom/vim-mode.svg?branch=master)](https://travis-ci.org/atom/vim-mode)\n\nProvides vim modal control for Atom, ideally blending the best of vim\nand Atom.\n\n### Installing\n\nUse the Atom package manager, which can be found in the Settings view or\nrun `apm install vim-mode` from the command line.\n\n### Current Status\n\nSizable portions of Vim's command mode work as you'd expect, including\nmany complex combinations. Even so, this package is far from finished (Vim\nwasn't built in a day).\n\nCurrently, vim-mode requires soft line wraps to be disabled, and has some issues\nwith international keyboard layouts.\n\nIf there's a feature of Vim you're missing, it might just be that you use it\nmore often than other developers. Adding a feature can be quick and easy. Check\nout the [closed pull requests](https://github.com/atom/vim-mode/pulls?direction=desc&page=1&sort=created&state=closed)\nto see examples of community contributions. We're looking forward to yours, too.\n\n### Documentation\n\n* [Overview](https://github.com/atom/vim-mode/blob/master/docs/overview.md)\n* [Motions](https://github.com/atom/vim-mode/blob/master/docs/motions.md)\n* [Operators](https://github.com/atom/vim-mode/blob/master/docs/operators.md)\n* [Windows](https://github.com/atom/vim-mode/blob/master/docs/windows.md)\n* [Scrolling](https://github.com/atom/vim-mode/blob/master/docs/scrolling.md)\n\n### Development\n\n* Create a branch with your feature/fix.\n* Add a spec (take inspiration from the ones that are already there).\n* If you're adding a command be sure to update the appropriate file in\n `docs/`\n* Create a PR.\n\nWhen in doubt, open a PR earlier rather than later so that you can receive\nfeedback from the community. We want to get your fix or feature included as much\nas you do.\n\nSee [the contribution guide](https://github.com/atom/vim-mode/blob/master/CONTRIBUTING.md).\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/atom/vim-mode/issues" - }, - "homepage": "https://github.com/atom/vim-mode", - "_id": "vim-mode@0.12.0", - "dist": { - "shasum": "71e439084b40d892ca62e64659b4e426ce864b47" - }, - "_resolved": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114614-1080-gh1mdu\\package.tgz", - "_from": "C:\\Users\\Adam\\AppData\\Local\\Temp\\d-114614-1080-gh1mdu\\package.tgz" -} diff --git a/.atom/packages/vim-mode/spec/motions-spec.coffee b/.atom/packages/vim-mode/spec/motions-spec.coffee deleted file mode 100644 index 2fe8d9a..0000000 --- a/.atom/packages/vim-mode/spec/motions-spec.coffee +++ /dev/null @@ -1,1410 +0,0 @@ -helpers = require './spec-helper' - -describe "Motions", -> - [editor, editorView, vimState] = [] - - beforeEach -> - vimMode = atom.packages.loadPackage('vim-mode') - vimMode.activateResources() - - editorView = helpers.cacheEditor(editorView) - editor = editorView.editor - - vimState = editorView.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() - - keydown = (key, options={}) -> - options.element ?= editorView[0] - helpers.keydown(key, options) - - commandModeInputKeydown = (key, opts = {}) -> - opts.element = editor.commandModeInputView.editor.find('input').get(0) - opts.raw = true - keydown(key, opts) - - describe "simple motions", -> - beforeEach -> - editor.setText("12345\nabcd\nABCDE") - editor.setCursorScreenPosition([1, 1]) - - describe "the h keybinding", -> - describe "as a motion", -> - it "moves the cursor left, but not to the previous line", -> - keydown('h') - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - keydown('h') - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe "as a selection", -> - it "selects the character to the left", -> - keydown('y') - keydown('h') - - expect(vimState.getRegister('"').text).toBe 'a' - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe "the j keybinding", -> - it "moves the cursor down, but not to the end of the last line", -> - keydown('j') - expect(editor.getCursorScreenPosition()).toEqual [2, 1] - - keydown('j') - expect(editor.getCursorScreenPosition()).toEqual [2, 1] - - it "moves the cursor to the end of the line, not past it", -> - editor.setCursorScreenPosition([0,4]) - - keydown('j') - expect(editor.getCursorScreenPosition()).toEqual [1, 3] - - it "remembers the position it column it was in after moving to shorter line", -> - editor.setCursorScreenPosition([0,4]) - - keydown('j') - expect(editor.getCursorScreenPosition()).toEqual [1, 3] - - keydown('j') - expect(editor.getCursorScreenPosition()).toEqual [2, 4] - - describe "when visual mode", -> - beforeEach -> - keydown('v') - - it "moves the cursor down", -> - keydown('j') - expect(editor.getCursorScreenPosition()).toEqual [2, 1] - - it "don't go over after the last line", -> - keydown('j') - expect(editor.getCursorScreenPosition()).toEqual [2, 1] - - it "selects the text while moving", -> - keydown('j') - expect(editor.getSelectedText()).toBe "bcd\nA" - - describe "the k keybinding", -> - it "moves the cursor up, but not to the beginning of the first line", -> - keydown('k') - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - keydown('k') - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - describe "the l keybinding", -> - beforeEach -> editor.setCursorScreenPosition([1, 2]) - - it "moves the cursor right, but not to the next line", -> - keydown('l') - expect(editor.getCursorScreenPosition()).toEqual [1, 3] - - keydown('l') - expect(editor.getCursorScreenPosition()).toEqual [1, 3] - - describe "the w keybinding", -> - beforeEach -> editor.setText("ab cde1+- \n xyz\n\nzip") - - describe "as a motion", -> - beforeEach -> editor.setCursorScreenPosition([0, 0]) - - it "moves the cursor to the beginning of the next word", -> - keydown('w') - expect(editor.getCursorScreenPosition()).toEqual [0, 3] - - keydown('w') - expect(editor.getCursorScreenPosition()).toEqual [0, 7] - - keydown('w') - expect(editor.getCursorScreenPosition()).toEqual [1, 1] - - keydown('w') - expect(editor.getCursorScreenPosition()).toEqual [2, 0] - - # FIXME: The definition of Cursor#getEndOfCurrentWordBufferPosition, - # means that the end of the word can't be the current cursor - # position (even though it is when your cursor is on a new line). - # - # Therefore it picks the end of the next word here (which is [3,3]) - # to start looking for the next word, which is also the end of the - # buffer so the cursor never advances. - # - # See atom/vim-mode#3 - keydown('w') - expect(editor.getCursorScreenPosition()).toEqual [3, 0] - - keydown('w') - expect(editor.getCursorScreenPosition()).toEqual [3, 3] - - # After cursor gets to the EOF, it should stay there. - keydown('w') - expect(editor.getCursorScreenPosition()).toEqual [3, 3] - - it "moves the cursor to the end of the word if last word in file", -> - editor.setText("abc") - editor.setCursorScreenPosition([0, 0]) - keydown('w') - expect(editor.getCursorScreenPosition()).toEqual([0, 3]) - - describe "as a selection", -> - describe "within a word", -> - beforeEach -> - editor.setCursorScreenPosition([0, 0]) - keydown('y') - keydown('w') - - it "selects to the end of the word", -> - expect(vimState.getRegister('"').text).toBe 'ab ' - - describe "between words", -> - beforeEach -> - editor.setCursorScreenPosition([0, 2]) - keydown('y') - keydown('w') - - it "selects the whitespace", -> - expect(vimState.getRegister('"').text).toBe ' ' - - describe "the W keybinding", -> - beforeEach -> editor.setText("cde1+- ab \n xyz\n\nzip") - - describe "as a motion", -> - beforeEach -> editor.setCursorScreenPosition([0, 0]) - - it "moves the cursor to the beginning of the next word", -> - keydown('W', shift:true) - expect(editor.getCursorScreenPosition()).toEqual [0, 7] - - keydown('W', shift:true) - expect(editor.getCursorScreenPosition()).toEqual [1, 1] - - keydown('W', shift:true) - expect(editor.getCursorScreenPosition()).toEqual [2, 0] - - keydown('W', shift:true) - expect(editor.getCursorScreenPosition()).toEqual [2, 0] - - describe "as a selection", -> - describe "within a word", -> - - it "selects to the end of the whole word", -> - editor.setCursorScreenPosition([0, 0]) - keydown('y') - keydown('W', shift:true) - expect(vimState.getRegister('"').text).toBe 'cde1+- ' - - it "doesn't go past the end of the file", -> - editor.setCursorScreenPosition([2, 0]) - keydown('y') - keydown('W', shift:true) - expect(vimState.getRegister('"').text).toBe '' - - describe "the e keybinding", -> - beforeEach -> editor.setText("ab cde1+- \n xyz\n\nzip") - - describe "as a motion", -> - beforeEach -> editor.setCursorScreenPosition([0, 0]) - - it "moves the cursor to the end of the current word", -> - keydown('e') - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - keydown('e') - expect(editor.getCursorScreenPosition()).toEqual [0, 6] - - keydown('e') - expect(editor.getCursorScreenPosition()).toEqual [0, 8] - - keydown('e') - expect(editor.getCursorScreenPosition()).toEqual [1, 3] - - # INCOMPATIBILITY: vim doesn't stop at [2, 0] it advances immediately - # to [3, 2] - keydown('e') - expect(editor.getCursorScreenPosition()).toEqual [2, 0] - - keydown('e') - expect(editor.getCursorScreenPosition()).toEqual [3, 2] - - describe "as selection", -> - describe "within a word", -> - beforeEach -> - editor.setCursorScreenPosition([0, 0]) - keydown('y') - keydown('e') - - it "selects to the end of the current word", -> - expect(vimState.getRegister('"').text).toBe 'ab' - - describe "between words", -> - beforeEach -> - editor.setCursorScreenPosition([0, 2]) - keydown('y') - keydown('e') - - it "selects to the end of the next word", -> - expect(vimState.getRegister('"').text).toBe ' cde1' - - describe "the E keybinding", -> - beforeEach -> editor.setText("ab cde1+- \n xyz \n\nzip\n") - - describe "as a motion", -> - beforeEach -> editor.setCursorScreenPosition([0, 0]) - - it "moves the cursor to the end of the current word", -> - keydown('E', shift: true) - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - keydown('E', shift: true) - expect(editor.getCursorScreenPosition()).toEqual [0, 9] - - keydown('E', shift: true) - expect(editor.getCursorScreenPosition()).toEqual [1, 3] - - keydown('E', shift: true) - expect(editor.getCursorScreenPosition()).toEqual [3, 2] - - keydown('E', shift: true) - expect(editor.getCursorScreenPosition()).toEqual [4, 0] - - describe "as selection", -> - describe "within a word", -> - beforeEach -> - editor.setCursorScreenPosition([0, 0]) - keydown('y') - keydown('E', shift: true) - - it "selects to the end of the current word", -> - expect(vimState.getRegister('"').text).toBe 'ab' - - describe "between words", -> - beforeEach -> - editor.setCursorScreenPosition([0, 2]) - keydown('y') - keydown('E', shift: true) - - it "selects to the end of the next word", -> - expect(vimState.getRegister('"').text).toBe ' cde1+-' - - describe "press more than once", -> - beforeEach -> - editor.setCursorScreenPosition([0, 0]) - keydown('v') - keydown('E', shift: true) - keydown('E', shift: true) - keydown('y') - - it "selects to the end of the current word", -> - expect(vimState.getRegister('"').text).toBe 'ab cde1+-' - - describe "the } keybinding", -> - beforeEach -> - editor.setText("abcde\n\nfghij\nhijk\n xyz \n\nzip\n\n \nthe end") - editor.setCursorScreenPosition([0, 0]) - - describe "as a motion", -> - it "moves the cursor to the end of the paragraph", -> - keydown('}') - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - keydown('}') - expect(editor.getCursorScreenPosition()).toEqual [5, 0] - - keydown('}') - expect(editor.getCursorScreenPosition()).toEqual [7, 0] - - keydown('}') - expect(editor.getCursorScreenPosition()).toEqual [9, 6] - - describe "as a selection", -> - beforeEach -> - keydown('y') - keydown('}') - - it 'selects to the end of the current paragraph', -> - expect(vimState.getRegister('"').text).toBe "abcde\n" - - describe "the { keybinding", -> - beforeEach -> - editor.setText("abcde\n\nfghij\nhijk\n xyz \n\nzip\n\n \nthe end") - editor.setCursorScreenPosition([9, 0]) - - describe "as a motion", -> - it "moves the cursor to the beginning of the paragraph", -> - keydown('{') - expect(editor.getCursorScreenPosition()).toEqual [7, 0] - - keydown('{') - expect(editor.getCursorScreenPosition()).toEqual [5, 0] - - keydown('{') - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - keydown('{') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "as a selection", -> - beforeEach -> - editor.setCursorScreenPosition([7, 0]) - keydown('y') - keydown('{') - - it 'selects to the beginning of the current paragraph', -> - expect(vimState.getRegister('"').text).toBe "\nzip\n" - - describe "the b keybinding", -> - beforeEach -> editor.setText(" ab cde1+- \n xyz\n\nzip }\n last") - - describe "as a motion", -> - beforeEach -> editor.setCursorScreenPosition([4,1]) - - it "moves the cursor to the beginning of the previous word", -> - keydown('b') - expect(editor.getCursorScreenPosition()).toEqual [3, 4] - - keydown('b') - expect(editor.getCursorScreenPosition()).toEqual [3, 0] - - keydown('b') - expect(editor.getCursorScreenPosition()).toEqual [2, 0] - - keydown('b') - expect(editor.getCursorScreenPosition()).toEqual [1, 1] - - keydown('b') - expect(editor.getCursorScreenPosition()).toEqual [0, 8] - - keydown('b') - expect(editor.getCursorScreenPosition()).toEqual [0, 4] - - keydown('b') - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - # Go to start of the file, after moving past the first word - keydown('b') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - # Stay at the start of the file - keydown('b') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "as a selection", -> - describe "within a word", -> - beforeEach -> - editor.setCursorScreenPosition([0, 2]) - keydown('y') - keydown('b') - - it "selects to the beginning of the current word", -> - expect(vimState.getRegister('"').text).toBe 'a' - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - describe "between words", -> - beforeEach -> - editor.setCursorScreenPosition([0, 4]) - keydown('y') - keydown('b') - - it "selects to the beginning of the last word", -> - expect(vimState.getRegister('"').text).toBe 'ab ' - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - describe "the B keybinding", -> - beforeEach -> editor.setText("cde1+- ab \n xyz-123\n\n zip") - - describe "as a motion", -> - beforeEach -> editor.setCursorScreenPosition([4, 1]) - - it "moves the cursor to the beginning of the previous word", -> - keydown('B', shift:true) - expect(editor.getCursorScreenPosition()).toEqual [3, 1] - - keydown('B', shift:true) - expect(editor.getCursorScreenPosition()).toEqual [2, 0] - - keydown('B', shift:true) - expect(editor.getCursorScreenPosition()).toEqual [1, 1] - - keydown('B', shift:true) - expect(editor.getCursorScreenPosition()).toEqual [0, 7] - - keydown('B', shift:true) - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "as a selection", -> - it "selects to the beginning of the whole word", -> - editor.setCursorScreenPosition([1, 8]) - keydown('y') - keydown('B', shift:true) - expect(vimState.getRegister('"').text).toBe 'xyz-123' - - it "doesn't go past the beginning of the file", -> - editor.setCursorScreenPosition([0, 0]) - keydown('y') - keydown('B', shift:true) - expect(vimState.getRegister('"').text).toBe '' - - describe "the ^ keybinding", -> - beforeEach -> - editor.setText(" abcde") - - describe "from the beginning of the line", -> - beforeEach -> editor.setCursorScreenPosition([0, 0]) - - describe "as a motion", -> - beforeEach -> keydown('^') - - it "moves the cursor to the first character of the line", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('^') - - it 'selects to the first character of the line', -> - expect(editor.getText()).toBe 'abcde' - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "from the first character of the line", -> - beforeEach -> editor.setCursorScreenPosition([0, 2]) - - describe "as a motion", -> - beforeEach -> keydown('^') - - it "stays put", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('^') - - it "does nothing", -> - expect(editor.getText()).toBe ' abcde' - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "from the middle of a word", -> - beforeEach -> editor.setCursorScreenPosition([0, 4]) - - describe "as a motion", -> - beforeEach -> keydown('^') - - it "moves the cursor to the first character of the line", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('^') - - it 'selects to the first character of the line', -> - expect(editor.getText()).toBe ' cde' - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "the 0 keybinding", -> - beforeEach -> - editor.setText(" abcde") - editor.setCursorScreenPosition([0, 4]) - - describe "as a motion", -> - beforeEach -> keydown('0') - - it "moves the cursor to the first column", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('0') - - it 'selects to the first column of the line', -> - expect(editor.getText()).toBe 'cde' - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "the $ keybinding", -> - beforeEach -> - editor.setText(" abcde\n\n1234567890") - editor.setCursorScreenPosition([0, 4]) - - describe "as a motion from empty line", -> - beforeEach -> editor.setCursorScreenPosition([1, 0]) - - it "moves the cursor to the end of the line", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe "as a motion", -> - beforeEach -> keydown('$') - - # FIXME: See atom/vim-mode#2 - it "moves the cursor to the end of the line", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 6] - - it "should remain in the last column when moving down", -> - keydown('j') - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - keydown('j') - expect(editor.getCursorScreenPosition()).toEqual [2, 9] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('$') - - it "selects to the beginning of the lines", -> - expect(editor.getText()).toBe " ab\n\n1234567890" - expect(editor.getCursorScreenPosition()).toEqual [0, 3] - - # FIXME: this doesn't work as we can't determine if this is a motion - # or part of a repeat prefix. - xdescribe "the 0 keybinding", -> - beforeEach -> - editor.setText(" a\n") - editor.setCursorScreenPosition([0, 2]) - - describe "as a motion", -> - beforeEach -> keydown('0') - - it "moves the cursor to the beginning of the line", -> - expect(editor.getCursorScreenPosition()).toEqual [0,0] - - describe "the - keybinding", -> - beforeEach -> - editor.setText("abcdefg\n abc\n abc\n") - - describe "from the middle of a line", -> - beforeEach -> editor.setCursorScreenPosition([1, 3]) - - describe "as a motion", -> - beforeEach -> keydown('-') - - it "moves the cursor to the first character of the previous line", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('-') - - it "deletes the current and previous line", -> - expect(editor.getText()).toBe " abc\n" - # commented out because the column is wrong due to a bug in `k`; re-enable when `k` is fixed - #expect(editor.getCursorScreenPosition()).toEqual [0, 3] - - describe "from the first character of a line indented the same as the previous one", -> - beforeEach -> editor.setCursorScreenPosition([2, 2]) - - describe "as a motion", -> - beforeEach -> keydown('-') - - it "moves to the first character of the previous line (directly above)", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 2] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('-') - - it "selects to the first character of the previous line (directly above)", -> - expect(editor.getText()).toBe "abcdefg\n" - # commented out because the column is wrong due to a bug in `k`; re-enable when `k` is fixed - #expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "from the beginning of a line preceded by an indented line", -> - beforeEach -> editor.setCursorScreenPosition([2, 0]) - - describe "as a motion", -> - beforeEach -> keydown('-') - - it "moves the cursor to the first character of the previous line", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 2] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('-') - - it "selects to the first character of the previous line", -> - expect(editor.getText()).toBe "abcdefg\n" - # commented out because the column is wrong due to a bug in `k`; re-enable when `k` is fixed - #expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "with a count", -> - beforeEach -> - editor.setText("1\n2\n3\n4\n5\n6\n") - editor.setCursorScreenPosition([4, 0]) - - describe "as a motion", -> - beforeEach -> - keydown('3') - keydown('-') - - it "moves the cursor to the first character of that many lines previous", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('3') - keydown('-') - - it "deletes the current line plus that many previous lines", -> - expect(editor.getText()).toBe "1\n6\n" - # commented out because the column is wrong due to a bug in `k`; re-enable when `k` is fixed - #expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe "the + keybinding", -> - beforeEach -> - editor.setText(" abc\n abc\nabcdefg\n") - - describe "from the middle of a line", -> - beforeEach -> editor.setCursorScreenPosition([1, 3]) - - describe "as a motion", -> - beforeEach -> keydown('+') - - it "moves the cursor to the first character of the next line", -> - expect(editor.getCursorScreenPosition()).toEqual [2, 0] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('+') - - it "deletes the current and next line", -> - expect(editor.getText()).toBe " abc\n" - # commented out because the column is wrong due to a bug in `j`; re-enable when `j` is fixed - #expect(editor.getCursorScreenPosition()).toEqual [0, 3] - - describe "from the first character of a line indented the same as the next one", -> - beforeEach -> editor.setCursorScreenPosition([0, 2]) - - describe "as a motion", -> - beforeEach -> keydown('+') - - it "moves to the first character of the next line (directly below)", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 2] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('+') - - it "selects to the first character of the next line (directly below)", -> - expect(editor.getText()).toBe "abcdefg\n" - # commented out because the column is wrong due to a bug in `j`; re-enable when `j` is fixed - #expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "from the beginning of a line followed by an indented line", -> - beforeEach -> editor.setCursorScreenPosition([0, 0]) - - describe "as a motion", -> - beforeEach -> keydown('+') - - it "moves the cursor to the first character of the next line", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 2] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('+') - - it "selects to the first character of the next line", -> - expect(editor.getText()).toBe "abcdefg\n" - # commented out because the column is wrong due to a bug in `j`; re-enable when `j` is fixed - #expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "with a count", -> - beforeEach -> - editor.setText("1\n2\n3\n4\n5\n6\n") - editor.setCursorScreenPosition([1, 0]) - - describe "as a motion", -> - beforeEach -> - keydown('3') - keydown('+') - - it "moves the cursor to the first character of that many lines following", -> - expect(editor.getCursorScreenPosition()).toEqual [4, 0] - - describe "as a selection", -> - beforeEach -> - keydown('d') - keydown('3') - keydown('+') - - it "deletes the current line plus that many following lines", -> - expect(editor.getText()).toBe "1\n6\n" - # commented out because the column is wrong due to a bug in `j`; re-enable when `j` is fixed - #expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe "the enter keybinding", -> - keydownCodeForEnter = '\r' # 'enter' does not work - startingText = " abc\n abc\nabcdefg\n" - - describe "from the middle of a line", -> - startingCursorPosition = [1, 3] - - describe "as a motion", -> - it "acts the same as the + keybinding", -> - # do it with + and save the results - editor.setText(startingText) - editor.setCursorScreenPosition(startingCursorPosition) - keydown('+') - referenceCursorPosition = editor.getCursorScreenPosition() - # do it again with enter and compare the results - editor.setText(startingText) - editor.setCursorScreenPosition(startingCursorPosition) - keydown(keydownCodeForEnter) - expect(editor.getCursorScreenPosition()).toEqual referenceCursorPosition - - describe "as a selection", -> - it "acts the same as the + keybinding", -> - # do it with + and save the results - editor.setText(startingText) - editor.setCursorScreenPosition(startingCursorPosition) - keydown('d') - keydown('+') - referenceText = editor.getText() - referenceCursorPosition = editor.getCursorScreenPosition() - # do it again with enter and compare the results - editor.setText(startingText) - editor.setCursorScreenPosition(startingCursorPosition) - keydown('d') - keydown(keydownCodeForEnter) - expect(editor.getText()).toEqual referenceText - expect(editor.getCursorScreenPosition()).toEqual referenceCursorPosition - - describe "the gg keybinding", -> - beforeEach -> - editor.setText(" 1abc\n 2\n3\n") - editor.setCursorScreenPosition([0, 2]) - - describe "as a motion", -> - describe "in command mode", -> - beforeEach -> - keydown('g') - keydown('g') - - it "moves the cursor to the beginning of the first line", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - describe "in linewise visual mode", -> - beforeEach -> - editor.setCursorScreenPosition([1, 0]) - vimState.activateVisualMode('linewise') - keydown('g') - keydown('g') - - it "selects to the first line in the file", -> - expect(editor.getSelectedText()).toBe " 1abc\n 2\n" - - it "moves the cursor to a specified line", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "in characterwise visual mode", -> - beforeEach -> - editor.setCursorScreenPosition([1, 1]) - vimState.activateVisualMode() - keydown('g') - keydown('g') - - it "selects to the first line in the file", -> - expect(editor.getSelectedText()).toBe "1abc\n 2" - - it "moves the cursor to a specified line", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - describe "as a repeated motion", -> - describe "in command mode", -> - beforeEach -> - keydown('2') - keydown('g') - keydown('g') - - it "moves the cursor to a specified line", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 1] - - describe "in linewise visual motion", -> - beforeEach -> - editor.setCursorScreenPosition([2, 0]) - vimState.activateVisualMode('linewise') - keydown('2') - keydown('g') - keydown('g') - - it "selects to a specified line", -> - expect(editor.getSelectedText()).toBe " 2\n3\n" - - it "moves the cursor to a specified line", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe "in characterwise visual motion", -> - beforeEach -> - editor.setCursorScreenPosition([2, 0]) - vimState.activateVisualMode() - keydown('2') - keydown('g') - keydown('g') - - it "selects to a first character of specified line", -> - expect(editor.getSelectedText()).toBe "2\n3" - - it "moves the cursor to a specified line", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 1] - - describe "the G keybinding", -> - beforeEach -> - editor.setText("1\n 2\n 3abc\n ") - editor.setCursorScreenPosition([0, 2]) - - describe "as a motion", -> - beforeEach -> keydown('G', shift: true) - - it "moves the cursor to the last line after whitespace", -> - expect(editor.getCursorScreenPosition()).toEqual [3, 1] - - describe "as a repeated motion", -> - beforeEach -> - keydown('2') - keydown('G', shift: true) - - it "moves the cursor to a specified line", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 4] - - describe "as a selection", -> - beforeEach -> - editor.setCursorScreenPosition([1, 0]) - vimState.activateVisualMode() - keydown('G', shift: true) - - it "selects to the last line in the file", -> - expect(editor.getSelectedText()).toBe " 2\n 3abc\n " - - it "moves the cursor to the last line after whitespace", -> - expect(editor.getCursorScreenPosition()).toEqual [3,1] - - describe "the / keybinding", -> - beforeEach -> - editor.setText("abc\ndef\nabc\ndef\n") - editor.setCursorBufferPosition([0, 0]) - - describe "as a motion", -> - it "moves the cursor to the specified search pattern", -> - keydown('/') - - editor.commandModeInputView.editor.setText 'def' - editor.commandModeInputView.editor.trigger 'core:confirm' - - expect(editor.getCursorBufferPosition()).toEqual [1, 0] - - it "loops back around", -> - editor.setCursorBufferPosition([3, 0]) - keydown('/') - editor.commandModeInputView.editor.setText 'def' - editor.commandModeInputView.editor.trigger 'core:confirm' - - expect(editor.getCursorBufferPosition()).toEqual [1, 0] - - it "uses a valid regex as a regex", -> - keydown('/') - # Cycle through the 'abc' on the first line with a character pattern - editor.commandModeInputView.editor.setText '[abc]' - editor.commandModeInputView.editor.trigger 'core:confirm' - expect(editor.getCursorBufferPosition()).toEqual [0, 1] - keydown('n') - expect(editor.getCursorBufferPosition()).toEqual [0, 2] - - it "uses an invalid regex as a literal string", -> - # Go straight to the literal [abc - editor.setText("abc\n[abc]\n") - keydown('/') - editor.commandModeInputView.editor.setText '[abc' - editor.commandModeInputView.editor.trigger 'core:confirm' - expect(editor.getCursorBufferPosition()).toEqual [1, 0] - keydown('n') - expect(editor.getCursorBufferPosition()).toEqual [1, 0] - - it 'works with selection in visual mode', -> - editor.setText('one two three') - keydown('v') - keydown('/') - editor.commandModeInputView.editor.setText 'th' - editor.commandModeInputView.editor.trigger 'core:confirm' - expect(editor.getCursorBufferPosition()).toEqual [0, 8] - keydown('d') - expect(editor.getText()).toBe 'three' - - it 'extends selection when repeating search in visual mode', -> - editor.setText('line1\nline2\nline3') - keydown('v') - keydown('/') - editor.commandModeInputView.editor.setText 'line' - editor.commandModeInputView.editor.trigger 'core:confirm' - {start, end} = editor.getSelectedBufferRange() - expect(start.row).toEqual 0 - expect(end.row).toEqual 1 - keydown('n') - {start,end} = editor.getSelectedBufferRange() - expect(start.row).toEqual 0 - expect(end.row).toEqual 2 - - describe "repeating", -> - it "does nothing with no search history", -> - # This tests that no exception is raised - keydown('n') - - beforeEach -> - keydown('/') - editor.commandModeInputView.editor.setText 'def' - editor.commandModeInputView.editor.trigger 'core:confirm' - - describe "the n keybinding", -> - it "repeats the last search", -> - keydown('n') - expect(editor.getCursorBufferPosition()).toEqual [3, 0] - - describe "the N keybinding", -> - it "repeats the last search backwards", -> - editor.setCursorBufferPosition([0, 0]) - keydown('N', shift: true) - expect(editor.getCursorBufferPosition()).toEqual [3, 0] - keydown('N', shift: true) - expect(editor.getCursorBufferPosition()).toEqual [1, 0] - - describe "composing", -> - it "composes with operators", -> - keydown('d') - keydown('/') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') - expect(editor.getText()).toEqual "def\nabc\ndef\n" - - it "repeats correctly with operators", -> - keydown('d') - keydown('/') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') - - keydown('.') - expect(editor.getText()).toEqual "def\n" - - describe "when reversed as ?", -> - it "moves the cursor backwards to the specified search pattern", -> - keydown('?') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') - expect(editor.getCursorBufferPosition()).toEqual [3, 0] - - describe "repeating", -> - beforeEach -> - keydown('?') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') - - describe 'the n keybinding', -> - it "repeats the last search backwards", -> - editor.setCursorBufferPosition([0, 0]) - keydown('n') - expect(editor.getCursorBufferPosition()).toEqual [3, 0] - - describe 'the N keybinding', -> - it "repeats the last search forwards", -> - editor.setCursorBufferPosition([0, 0]) - keydown('N', shift: true) - expect(editor.getCursorBufferPosition()).toEqual [1, 0] - - describe "using search history", -> - beforeEach -> - keydown('/') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') - expect(editor.getCursorBufferPosition()).toEqual [1, 0] - - keydown('/') - editor.commandModeInputView.editor.setText('abc') - editor.commandModeInputView.editor.trigger('core:confirm') - expect(editor.getCursorBufferPosition()).toEqual [2, 0] - - it "allows searching history in the search field", -> - keydown('/') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('abc') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('def') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('def') - - it "resets the search field to empty when scrolling back", -> - keydown('/') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('abc') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('def') - editor.commandModeInputView.editor.trigger('core:move-down') - expect(editor.commandModeInputView.editor.getText()).toEqual('abc') - editor.commandModeInputView.editor.trigger('core:move-down') - expect(editor.commandModeInputView.editor.getText()).toEqual '' - - describe "the * keybinding", -> - beforeEach -> - editor.setText("abc\n@def\nabc\ndef\n") - editor.setCursorBufferPosition([0, 0]) - - describe "as a motion", -> - it "moves cursor to next occurence of word under cursor", -> - keydown("*") - expect(editor.getCursorBufferPosition()).toEqual [2, 0] - - it "doesn't move cursor unless next occurence is the exact word (no partial matches)", -> - editor.setText("abc\ndef\nghiabc\njkl\nabcdef") - editor.setCursorBufferPosition([0, 0]) - keydown("*") - expect(editor.getCursorBufferPosition()).toEqual [0, 0] - - describe "with words that contain 'non-word' characters", -> - it "moves cursor to next occurence of word under cursor", -> - editor.setText("abc\n@def\nabc\n@def\n") - editor.setCursorBufferPosition([1, 0]) - keydown("*") - expect(editor.getCursorBufferPosition()).toEqual [3, 0] - - it "doesn't move cursor unless next match has exact word ending", -> - editor.setText("abc\n@def\nabc\n@def1\n") - # FIXME: I suspect there is a bug laying around - # Cursor#getEndOfCurrentWordBufferPosition, this function - # is returning '@' as a word, instead of returning the whole - # word '@def', this behavior is avoided in this test, when we - # execute the '*' command when cursor is on character after '@' - # (in this particular example, the 'd' char) - editor.setCursorBufferPosition([1, 1]) - keydown("*") - expect(editor.getCursorBufferPosition()).toEqual [1, 0] - - # FIXME: This behavior is different from the one found in - # vim. This is because the word boundary match in Javascript - # ignores starting 'non-word' characters. - # e.g. - # in Vim: /\/.test("@def") => false - # in Javascript: /\bdef\b/.test("@def") => true - it "moves cursor to the start of valid word char", -> - editor.setText("abc\ndef\nabc\n@def\n") - editor.setCursorBufferPosition([1, 0]) - keydown("*") - expect(editor.getCursorBufferPosition()).toEqual [3, 1] - - describe "when cursor is on non-word char column", -> - it "matches only the non-word char", -> - editor.setText("abc\n@def\nabc\n@def\n") - editor.setCursorBufferPosition([1, 0]) - keydown("*") - expect(editor.getCursorBufferPosition()).toEqual [3, 0] - - describe "when cursor is not on a word", -> - it "does a match with the next word", -> - editor.setText("abc\n @def\n abc\n @def") - editor.setCursorBufferPosition([1, 0]) - keydown("*") - expect(editor.getCursorBufferPosition()).toEqual [3, 1] - - describe "when cursor is at EOF", -> - it "doesn't try to do any match", -> - editor.setText("abc\n@def\nabc\n ") - editor.setCursorBufferPosition([3, 0]) - keydown("*") - expect(editor.getCursorBufferPosition()).toEqual [3, 1] - - describe "the hash keybinding", -> - describe "as a motion", -> - it "moves cursor to next occurence of word under cursor", -> - editor.setText("abc\n@def\nabc\ndef\n") - editor.setCursorBufferPosition([2, 0]) - keydown("#") - expect(editor.getCursorBufferPosition()).toEqual [0, 0] - - it "doesn't move cursor unless next occurence is the exact word (no partial matches)", -> - editor.setText("abc\ndef\nghiabc\njkl\nabcdef") - editor.setCursorBufferPosition([0, 0]) - keydown("#") - expect(editor.getCursorBufferPosition()).toEqual [0, 0] - - describe "with words that containt 'non-word' characters", -> - it "moves cursor to next occurence of word under cursor", -> - editor.setText("abc\n@def\nabc\n@def\n") - editor.setCursorBufferPosition([3, 0]) - keydown("#") - expect(editor.getCursorBufferPosition()).toEqual [1, 0] - - it "moves cursor to the start of valid word char", -> - editor.setText("abc\n@def\nabc\ndef\n") - editor.setCursorBufferPosition([3, 0]) - keydown("#") - expect(editor.getCursorBufferPosition()).toEqual [1, 1] - - describe "when cursor is on non-word char column", -> - it "matches only the non-word char", -> - editor.setText("abc\n@def\nabc\n@def\n") - editor.setCursorBufferPosition([1, 0]) - keydown("*") - expect(editor.getCursorBufferPosition()).toEqual [3, 0] - - describe "the H keybinding", -> - beforeEach -> - editor.setText("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n") - editor.setCursorScreenPosition([8, 0]) - spyOn(editor, 'setCursorScreenPosition') - - it "moves the cursor to the first row if visible", -> - spyOn(editorView, 'getFirstVisibleScreenRow').andReturn(0) - keydown('H', shift: true) - expect(editor.setCursorScreenPosition).toHaveBeenCalledWith([0, 0]) - - it "moves the cursor to the first visible row plus offset", -> - spyOn(editorView, 'getFirstVisibleScreenRow').andReturn(2) - keydown('H', shift: true) - expect(editor.setCursorScreenPosition).toHaveBeenCalledWith([4, 0]) - - it "respects counts", -> - spyOn(editorView, 'getFirstVisibleScreenRow').andReturn(0) - keydown('3') - keydown('H', shift: true) - expect(editor.setCursorScreenPosition).toHaveBeenCalledWith([2, 0]) - - describe "the L keybinding", -> - beforeEach -> - editor.setText("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n") - editor.setCursorScreenPosition([8, 0]) - spyOn(editor, 'setCursorScreenPosition') - - it "moves the cursor to the first row if visible", -> - spyOn(editorView, 'getLastVisibleScreenRow').andReturn(10) - keydown('L', shift: true) - expect(editor.setCursorScreenPosition).toHaveBeenCalledWith([10, 0]) - - it "moves the cursor to the first visible row plus offset", -> - spyOn(editorView, 'getLastVisibleScreenRow').andReturn(6) - keydown('L', shift: true) - expect(editor.setCursorScreenPosition).toHaveBeenCalledWith([4, 0]) - - it "respects counts", -> - spyOn(editorView, 'getLastVisibleScreenRow').andReturn(10) - keydown('3') - keydown('L', shift: true) - expect(editor.setCursorScreenPosition).toHaveBeenCalledWith([8, 0]) - - describe "the M keybinding", -> - beforeEach -> - editor.setText("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n") - editor.setCursorScreenPosition([8, 0]) - spyOn(editor, 'setCursorScreenPosition') - spyOn(editorView, 'getLastVisibleScreenRow').andReturn(10) - spyOn(editorView, 'getFirstVisibleScreenRow').andReturn(0) - - it "moves the cursor to the first row if visible", -> - keydown('M', shift: true) - expect(editor.setCursorScreenPosition).toHaveBeenCalledWith([5, 0]) - - describe 'the mark keybindings', -> - beforeEach -> - editor.setText(' 12\n 34\n56\n') - editor.setCursorBufferPosition([0,1]) - - it 'moves to the beginning of the line of a mark', -> - editor.setCursorBufferPosition([1,1]) - keydown('m') - commandModeInputKeydown('a') - editor.setCursorBufferPosition([0,0]) - keydown('\'') - commandModeInputKeydown('a') - expect(editor.getCursorBufferPosition()).toEqual [1,4] - - it 'moves literally to a mark', -> - editor.setCursorBufferPosition([1,1]) - keydown('m') - commandModeInputKeydown('a') - editor.setCursorBufferPosition([0,0]) - keydown('`') - commandModeInputKeydown('a') - expect(editor.getCursorBufferPosition()).toEqual [1,1] - - it 'deletes to a mark by line', -> - editor.setCursorBufferPosition([1,5]) - keydown('m') - commandModeInputKeydown('a') - editor.setCursorBufferPosition([0,0]) - keydown('d') - keydown('\'') - commandModeInputKeydown('a') - expect(editor.getText()).toEqual '\n56\n' - - it 'deletes before to a mark literally', -> - editor.setCursorBufferPosition([1,5]) - keydown('m') - commandModeInputKeydown('a') - editor.setCursorBufferPosition([0,1]) - keydown('d') - keydown('`') - commandModeInputKeydown('a') - expect(editor.getText()).toEqual ' 4\n56\n' - - it 'deletes after to a mark literally', -> - editor.setCursorBufferPosition([1,5]) - keydown('m') - commandModeInputKeydown('a') - editor.setCursorBufferPosition([2,1]) - keydown('d') - keydown('`') - commandModeInputKeydown('a') - expect(editor.getText()).toEqual ' 12\n 36\n' - - it 'moves back to previous', -> - editor.setCursorBufferPosition([1,5]) - keydown('`') - commandModeInputKeydown('`') - editor.setCursorBufferPosition([2,1]) - keydown('`') - commandModeInputKeydown('`') - expect(editor.getCursorBufferPosition()).toEqual [1,5] - - - describe 'the f/F keybindings', -> - beforeEach -> - editor.setText("abcabcabcabc\n") - editor.setCursorScreenPosition([0, 0]) - - it 'moves to the first specified character it finds', -> - keydown('f') - commandModeInputKeydown('c') - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - it 'moves backwards to the first specified character it finds', -> - editor.setCursorScreenPosition([0, 2]) - keydown('F', shift: true) - commandModeInputKeydown('a') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - it 'respects count forward', -> - keydown('2') - keydown('f') - commandModeInputKeydown('a') - expect(editor.getCursorScreenPosition()).toEqual [0, 6] - - it 'respects count backward', -> - editor.setCursorScreenPosition([0, 6]) - keydown('2') - keydown('F', shift: true) - commandModeInputKeydown('a') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - it "doesn't move if the character specified isn't found", -> - keydown('f') - commandModeInputKeydown('d') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - it "doesn't move if there aren't the specified count of the specified character", -> - keydown('1') - keydown('0') - keydown('f') - commandModeInputKeydown('a') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - it "composes with d", -> - editor.setCursorScreenPosition([0,3]) - keydown('d') - keydown('2') - keydown('f') - commandModeInputKeydown('a') - expect(editor.getText()).toEqual 'abcbc\n' - - describe 'the t/T keybindings', -> - beforeEach -> - editor.setText("abcabcabcabc\n") - editor.setCursorScreenPosition([0, 0]) - - it 'moves to the character previous to the first specified character it finds', -> - keydown('t') - commandModeInputKeydown('a') - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - it 'moves backwards to the character after the first specified character it finds', -> - editor.setCursorScreenPosition([0, 2]) - keydown('T', shift: true) - commandModeInputKeydown('a') - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - it 'respects count forward', -> - keydown('2') - keydown('t') - commandModeInputKeydown('a') - expect(editor.getCursorScreenPosition()).toEqual [0, 5] - - it 'respects count backward', -> - editor.setCursorScreenPosition([0, 6]) - keydown('2') - keydown('T', shift: true) - commandModeInputKeydown('a') - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - it "doesn't move if the character specified isn't found", -> - keydown('t') - commandModeInputKeydown('d') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - it "doesn't move if there aren't the specified count of the specified character", -> - keydown('1') - keydown('0') - keydown('t') - commandModeInputKeydown('a') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - it "composes with d", -> - editor.setCursorScreenPosition([0,3]) - keydown('d') - keydown('2') - keydown('t') - commandModeInputKeydown('a') - expect(editor.getText()).toEqual 'abcabc\n' - - describe 'the % motion', -> - beforeEach -> - editor.setText("( ( ) )--{ text in here; and a function call(with parameters) }\n") - editor.setCursorScreenPosition([0, 0]) - - it 'matches the correct parenthesis', -> - keydown('%') - expect(editor.getCursorScreenPosition()).toEqual [0, 6] - - it 'matches the correct brace', -> - editor.setCursorScreenPosition([0, 9]) - keydown('%') - expect(editor.getCursorScreenPosition()).toEqual [0, 62] - - it 'composes correctly with d', -> - editor.setCursorScreenPosition([0, 9]) - keydown('d') - keydown('%') - expect(editor.getText()).toEqual "( ( ) )--\n" - - it 'moves correctly when composed with v going forward', -> - keydown('v') - keydown('%') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - it 'moves correctly when composed with v going backward', -> - editor.setCursorScreenPosition([0, 6]) - keydown('v') - keydown('%') - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - it 'it moves appropriately to find the nearest matching action', -> - editor.setCursorScreenPosition([0, 3]) - keydown('%') - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - expect(editor.getText()).toEqual "( ( ) )--{ text in here; and a function call(with parameters) }\n" - - it 'it moves appropriately to find the nearest matching action', -> - editor.setCursorScreenPosition([0, 26]) - keydown('%') - expect(editor.getCursorScreenPosition()).toEqual [0, 60] - expect(editor.getText()).toEqual "( ( ) )--{ text in here; and a function call(with parameters) }\n" diff --git a/.atom/packages/vim-mode/spec/operators-spec.coffee b/.atom/packages/vim-mode/spec/operators-spec.coffee deleted file mode 100644 index 48b7f46..0000000 --- a/.atom/packages/vim-mode/spec/operators-spec.coffee +++ /dev/null @@ -1,1036 +0,0 @@ -helpers = require './spec-helper' - -describe "Operators", -> - [editor, editorView, vimState] = [] - - beforeEach -> - vimMode = atom.packages.loadPackage('vim-mode') - vimMode.activateResources() - - editorView = helpers.cacheEditor(editorView) - editor = editorView.editor - - vimState = editorView.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() - - keydown = (key, options={}) -> - options.element ?= editorView[0] - helpers.keydown(key, options) - - commandModeInputKeydown = (key, opts = {}) -> - opts.element = editor.commandModeInputView.editor.find('input').get(0) - opts.raw = true - keydown(key, opts) - - describe "cancel operation is robust", -> - it "can call cancel operation, even if no operator pending", -> - # cancel operation pushes an empty input operation - # doing this without a pending operation throws an exception - expect(-> vimState.pushOperations(new Input(''))).toThrow() - - # make sure commandModeInputView is created - keydown('/') - expect(vimState.isOperatorPending()).toBe true - editor.commandModeInputView.viewModel.cancel() - - # now again cancel op, although there is none pending - expect(vimState.isOperatorPending()).toBe false - - # which should not raise an exception - expect(-> editor.commandModeInputView.viewModel.cancel()).not.toThrow() - - - describe "the x keybinding", -> - describe "on a line with content", -> - beforeEach -> - editor.setText("012345") - editor.setCursorScreenPosition([0, 4]) - - it "deletes a character", -> - keydown('x') - expect(editor.getText()).toBe '01235' - expect(editor.getCursorScreenPosition()).toEqual [0, 4] - expect(vimState.getRegister('"').text).toBe '4' - - keydown('x') - expect(editor.getText()).toBe '0123' - expect(editor.getCursorScreenPosition()).toEqual [0, 3] - expect(vimState.getRegister('"').text).toBe '5' - - keydown('x') - expect(editor.getText()).toBe '012' - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - expect(vimState.getRegister('"').text).toBe '3' - - describe "on an empty line", -> - beforeEach -> - editor.setText("012345\n\nabcdef") - editor.setCursorScreenPosition([1, 0]) - keydown('x') - - it "deletes nothing when cursor is on empty line", -> - expect(editor.getText()).toBe "012345\n\nabcdef" - - describe "the X keybinding", -> - describe "on a line with content", -> - beforeEach -> - editor.setText("012345") - editor.setCursorScreenPosition([0, 2]) - - it "deletes a character", -> - keydown('X', shift: true) - expect(editor.getText()).toBe '02345' - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(vimState.getRegister('"').text).toBe '1' - - keydown('X', shift: true) - expect(editor.getText()).toBe '2345' - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - expect(vimState.getRegister('"').text).toBe '0' - - keydown('X', shift: true) - expect(editor.getText()).toBe '2345' - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - expect(vimState.getRegister('"').text).toBe '0' - - describe "on an empty line", -> - beforeEach -> - editor.setText("012345\n\nabcdef") - editor.setCursorScreenPosition([1, 0]) - keydown('X', shift: true) - - it "deletes nothing when cursor is on empty line", -> - expect(editor.getText()).toBe "012345\n\nabcdef" - - describe "the s keybinding", -> - beforeEach -> - editor.setText('012345') - editor.setCursorScreenPosition([0, 1]) - - it "deletes the character to the right and enters insert mode", -> - keydown('s') - expect(editorView).toHaveClass 'insert-mode' - expect(editor.getText()).toBe '02345' - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(vimState.getRegister('"').text).toBe '1' - - it "is repeatable", -> - editor.setCursorScreenPosition([0, 0]) - keydown('3') - keydown('s') - editor.insertText("ab") - keydown('escape') - expect(editor.getText()).toBe 'ab345' - editor.setCursorScreenPosition([0, 2]) - keydown('.') - expect(editor.getText()).toBe 'abab' - - it "is undoable", -> - editor.setCursorScreenPosition([0, 0]) - keydown('3') - keydown('s') - editor.insertText("ab") - keydown('escape') - expect(editor.getText()).toBe 'ab345' - keydown('u') - expect(editor.getText()).toBe '012345' - - describe "in visual mode", -> - beforeEach -> - keydown('v') - editor.selectRight() - editor.selectRight() - keydown('s') - - it "deletes the selected characters and enters insert mode", -> - expect(editorView).toHaveClass 'insert-mode' - expect(editor.getText()).toBe '0345' - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(vimState.getRegister('"').text).toBe '12' - - describe "the S keybinding", -> - beforeEach -> - editor.setText("12345\nabcde\nABCDE") - editor.setCursorScreenPosition([1, 3]) - - it "deletes the entire line and enters insert mode", -> - keydown('S', shift: true) - expect(editorView).toHaveClass 'insert-mode' - expect(editor.getText()).toBe "12345\n\nABCDE" - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - expect(vimState.getRegister('"').text).toBe "abcde\n" - expect(vimState.getRegister('"').type).toBe 'linewise' - - it "is repeatable", -> - keydown('S', shift: true) - editor.insertText("abc") - keydown 'escape' - expect(editor.getText()).toBe "12345\nabc\nABCDE" - editor.setCursorScreenPosition([2, 3]) - keydown '.' - expect(editor.getText()).toBe "12345\nabc\nabc\n" - - it "is undoable", -> - keydown('S', shift: true) - editor.insertText("abc") - keydown 'escape' - expect(editor.getText()).toBe "12345\nabc\nABCDE" - keydown 'u' - expect(editor.getText()).toBe "12345\nabcde\nABCDE" - - # Can't be tested without setting grammar of test buffer - xit "respects indentation", -> - - describe "the d keybinding", -> - it "enters operator-pending mode", -> - keydown('d') - expect(editorView).toHaveClass('operator-pending-mode') - expect(editorView).not.toHaveClass('command-mode') - - describe "when followed by a d", -> - it "deletes the current line and exits operator-pending mode", -> - editor.setText("12345\nabcde\n\nABCDE") - editor.setCursorScreenPosition([1, 1]) - - keydown('d') - keydown('d') - - expect(editor.getText()).toBe "12345\n\nABCDE" - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - expect(vimState.getRegister('"').text).toBe "abcde\n" - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - it "deletes the last line", -> - editor.setText("12345\nabcde\nABCDE") - editor.setCursorScreenPosition([2, 1]) - - keydown('d') - keydown('d') - - expect(editor.getText()).toBe "12345\nabcde" - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe "undo behavior", -> - beforeEach -> - editor.setText("12345\nabcde\nABCDE\nQWERT") - editor.setCursorScreenPosition([1,1]) - - keydown('d') - keydown('2') - keydown('d') - - keydown('u') - - it "undoes both lines", -> - expect(editor.getText()).toBe "12345\nabcde\nABCDE\nQWERT" - - describe "when followed by a w", -> - it "deletes the next word until the end of the line and exits operator-pending mode", -> - editor.setText("abcd efg\nabc") - editor.setCursorScreenPosition([0, 5]) - - keydown('d') - keydown('w') - - expect(editor.getText()).toBe "abcd \nabc" - expect(editor.getCursorScreenPosition()).toEqual [0, 4] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - it "deletes to the beginning of the next word", -> - editor.setText('abcd efg') - editor.setCursorScreenPosition([0, 2]) - - keydown('d') - keydown('w') - - expect(editor.getText()).toBe 'abefg' - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - editor.setText('one two three four') - editor.setCursorScreenPosition([0, 0]) - - keydown('d') - keydown('3') - keydown('w') - - expect(editor.getText()).toBe 'four' - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "when followed by an iw", -> - it "deletes the containing word", -> - editor.setText("12345 abcde ABCDE") - editor.setCursorScreenPosition([0, 9]) - - keydown('d') - expect(editorView).toHaveClass('operator-pending-mode') - keydown('i') - keydown('w') - - expect(editor.getText()).toBe "12345 ABCDE" - expect(editor.getCursorScreenPosition()).toEqual [0, 6] - expect(vimState.getRegister('"').text).toBe "abcde" - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - describe "when followed by an j", -> - beforeEach -> - originalText = "12345\nabcde\nABCDE" - editor.setText(originalText) - - describe "on the beginning of the file", -> - editor.setCursorScreenPosition([0, 0]) - it "deletes the next two lines", -> - keydown('d') - keydown('j') - expect(editor.getText()).toBe("ABCDE") - - describe "on the end of the file", -> - editor.setCursorScreenPosition([4,2]) - it "deletes nothing", -> - keydown('d') - keydown('j') - expect(editor.getText()).toBe(originalText) - - describe "on the middle of second line", -> - editor.setCursorScreenPosition([2,1]) - it "deletes the last two lines", -> - keydown('d') - keydown('j') - expect(editor.getText()).toBe("12345") - - describe "when followed by an k", -> - beforeEach -> - originalText = "12345\nabcde\nABCDE" - editor.setText(originalText) - - describe "on the end of the file", -> - editor.setCursorScreenPosition([4, 2]) - it "deletes the bottom two lines", -> - keydown('d') - keydown('k') - expect(editor.getText()).toBe("ABCDE") - - describe "on the beginning of the file", -> - editor.setCursorScreenPosition([0,0]) - it "deletes nothing", -> - keydown('d') - keydown('k') - expect(editor.getText()).toBe(originalText) - - describe "when on the middle of second line", -> - editor.setCursorScreenPosition([2,1]) - it "deletes the first two lines", -> - keydown('d') - keydown('k') - expect(editor.getText()).toBe("12345") - - - describe "the D keybinding", -> - beforeEach -> - editor.getBuffer().setText("012\n") - editor.setCursorScreenPosition([0, 1]) - keydown('D', shift: true) - - it "deletes the contents until the end of the line", -> - expect(editor.getText()).toBe "0\n" - - describe "the c keybinding", -> - beforeEach -> - editor.setText("12345\nabcde\nABCDE") - - describe "when followed by a c", -> - it "deletes the current line and enters insert mode", -> - editor.setCursorScreenPosition([1, 1]) - - keydown('c') - keydown('c') - - expect(editor.getText()).toBe "12345\n\nABCDE" - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - expect(editorView).not.toHaveClass 'command-mode' - expect(editorView).toHaveClass 'insert-mode' - - describe "when the cursor is on the last line", -> - it "deletes the line's content and enters insert mode on the last line", -> - editor.setCursorScreenPosition([2, 1]) - - keydown('c') - keydown('c') - - expect(editor.getText()).toBe "12345\nabcde\n" - expect(editor.getCursorScreenPosition()).toEqual [2, 0] - expect(editorView).not.toHaveClass 'command-mode' - expect(editorView).toHaveClass 'insert-mode' - - describe "when the cursor is on the only line", -> - it "deletes the line's content and enters insert mode", -> - editor.setText("12345") - editor.setCursorScreenPosition([0, 2]) - - keydown('c') - keydown('c') - - expect(editor.getText()).toBe "" - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - expect(editorView).not.toHaveClass 'command-mode' - expect(editorView).toHaveClass 'insert-mode' - - describe "when followed by i w", -> - it "undo's and redo's completely", -> - editor.setCursorScreenPosition([1, 1]) - - keydown('c') - keydown('i') - keydown('w') - expect(editor.getText()).toBe "12345\n\nABCDE" - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - expect(editorView).toHaveClass 'insert-mode' - - # Just cannot get "typing" to work correctly in test. - editor.setText("12345\nfg\nABCDE") - keydown('escape') - expect(editorView).toHaveClass 'command-mode' - expect(editor.getText()).toBe "12345\nfg\nABCDE" - - keydown('u') - expect(editor.getText()).toBe "12345\nabcde\nABCDE" - keydown('r', ctrl: true) - expect(editor.getText()).toBe "12345\nfg\nABCDE" - - describe "the C keybinding", -> - beforeEach -> - editor.getBuffer().setText("012\n") - editor.setCursorScreenPosition([0, 1]) - keydown('C', shift: true) - - it "deletes the contents until the end of the line and enters insert mode", -> - expect(editor.getText()).toBe "0\n" - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(editorView).not.toHaveClass 'command-mode' - expect(editorView).toHaveClass 'insert-mode' - - describe "the y keybinding", -> - beforeEach -> - editor.getBuffer().setText("012 345\nabc\n") - editor.setCursorScreenPosition([0, 4]) - - describe "when selected lines in visual linewise mode", -> - beforeEach -> - keydown('V', shift: true) - keydown('j') - keydown('y') - - it "is in linewise motion", -> - expect(vimState.getRegister('"').type).toEqual "linewise" - - it "saves the lines to the default register", -> - expect(vimState.getRegister('"').text).toBe "012 345\nabc\n" - - describe "when followed by a second y ", -> - beforeEach -> - keydown('y') - keydown('y') - - it "saves the line to the default register", -> - expect(vimState.getRegister('"').text).toBe "012 345\n" - expect(editor.getCursorScreenPosition()).toEqual [0, 4] - - describe "when followed with a repeated y", -> - beforeEach -> - keydown('y') - keydown('2') - keydown('y') - - it "copies n lines, starting from the current", -> - expect(vimState.getRegister('"').text).toBe "012 345\nabc\n" - - describe "with a register", -> - beforeEach -> - keydown('"') - keydown('a') - keydown('y') - keydown('y') - - it "saves the line to the a register", -> - expect(vimState.getRegister('a').text).toBe "012 345\n" - - describe "with a motion", -> - beforeEach -> - keydown('y') - keydown('w') - - it "saves the first word to the default register", -> - expect(vimState.getRegister('"').text).toBe '345' - - describe "the yy keybinding", -> - describe "on a single line file", -> - beforeEach -> - editor.getBuffer().setText "exclamation!\n" - editor.setCursorScreenPosition [0, 0] - - it "copies the entire line and pastes it correctly", -> - keydown('y') - keydown('y') - keydown('p') - - expect(vimState.getRegister('"').text).toBe "exclamation!\n" - expect(editor.getText()).toBe "exclamation!\nexclamation!\n" - - describe "on a single line file with no newline", -> - beforeEach -> - editor.getBuffer().setText "no newline!" - editor.setCursorScreenPosition [0, 0] - - it "copies the entire line and pastes it correctly", -> - keydown('y') - keydown('y') - keydown('p') - - expect(vimState.getRegister('"').text).toBe "no newline!" - expect(editor.getText()).toBe "no newline!\nno newline!" - - describe "the Y keybinding", -> - beforeEach -> - editor.getBuffer().setText "012 345\nabc\n" - editor.setCursorScreenPosition [0, 4] - - it "saves the line to the default register", -> - keydown('Y', shift: true) - - expect(vimState.getRegister('"').text).toBe "012 345\n" - expect(editor.getCursorScreenPosition()).toEqual [0, 4] - - describe "the p keybinding", -> - describe "with character contents", -> - beforeEach -> - editor.getBuffer().setText "012\n" - editor.setCursorScreenPosition [0, 0] - vimState.setRegister('"', text: '345') - vimState.setRegister('a', text: 'a') - - describe "from the default register", -> - beforeEach -> keydown('p') - - it "inserts the contents", -> - expect(editor.getText()).toBe "034512\n" - expect(editor.getCursorScreenPosition()).toEqual [0, 3] - - describe "from a specified register", -> - beforeEach -> - keydown('"') - keydown('a') - keydown('p') - - it "inserts the contents of the 'a' register", -> - expect(editor.getText()).toBe "0a12\n" - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - describe "at the end of a line", -> - it "inserts before the current line's newline", -> - editor.setText("abcde\none two three") - editor.setCursorScreenPosition([1, 4]) - - keydown 'd' - keydown '$' - keydown 'k' - keydown '$' - keydown 'p' - - expect(editor.getText()).toBe "abcdetwo three\none " - - - describe "with linewise contents", -> - beforeEach -> - editor.getBuffer().setText("012") - editor.setCursorScreenPosition([0, 1]) - vimState.setRegister('"', text: " 345\n", type: 'linewise') - keydown('p') - - it "inserts the contents of the default register", -> - expect(editor.getText()).toBe "012\n 345" - expect(editor.getCursorScreenPosition()).toEqual [1, 1] - - describe "with linewise contents", -> - beforeEach -> - editor.getBuffer().setText("012\n 345") - editor.setCursorScreenPosition([0, 1]) - vimState.setRegister('"', text: " 456\n", type: 'linewise') - keydown('p') - - it "inserts the contents of the default register at middle line", -> - expect(editor.getText()).toBe "012\n 456\n 345" - expect(editor.getCursorScreenPosition()).toEqual [1, 1] - - describe "with linewise contents", -> - beforeEach -> - editor.getBuffer().setText("012\n 345") - editor.setCursorScreenPosition([1, 1]) - vimState.setRegister('"', text: " 456", type: 'linewise') - keydown('p') - - it "inserts the contents of the default register at end of line", -> - expect(editor.getText()).toBe "012\n 345\n 456" - expect(editor.getCursorScreenPosition()).toEqual [2, 1] - - describe "with multiple linewise contents", -> - beforeEach -> - editor.getBuffer().setText("012\nabc") - editor.setCursorScreenPosition([1, 0]) - vimState.setRegister('"', text: " 345\n 678\n", type: 'linewise') - keydown('p') - - it "inserts the contents of the default register", -> - expect(editor.getText()).toBe "012\nabc\n 345\n 678" - expect(editor.getCursorScreenPosition()).toEqual [2, 1] - - describe "pasting twice", -> - beforeEach -> - editor.setText("12345\nabcde\nABCDE\nQWERT") - editor.setCursorScreenPosition([1, 1]) - vimState.setRegister('"', text: '123') - keydown('2') - keydown('p') - - it "inserts the same line twice", -> - expect(editor.getText()).toBe "12345\nab123123cde\nABCDE\nQWERT" - - describe "when undone", -> - beforeEach -> - keydown('u') - - it "removes both lines", -> - expect(editor.getText()).toBe "12345\nabcde\nABCDE\nQWERT" - - describe "the P keybinding", -> - describe "with character contents", -> - beforeEach -> - editor.getBuffer().setText("012\n") - editor.setCursorScreenPosition([0, 0]) - vimState.setRegister('"', text: '345') - vimState.setRegister('a', text: 'a') - keydown('P', shift: true) - - it "inserts the contents of the default register above", -> - expect(editor.getText()).toBe "345012\n" - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "the O keybinding", -> - beforeEach -> - spyOn(editor, 'shouldAutoIndent').andReturn(true) - spyOn(editor, 'autoIndentBufferRow').andCallFake (line) -> - editor.indent() - - editor.getBuffer().setText(" abc\n 012\n") - editor.setCursorScreenPosition([1, 1]) - - it "switches to insert and adds a newline above the current one", -> - keydown('O', shift: true) - expect(editor.getText()).toBe " abc\n \n 012\n" - expect(editor.getCursorScreenPosition()).toEqual [1, 2] - expect(editorView).toHaveClass 'insert-mode' - - it "is repeatable", -> - editor.getBuffer().setText(" abc\n 012\n 4spaces\n") - editor.setCursorScreenPosition([1, 1]) - keydown('O', shift: true) - editor.insertText "def" - keydown 'escape' - expect(editor.getText()).toBe " abc\n def\n 012\n 4spaces\n" - editor.setCursorScreenPosition([1, 1]) - keydown '.' - expect(editor.getText()).toBe " abc\n def\n def\n 012\n 4spaces\n" - editor.setCursorScreenPosition([4, 1]) - keydown '.' - expect(editor.getText()).toBe " abc\n def\n def\n 012\n def\n 4spaces\n" - - it "is undoable", -> - keydown('O', shift: true) - editor.insertText "def" - keydown 'escape' - expect(editor.getText()).toBe " abc\n def\n 012\n" - keydown 'u' - expect(editor.getText()).toBe " abc\n 012\n" - - describe "the o keybinding", -> - beforeEach -> - spyOn(editor, 'shouldAutoIndent').andReturn(true) - spyOn(editor, 'autoIndentBufferRow').andCallFake (line) -> - editor.indent() - - editor.getBuffer().setText("abc\n 012\n") - editor.setCursorScreenPosition([1, 2]) - - it "switches to insert and adds a newline above the current one", -> - keydown('o') - expect(editor.getText()).toBe "abc\n 012\n \n" - expect(editorView).toHaveClass 'insert-mode' - expect(editor.getCursorScreenPosition()).toEqual [2, 2] - - # This works in practice, but the editor doesn't respect the indentation - # rules without a syntax grammar. Need to set the editor's grammar - # to fix it. - xit "is repeatable", -> - editor.getBuffer().setText(" abc\n 012\n 4spaces\n") - editor.setCursorScreenPosition([1, 1]) - keydown('o') - editor.insertText "def" - keydown 'escape' - expect(editor.getText()).toBe " abc\n 012\n def\n 4spaces\n" - keydown '.' - expect(editor.getText()).toBe " abc\n 012\n def\n def\n 4spaces\n" - editor.setCursorScreenPosition([4, 1]) - keydown '.' - expect(editor.getText()).toBe " abc\n def\n def\n 012\n 4spaces\n def\n" - - it "is undoable", -> - keydown('o') - editor.insertText "def" - keydown 'escape' - expect(editor.getText()).toBe "abc\n 012\n def\n" - keydown 'u' - expect(editor.getText()).toBe "abc\n 012\n" - - - describe "the a keybinding", -> - beforeEach -> - editor.getBuffer().setText("012\n") - - describe "at the beginning of the line", -> - beforeEach -> - editor.setCursorScreenPosition([0, 0]) - keydown('a') - - it "switches to insert mode and shifts to the right", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(editorView).toHaveClass 'insert-mode' - - describe "at the end of the line", -> - beforeEach -> - editor.setCursorScreenPosition([0, 3]) - keydown('a') - - it "doesn't linewrap", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 3] - - describe "the A keybinding", -> - beforeEach -> - editor.getBuffer().setText("11\n22\n") - - describe "at the beginning of a line", -> - it "switches to insert mode at the end of the line", -> - editor.setCursorScreenPosition([0,0]) - keydown('A', shift: true) - - expect(editorView).toHaveClass 'insert-mode' - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "the I keybinding", -> - beforeEach -> - editor.getBuffer().setText("11\n 22\n") - - describe "at the end of a line", -> - it "switches to insert mode at the beginning of the line", -> - editor.setCursorScreenPosition([0,2]) - keydown('I', shift: true) - - expect(editorView).toHaveClass 'insert-mode' - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - it "switches to insert mode after leading whitespace", -> - editor.setCursorScreenPosition([1,4]) - keydown('I', shift: true) - - expect(editorView).toHaveClass 'insert-mode' - expect(editor.getCursorScreenPosition()).toEqual [1, 2] - - describe "the J keybinding", -> - beforeEach -> - editor.getBuffer().setText("012\n 456\n") - editor.setCursorScreenPosition([0, 1]) - - describe "without repeating", -> - beforeEach -> keydown('J', shift: true) - - it "joins the contents of the current line with the one below it", -> - expect(editor.getText()).toBe "012 456\n" - - describe "with repeating", -> - beforeEach -> - editor.setText("12345\nabcde\nABCDE\nQWERT") - editor.setCursorScreenPosition([1, 1]) - keydown('2') - keydown('J', shift: true) - - describe "undo behavior", -> - beforeEach -> keydown('u') - - it "handles repeats", -> - expect(editor.getText()).toBe "12345\nabcde\nABCDE\nQWERT" - - describe "the > keybinding", -> - beforeEach -> - editor.setText("12345\nabcde\nABCDE") - - describe "on the last line", -> - beforeEach -> - editor.setCursorScreenPosition([2, 0]) - - describe "when followed by a >", -> - beforeEach -> - keydown('>') - keydown('>') - - it "indents the current line", -> - expect(editor.getText()).toBe "12345\nabcde\n ABCDE" - expect(editor.getCursorScreenPosition()).toEqual [2, 2] - - describe "on the first line", -> - beforeEach -> - editor.setCursorScreenPosition([0, 0]) - - describe "when followed by a >", -> - beforeEach -> - keydown('>') - keydown('>') - - it "indents the current line", -> - expect(editor.getText()).toBe " 12345\nabcde\nABCDE" - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "when followed by a repeating >", -> - beforeEach -> - keydown('3') - keydown('>') - keydown('>') - - it "indents multiple lines at once", -> - expect(editor.getText()).toBe " 12345\n abcde\n ABCDE" - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "undo behavior", -> - beforeEach -> keydown('u') - - it "outdents all three lines", -> - expect(editor.getText()).toBe "12345\nabcde\nABCDE" - - describe "the < keybinding", -> - beforeEach -> - editor.setText(" 12345\n abcde\nABCDE") - editor.setCursorScreenPosition([0, 0]) - - describe "when followed by a <", -> - beforeEach -> - keydown('<') - keydown('<') - - it "indents the current line", -> - expect(editor.getText()).toBe "12345\n abcde\nABCDE" - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "when followed by a repeating <", -> - beforeEach -> - keydown('2') - keydown('<') - keydown('<') - - it "indents multiple lines at once", -> - expect(editor.getText()).toBe "12345\nabcde\nABCDE" - expect(editor.getCursorScreenPosition()).toEqual [0, 0] - - describe "undo behavior", -> - beforeEach -> keydown('u') - - it "indents both lines", -> - expect(editor.getText()).toBe " 12345\n abcde\nABCDE" - - describe "the = keybinding", -> - oldGrammar = [] - - beforeEach -> - waitsForPromise -> - atom.packages.activatePackage('language-javascript') - - oldGrammar = editor.getGrammar() - editor.setText("foo\n bar\n baz") - editor.setCursorScreenPosition([1, 0]) - - describe "when used in a scope that supports auto-indent", -> - beforeEach -> - jsGrammar = atom.syntax.grammarForScopeName('source.js') - editor.setGrammar(jsGrammar) - - afterEach -> - editor.setGrammar(oldGrammar) - - describe "when followed by a =", -> - beforeEach -> - keydown('=') - keydown('=') - - it "indents the current line", -> - expect(editor.indentationForBufferRow(1)).toBe 0 - - describe "when followed by a repeating =", -> - beforeEach -> - keydown('2') - keydown('=') - keydown('=') - - it "autoindents multiple lines at once", -> - expect(editor.getText()).toBe "foo\nbar\nbaz" - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe "undo behavior", -> - beforeEach -> keydown('u') - - it "indents both lines", -> - expect(editor.getText()).toBe "foo\n bar\n baz" - - describe "the . keybinding", -> - beforeEach -> - editor.setText("12\n34\n56\n78") - editor.setCursorScreenPosition([0,0]) - - it "repeats the last operation", -> - keydown '2' - keydown 'd' - keydown 'd' - keydown '.' - - expect(editor.getText()).toBe "" - - it "composes with motions", -> - keydown 'd' - keydown 'd' - keydown '2' - keydown '.' - - expect(editor.getText()).toBe "78" - - describe "the r keybinding", -> - beforeEach -> - editor.setText("12\n34\n\n") - editor.setCursorBufferPosition([0,0]) - - it "replaces a single character", -> - keydown('r') - commandModeInputKeydown('x') - expect(editor.getText()).toBe 'x2\n34\n\n' - - it "composes properly with motions", -> - keydown('2') - keydown('r') - commandModeInputKeydown('x') - expect(editor.getText()).toBe 'xx\n34\n\n' - - it "does nothing on an empty line", -> - editor.setCursorBufferPosition([2, 0]) - keydown('r') - commandModeInputKeydown('x') - expect(editor.getText()).toBe '12\n34\n\n' - - it "does nothing if asked to replace more characters than there are on a line", -> - keydown('3') - keydown('r') - commandModeInputKeydown('x') - expect(editor.getText()).toBe '12\n34\n\n' - - describe 'the m keybinding', -> - beforeEach -> - editor.setText('12\n34\n56\n') - editor.setCursorBufferPosition([0,1]) - - it 'marks a position', -> - keydown('m') - commandModeInputKeydown('a') - expect(vimState.getMark('a')).toEqual [0,1] - - describe 'the ~ keybinding', -> - beforeEach -> - editor.setText('aBc') - editor.setCursorBufferPosition([0, 0]) - - it 'toggles the case and moves right', -> - keydown('~') - expect(editor.getText()).toBe 'ABc' - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - - keydown('~') - expect(editor.getText()).toBe 'Abc' - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - keydown('~') - expect(editor.getText()).toBe 'AbC' - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - it 'can be repeated', -> - keydown('4') - keydown('~') - - expect(editor.getText()).toBe 'AbC' - expect(editor.getCursorScreenPosition()).toEqual [0, 2] - - describe "the i keybinding", -> - beforeEach -> - editor.setText('') - editor.setCursorBufferPosition([0, 0]) - - it "allows undoing an entire batch of typing", -> - keydown 'i' - editor.insertText("abc") - keydown 'escape' - keydown 'i' - editor.insertText("def") - keydown 'escape' - expect(editor.getText()).toBe "abdefc" - keydown 'u' - expect(editor.getText()).toBe "abc" - keydown 'u' - expect(editor.getText()).toBe "" - - it "allows repeating typing", -> - keydown 'i' - editor.insertText("abc") - keydown 'escape' - keydown '.' - editor.insertText("ababcc") - - # This one doesn't work because we can't simulate typing correctly, - # and VimState#resetInputTransactions actually inspects buffer patches to - # build patches for repeating - xit "resets transactions for repeats after movement", -> - editor.setCursorBufferPosition([0, 0]) - editor.insertText("abc\n123") - keydown 'i' - editor.insertText("def") - editorView.trigger 'core:move-down' - expect(editor.getCursorBufferPosition()).toEqual [1, 3] - editor.insertText("456") - keydown 'escape' - editor.setCursorBufferPosition([0, 0]) - keydown '.' - expect(editor.getText()).toEqual "456defabc\n456123" - - describe 'the a keybinding', -> - beforeEach -> - editor.setText('') - editor.setCursorBufferPosition([0, 0]) - - it "can be undone in one go", -> - keydown 'a' - editor.insertText("abc") - keydown 'escape' - expect(editor.getText()).toBe "abc" - keydown 'u' - expect(editor.getText()).toBe "" - - it "repeats correctly", -> - keydown 'a' - editor.insertText("abc") - keydown 'escape' - expect(editor.getText()).toBe "abc" - keydown '.' - expect(editor.getText()).toBe "abcabc" diff --git a/.atom/packages/vim-mode/spec/panes-spec.coffee b/.atom/packages/vim-mode/spec/panes-spec.coffee deleted file mode 100644 index ba76222..0000000 --- a/.atom/packages/vim-mode/spec/panes-spec.coffee +++ /dev/null @@ -1,71 +0,0 @@ -helpers = require './spec-helper' - -describe "Panes", -> - [editor, editorView, vimState] = [] - - beforeEach -> - vimMode = atom.packages.loadPackage('vim-mode') - vimMode.activateResources() - - editorView = helpers.cacheEditor(editorView) - editor = editorView.editor - - vimState = editorView.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() - - keydown = (key, options={}) -> - options.element ?= editorView[0] - helpers.keydown(key, options) - - describe "switch panes", -> - beforeEach -> - editor.setText("abcde\n") - atom.workspaceView = { - focusPaneViewOnRight: -> - focusPaneViewOnLeft: -> - focusPaneViewBelow: -> - focusPaneViewAbove: -> - getActivePaneItem: -> editor - getActiveView: -> editorView - } - - describe "the ctrl-w l keybinding", -> - beforeEach -> - spyOn(atom.workspaceView, 'focusPaneViewOnRight') - - it "focuses the pane on the right", -> - keydown('w', ctrl: true) - keydown('l') - - expect(atom.workspaceView.focusPaneViewOnRight).toHaveBeenCalled() - - describe "the ctrl-w h keybinding", -> - beforeEach -> - spyOn(atom.workspaceView, 'focusPaneViewOnLeft') - - it "focuses the pane on the left", -> - keydown('w', ctrl: true) - keydown('h') - - expect(atom.workspaceView.focusPaneViewOnLeft).toHaveBeenCalled() - - describe "the ctrl-w j keybinding", -> - beforeEach -> - spyOn(atom.workspaceView, 'focusPaneViewBelow') - - it "focuses the pane on the below", -> - keydown('w', ctrl: true) - keydown('j') - - expect(atom.workspaceView.focusPaneViewBelow).toHaveBeenCalled() - - describe "the ctrl-w k keybinding", -> - beforeEach -> - spyOn(atom.workspaceView, 'focusPaneViewAbove') - - it "focuses the pane on the above", -> - keydown('w', ctrl: true) - keydown('k') - - expect(atom.workspaceView.focusPaneViewAbove).toHaveBeenCalled() diff --git a/.atom/packages/vim-mode/spec/prefixes-spec.coffee b/.atom/packages/vim-mode/spec/prefixes-spec.coffee deleted file mode 100644 index 7209479..0000000 --- a/.atom/packages/vim-mode/spec/prefixes-spec.coffee +++ /dev/null @@ -1,127 +0,0 @@ -helpers = require './spec-helper' - -describe "Prefixes", -> - [editor, editorView, vimState] = [] - - beforeEach -> - vimMode = atom.packages.loadPackage('vim-mode') - vimMode.activateResources() - - editorView = helpers.cacheEditor(editorView) - editor = editorView.editor - - vimState = editorView.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() - - keydown = (key, options={}) -> - options.element ?= editorView[0] - helpers.keydown(key, options) - - describe "Repeat", -> - describe "with operations", -> - beforeEach -> - editor.setText("123456789abc") - editor.setCursorScreenPosition([0, 0]) - - it "repeats N times", -> - keydown('3') - keydown('x') - - expect(editor.getText()).toBe '456789abc' - - it "repeats NN times", -> - keydown('1') - keydown('0') - keydown('x') - - expect(editor.getText()).toBe 'bc' - - describe "with motions", -> - beforeEach -> - editor.setText('one two three') - editor.setCursorScreenPosition([0, 0]) - - it "repeats N times", -> - keydown('d') - keydown('2') - keydown('w') - - expect(editor.getText()).toBe 'three' - - describe "in visual mode", -> - beforeEach -> - editor.setText('one two three') - editor.setCursorScreenPosition([0, 0]) - - it "repeats movements in visual mode", -> - keydown("v") - keydown("2") - keydown("w") - - expect(editor.getCursorScreenPosition()).toEqual [0, 8] - - describe "Register", -> - describe "the a register", -> - it "saves a value for future reading", -> - vimState.setRegister('a', text: 'new content') - expect(vimState.getRegister("a").text).toEqual 'new content' - - it "overwrites a value previously in the register", -> - vimState.setRegister('a', text: 'content') - vimState.setRegister('a', text: 'new content') - expect(vimState.getRegister("a").text).toEqual 'new content' - - - describe "the * register", -> - describe "reading", -> - it "is the same the system clipboard", -> - expect(vimState.getRegister('*').text).toEqual 'initial clipboard content' - expect(vimState.getRegister('*').type).toEqual 'character' - - describe "writing", -> - beforeEach -> - vimState.setRegister('*', text: 'new content') - - it "overwrites the contents of the system clipboard", -> - expect(atom.clipboard.read()).toEqual 'new content' - - # FIXME: once linux support comes out, this needs to read from - # the correct clipboard. For now it behaves just like the * register - # See :help x11-cut-buffer and :help registers for more details on how these - # registers work on an X11 based system. - describe "the + register", -> - describe "reading", -> - it "is the same the system clipboard", -> - expect(vimState.getRegister('*').text).toEqual 'initial clipboard content' - expect(vimState.getRegister('*').type).toEqual 'character' - - describe "writing", -> - beforeEach -> - vimState.setRegister('*', text: 'new content') - - it "overwrites the contents of the system clipboard", -> - expect(atom.clipboard.read()).toEqual 'new content' - - describe "the _ register", -> - describe "reading", -> - it "is always the empty string", -> - expect(vimState.getRegister("_").text).toEqual '' - - describe "writing", -> - it "throws away anything written to it", -> - vimState.setRegister('_', text: 'new content') - expect(vimState.getRegister("_").text).toEqual '' - - describe "the % register", -> - beforeEach -> - spyOn(editor, 'getUri').andReturn('/Users/atom/known_value.txt') - - describe "reading", -> - it "returns the filename of the current editor", -> - expect(vimState.getRegister('%').text).toEqual '/Users/atom/known_value.txt' - - describe "writing", -> - it "throws away anything written to it", -> - vimState.setRegister('%', "new content") - expect(vimState.getRegister('%').text).toEqual '/Users/atom/known_value.txt' diff --git a/.atom/packages/vim-mode/spec/scroll-spec.coffee b/.atom/packages/vim-mode/spec/scroll-spec.coffee deleted file mode 100644 index d364fe0..0000000 --- a/.atom/packages/vim-mode/spec/scroll-spec.coffee +++ /dev/null @@ -1,46 +0,0 @@ -helpers = require './spec-helper' - -describe "Scrolling", -> - [editor, editorView, vimState] = [] - - beforeEach -> - vimMode = atom.packages.loadPackage('vim-mode') - vimMode.activateResources() - - editorView = helpers.cacheEditor(editorView) - editor = editorView.editor - - vimState = editorView.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() - - keydown = (key, options={}) -> - options.element ?= editorView[0] - helpers.keydown(key, options) - - describe "scrolling keybindings", -> - beforeEach -> - editor.setText("1\n2\n3\n4\n5\n6\n7\n8\n9\n10") - spyOn(editorView, 'getFirstVisibleScreenRow').andReturn(2) - spyOn(editorView, 'getLastVisibleScreenRow').andReturn(8) - spyOn(editorView, 'scrollToScreenPosition') - - describe "the ctrl-e keybinding", -> - beforeEach -> - spyOn(editor, 'getCursorScreenPosition').andReturn({row: 4, column: 0}) - spyOn(editor, 'setCursorScreenPosition') - - it "moves the screen down by one and keeps cursor onscreen", -> - keydown('e', ctrl: true) - expect(editorView.scrollToScreenPosition).toHaveBeenCalledWith([7, 0]) - expect(editor.setCursorScreenPosition).toHaveBeenCalledWith([6, 0]) - - describe "the ctrl-y keybinding", -> - beforeEach -> - spyOn(editor, 'getCursorScreenPosition').andReturn({row: 6, column: 0}) - spyOn(editor, 'setCursorScreenPosition') - - it "moves the screen up by one and keeps the cursor onscreen", -> - keydown('y', ctrl: true) - expect(editorView.scrollToScreenPosition).toHaveBeenCalledWith([3, 0]) - expect(editor.setCursorScreenPosition).toHaveBeenCalledWith([4, 0]) diff --git a/.atom/packages/vim-mode/spec/spec-helper.coffee b/.atom/packages/vim-mode/spec/spec-helper.coffee deleted file mode 100644 index 34b88d8..0000000 --- a/.atom/packages/vim-mode/spec/spec-helper.coffee +++ /dev/null @@ -1,64 +0,0 @@ -{EditorView} = require 'atom' -VimState = require '../lib/vim-state' -VimMode = require '../lib/vim-mode' - -originalKeymap = null - -beforeEach -> - atom.workspace ||= {} - VimMode._initializeWorkspaceState() - -cacheEditor = (existingEditorView) -> - session = atom.project.openSync() - if existingEditorView? - existingEditorView.edit(session) - existingEditorView.vimState = new VimState(existingEditorView) - existingEditorView.bindKeys() - existingEditorView.enableKeymap() - else - editorView = new EditorView(session) - editorView.simulateDomAttachment() - editorView.enableKeymap() - - editorView.addClass('vim-mode') - editorView.vimState = new VimState(editorView) - - view = existingEditorView or editorView - history = view.editor.buffer.history - history.abortTransaction() if history.currentTransaction? - history.clearUndoStack() - view - -mockPlatform = (editorView, platform) -> - wrapper = document.createElement('div') - wrapper.className = platform - wrapper.appendChild(editorView[0]) - -unmockPlatform = (editorView) -> - editorView[0].parentNode.removeChild(editorView[0]) - -keydown = (key, {element, ctrl, shift, alt, meta, raw}={}) -> - dispatchKeyboardEvent = (target, eventArgs...) -> - e = document.createEvent('KeyboardEvent') - e.initKeyboardEvent eventArgs... - # 0 is the default, and it's valid ASCII, but it's wrong. - Object.defineProperty(e, 'keyCode', get: -> undefined) if e.keyCode is 0 - target.dispatchEvent e - - dispatchTextEvent = (target, eventArgs...) -> - e = document.createEvent('TextEvent') - e.initTextEvent eventArgs... - target.dispatchEvent e - - key = "U+#{key.charCodeAt(0).toString(16)}" unless key == 'escape' || raw? - element ||= document.activeElement - eventArgs = [true, true, null, key, 0, ctrl, alt, shift, meta] # bubbles, cancelable, view, key, location - - canceled = not dispatchKeyboardEvent(element, 'keydown', eventArgs...) - dispatchKeyboardEvent(element, 'keypress', eventArgs...) - if not canceled - if dispatchTextEvent(element, 'textInput', eventArgs...) - element.value += key - dispatchKeyboardEvent(element, 'keyup', eventArgs...) - -module.exports = { keydown, cacheEditor, mockPlatform, unmockPlatform } diff --git a/.atom/packages/vim-mode/spec/text-objects-spec.coffee b/.atom/packages/vim-mode/spec/text-objects-spec.coffee deleted file mode 100644 index 6aed321..0000000 --- a/.atom/packages/vim-mode/spec/text-objects-spec.coffee +++ /dev/null @@ -1,168 +0,0 @@ -helpers = require './spec-helper' - -describe "TextObjects", -> - [editor, editorView, vimState] = [] - - beforeEach -> - vimMode = atom.packages.loadPackage('vim-mode') - vimMode.activateResources() - - editorView = helpers.cacheEditor(editorView) - editor = editorView.editor - - vimState = editorView.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() - - keydown = (key, options={}) -> - options.element ?= editorView[0] - helpers.keydown(key, options) - - commandModeInputKeydown = (key, opts = {}) -> - opts.element = editor.commandModeInputView.editor.find('input').get(0) - opts.raw = true - keydown(key, opts) - - describe "the 'iw' text object", -> - beforeEach -> - editor.setText("12345 abcde ABCDE") - editor.setCursorScreenPosition([0, 9]) - - it "applies operators inside the current word in operator-pending mode", -> - keydown('d') - keydown('i') - keydown('w') - - expect(editor.getText()).toBe "12345 ABCDE" - expect(editor.getCursorScreenPosition()).toEqual [0, 6] - expect(vimState.getRegister('"').text).toBe "abcde" - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - it "selects inside the current word in visual mode", -> - keydown('v') - keydown('i') - keydown('w') - - expect(editor.getSelectedScreenRange()).toEqual [[0, 6], [0, 11]] - - describe "the 'i(' text object", -> - beforeEach -> - editor.setText("( something in here and in (here) )") - editor.setCursorScreenPosition([0, 9]) - - it "applies operators inside the current word in operator-pending mode", -> - keydown('d') - keydown('i') - keydown('(') - expect(editor.getText()).toBe "()" - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - it "applies operators inside the current word in operator-pending mode (second test)", -> - editor.setCursorScreenPosition([0, 29]) - keydown('d') - keydown('i') - keydown('(') - expect(editor.getText()).toBe "( something in here and in () )" - expect(editor.getCursorScreenPosition()).toEqual [0, 28] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - describe "the 'i{' text object", -> - beforeEach -> - editor.setText("{ something in here and in {here} }") - editor.setCursorScreenPosition([0, 9]) - - it "applies operators inside the current word in operator-pending mode", -> - keydown('d') - keydown('i') - keydown('{') - expect(editor.getText()).toBe "{}" - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - it "applies operators inside the current word in operator-pending mode (second test)", -> - editor.setCursorScreenPosition([0, 29]) - keydown('d') - keydown('i') - keydown('{') - expect(editor.getText()).toBe "{ something in here and in {} }" - expect(editor.getCursorScreenPosition()).toEqual [0, 28] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - - describe "the 'i<' text object", -> - beforeEach -> - editor.setText("< something in here and in >") - editor.setCursorScreenPosition([0, 9]) - - it "applies operators inside the current word in operator-pending mode", -> - keydown('d') - keydown('i') - keydown('<') - expect(editor.getText()).toBe "<>" - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - it "applies operators inside the current word in operator-pending mode (second test)", -> - editor.setCursorScreenPosition([0, 29]) - keydown('d') - keydown('i') - keydown('<') - expect(editor.getText()).toBe "< something in here and in <> >" - expect(editor.getCursorScreenPosition()).toEqual [0, 28] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - describe "the 'i\'' text object", -> - beforeEach -> - editor.setText("' something in here and in 'here' '") - editor.setCursorScreenPosition([0, 9]) - - it "applies operators inside the current word in operator-pending mode", -> - keydown('d') - keydown('i') - keydown('\'') - expect(editor.getText()).toBe "''here' '" - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - it "applies operators inside the current word in operator-pending mode (second test)", -> - editor.setCursorScreenPosition([0, 29]) - keydown('d') - keydown('i') - keydown('\'') - expect(editor.getText()).toBe "' something in here and in '' '" - expect(editor.getCursorScreenPosition()).toEqual [0, 28] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - describe "the 'i\"' text object", -> - beforeEach -> - editor.setText("\" something in here and in \"here\" \"") - editor.setCursorScreenPosition([0, 9]) - - it "applies operators inside the current word in operator-pending mode", -> - keydown('d') - keydown('i') - keydown('""') - expect(editor.getText()).toBe '""here" "' - expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') - - it "applies operators inside the current word in operator-pending mode (second test)", -> - editor.setCursorScreenPosition([0, 29]) - keydown('d') - keydown('i') - keydown('"') - expect(editor.getText()).toBe "\" something in here and in \"\" \"" - expect(editor.getCursorScreenPosition()).toEqual [0, 28] - expect(editorView).not.toHaveClass('operator-pending-mode') - expect(editorView).toHaveClass('command-mode') diff --git a/.atom/packages/vim-mode/spec/vim-mode-spec.coffee b/.atom/packages/vim-mode/spec/vim-mode-spec.coffee deleted file mode 100644 index 539813b..0000000 --- a/.atom/packages/vim-mode/spec/vim-mode-spec.coffee +++ /dev/null @@ -1,36 +0,0 @@ -{WorkspaceView} = require 'atom' - -describe "VimMode", -> - [editorView] = [] - - beforeEach -> - atom.workspaceView = new WorkspaceView - atom.workspaceView.openSync() - atom.workspaceView.simulateDomAttachment() - - waitsForPromise -> - atom.packages.activatePackage('vim-mode') - - runs -> - editorView = atom.workspaceView.getActiveView() - editorView.enableKeymap() - - describe "initialize", -> - it "puts the editor in command-mode initially by default", -> - expect(editorView).toHaveClass 'vim-mode' - expect(editorView).toHaveClass 'command-mode' - - describe 'deactivate', -> - beforeEach -> - atom.packages.deactivatePackage('vim-mode') - - waitsForPromise -> - atom.packages.activatePackage('vim-mode') - - runs -> - editorView = atom.workspaceView.getActiveView() - editorView.enableKeymap() - - it 'clears the vim namespaced events from the editorView', -> - handlers = editorView.handlers() - expect(handlers['vim-mode:move-down'].length).toEqual(1) diff --git a/.atom/packages/vim-mode/spec/vim-state-spec.coffee b/.atom/packages/vim-mode/spec/vim-state-spec.coffee deleted file mode 100644 index b3be692..0000000 --- a/.atom/packages/vim-mode/spec/vim-state-spec.coffee +++ /dev/null @@ -1,252 +0,0 @@ -helpers = require './spec-helper' -VimState = require '../lib/vim-state' - -describe "VimState", -> - [editor, editorView, vimState] = [] - - beforeEach -> - vimMode = atom.packages.loadPackage('vim-mode') - vimMode.activateResources() - - editorView = helpers.cacheEditor(editorView) - editor = editorView.editor - - vimState = editorView.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() - - keydown = (key, options={}) -> - options.element ?= editorView[0] - helpers.keydown(key, options) - - commandModeInputKeydown = (key, opts = {}) -> - opts.element = editor.commandModeInputView.editor.find('input').get(0) - opts.raw = true - keydown(key, opts) - - describe "initialization", -> - it "puts the editor in command-mode initially by default", -> - expect(editorView).toHaveClass 'vim-mode' - expect(editorView).toHaveClass 'command-mode' - - it "puts the editor in insert-mode if startInInsertMode is true", -> - atom.config.set 'vim-mode.startInInsertMode', true - editorView.vimState = new VimState(editorView) # Reload vim-mode - expect(editorView).toHaveClass 'insert-mode' - - describe "command-mode", -> - describe "when entering an insertable character", -> - beforeEach -> keydown('\\') - - it "stops propagation", -> - expect(editor.getText()).toEqual '' - - describe "when entering an operator", -> - beforeEach -> keydown('d') - - describe "with an operator that can't be composed", -> - beforeEach -> keydown('x') - - it "clears the operator stack", -> - expect(vimState.opStack.length).toBe 0 - - describe "the escape keybinding", -> - beforeEach -> keydown('escape') - - it "clears the operator stack", -> - expect(vimState.opStack.length).toBe 0 - - describe "the ctrl-c keybinding", -> - beforeEach -> keydown('c', ctrl: true) - - it "clears the operator stack", -> - expect(vimState.opStack.length).toBe 0 - - describe "the v keybinding", -> - beforeEach -> keydown('v') - - it "puts the editor into visual characterwise mode", -> - expect(editorView).toHaveClass 'visual-mode' - expect(vimState.submode).toEqual 'characterwise' - expect(editorView).not.toHaveClass 'command-mode' - - describe "the V keybinding", -> - beforeEach -> - editor.setText("012345\nabcdef") - editor.setCursorScreenPosition([0, 0]) - keydown('V', shift: true) - - it "puts the editor into visual linewise mode", -> - expect(editorView).toHaveClass 'visual-mode' - expect(vimState.submode).toEqual 'linewise' - expect(editorView).not.toHaveClass 'command-mode' - - it "selects the current line", -> - expect(editor.getSelection().getText()).toEqual '012345\n' - - describe "the ctrl-v keybinding", -> - beforeEach -> keydown('v', ctrl: true) - - it "puts the editor into visual characterwise mode", -> - expect(editorView).toHaveClass 'visual-mode' - expect(vimState.submode).toEqual 'blockwise' - expect(editorView).not.toHaveClass 'command-mode' - - describe "the i keybinding", -> - beforeEach -> keydown('i') - - it "puts the editor into insert mode", -> - expect(editorView).toHaveClass 'insert-mode' - expect(editorView).not.toHaveClass 'command-mode' - - describe "with content", -> - beforeEach -> editor.setText("012345\n\nabcdef") - - # FIXME: See atom/vim-mode#2 - xdescribe "on a line with content", -> - beforeEach -> editor.setCursorScreenPosition([0, 6]) - - it "does not allow the cursor to be placed on the \n character", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 5] - - describe "on an empty line", -> - beforeEach -> editor.setCursorScreenPosition([1, 0]) - - it "allows the cursor to be placed on the \n character", -> - expect(editor.getCursorScreenPosition()).toEqual [1, 0] - - describe 'with character-input operations', -> - beforeEach -> editor.setText('012345\nabcdef') - - it 'properly clears the opStack', -> - keydown('d') - keydown('r') - expect(vimState.mode).toBe 'command' - expect(vimState.opStack.length).toBe 0 - commandModeInputKeydown('escape') - keydown('d') - expect(editor.getText()).toBe '012345\nabcdef' - - describe "insert-mode", -> - beforeEach -> - keydown('i') - - describe "with content", -> - beforeEach -> editor.setText("012345\n\nabcdef") - - describe "when cursor is in the middle of the line", -> - beforeEach -> editor.setCursorScreenPosition([0,3]) - - it "moves the cursor to the left when exiting insert mode", -> - keydown('escape') - expect(editor.getCursorScreenPosition()).toEqual [0,2] - - describe "when cursor is at the beginning of line", -> - beforeEach -> editor.setCursorScreenPosition([1,0]) - - it "leaves the cursor at the beginning of line", -> - keydown('escape') - expect(editor.getCursorScreenPosition()).toEqual [1,0] - - describe "on a line with content", -> - beforeEach -> editor.setCursorScreenPosition([0, 6]) - - it "allows the cursor to be placed on the \n character", -> - expect(editor.getCursorScreenPosition()).toEqual [0, 6] - - it "puts the editor into command mode when is pressed", -> - keydown('escape') - - expect(editorView).toHaveClass 'command-mode' - expect(editorView).not.toHaveClass 'insert-mode' - expect(editorView).not.toHaveClass 'visual-mode' - - it "puts the editor into command mode when is pressed", -> - helpers.mockPlatform(editorView, 'platform-darwin') - keydown('c', ctrl: true) - helpers.unmockPlatform(editorView) - - expect(editorView).toHaveClass 'command-mode' - expect(editorView).not.toHaveClass 'insert-mode' - expect(editorView).not.toHaveClass 'visual-mode' - - it "puts the editor into command mode before undoing, saving work", -> - editor.setText("012345\n\nabcdef") - editorView.trigger("core:undo") - expect(editorView).toHaveClass "command-mode" - expect(editor.getText()).toEqual("") - editorView.trigger("core:redo") - expect(editor.getText()).toEqual("012345\n\nabcdef") - - describe "visual-mode", -> - beforeEach -> keydown('v') - - it "puts the editor into command mode when is pressed", -> - keydown('escape') - - expect(editorView).toHaveClass 'command-mode' - expect(editorView).not.toHaveClass 'visual-mode' - - describe "motions", -> - beforeEach -> - editor.setText("012345\n\nabcdef") - editor.setCursorScreenPosition([0, 0]) - keydown('w') - - it "execute instead of select", -> - expect(editor.getSelection().getText()).toEqual '012345' - - describe "operators", -> - beforeEach -> - editor.setText("012345\n\nabcdef") - editor.setCursorScreenPosition([0, 0]) - editor.selectLine() - keydown('d') - - it "operate on the current selection", -> - expect(editor.getText()).toEqual "\nabcdef" - - describe "returning to command-mode", -> - beforeEach -> - editor.setText("012345\n\nabcdef") - editor.selectLine() - keydown('escape') - - it "operate on the current selection", -> - expect(editor.getSelection().getText()).toEqual '' - - describe "marks", -> - beforeEach -> editor.setText("text in line 1\ntext in line 2\ntext in line 3") - - it "basic marking functionality", -> - editor.setCursorScreenPosition([1, 1]) - keydown('m') - commandModeInputKeydown('t') - expect(editor.getText()).toEqual "text in line 1\ntext in line 2\ntext in line 3" - editor.setCursorScreenPosition([2, 2]) - keydown('`') - commandModeInputKeydown('t') - expect(editor.getCursorScreenPosition()).toEqual [1,1] - - it "real (tracking) marking functionality", -> - editor.setCursorScreenPosition([2, 2]) - keydown('m') - commandModeInputKeydown('q') - editor.setCursorScreenPosition([1, 2]) - keydown('o') - keydown('escape') - keydown('`') - commandModeInputKeydown('q') - expect(editor.getCursorScreenPosition()).toEqual [3,2] - - it "real (tracking) marking functionality", -> - editor.setCursorScreenPosition([2, 2]) - keydown('m') - commandModeInputKeydown('q') - editor.setCursorScreenPosition([1, 2]) - keydown('d') - keydown('d') - keydown('escape') - keydown('`') - commandModeInputKeydown('q') - expect(editor.getCursorScreenPosition()).toEqual [1,2] diff --git a/.atom/packages/vim-mode/stylesheets/vim-mode.less b/.atom/packages/vim-mode/stylesheets/vim-mode.less deleted file mode 100644 index ca53305..0000000 --- a/.atom/packages/vim-mode/stylesheets/vim-mode.less +++ /dev/null @@ -1,51 +0,0 @@ -@import "syntax-variables"; -@import "ui-variables"; - -.block-cursor(@visibility: visible) { - border: 0; - background-color: @syntax-cursor-color; - visibility: @visibility; - opacity: 0.5; -} - -.vim-mode.command-mode, .vim-mode.operator-pending-mode, .vim-mode.visual-mode { - .cursor, .cursor.blink-off { - .block-cursor(hidden); - } - - &.editor.is-focused { - .cursor, .cursor.blink-off { - .block-cursor; - } - } -} - -.vim-mode.visual-mode { - .cursor.hidden-cursor { - display: block; - } -} - -.command-mode-input .editor.mini { - background-color: inherit; - border: none; - width: 100%; - font-weight: normal; - color: @text-color; - // see also the commandModeInputViewFontSize setting. - line-height: 1.28; - cursor: default; - white-space: nowrap; - padding-left: 10px; -} - -.command-mode-input .hidden-input { - padding: 0; - border: 0; - position: absolute; - z-index: -1; - top: 0; - left: 0; - opacity: 0; - width: 1px; -} diff --git a/.atom/snippets.cson b/.atom/snippets.cson deleted file mode 100644 index 9578993..0000000 --- a/.atom/snippets.cson +++ /dev/null @@ -1,15 +0,0 @@ -# Your snippets -# -# Atom snippets allow you to enter a simple prefix in the editor and hit tab to -# expand the prefix into a larger code block with templated values. -# -# You can create a new snippet in this file by typing "snip" and then hitting -# tab. -# -# An example CoffeeScript snippet to expand log to console.log: -# -# '.source.coffee': -# 'Console log': -# 'prefix': 'log' -# 'body': 'console.log $1' -# diff --git a/.atom/styles.less b/.atom/styles.less deleted file mode 100644 index d37163b..0000000 --- a/.atom/styles.less +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Your Stylesheet - * - * This stylesheet is loaded when Atom starts up and is reloaded automatically - * when it is changed. - * - * If you are unfamiliar with LESS, you can read more about it here: - * http://www.lesscss.org - */ - -.tree-view { - -} - -.editor { - -} - -.editor .cursor { - -}