Removing any parens we're not forced to use. Lean into it.

This commit is contained in:
Chris Wanstrath 2011-08-29 22:57:30 -07:00
parent 5770b38c5d
commit 918ee8e15e
7 changed files with 32 additions and 31 deletions

View File

@ -7,15 +7,15 @@ Editor = require 'editor'
{bindKey} = require 'editor'
exports.init = ->
@html = File.read(Chrome.appRoot() + "/plugins/project/project.html")
@html = File.read Chrome.appRoot() + "/plugins/project/project.html"
bindKey 'toggleProjectDrawer', 'Command-Ctrl-N', (env) =>
@toggle()
$('#project .file').live 'click', (event) =>
el = $(event.currentTarget)
path = decodeURIComponent el.attr('path')
Editor.open(path)
path = decodeURIComponent el.attr 'path'
Editor.open path
exports.toggle = ->
if @showing
@ -28,12 +28,12 @@ exports.toggle = ->
exports.reload = ->
dir = OSX.NSFileManager.defaultManager.currentDirectoryPath
$('#project .cwd').text(dir)
$('#project .cwd').text dir
files = Dir.list(dir)
files = Dir.list dir
listItems = _.map files, (path) ->
filename = path.replace(dir, "").substring(1)
filename = path.replace(dir, "").substring 1
type = if Dir.isDir(path) then 'dir' else 'file'
"<li class='#{type}' path='#{encodeURIComponent path}'>#{filename}</li>"
$('#project .files').append(listItems.join('\n'))
$('#project .files').append listItems.join '\n'

View File

@ -1 +1 @@
exports.Tabs = Tabs = require('tabs/tabs')
exports.Tabs = Tabs = require 'tabs/tabs'

View File

@ -26,7 +26,7 @@ bindKey 'toggleTabs', 'Command-Ctrl-T', (env) ->
showTabs = ->
Chrome.addPane 'top', require('tabs/tabs.html')
$('#tabs').parents('.pane').css height: 'inherit'
css = $('<style id="tabs-style"></style>').html require('tabs/tabs.css')
css = $('<style id="tabs-style"></style>').html require 'tabs/tabs.css'
$('head').append css
hideTabs = ->

View File

@ -3,7 +3,7 @@
console.originalLog = console.log
console.log = (thing) ->
OSX.NSLog thing.toString() if thing?
console.originalLog(thing)
console.originalLog thing
# load require() function

View File

@ -35,9 +35,9 @@ save = ->
exports.open = open = (path) ->
filename = path
if Dir.isDir(filename)
Process.cwd(filename)
Chrome.title _.last filename.split('/')
if Dir.isDir filename
Process.cwd filename
Chrome.title _.last filename.split '/'
editor.getSession().setValue ""
setMode()
Chrome.setDirty false
@ -45,7 +45,7 @@ exports.open = open = (path) ->
if /png|jpe?g|gif/i.test filename
Chrome.openURL filename
else
Chrome.title _.last filename.split('/')
Chrome.title _.last filename.split '/'
editor.getSession().setValue File.read filename
setMode()
Chrome.setDirty false
@ -59,7 +59,7 @@ setMode = ->
saveAs = ->
if file = Chrome.savePanel()
filename = file
Chrome.title _.last filename.split('/')
Chrome.title _.last filename.split '/'
save()
exports.bindKey = bindKey = (name, shortcut, callback) ->
canon.addCommand
@ -73,7 +73,7 @@ exports.bindKey = bindKey = (name, shortcut, callback) ->
bindKey 'open', 'Command-O', (env, args, request) ->
if file = Chrome.openPanel()
open(file)
open file
bindKey 'openURL', 'Command-Shift-O', (env, args, request) ->
if url = prompt "Enter URL:"

View File

@ -3,12 +3,11 @@
exports.outArgument = (args...) ->
# Derive to store some javascript data in the internal hash
if not @outArgument2?
OSX.JSCocoa.createClass_parentClass_('JSCocoaOutArgument2', 'JSCocoaOutArgument')
OSX.JSCocoa.createClass_parentClass_ 'JSCocoaOutArgument2', 'JSCocoaOutArgument'
o = OSX.JSCocoaOutArgument2.instance
o.isOutArgument = true
if args.length == 2
o.mateWithMemoryBuffer_atIndex_(args[0], args[1])
o.mateWithMemoryBuffer_atIndex_ args[0], args[1]
o

View File

@ -10,19 +10,19 @@ Chrome =
verticalDiv = $('#app-vertical')
horizontalDiv = $('#app-horizontal')
el = document.createElement("div")
el.setAttribute('class', "pane " + position)
el = document.createElement "div"
el.setAttribute 'class', "pane " + position
el.innerHTML = html
switch position
when 'top', 'main'
verticalDiv.prepend(el)
verticalDiv.prepend el
when 'left'
horizontalDiv.prepend(el)
horizontalDiv.prepend el
when 'bottom'
verticalDiv.append(el)
verticalDiv.append el
when 'right'
horizontalDiv.append(el)
horizontalDiv.append el
else
throw "I DON'T KNOW HOW TO DEAL WITH #{position}"
@ -51,7 +51,7 @@ Chrome =
# Returns null or a file path.
openPanel: ->
panel = OSX.NSOpenPanel.openPanel
panel.setCanChooseDirectories(true)
panel.setCanChooseDirectories true
if panel.runModal isnt OSX.NSFileHandlingPanelOKButton
return null
panel.filenames.lastObject
@ -94,7 +94,8 @@ File =
path
isFile: (path) ->
isDir = new jscocoa.outArgument
exists = OSX.NSFileManager.defaultManager.fileExistsAtPath_isDirectory(path, isDir)
exists = OSX.NSFileManager.defaultManager.
fileExistsAtPath_isDirectory path, isDir
exists and not isDir.valueOf()
Dir =
@ -108,18 +109,19 @@ Dir =
_.map paths, (entry) -> "#{path}/#{entry}"
isDir: (path) ->
isDir = new jscocoa.outArgument
exists = OSX.NSFileManager.defaultManager.fileExistsAtPath_isDirectory(path, isDir)
exists = OSX.NSFileManager.defaultManager.
fileExistsAtPath_isDirectory path, isDir
exists and isDir.valueOf()
Process =
cwd: (path) ->
if path?
OSX.NSFileManager.defaultManager.changeCurrentDirectoryPath(path)
OSX.NSFileManager.defaultManager.changeCurrentDirectoryPath path
else
OSX.NSFileManager.defaultManager.currentDirectoryPath()
OSX.NSFileManager.defaultManager.currentDirectoryPath
env: ->
OSX.NSProcess.processInfo.environment()
OSX.NSProcess.processInfo.environment
exports.Chrome = Chrome
exports.File = File