Removed unused code.

This commit is contained in:
Corey Johnson 2011-12-19 13:21:06 -08:00
parent ce9f5b7f5d
commit 33f125a8e6
54 changed files with 1 additions and 4447 deletions

View File

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>Icon.icns</string>
<key>CFBundleIdentifier</key>
<string>GitHub.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2011 __MyCompanyName__. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>AtomApp</string>
</dict>
</plist>

View File

@ -66,7 +66,6 @@
043D7E91145795B70078D710 /* AtomApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AtomApp.m; path = Classes/AtomApp.m; sourceTree = "<group>"; };
043D7E92145795B70078D710 /* AtomController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AtomController.h; path = Classes/AtomController.h; sourceTree = "<group>"; };
043D7E93145795B70078D710 /* AtomController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AtomController.m; path = Classes/AtomController.m; sourceTree = "<group>"; };
047E2FF8149FDD960014E327 /* Atom copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Atom copy-Info.plist"; path = "/Users/corey/code/mine/Atom/Atom copy-Info.plist"; sourceTree = "<absolute>"; };
047F26011457978C006DC904 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
047F260314579792006DC904 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
047F260D145883B9006DC904 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = "<group>"; };
@ -92,7 +91,6 @@
043D7E51145794990078D710 /* Atom */,
043D7E4A145794990078D710 /* Frameworks */,
043D7E48145794990078D710 /* Products */,
047E2FF8149FDD960014E327 /* Atom copy-Info.plist */,
);
sourceTree = "<group>";
};

View File

@ -8,7 +8,7 @@ task :build do
dest = File.join(built_dir, contents_dir, "Resources")
%w(index.html src docs static extensions test vendor ).each do |dir|
%w(index.html src docs static extensions vendor ).each do |dir|
rm_rf File.join(dest, dir)
cp_r dir, File.join(dest, dir)
end

View File

@ -1,47 +0,0 @@
$ = require 'jquery'
Resource = require 'resource'
# Events:
# browser:close (browser) -> Called when a browser is closed.
module.exports =
class Browser extends Resource
atom.router.add this
open: (url) ->
return false if not /^https?:/.test url
@url = url
@show()
true
close: ->
atom.trigger 'browser:close', this
super
# innerHTML - Optional String to set as iframe's content.
show: (innerHTML=null) ->
if not @pane
@add innerHTML
else
super
# innerHTML - Optional String to set as iframe's content.
add: (innerHTML=null) ->
style = "width:100%;height:100%;background-color:#fff;border:none"
@html = "<iframe src='#{@url}' style='#{style}'></iframe>"
super
iframe = @pane.find('iframe')[0]
if innerHTML
iframe.contentWindow.document.body.innerHTML = innerHTML
if @title
window.setTitle @title
else
window.setTitle iframe.contentWindow.document.title
$(iframe).bind 'load', (e) =>
window.setTitle e.target.contentWindow.document.title

View File

@ -1,31 +0,0 @@
$ = require 'jquery'
_ = require 'underscore'
fs = require 'fs'
Pane = require 'pane'
ace = require 'ace/ace'
module.exports =
class EditorPane extends Pane
position: 'main'
editor: null
show: ->
super
return if @ace
@ace = ace.edit @paneID
# Resize editor when panes are added/removed
el = document.body
el.addEventListener 'DOMNodeInsertedIntoDocument', => @resize()
el.addEventListener 'DOMNodeRemovedFromDocument', => @resize()
remove: ->
@pane?.remove()
resize: (timeout=1) ->
setTimeout =>
@ace.focus()
@ace.resize()
, timeout

View File

@ -1,30 +0,0 @@
fs = require 'fs'
module.exports =
class ExtensionManager
constructor: ->
@loadExtensions()
atom.on 'window:close', @unloadExtensions
loadExtensions: =>
extension.shutdown() for name, extension of atom.extensions
atom.extensions = {}
extensionPaths = fs.list require.resourcePath + "/extensions"
for extensionPath in extensionPaths when fs.isDirectory extensionPath
try
extension = require extensionPath
extension = atom.extensions[extension.name] = new extension
atom.keybinder.load "#{extensionPath}/key-bindings.coffee"
atom.settings.applyTo extension if extension.settings
catch error
console.warn "Loading Extension '#{fs.base extensionPath}' failed."
console.warn error
unloadExtensions: =>
for name, extension of atom.extensions
try
extension.shutdown() if extension.running
catch e
console.error "Failed to shutdown #{name}"
console.error e

View File

@ -1,15 +0,0 @@
# Extension subclasses must call super in all overridden methods.
module.exports =
class Extension
running: false
# `startup` should be called by you in Extension subclasses when they need
# to appear on the screen, attach themselves to a Resource, or otherwise become active.
startup: ->
@running = true
# `shutdown` shuold be called by you in Extension subclasses when they need
# to be remove from the screen, unattach themselves from a Resource, or otherwise become
# inactive.
shutdown: ->
@running = false

View File

@ -1,32 +0,0 @@
app:
'cmd-q': (app) -> app.quit()
'cmd-n': (app) -> atom.native.newWindow()
window:
'cmd-shift-I': (window) -> window.showConsole()
'cmd-w': (window) -> window.close()
'cmd-o': (window) -> window.open()
'cmd-O': (window) -> window.open window.prompt "Open URL:"
'cmd-s': (window) -> window.save()
'cmd-ctrl-s': ->
if query = escape prompt 'Search the web:'
window.open 'http://duckduckgo.com?q=' + query
'cmd-shift-e': ->
s = document.createElement 'script'
s.type = 'text/javascript'
document.body.appendChild s
s.src = 'http://erkie.github.com/asteroids.min.js'
editor:
'cmd-shift-s': 'saveAs'
'cmd-c': 'copy'
'cmd-x': 'cut'
'cmd-/': 'toggleComment'
'cmd-[': 'outdent'
'cmd-]': 'indent'
'alt-f': 'forwardWord'
'alt-b': 'backWord'
'alt-d': 'deleteWord'
'alt-shift-,': 'home'
'alt-shift-.': 'end'
'ctrl-l': 'consolelog'

