mirror of
https://github.com/atom/atom.git
synced 2026-01-25 23:08:18 -05:00
Merge branch 'master' into paste-indentation
This commit is contained in:
@@ -108,6 +108,7 @@ class EditSession
|
||||
setSoftWrap: (@softWrap) ->
|
||||
|
||||
getTabText: -> new Array(@tabLength + 1).join(" ")
|
||||
getTabLength: -> @tabLength
|
||||
|
||||
clipBufferPosition: (bufferPosition) ->
|
||||
@buffer.clipPosition(bufferPosition)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
@@ -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 =>
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -26,8 +26,7 @@ class Autocomplete extends View
|
||||
|
||||
@activate: (rootView) ->
|
||||
new Autocomplete(editor) for editor in rootView.getEditors()
|
||||
rootView.on 'editor-open', (e, editor) ->
|
||||
editor.autoComplete = new Autocomplete(editor) unless editor.is('.autocomplete .mini')
|
||||
rootView.on 'editor-open', (e, editor) -> new Autocomplete(editor) unless editor.mini
|
||||
|
||||
initialize: (@editor) ->
|
||||
requireStylesheet 'autocomplete.css'
|
||||
@@ -39,8 +38,8 @@ class Autocomplete extends View
|
||||
@editor.on 'before-remove', => @currentBuffer?.off '.autocomplete'
|
||||
|
||||
@editor.command 'autocomplete:attach', => @attach()
|
||||
@editor.command 'autocomplete:cancel', => @cancel()
|
||||
@command 'autocomplete:confirm', => @confirm()
|
||||
@command 'core:cancel', => @cancel()
|
||||
@command 'core:confirm', => @confirm()
|
||||
|
||||
@matchesList.on 'mousedown', (e) =>
|
||||
index = $(e.target).attr('index')
|
||||
|
||||
@@ -2,6 +2,7 @@ window.keymap.bindKeys '.editor',
|
||||
'ctrl-space': 'autocomplete:attach'
|
||||
|
||||
window.keymap.bindKeys '.autocomplete .editor',
|
||||
'enter': 'autocomplete:confirm'
|
||||
'escape': 'autocomplete:cancel'
|
||||
'ctrl-space': 'autocomplete:cancel'
|
||||
'ctrl-space': 'core:cancel'
|
||||
|
||||
window.keymap.bindKeys ".autocomplete .mini.editor input",
|
||||
'enter': 'core:confirm'
|
||||
@@ -33,7 +33,7 @@ class CommandPanel extends View
|
||||
commandPanel
|
||||
|
||||
@content: (rootView) ->
|
||||
@div class: 'command-panel', =>
|
||||
@div class: 'command-panel tool-pane', =>
|
||||
@subview 'previewList', new PreviewList(rootView)
|
||||
@div class: 'prompt-and-editor', =>
|
||||
@div ':', class: 'prompt', outlet: 'prompt'
|
||||
@@ -50,9 +50,9 @@ class CommandPanel extends View
|
||||
@history ?= []
|
||||
@historyIndex = @history.length
|
||||
|
||||
@command 'command-panel:unfocus', => @rootView.focus()
|
||||
@command 'command-panel:close', => @detach()
|
||||
@command 'command-panel:execute', => @execute()
|
||||
@command 'tool-pane:unfocus', => @rootView.focus()
|
||||
@command 'core:close', => @detach()
|
||||
@command 'core:confirm', => @execute()
|
||||
|
||||
@rootView.command 'command-panel:toggle', => @toggle()
|
||||
@rootView.command 'command-panel:toggle-preview', => @togglePreview()
|
||||
|
||||
@@ -5,9 +5,7 @@ window.keymap.bindKeys '*'
|
||||
'meta-F': 'command-panel:find-in-project'
|
||||
|
||||
window.keymap.bindKeys '.command-panel .preview-list, .command-panel .editor input',
|
||||
'meta-w': 'command-panel:close'
|
||||
escape: 'command-panel:unfocus'
|
||||
enter: 'command-panel:execute'
|
||||
'enter': 'core:confirm'
|
||||
|
||||
window.keymap.bindKeys '.editor',
|
||||
'meta-g': 'command-panel:repeat-relative-address'
|
||||
|
||||
@@ -14,7 +14,7 @@ class PreviewList extends ScrollView
|
||||
super
|
||||
@on 'core:move-down', => @selectNextOperation()
|
||||
@on 'core:move-up', => @selectPreviousOperation()
|
||||
@on 'command-panel:execute', => @executeSelectedOperation()
|
||||
@on 'core:confirm', => @executeSelectedOperation()
|
||||
|
||||
@on 'mousedown', 'li', (e) =>
|
||||
@setSelectedOperationIndex(parseInt($(e.target).closest('li').data('index')))
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
margin: 4px 0;
|
||||
}
|
||||
|
||||
|
||||
.event-palette li .right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
{View, $$} = require 'space-pen'
|
||||
SelectList = require 'select-list'
|
||||
stringScore = require 'stringscore'
|
||||
fuzzyFilter = require 'fuzzy-filter'
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
Editor = require 'editor'
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
window.keymap.bindKeys '.editor',
|
||||
'meta-P': 'markdown-preview:attach'
|
||||
'meta-P': 'markdown-preview:toggle'
|
||||
|
||||
window.keymap.bindKeys '.markdown-preview',
|
||||
'escape': 'markdown-preview:detach'
|
||||
'meta-P': 'markdown-preview:toggle'
|
||||
@@ -15,13 +15,18 @@ class MarkdownPreview extends ScrollView
|
||||
|
||||
initialize: (@rootView) ->
|
||||
super
|
||||
@rootView.command 'markdown-preview:attach', =>
|
||||
path = rootView.getActiveEditor()?.getPath()
|
||||
@attach() if @isMarkdownFile(path)
|
||||
@rootView.command 'markdown-preview:toggle', => @toggle()
|
||||
@command 'core:cancel', => @detach()
|
||||
|
||||
@command 'markdown-preview:detach', => @detach()
|
||||
toggle: ->
|
||||
if @hasParent()
|
||||
@detach()
|
||||
else
|
||||
@attach()
|
||||
|
||||
attach: ->
|
||||
path = rootView.getActiveEditor()?.getPath()
|
||||
return unless @isMarkdownFile(path)
|
||||
@rootView.append(this)
|
||||
@markdownBody.hide()
|
||||
@markdownSpinner.show()
|
||||
|
||||
@@ -12,8 +12,8 @@ class Dialog extends View
|
||||
|
||||
initialize: ({path, @onConfirm, select} = {}) ->
|
||||
@miniEditor.focus()
|
||||
@on 'tree-view:confirm', => @onConfirm(@miniEditor.getText())
|
||||
@on 'tree-view:cancel', => @cancel()
|
||||
@on 'core:confirm', => @onConfirm(@miniEditor.getText())
|
||||
@on 'core:cancel', => @cancel()
|
||||
@miniEditor.on 'focusout', => @remove()
|
||||
|
||||
@miniEditor.setText(path)
|
||||
|
||||
@@ -3,8 +3,6 @@ window.keymap.bindKeys '#root-view'
|
||||
'ctrl-meta-1': 'tree-view:reveal-active-file'
|
||||
|
||||
window.keymap.bindKeys '.tree-view'
|
||||
'escape': 'tree-view:unfocus'
|
||||
'meta-w': 'tree-view:toggle'
|
||||
'right': 'tree-view:expand-directory'
|
||||
'left': 'tree-view:collapse-directory'
|
||||
'enter': 'tree-view:open-selected-entry'
|
||||
@@ -14,5 +12,5 @@ window.keymap.bindKeys '.tree-view'
|
||||
'backspace': 'tree-view:remove'
|
||||
|
||||
window.keymap.bindKeys '.tree-view-dialog .mini.editor'
|
||||
'enter': 'tree-view:confirm'
|
||||
'escape': 'tree-view:cancel'
|
||||
'enter': 'core:confirm'
|
||||
'escape': 'core:cancel'
|
||||
@@ -27,7 +27,7 @@ class TreeView extends ScrollView
|
||||
@instance.serialize()
|
||||
|
||||
@content: (rootView) ->
|
||||
@div class: 'tree-view', tabindex: -1, =>
|
||||
@div class: 'tree-view tool-panel', tabindex: -1, =>
|
||||
if rootView.project.getRootDirectory()
|
||||
@subview 'root', new DirectoryView(directory: rootView.project.getRootDirectory(), isExpanded: true)
|
||||
|
||||
@@ -50,18 +50,19 @@ class TreeView extends ScrollView
|
||||
@on 'click', '.entry', (e) => @entryClicked(e)
|
||||
@command 'core:move-up', => @moveUp()
|
||||
@command 'core:move-down', => @moveDown()
|
||||
@command 'core:close', => @detatch()
|
||||
@command 'tree-view:expand-directory', => @expandDirectory()
|
||||
@command 'tree-view:collapse-directory', => @collapseDirectory()
|
||||
@command 'tree-view:open-selected-entry', => @openSelectedEntry(true)
|
||||
@command 'tree-view:move', => @moveSelectedEntry()
|
||||
@command 'tree-view:add', => @add()
|
||||
@command 'tree-view:remove', => @removeSelectedEntry()
|
||||
@command 'tool-panel:unfocus', => @rootView.focus()
|
||||
@command 'tree-view:directory-modified', =>
|
||||
if @hasFocus()
|
||||
@selectEntryForPath(@selectedPath) if @selectedPath
|
||||
else
|
||||
@selectActiveFile()
|
||||
@on 'tree-view:unfocus', => @rootView.focus()
|
||||
@rootView.command 'tree-view:toggle', => @toggle()
|
||||
@rootView.command 'tree-view:reveal-active-file', => @revealActiveFile()
|
||||
@rootView.on 'active-editor-path-change', => @selectActiveFile()
|
||||
@@ -86,17 +87,20 @@ class TreeView extends ScrollView
|
||||
toggle: ->
|
||||
if @hasFocus()
|
||||
@detach()
|
||||
@rootView.focus()
|
||||
else
|
||||
@attach() unless @hasParent()
|
||||
@focus()
|
||||
if @hasParent()
|
||||
@focus()
|
||||
else
|
||||
@attach()
|
||||
|
||||
attach: ->
|
||||
@rootView.horizontal.prepend(this)
|
||||
@focus()
|
||||
|
||||
detach: ->
|
||||
@scrollTopAfterAttach = @scrollTop()
|
||||
super
|
||||
@rootView.focus()
|
||||
|
||||
hasFocus: ->
|
||||
@is(':focus')
|
||||
|
||||
@@ -14,11 +14,13 @@ class ChildProccess
|
||||
options.stderr = @bufferLines(options.stderr) if options.stderr
|
||||
|
||||
$native.exec command, options, (exitStatus, stdout, stderr) ->
|
||||
options.stdout?(stdout)
|
||||
options.stderr?(stderr)
|
||||
try
|
||||
if exitStatus != 0
|
||||
deferred.reject({command, exitStatus, stderr})
|
||||
deferred.reject({command, exitStatus})
|
||||
else
|
||||
deferred.resolve(stdout, stderr)
|
||||
deferred.resolve()
|
||||
catch e
|
||||
console.error "In ChildProccess termination callback: ", e.message
|
||||
console.error e.stack
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# Like sands through the hourglass, so are the days of our lives.
|
||||
require 'atom'
|
||||
require 'window'
|
||||
window.startup window.location.params.pathToOpen
|
||||
|
||||
window.attachRootView(window.location.params.pathToOpen)
|
||||
|
||||
Reference in New Issue
Block a user