Merge branch 'master' into paste-indentation

This commit is contained in:
Nathan Sobo
2012-10-24 12:37:50 -06:00
29 changed files with 172 additions and 126 deletions

View File

@@ -108,6 +108,7 @@ class EditSession
setSoftWrap: (@softWrap) ->
getTabText: -> new Array(@tabLength + 1).join(" ")
getTabLength: -> @tabLength
clipBufferPosition: (bufferPosition) ->
@buffer.clipPosition(bufferPosition)

View File

@@ -18,6 +18,7 @@ class Keymap
'meta-n': 'new-window'
'meta-,': 'open-user-configuration'
'meta-o': 'open'
'meta-w': 'core:close'
$(document).on 'new-window', => atom.newWindow()
$(document).on 'open-user-configuration', => atom.open(atom.configFilePath)

View File

@@ -1,10 +1,11 @@
window.keymap.bindKeys 'body'
'alt-meta-i': 'toggle-dev-tools'
'enter': 'core:confirm'
'escape': 'core:cancel'
'meta-w': 'core:close'
up: 'core:move-up'
down: 'core:move-down'
left: 'core:move-left'
right: 'core:move-right'
'up': 'core:move-up'
'down': 'core:move-down'
'left': 'core:move-left'
'right': 'core:move-right'
'shift-up': 'core:select-up'
'shift-down': 'core:select-down'
'shift-left': 'core:select-left'
@@ -18,10 +19,15 @@ window.keymap.bindKeys 'body'
'meta-x': 'core:cut'
'meta-c': 'core:copy'
'meta-v': 'core:paste'
pageup: 'core:page-up'
pagedown: 'core:page-down'
'pageup': 'core:page-up'
'pagedown': 'core:page-down'
'meta-S': 'window:save-all'
'meta-+': 'window:increase-font-size'
'meta--': 'window:decrease-font-size'
'ctrl-w w': 'window:focus-next-pane'
'alt-meta-i': 'toggle-dev-tools'
window.keymap.bindKeys '.tool-panel'
'escape': 'tool-panel:unfocus'

View File

@@ -249,10 +249,10 @@ class Selection
outdentSelectedRows: ->
range = @getBufferRange()
buffer = @editSession.buffer
leadingTabRegex = new RegExp("^#{@editSession.getTabText()}")
leadingTabRegex = new RegExp("^ {1,#{@editSession.getTabLength()}}|\t")
for row in [range.start.row..range.end.row]
if leadingTabRegex.test buffer.lineForRow(row)
buffer.delete [[row, 0], [row, @editSession.tabLength]]
if matchLength = buffer.lineForRow(row).match(leadingTabRegex)?[0].length
buffer.delete [[row, 0], [row, matchLength]]
toggleLineComments: ->
@modifySelection =>

View File

@@ -8,6 +8,9 @@ fs = require 'fs'
_ = require 'underscore'
$ = require 'jquery'
{CoffeeScript} = require 'coffee-script'
RootView = require 'root-view'
require 'jquery-extensions'
require 'underscore-extensions'
windowAdditions =
rootViewParentSelector: 'body'
@@ -15,16 +18,28 @@ windowAdditions =
keymap: null
platform: $native.getPlatform()
startup: (path) ->
# This method runs when the file is required. Any code here will run
# in all environments: spec, benchmark, and application
startup: ->
TextMateBundle.loadAll()
TextMateTheme.loadAll()
@setUpKeymap()
$(window).on 'core:close', => @close()
@attachRootView(path)
$(window).on 'close', => @close()
# This method is intended only to be run when starting a normal application
# Note: RootView assigns itself on window on initialization so that
# window.rootView is available when loading user configuration
attachRootView: (pathToOpen) ->
if rootViewState = atom.getRootViewStateForPath(pathToOpen)
RootView.deserialize(rootViewState)
else
new RootView(pathToOpen)
$(@rootViewParentSelector).append(@rootView)
$(window).focus()
$(window).on 'beforeunload', =>
@shutdown()
false
$(window).focus()
shutdown: ->
@rootView.deactivate()
@@ -42,16 +57,6 @@ windowAdditions =
@_handleKeyEvent = (e) => @keymap.handleKeyEvent(e)
$(document).on 'keydown', @_handleKeyEvent
# Note: RootView assigns itself on window on initialization so that
# window.rootView is available when loading user configuration
attachRootView: (pathToOpen) ->
if rootViewState = atom.getRootViewStateForPath(pathToOpen)
RootView.deserialize(rootViewState)
else
new RootView(pathToOpen)
$(@rootViewParentSelector).append @rootView
requireStylesheet: (path) ->
unless fullPath = require.resolve(path)
throw new Error("requireStylesheet could not find a file at path '#{path}'")
@@ -91,12 +96,7 @@ windowAdditions =
console.log description, result
window[key] = value for key, value of windowAdditions
window.setUpKeymap()
RootView = require 'root-view'
require 'jquery-extensions'
require 'underscore-extensions'
window.startup()
requireStylesheet 'reset.css'
requireStylesheet 'atom.css'