View File

@ -1,167 +0,0 @@
$ = require 'jquery'
_ = require 'underscore'
Modal = require 'modal'
jQuery = $
require 'stringscore'
module.exports =
class ModalSelector extends Modal
selectorHTML: '''
<div id="modal-selector">
<input type="search">
<br>
<ul class="list">
</ul>
</div>
'''
showing: false
# A callback which should return the items to filter.
# Return should be an Array of {name, url} objects.
filterCallback: -> []
constructor: (@filterCallback) ->
super @selectorHTML
head = $('head')[0]
style = document.createElement 'style'
rules = document.createTextNode @selectorCSS
style.type = 'text/css'
style.appendChild rules
head.appendChild style
onKeydown: (e) =>
keys = up: 38, down: 40, enter: 13
if e.keyCode is keys.enter
@openSelected()
false
else if e.keyCode is keys.up
@moveUp()
else if e.keyCode is keys.down
@moveDown()
else
@filter()
show: ->
super
@list = @filterCallback()
@filter()
$('#modal-selector input').live 'keydown.modal-selector', @onKeydown
hide: ->
super
$(document).unbind '.modal-selector'
filter: ->
if query = $('#modal-selector input').val()
items = @findMatchingItems query
else
items = @list
$('#modal-selector ul').empty()
for {name} in items[0..10]
$('#modal-selector ul').append "<li>#{name}</li>"
$('#modal-selector input').focus()
$('#modal-selector li:first').addClass 'selected'
findMatchingItems: (query) ->
return [] if not query
results = []
for item in @list
{name, url} = item
score = name.score query
if score > 0
# Basename matches count for more.
if not query.match '/'
if name.match '/'
score += name.replace(/^.*\//, '').score query
else
score *= 2
results.push [score, item]
sorted = results.sort (a, b) -> b[0] - a[0]
_.map sorted, (el) -> el[1]
openSelected: ->
text = $('#modal-selector .selected').text()
{url} = _.find @list, (item) -> item.name is text
if typeof url is 'function'
url()
else
window.open url
@toggle()
moveUp: ->
selected = $('#modal-selector .selected')
if selected.prev().length
selected.prev().addClass 'selected'
selected.removeClass 'selected'
moveDown: ->
selected = $('#modal-selector .selected')
if selected.next().length
selected.next().addClass 'selected'
selected.removeClass 'selected'
selectorCSS: '''
#modal .content {
background: #ededed;
padding: 0;
}
#modal .close {
display: none;
}
#modal-selector .list {
height: 100px;
overflow: hidden;
padding: 10px 0;
}
#modal-selector input[type=search] {
width: 95%;
margin: 10px;
}
#modal .content {
min-width: 200px;
height: 100%;
background-color: #DDE3EA;
color: #000;
border-right: 1px solid #B4B4B4;
cursor: default;
-webkit-user-select: none;
overflow: auto;
}
#modal .content .cwd {
padding-top: 5px;
padding-left: 5px;
font-weight: bold;
color: #708193;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
#modal .content ul {
margin: 0;
padding-top: 2px;
list-style-type: none;
}
#modal .content li {
padding: 0;
padding-left: 5px;
line-height: 20px;
font-size: 14px;
}
#modal .content li.selected {
background-image: -webkit-gradient(linear,0% 0,0% 100%,from(#BCCBEB),to(#8094BB));
border-top: 1px solid #A0AFCD;
color: #fff;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
'''

View File

@ -1,151 +0,0 @@
$ = require 'jquery'
# Events:
# modal:show (modal) -> Called when the modal is displayed on screen.
# modal:hide (modal) -> Called when the modal hides.
module.exports =
class Modal
template: '''
<div id="modal">
<div class="popup">
<div class="content"></div>
<a href="#" class="close inline">&nbsp;</a>
</div>
</div>
'''
showing: false
constructor: (@html) ->
head = $('head')[0]
style = document.createElement 'style'
rules = document.createTextNode @css
style.type = 'text/css'
style.appendChild rules
head.appendChild style
show: ->
@showing = true
$('body').append('<div id="modal-overlay"></div>')
$(window).bind 'resize.modal', => @resize()
$(document).bind 'keydown.modal', (e) =>
if e.keyCode is (esc = 27) then @hide(); false
$('body').append $(@template).hide()
$('#modal .content').append @html
$('#modal-overlay')
.css('opacity', 0)
.click(=> @hide())
.fadeIn 10, =>
$('#modal').show()
$('#modal input').focus()
@resize()
atom.trigger 'modal:show', this
resize: ->
$('#modal').css
top: $(window).scrollTop() + ($(window).height() / 10),
left: $(window).width() / 2 - ($('#modal .popup').outerWidth() / 2)
hide: ->
@showing = false
$('#modal').remove()
$('#modal-overlay').fadeOut 200, -> $(this).remove()
$(document).unbind '.modal'
$(window).unbind '.modal'
atom.trigger 'modal:hide', this
toggle: ->
if @showing
@hide()
else
@show()
css: """
#modal {
position:absolute;
top:0;
left:0;
z-index:100;
text-align:left;
}
#modal .popup{
position:relative;
border:3px solid rgba(0,0,0,0);
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
-webkit-box-shadow:0 0 18px rgba(0,0,0,0.4);
-moz-box-shadow:0 0 18px rgba(0,0,0,0.4);
box-shadow:0 0 18px rgba(0,0,0,0.4);
}
#modal .content{
display:table;
width:370px;
padding:10px;
background:#fff;
-webkit-border-radius:4px;
-moz-border-radius:4px;
border-radius:4px;
}
#modal .content > p:first-child{
margin-top:0;
}
#modal .content > p:last-child{
margin-bottom:0;
}
#modal .close{
position:absolute;
top:5px;
right:5px;
padding:2px;
width:8px;
height:8px;
opacity:0.3;
z-index:10000;
}
#modal .close:hover{
opacity:1.0;
text-decoration:none;
}
#modal .fb-loading{
height:32px;
text-align:center;
}
#modal img{
display:block;
border:0;
margin:0 auto;
}
#modal-overlay{
position:fixed;
top:0px;
left:0px;
height:100%;
width:100%;
background-color:#000;
z-index:99;
display:none;
}
#modal .close.inline{
background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAEpJREFUeNpiYGBgEAXivUCsxYAAukC8CyoHlvwPxK+gErpQ9n+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2IN6pXt2owBAQAh+QQFCgAAACwAAA8AGQARAAAIgAAXHBhI8ACAgwgTKjxYsODChwkFEnQwEKLFixgxFjCQseOCjg8ZgIQYIGEAAhgHQGTAQOXBlgsJDJiZ0CVHhCxFAjDAE4DMmQUSBlXIEiHPmz9dWmT5cWfPgzMHoHy4oKjRp1BpLk14tKbWhVav3kQ4FWJThAsMnB2p0EDZhAEBACH5BAUKAAAALAEACAARABgAAAh3AAccOGAAgMGDCA8aGDhwQcKHABgOZDAAIsIFEg9YTBhgYMGNHEGKHEmypMmTKDcuYMCgJEuWIF++BLmyJcICHx+ydHhwgQEDFQcINUggIYGfBgoAEFoRItKmTCEOQHow6kOkRQ1aTfizqdahDwl4/ToWpFgAAQEAIfkEBQoAAAAsAAACAA4AHQAACIoAAQgcCGCBAYIIBx44wCAhwoUHBjgcGADiRIULD15cYJFgQ4IQP3qUCIDAgQAEUYokMHHAR5ETFwiUeRFAAY01WzLYyROmwJ49E7rcCYBnzqMISV4cYMCAUoQEmkp1aFDqggJCrQ4kMACrwKhOCQ4Yy1Kg14EFxg4o61At24Rcx9ZUm1NuzgJvAwIAOw==") no-repeat;
}
"""

View File

@ -1,174 +0,0 @@
$ = require 'jquery'
_ = require 'underscore'
fs = require 'fs'
Resource = require 'resource'
EditorPane = require 'editor-pane'
{EditSession} = require 'ace/edit_session'
{UndoManager} = require 'ace/undomanager'
# Events:
# editor:open (editor) -> Called when an editor is opened.
# editor:close (editor) -> Called when an editor is closed.
module.exports =
class Editor extends Resource
atom.router.add this
dirty: false
modeMap:
js: 'javascript'
c: 'c_cpp'
cpp: 'c_cpp'
h: 'c_cpp'
m: 'c_cpp'
md: 'markdown'
cs: 'csharp'
rb: 'ruby'
ru: 'ruby'
gemspec: 'ruby'
mustache: 'html'
modeFileMap:
Gemfile: 'ruby'
Rakefile: 'ruby'
settings:
theme: 'twilight'
softTabs: true
tabSize: 2
showInvisibles: false
marginColumn: 80
modeForURL: (url) ->
return if not url
if not modeName = @modeFileMap[ _.last url.split '/' ]
language = _.last url.split '.'
language = language.toLowerCase()
modeName = @modeMap[language] or language
try
require("ace/mode/#{modeName}").Mode
catch e
console.error e
require("ace/mode/text").Mode
setModeForURL: (url) ->
@pane.ace.session.setMode new (@modeForURL url)
title: ->
if @url then _.last @url.split '/' else 'untitled'
show: (code) ->
window.setTitle @title()
@pane ?= new EditorPane
@pane.show()
if code or not @session
@session = new EditSession code or ''
@session.setValue code or ''
@session.setUseSoftTabs @settings.softTabs
@session.setTabSize if @settings.softTabs then @settings.tabSize else 8
@session.setUndoManager new UndoManager
@session.on 'change', => @dirty = true
@pane.ace.setSession @session
@setModeForURL @url if @url
@dirty = false
@pane.ace.setTheme require "ace/theme/#{@settings.theme}"
@pane.ace.setShowInvisibles @settings.showInvisibles
@pane.ace.setPrintMarginColumn @settings.marginColumn
@pane.ace.resize()
open: (url) ->
if url
return false if not fs.isFile url
return false if @url
@url = url
@show if @url then fs.read @url else ''
atom.trigger 'editor:open', this
true
close: ->
if @dirty
detailedMessage = if @url
"#{@url} has changes."
else
"An untitled file has changes."
close = atom.native.alert "Do you want to save your changes?",
detailedMessage,
"Save": => @save()
"Cancel": => false
"Don't Save": => true
return not close
atom.trigger 'editor:close', this
super
save: ->
return @saveAs() if not @url
@removeTrailingWhitespace()
fs.write @url, @code()
@dirty = false
@url
saveAs: ->
if url = atom.native.savePanel()?.toString()
@url = url
@save url
code: ->
@pane.ace.getSession().getValue()
setCode: (code) ->
@pane.ace.getSession().setValue code
removeTrailingWhitespace: ->
@pane.ace.replaceAll "",
needle: "[ \t]+$"
regExp: true
wrap: true
usesSoftTabs: (code) ->
not /^\t/m.test code or @code()
guessTabSize: (code) ->
# * ignores indentation of css/js block comments
match = /^( +)[^*]/im.exec code || @code()
match?[1].length or 2
copy: ->
text = @pane.ace.getSession().doc.getTextRange @pane.ace.getSelectionRange()
atom.native.writeToPasteboard text
cut: ->
text = @pane.ace.getSession().doc.getTextRange @pane.ace.getSelectionRange()
atom.native.writeToPasteboard text
@pane.ace.session.remove @pane.ace.getSelectionRange()
eval: -> eval @code()
toggleComment: -> @pane.ace.toggleCommentLines()
outdent: -> @pane.ace.blockOutdent()
indent: -> @pane.ace.indent()
forwardWord: -> @pane.ace.navigateWordRight()
backWord: -> @pane.ace.navigateWordLeft()
deleteWord: -> @pane.ace.removeWordRight()
home: -> @pane.ace.navigateFileStart()
end: -> @pane.ace.navigateFileEnd()
wordWrap: ->
@pane.ace.getSession().setUseWrapMode true
consolelog: ->
@pane.ace.insert 'console.log ""'
@pane.ace.navigateLeft()

View File

@ -1,95 +0,0 @@
$ = require 'jquery'
_ = require 'underscore'
module.exports =
class Pane
paneID: null
position: null
constructor: (html) ->
@paneID = _.uniqueId 'pane-'
@el = $ "<div id='#{@paneID}'></div>"
@el.addClass "pane " + @position
@el.append html
mousemove = (event) =>
if @position == "left"
@el.width event.clientX
else if @position == "right"
@el.width window.outerWidth - event.clientX
else if @position == "bottom"
@el.height window.outerHeight - event.clientY
else if @position == "top"
@el.height event.clientY - @el.offset().top
mousedown = (event) =>
maxEdgeDistance = 10
edgeDistance = switch @position
when 'top'
@el.height() - event.clientY + @el.offset().top
when 'left'
@el.width() - event.clientX + @el.offset().left
when 'bottom'
event.clientY - @el.offset().top
when 'right'
event.clientX - @el.offset().left
else
throw "pane position for #{this} can't be `#{@position}`"
if edgeDistance < maxEdgeDistance
$(document).on 'mouseup', 'body', mouseup
$(document).on 'mousemove', 'body', mousemove
mouseup = (event) =>
$(document).off 'mouseup', 'body', mouseup
$(document).off 'mousemove', 'body', mousemove
if @position != 'main'
id = "##{@paneID}"
$(document).on 'mousedown', id, mousedown
add: ->
verticalDiv = $('#app-vertical')
horizontalDiv = $('#app-horizontal')
switch @position
when 'main'
# Only one main pane can be visiable.
$('#main > div').addClass 'hidden'
$('#main').append @el
when 'top'
verticalDiv.prepend @el
when 'left'
horizontalDiv.prepend @el
when 'bottom'
verticalDiv.append @el
when 'right'
horizontalDiv.append @el
else
throw "pane position of #{this} can't be `#{@position}`"
remove: ->
@el?.remove()
el: ->
el = $ "##{@paneID}"
el[0] and el # Return null if doesn't exist, jquery object if it does
showing: ->
@el and not @el.hasClass 'hidden'
show: ->
if not @el.parent()[0]
@add()
else
$('#main > div').addClass 'hidden' if @position == 'main'
@el.removeClass 'hidden'
hide: ->
@el.addClass 'hidden'
toggle: ->
if @showing()
@hide()
else
@show()

View File

@ -1,128 +0,0 @@
$ = require 'jquery'
_ = require 'underscore'
fs = require 'fs'
Resource = require 'resource'
# Events:
# project:open (project) -> Called when a project is opened.
# project:resource:open (project, resource) ->
# Called when the project opens a resource.
# project:resource:close (project, resource) ->
# Called when the project closes a resource.
# project:resource:active (project, resource) ->
# Called when a resource becomes active (i.e. the focal point)
# in a project.
module.exports =
class Project extends Resource
atom.router.add this
settings:
# Regexp used to ignore paths.
ignorePattern: /(\.git|\.xcodeproj|\.DS_Store|node_modules|\.bundle|\.sass-cache|vendor)/
# Arrays of { name, url, type } keyed by the root URL.
# Used when looking up a directory's contents by url
# to add metadata such as magic files or directories.
extraURLs: {}
resources: {}
responder: ->
@activeResource() or this
open: (url) ->
if not @url
# Can only open directories.
return false if not fs.isDirectory url
@url = url
window.setTitle @title()
atom.trigger 'project:open', this
true
else if @url
# Can't open directories once we have a URL.
if fs.isDirectory url
return false
# Ignore non-children files
if (fs.isFile url) and not @childURL url
return false
# Is this resource already open?
if resource = @resources[url]
@setActiveResource resource
resource.show()
true
else if resource = atom.router.open url
@resources[url] = resource
atom.trigger 'project:resource:open', this, resource
@setActiveResource resource
true
close: (url) ->
if url
resource = @resources[url]
else
resource = @activeResource()
if resource
return true if resource?.close()
delete @resources[resource.url]
@setActiveResource()
atom.trigger 'project:resource:close', this, resource
@activeResource()?.show()
true
save: ->
@activeResource()?.save()
# Finds the active resource or makes a guess based on open resources.
# Returns a resource or null.
activeResource: ->
@__activeResource or @setActiveResource()
# Sets a resource as active.
#
# resource - Optional. The resource to set as active.
# If none given tries to pick one.
#
# Returns the resource that was set to active if we succeeded.
# Returns null if we couldn't set any resource to active.
setActiveResource: (resource) ->
if not resource
resource = _.last _.values @resources
@__activeResource = resource
if resource
atom.trigger 'project:resource:active', this, resource
resource
title: ->
_.last @url.split '/'
# Determines if a passed URL is a child of @url.
# Returns a Boolean.
childURL: (url) ->
return false if not @url
parent = @url.replace /([^\/])$/, "$1/"
child = url.replace /([^\/])$/, "$1/"
child.match "^" + parent
urls: (root=@url) ->
_.compact _.map (fs.list root), (url) =>
return if @settings.ignorePattern.test url
type: if fs.isDirectory url then 'dir' else 'file'
name: url.replace(root, "").substring 1
url: url
.concat @settings.extraURLs[root] or []
# WARNING THIS IS PROBABLY SLOW
allURLs: ->
_.compact _.map (fs.listDirectoryTree @url), (url) =>
name = url.replace "#{window.url}/", ''
return if @settings.ignorePattern.test name
{ name, url }

View File

@ -1,26 +0,0 @@
_ = require 'underscore'
Pane = require 'pane'
# When subclassing, call super() at the end of your
# constructor.
#
# Events:
# resource:close (resource) -> Called when a resource is closed.
module.exports =
class Resource extends Pane
position: "main"
pane: null
settings: {}
url: null
# Can be used to delegate key events to another object, such as a pane.
constructor: ->
atom.settings.applyTo this
responder: ->
this
close: ->
atom.trigger 'resource:close', this
@pane?.remove()
false

View File

@ -1,15 +0,0 @@
module.exports =
class Router
resources: []
add: (resource) ->
@resources.unshift resource
open: (url) ->
success = false
for resourceType in @resources
resource = new resourceType
break if success = resource.open url
resource if success

View File

@ -36,9 +36,6 @@ windowAdditions =
onerror: ->
@showConsole true
triggerEvent: ->
null
for key, value of windowAdditions
console.warn "DOMWindow already has a key named `#{key}`" if window[key]
window[key] = value

View File

@ -1,14 +0,0 @@
assert = require 'assert'
ChildProcess = require 'child-process'
ChildProcess.exec "echo hello", (error, stdout, stderr) ->
assert.equal "hello", stdout.trim()
assert.equal null, error
ChildProcess.exec "derp hello", (error, stdout, stderr) ->
assert.equal "/bin/bash: derp: command not found", stderr.trim()
assert.ok error
assert.equal 127, error.code
ChildProcess.exec "coffee -e 'console.log 1+1'", (error, stdout, stderr) ->
assert.equal "2", stdout.trim()

View File

@ -1,26 +0,0 @@
fs = require 'fs'
assert = require 'assert'
root = OSX.NSBundle.mainBundle.resourcePath
resolve = (path) ->
# use a list of known load paths in the tests
paths = require.paths
require.paths = [ "#{root}/src", "#{root}/extensions", "#{root}/vendor" ]
path = require.resolve path
require.paths = paths
path
assert.equal resolve('underscore'), "#{root}/vendor/underscore.js"
assert.equal resolve('atom/window'), "#{root}/src/atom/window.js"
assert.equal resolve('tabs/tabs'), "#{root}/extensions/tabs/tabs.js"
#assert.equal resolve('./resource'), "#{root}/src/resource.js"
#assert.equal resolve('../README.md'), "#{root}/README.md"
dotatom = fs.absolute "~/.atom"
assert.equal resolve('~/.atom'), "#{dotatom}/index.coffee"
assert.equal resolve('ace/requirejs/text!ace/css/editor.css'),
"#{root}/vendor/ace/css/editor.css"
assert.equal resolve('ace/keyboard/keybinding'),
"#{root}/vendor/ace/keyboard/keybinding.js"

View File

@ -1,23 +0,0 @@
fs = require 'fs'
Editor = require 'editor'
Extension = require 'extension'
{CoffeeScript} = require 'coffee-script'
module.exports =
class CompileCoffee extends Editor
atom.router.add this
running: true
open: (url) ->
return false if not url
if match = url.match /^compilecoffee:\/\/(.+)/
@url = url
@show CoffeeScript.compile fs.read match[1]
@setModeForURL @url.replace '.coffee', '.js'
true

View File

@ -1 +0,0 @@
module.exports = require 'compilecoffee/compile-coffee'

View File

@ -1,2 +0,0 @@
editor:
'cmd-shift-r': (editor) => window.open "compilecoffee://#{editor.url}"

View File

@ -1,166 +0,0 @@
# cdoc is a bite sized library which scans CoffeeScript
# source code and returns a js object containing class, module
# and method names, along with the comments and line numbers
# associated with them.
#
# It pairs finely with TomDoc, but really doesn't care which
# documentation format you use. As long as your class, module, and
# method definitions are preceded by a comment, cdoc will do its job.
module.exports = cdoc =
# Parses CoffeeScript source code into an object describing
# the class names and modules defined therein. Method names,
# comments, and line numbers are also included.
#
# text - The String CoffeeScript source code to parse into a js object.
#
# Returns an object like this:
#
# [
# name: "App"
# comment:"Singleton object representing the application.",
# line: 5,
# methods: [
# name: "setTitle"
# signature: "setTitle: (title) ->"
# params: [
# name: "title"
# ]
# comment: "Sets the title of the app."
# line: 7
# ,
# name: "title"
# signature: "title: ->"
# params: []
# comment: "Returns the String title of the app."
# line: 11
# ]
# name: "class Robot"
# comment: "A Robot that can walk and talk, just like a real boy."
# line: 15
# methods: [
# name: "constructor"
# signature: "constructor: (path) ->"
# params: [
# name: "path"
# ]
# comment: "Robots receive messages from a..."
# line: 20
# ]
# ]
#
# In the above, App is an object while Robot is a class.
parse: (text) ->
scopes = []
lastComment = ''
methodIndent = null
moduleIsFn = false
text.split("\n").forEach (line, lineno) =>
return if moduleIsFn
lineno++
# Skip empty lines and lines containing only a comment symbol.
return if not line.trim()
# If this line is a comment, record it and move on.
if line.trim()[0] is '#'
lastComment += line.trim().match(/^\s*\#\s?(.*)$/)[1] + "\n"
return
# detect:
# 1. module.exports = (params) ->
# 2. module.exports = (params) =>
if match = line.match /^\s*module.exports\s*=\s*((?:\((.+)\))?\s*(-|=)>)/
moduleIsFn = true
[ signature, params ] = match[1..2]
params = for param in params?.split(',') or []
{ name: param.trim() }
scopes.push
name: 'module'
signature: signature
params: params
comment: lastComment.trim()
line: lineno
# detect:
# 1. module.exports =
# 2. module.exports = MyModule =
# 3. module.exports = class MyClass
# 4. exports.MyClass = class MyClass
else if match = line.match /^\s*(?:module.exports|exports\.[\w\.]+)\s*=\s*(?:(class [\w\.]+)(?:\s+extends [\w.]+)?|([\w\.]+)\s*=)\s*$/
methodIndent = null
scopes.push
name: match[1] or match[2] or 'module'
comment: lastComment.trim()
line: lineno
methods: []
# detect: class Window
else if newScope = line.match(/^\s*class ([\w\.]+)/)?[0]
methodIndent = null
scopes.push
name: newScope
comment: lastComment.trim()
line: lineno
methods: []
# detect:
# 1. hear: ->
# 2. hear: (regex, args...) ->
# 3. hear = ->
# 4. hear = (regex, args...) ->
# also detect `@hear` and `=>` forms of the above
# as well as `exports.head = (regex, args...) ->` form
else if match = line.match /^\s*(@|exports\.)?(([\w\.]+)\s*(:|=)\s*(?:\((.*?)\))?\s*(-|=)>)\s*/
# If the indentation of this method is deeper than the
# previous method definition, and we're still in the same
# scope, bail out. Probably an inner function.
indent = line.match(/^(\s*)/)[0].length
return if methodIndent? and methodIndent < indent
methodIndent = indent
[ prefix, fn, name, type, params ] = match[1..-1]
# floating function
if type is '=' and prefix isnt 'exports.'
return
# Normalize the method signature.
# 1. exports.method = (param) ->
# exports.method: (param) ->
# 2. method: () ->
# method: ->
fn = fn.trim()
fn = fn.replace /\s+=\s+((\(|-|=))/, ': $1'
fn = fn.replace /\s*\(\)/, ''
params = for param in params?.split(',') or []
{ name: param.trim() }
if prefix is 'exports.'
modules = scopes.filter (scope) -> scope?.name is 'module'
scope = modules[0]
if not scope
scopes.push scope =
name: 'module'
comment: ""
line: 0
methods: []
else
scope = scopes[scopes.length - 1]
scope.methods ?= []
scope.methods.push
name: name
signature: fn
params: params
comment: lastComment.trim()
line: lineno
# Clear the last comment, we're done with it.
lastComment = ''
scopes

View File

@ -1,20 +0,0 @@
fs = require 'fs'
tdoc = require 'docs/tdoc'
Browser = require 'browser'
module.exports =
class Docs extends Browser
atom.router.add this
running: true
open: (url) ->
return false if not url
if match = url.match /^docs:\/\/(.+)/
@url = url
code = fs.read match[1]
@show tdoc.html code
true

View File

@ -1,20 +0,0 @@
hbar = require 'handlebars'
{Showdown} = require './showdown'
converter = new Showdown.converter
hbar.registerHelper 'format', (comment) ->
comment = comment+''
# param - info => <b>param:</b> info
comment = comment.replace /(?:^\s*(\S+?)\s+-\s+(.+)$)+/img,
'<br>**$1:** $2'
comment = comment.replace '<br>**', '<br><br>**'
# markdownize
comment = converter.makeHtml comment
# <pre><code>code</code></pre> => <pre>code</pre>
comment = comment.replace /<pre><code>((?:.|\n)+)<\/code><\/pre>/img,
'<pre>$1</pre>'
new hbar.SafeString comment

View File

@ -1 +0,0 @@
module.exports = require 'docs/docs'

View File

@ -1,2 +0,0 @@
editor:
'cmd-shift-d': (editor) -> window.open "docs://#{editor.url}"

File diff suppressed because it is too large Load Diff

View File

@ -1,82 +0,0 @@
# tdoc is a bite sized library for generating HTML documentation
# from CoffeeScript source code and Markdown files.
#
# It pairs finely with TomDoc, but really doesn't care which
# documentation format you use. As long as your class, module, and
# method definitions are preceded by a comment, tdoc will do its job.
File = require 'fs'
cdoc = require './cdoc'
hbar = require 'handlebars'
require './helpers'
# The tdoc module is our main interface. Using it we can turn CoffeeScript
# or Markdown into HTML using a template.
module.exports = tdoc =
# Theme to use. Set using setTheme()
theme: 'default'
# Turns code into HTML docs.
#
# code - String of source code.
# options -
# path: The path to the file this code is from.
#
# Returns a String of HTML.
html: (code, options={}) ->
options.path ?= ''
options.paths = options.paths ? []
options.sourceURL = "https://github.com/github/hubot/tree/master/"
options.code = code
if /\.(md|markdown|mdown|txt)$/.test options.path
@render @template('markdown'), options
else if options.path is '' or /\.coffee$/.test options.path
context = cdoc.parse code
context[key] = value for key, value of options
@render @template(), context
else
"Don't know how to parse #{options.path}."
# Sets the current theme.
#
# theme - String name of the theme you want to use.
#
# Returns nothing.
setTheme: (name) ->
@theme = name
# Finds a template.
#
# name - String name of the template you want.
#
# Returns a String template
template: (name='module') ->
# lame require.resolve hack :(
layout = @read require.resolve "docs/themes/#{@theme}/layout.html"
file = @read require.resolve "docs/themes/#{@theme}/#{name}.html"
layout.replace /{{{\s*yield\s*}}}/, file
# Renders a template using Handlebars.js.
#
# template - String template to render.
# context - Object to use as context of the template.
#
# Returns the fully rendered template.
render: (template, context) ->
compiled = hbar.compile template
compiled context
# Reads a file synchronously using either CommonJS or node.
#
# path - String path to the file you want to read.
# encoding - String encoding to use when reading the file.
#
# Returns a String.
read: (path, encoding="utf8") ->
if File.readFileSync?
File.readFileSync path, encoding
else if File.read?
File.read path

View File

@ -1,11 +0,0 @@
<h1>Hubot</h1>
<h3>A simple helpful Robot for your Company</h3>
<p>
<ul class="unstyled">
<li><a href="#">Creator</a></li>
<li><a href="#">Robot</a></li>
<li><a href="#">Robot.Response</a></li>
</ul>
</p>

View File

@ -1,32 +0,0 @@
<html>
<head>
<link rel="stylesheet" href="static/bootstrap-1.4.0.css">
<style>
p { color: #404040; margin-bottom: 20px; font-size: 14px; line-height: 20px; }
ul { list-style-type: none; }
li { color: #404040; }
h5 { border-bottom: 1px dotted #404040; line-height: 20px; margin-bottom: 8px; }
h5 a { color: inherit; }
h5 a:hover { text-decoration: none; }
pre { background-color: #FEE9CC; }
#main { width: 610px; margin:0 auto; padding-top: 10px; }
#sidebar { float: left; padding-top: 12px; }
</style>
</head>
<body>
<div class="container">
<div id="sidebar">
<ul>
{{# paths}}
<li><a href="{{this}}.html">{{this}}</a></li>
{{/ paths}}
</ul>
</div>
<div id="main">
{{{yield}}}
</div>
</div>
</body>
</html>

View File

@ -1 +0,0 @@
{{format code}}

View File

@ -1,19 +0,0 @@
{{# this}}
<h3>{{name}}</h3>
<ul>
{{#if comment}}
<li><p>{{comment}}</p></li>
{{/if}}
{{# methods}}
<li>
{{#if ../../sourceURL}}
<h5><a href="{{../../../sourceURL}}{{../../../path}}#L{{line}}" target="_blank">{{signature}}</a></h5>
{{else}}
<h5>{{signature}}</h5>
{{/if}}
{{format comment}}
</li>
{{/ methods}}
</ul>
{{/ this}}

View File

@ -1,72 +0,0 @@
_ = require 'underscore'
$ = require 'jquery'
fs = require 'fs'
handlebars = require 'handlebars'
ChildProcess = require 'child-process'
Browser = require 'browser'
Extension = require 'extension'
ModalSelector = require 'modal-selector'
module.exports =
class FindInProject extends Browser
atom.router.add this
running: true
# Array of { name, url } objects
results: []
# String search term
term: ''
open: (url) ->
return if not url
if match = url.match /^findinproject:\/\/(.+)/
@term = match[1]
@url = url
@title = "Find #{@term}"
@findInProject @term, (@results) => @show()
true
findInProject: (term, callback) ->
return callback [] if not url = window.url
ChildProcess.exec "ack --ignore-dir=Cocoa/build --ignore-dir=vendor #{term} #{url}", (error, stdout, stderr) ->
callback _.compact _.map (stdout.split "\n"), (line) ->
return if _.isEmpty line.trim()
name: line.replace "#{url}/", ''
url: _.first line.split ":"
add: ->
super @render()
# gross!
iframe = $ $('iframe')[0].contentDocument.body
iframe.find('#find-in-project-results-view a').click ->
window.open this.href.replace 'file://', ''
false
render: ->
results = _.map @results, ({name, url}) =>
line = _.escape name
[file, match...] = line.split ':'
match: (match.join ':').replace(@term, "<code>#{@term}</code>")
url: url
file: file
@template results: results
template: handlebars.compile '''
<link rel="stylesheet" href="static/bootstrap-1.4.0.css">
<style>body { padding:10px; }</style>
<h1>Results</h1>
<ul id="find-in-project-results-view">
{{#each results}}
<li><a href='{{url}}'>{{{file}}}:{{{match}}}</a></li>
{{/each}}
</ul>
'''

View File

@ -1 +0,0 @@
module.exports = require 'findinproject/find-in-project'

View File

@ -1,4 +0,0 @@
findinproject:
'cmd-shift-f': (findinproject) ->
if term = prompt "Find in project:"
window.open "findinproject://#{term}"

View File

@ -1,40 +0,0 @@
$ = require 'jquery'
_ = require 'underscore'
fs = require 'fs'
Extension = require 'extension'
ModalSelector = require 'modal-selector'
module.exports =
class Gemfile extends Extension
constructor: ->
atom.on 'project:open', @startup
startup: (@project) =>
urls = @project.urls()
gemfile = _.detect urls, ({url}) -> /Gemfile/i.test url
{url} = gemfile if gemfile
gems = @gems url if url
if url and gems.length > 0
@project.settings.extraURLs[@project.url] = [
name: "RubyGems"
url: "http://rubygems.org/"
type: 'dir'
]
@project.settings.extraURLs["http://rubygems.org/"] = gems
@pane = new ModalSelector -> gems
toggle: ->
@pane?.toggle()
gems: (url) ->
file = fs.read url
gems = []
for line in file.split "\n"
if gem = line.match(/^\s*gem ['"](.+?)['"]/)?[1]
gems.push type: 'file', name: gem, url: "https://rubygems.org/gems/#{gem}"
gems

View File

@ -1 +0,0 @@
module.exports = require 'gemfile/gemfile'

View File

@ -1,2 +0,0 @@
gemfile:
'cmd-ctrl-g': (gemfile) -> gemfile.toggle()

View File

@ -1,144 +0,0 @@
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
}
module.exports = Base64;

View File

@ -1,68 +0,0 @@
_ = require 'underscore'
$ = require 'jquery'
fs = require 'fs'
Extension = require 'resource'
ModalSelector = require 'modal-selector'
Editor = require 'editor'
Base64 = require 'gist/base64'
module.exports =
class Gist extends Editor
atom.router.add this
settings:
username: ''
password: ''
open: (url) ->
return if not url
if match = url.match /^https?:\/\/gist\.github\.com\/([^\/]+)\/?/
super()
@setCode "Loading Gist..."
@url = url
@id = match[1]
$.ajax
url: "https://api.github.com/gists/#{@id}"
error: => @setCode "Loading Gist failed."
success: (data) =>
# only one file for now
@filename = _.first _.keys data.files
@metadata = _.first _.values data.files
@setModeForURL @filename
@setCode @metadata.content
true
save: ->
user = @settings.username
pass = @settings.password
if not user or not pass
console.error "Please gist.username and gist.password in your local settings file."
return
# Can't get this to work yet. 500ing
if @id
files = {}
files[@filename] = content: @code()
$.ajax
# Needed for CORS, otherwise we send an unparseable Origin
headers: { origin: null }
url: "https://api.github.com/gists/#{@id}"
type: 'patch'
contentType: 'application/json'
data: JSON.stringify { files }
error: -> console.error "Saving Gist failed."
success: (data) =>
atom.native.writeToPasteboard @url
console.log 'it worked'
beforeSend: (req) =>
req.setRequestHeader 'Authorization', @authorization user, pass
true
# basic auth
authorization: (user, pass) ->
token = "#{user}:#{pass}"
hash = Base64.encode token
"Basic #{hash}"

View File

@ -1 +0,0 @@
module.exports = require 'gist/gist'

View File

@ -1 +0,0 @@
module.exports = require 'markdownpreview/markdownpreview'

View File

@ -1,2 +0,0 @@
editor:
'cmd-ctrl-p': (editor) -> window.open "markdown:#{editor.url}"

View File

@ -1,34 +0,0 @@
fs = require 'fs'
tdoc = require 'docs/tdoc'
Browser = require 'browser'
{Showdown} = require './showdown'
converter = new Showdown.converter
module.exports =
class Markdownpreview extends Browser
atom.router.add this
running: true
open: (url) ->
return false if not url
if match = url.match /^markdown:(.+)/
@url = url
html = '''
<link rel="stylesheet" href="static/bootstrap-1.4.0.css">
<style>
body { padding:10px; }
code { line-height:16px; }
</style>
'''
html += converter.makeHtml fs.read match[1]
@show html
true

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
module.exports = require 'projectfinder/projectfinder'

View File

@ -1,2 +0,0 @@
projectfinder:
'cmd-shift-p': (projectfinder) => projectfinder.toggle()

View File

@ -1,23 +0,0 @@
_ = require 'underscore'
fs = require 'fs'
Extension = require 'extension'
ModalSelector = require 'modal-selector'
module.exports =
class Projectfinder extends Extension
settings:
root: "~/Code"
constructor: ->
atom.on 'window:load', @startup
startup: (@project) =>
@pane = new ModalSelector =>
_.compact _.map (fs.list @settings.root), (url) =>
return if fs.isFile url
name = url.replace "#{fs.absolute @settings.root}/", ''
{ name, url }
toggle: ->
@pane?.toggle()

View File

@ -1 +0,0 @@
module.exports = require 'showkeybindings/showkeybindings'

View File

@ -1,2 +0,0 @@
showkeybindings:
'cmd-shift-k': -> window.open 'atom://keybindings'

View File

@ -1,40 +0,0 @@
_ = require 'underscore'
$ = require 'jquery'
fs = require 'fs'
Browser = require 'browser'
module.exports =
class Showkeybindings extends Browser
atom.router.add this
constructor: ->
@running = true
open: (url) ->
return if not url
if url is 'atom://keybindings'
@title = 'Keybindings'
@url = url
@show()
true
innerHTML: ->
html = '''
<link rel="stylesheet" href="static/bootstrap-1.4.0.css">
<style>body { padding:10px; }</style>
'''
html += '<h1>Keybindings</h1>'
for name, bindings of atom.keybinder.keymaps
html += "<h3>#{name}</h3>"
html += "<ul>"
for binding, method of bindings
html += """
<li>#{atom.keybinder.bindingFromAscii(binding)} - #{method}</li>
"""
html += "</ul>"
html
show: ->
super @innerHTML()

View File

@ -1 +0,0 @@
module.exports = require 'tinytest/tinytest'

View File

@ -1,3 +0,0 @@
tinytest:
'cmd-ctrl-t': (tinytest) ->
tinytest.run()

View File

@ -1,29 +0,0 @@
$ = require 'jquery'
_ = require 'underscore'
fs = require 'fs'
Pane = require 'pane'
Extension = require 'extension'
{CoffeeScript} = require 'coffee-script'
module.exports =
class TinyTest extends Extension
run: ->
_.map fs.list(window.url + '/test'), @runTest
runTest: (path) ->
name = _.last path.split '/'
try
delete require.__modules[path] if require.__modules[path]
require path
console.log "all tests passed in #{name}"
catch e
if e.actual? and e.expected?
console.error "#{e.operator} test failed in #{name}:"
console.error e.actual
console.error "isn't"
console.error e.expected
else
throw e