mirror of
https://github.com/wassname/nvatom.git
synced 2026-06-27 16:10:36 +08:00
Initialize a package using Atom's package generator
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
.DS_Store
|
||||
npm-debug.log
|
||||
node_modules
|
||||
@@ -0,0 +1,3 @@
|
||||
## 0.1.0 - First Release
|
||||
* Every feature added
|
||||
* Every bug fixed
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2014 <Your name here>
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,5 @@
|
||||
# notational-velocity package
|
||||
|
||||
A short description of your package.
|
||||
|
||||

|
||||
@@ -0,0 +1,11 @@
|
||||
# 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-alt-o': 'notational-velocity:toggle'
|
||||
@@ -0,0 +1,43 @@
|
||||
fs = require 'fs'
|
||||
|
||||
module.exports =
|
||||
class NotationalVelocityView
|
||||
constructor: (serializeState) ->
|
||||
# Create root element
|
||||
@element = document.createElement('div')
|
||||
@element.classList.add('notational-velocity', 'overlay', 'from-top')
|
||||
|
||||
# Create message element
|
||||
message = document.createElement('div')
|
||||
message.textContent = "The NotationalVelocity package is Alive! It's ALIVE!"
|
||||
message.classList.add('message')
|
||||
@element.appendChild(message)
|
||||
|
||||
# Register command that toggles this view
|
||||
atom.commands.add 'atom-workspace', 'notational-velocity:toggle': => @toggle()
|
||||
|
||||
# Returns an object that can be retrieved when package is activated
|
||||
serialize: ->
|
||||
|
||||
# Tear down any state and detach
|
||||
destroy: ->
|
||||
@element.remove()
|
||||
|
||||
# Toggle the visibility of this view
|
||||
toggle: ->
|
||||
console.log 'NotationalVelocityView was toggled!'
|
||||
|
||||
@readdir()
|
||||
|
||||
if @element.parentElement?
|
||||
@element.remove()
|
||||
else
|
||||
atom.workspaceView.append(@element)
|
||||
|
||||
# read filenames in a specific directory
|
||||
readdir: ->
|
||||
fs.readdir '.', (error, filenames) =>
|
||||
if error
|
||||
throw error
|
||||
for filename in filenames
|
||||
console.log filename
|
||||
@@ -0,0 +1,13 @@
|
||||
NotationalVelocityView = require './notational-velocity-view'
|
||||
|
||||
module.exports =
|
||||
notationalVelocityView: null
|
||||
|
||||
activate: (state) ->
|
||||
@notationalVelocityView = new NotationalVelocityView(state.notationalVelocityViewState)
|
||||
|
||||
deactivate: ->
|
||||
@notationalVelocityView.destroy()
|
||||
|
||||
serialize: ->
|
||||
notationalVelocityViewState: @notationalVelocityView.serialize()
|
||||
@@ -0,0 +1,22 @@
|
||||
# See https://atom.io/docs/latest/creating-a-package#menus for more details
|
||||
'context-menu':
|
||||
'atom-text-editor': [
|
||||
{
|
||||
'label': 'Toggle notational-velocity'
|
||||
'command': 'notational-velocity:toggle'
|
||||
}
|
||||
]
|
||||
'menu': [
|
||||
{
|
||||
'label': 'Packages'
|
||||
'submenu': [
|
||||
'label': 'notational-velocity'
|
||||
'submenu': [
|
||||
{
|
||||
'label': 'Toggle'
|
||||
'command': 'notational-velocity:toggle'
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "notational-velocity",
|
||||
"main": "./lib/notational-velocity",
|
||||
"version": "0.0.0",
|
||||
"description": "A short description of your package",
|
||||
"activationCommands": {
|
||||
"atom-workspace": "notational-velocity:toggle"
|
||||
},
|
||||
"repository": "https://github.com/atom/notational-velocity",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"atom": ">0.50.0"
|
||||
},
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{WorkspaceView} = require 'atom'
|
||||
NotationalVelocity = require '../lib/notational-velocity'
|
||||
|
||||
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
|
||||
#
|
||||
# To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
|
||||
# or `fdescribe`). Remove the `f` to unfocus the block.
|
||||
|
||||
describe "NotationalVelocity", ->
|
||||
activationPromise = null
|
||||
|
||||
beforeEach ->
|
||||
atom.workspaceView = new WorkspaceView
|
||||
activationPromise = atom.packages.activatePackage('notational-velocity')
|
||||
|
||||
describe "when the notational-velocity:toggle event is triggered", ->
|
||||
it "attaches and then detaches the view", ->
|
||||
expect(atom.workspaceView.find('.notational-velocity')).not.toExist()
|
||||
|
||||
# This is an activation event, triggering it will cause the package to be
|
||||
# activated.
|
||||
atom.commands.dispatch atom.workspaceView.element, 'notational-velocity:toggle'
|
||||
|
||||
waitsForPromise ->
|
||||
activationPromise
|
||||
|
||||
runs ->
|
||||
expect(atom.workspaceView.find('.notational-velocity')).toExist()
|
||||
atom.commands.dispatch atom.workspaceView.element, 'notational-velocity:toggle'
|
||||
expect(atom.workspaceView.find('.notational-velocity')).not.toExist()
|
||||
@@ -0,0 +1,5 @@
|
||||
NotationalVelocityView = require '../lib/notational-velocity-view'
|
||||
|
||||
describe "NotationalVelocityView", ->
|
||||
it "has one valid test", ->
|
||||
expect("life").toBe "easy"
|
||||
@@ -0,0 +1,8 @@
|
||||
// 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";
|
||||
|
||||
.notational-velocity {
|
||||
}
|
||||
Reference in New Issue
Block a user