diff --git a/src/atom.coffee b/src/atom.coffee index 53a76d440..8f01d2122 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -204,6 +204,45 @@ class Atom extends Model GrammarRegistry = require './grammar-registry' @grammars = new GrammarRegistry({@config}) + @registerDeserializersAndViewProviders() + + registerDefaultCommands = require './register-default-commands' + registerDefaultCommands(@commands) + + registerDeserializersAndViewProviders: -> + Workspace = require './workspace' + PaneContainer = require './pane-container' + PaneAxis = require './pane-axis' + Pane = require './pane' + Project = require './project' + TextEditor = require './text-editor' + TextBuffer = require 'text-buffer' + + @deserializers.add(Workspace) + @deserializers.add(PaneContainer) + @deserializers.add(PaneAxis) + @deserializers.add(Pane) + @deserializers.add(Project) + @deserializers.add(TextEditor) + @deserializers.add(TextBuffer) + + Gutter = require './gutter' + PaneElement = require './pane-element' + PaneContainerElement = require './pane-container-element' + PaneAxisElement = require './pane-axis-element' + TextEditorElement = require './text-editor-element' + {createGutterView} = require './gutter-component-helpers' + + @views.addViewProvider PaneContainer, (model) -> + new PaneContainerElement().initialize(model) + @views.addViewProvider PaneAxis, (model) -> + new PaneAxisElement().initialize(model) + @views.addViewProvider Pane, (model) -> + new PaneElement().initialize(model) + @views.addViewProvider TextEditor, (model) -> + new TextEditorElement().initialize(model) + @views.addViewProvider(Gutter, createGutterView) + reset: -> @config.reset() @@ -254,47 +293,14 @@ class Atom extends Model @keymaps.subscribeToFileReadFailure() - @registerViewProviders() document.head.appendChild(new StylesElement) if grammarOverridesByPath = @state.grammars?.grammarOverridesByPath @grammars.grammarOverridesByPath = grammarOverridesByPath @disposables.add @packages.onDidActivateInitialPackages => @watchThemes() - - Project = require './project' - TextBuffer = require 'text-buffer' - @deserializers.add(TextBuffer) - TokenizedBuffer = require './tokenized-buffer' - DisplayBuffer = require './display-buffer' - TextEditor = require './text-editor' - @windowEventHandler = new WindowEventHandler - # Register the core views as early as possible in case they are needed for - # package deserialization. - registerViewProviders: -> - Gutter = require './gutter' - Pane = require './pane' - PaneElement = require './pane-element' - PaneContainer = require './pane-container' - PaneContainerElement = require './pane-container-element' - PaneAxis = require './pane-axis' - PaneAxisElement = require './pane-axis-element' - TextEditor = require './text-editor' - TextEditorElement = require './text-editor-element' - {createGutterView} = require './gutter-component-helpers' - - atom.views.addViewProvider PaneContainer, (model) -> - new PaneContainerElement().initialize(model) - atom.views.addViewProvider PaneAxis, (model) -> - new PaneAxisElement().initialize(model) - atom.views.addViewProvider Pane, (model) -> - new PaneElement().initialize(model) - atom.views.addViewProvider TextEditor, (model) -> - new TextEditorElement().initialize(model) - atom.views.addViewProvider(Gutter, createGutterView) - ### Section: Event Subscription ### diff --git a/src/pane-axis.coffee b/src/pane-axis.coffee index 57d07d8a9..3bb4e285e 100644 --- a/src/pane-axis.coffee +++ b/src/pane-axis.coffee @@ -4,8 +4,6 @@ Model = require './model' module.exports = class PaneAxis extends Model - atom.deserializers.add(this) - parent: null container: null orientation: null diff --git a/src/pane-container.coffee b/src/pane-container.coffee index 786c4b84f..18f6166c0 100644 --- a/src/pane-container.coffee +++ b/src/pane-container.coffee @@ -7,8 +7,6 @@ ItemRegistry = require './item-registry' module.exports = class PaneContainer extends Model - atom.deserializers.add(this) - @version: 1 root: null diff --git a/src/pane-element.coffee b/src/pane-element.coffee index c6ded79c4..41f110ddb 100644 --- a/src/pane-element.coffee +++ b/src/pane-element.coffee @@ -123,30 +123,4 @@ class PaneElement extends HTMLElement hasFocus: -> this is document.activeElement or @contains(document.activeElement) -atom.commands.add 'atom-workspace', - 'pane:show-next-item': -> @getModel().getActivePane().activateNextItem() - 'pane:show-previous-item': -> @getModel().getActivePane().activatePreviousItem() - 'pane:show-item-1': -> @getModel().getActivePane().activateItemAtIndex(0) - 'pane:show-item-2': -> @getModel().getActivePane().activateItemAtIndex(1) - 'pane:show-item-3': -> @getModel().getActivePane().activateItemAtIndex(2) - 'pane:show-item-4': -> @getModel().getActivePane().activateItemAtIndex(3) - 'pane:show-item-5': -> @getModel().getActivePane().activateItemAtIndex(4) - 'pane:show-item-6': -> @getModel().getActivePane().activateItemAtIndex(5) - 'pane:show-item-7': -> @getModel().getActivePane().activateItemAtIndex(6) - 'pane:show-item-8': -> @getModel().getActivePane().activateItemAtIndex(7) - 'pane:show-item-9': -> @getModel().getActivePane().activateItemAtIndex(8) - 'pane:move-item-right': -> @getModel().getActivePane().moveItemRight() - 'pane:move-item-left': -> @getModel().getActivePane().moveItemLeft() - -atom.commands.add 'atom-pane', - 'pane:save-items': -> @getModel().saveItems() - 'pane:split-left': -> @getModel().splitLeft(copyActiveItem: true) - 'pane:split-right': -> @getModel().splitRight(copyActiveItem: true) - 'pane:split-up': -> @getModel().splitUp(copyActiveItem: true) - 'pane:split-down': -> @getModel().splitDown(copyActiveItem: true) - 'pane:close': -> @getModel().close() - 'pane:close-other-items': -> @getModel().destroyInactiveItems() - 'pane:increase-size': -> @getModel().increaseSize() - 'pane:decrease-size': -> @getModel().decreaseSize() - module.exports = PaneElement = document.registerElement 'atom-pane', prototype: PaneElement.prototype diff --git a/src/pane.coffee b/src/pane.coffee index a146b66fc..45577dab7 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -10,8 +10,6 @@ TextEditor = require './text-editor' # the default configuration, tabs are also displayed for each item. module.exports = class Pane extends Model - atom.deserializers.add(this) - container: undefined activeItem: undefined focused: false diff --git a/src/project.coffee b/src/project.coffee index b3f05a942..faead038e 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -17,8 +17,6 @@ GitRepositoryProvider = require './git-repository-provider' # An instance of this class is always available as the `atom.project` global. module.exports = class Project extends Model - atom.deserializers.add(this) - ### Section: Construction and Destruction ### diff --git a/src/register-default-commands.coffee b/src/register-default-commands.coffee new file mode 100644 index 000000000..c43fd5bb7 --- /dev/null +++ b/src/register-default-commands.coffee @@ -0,0 +1,210 @@ +module.exports = (commandRegistry) -> + commandRegistry.add 'atom-workspace', + 'pane:show-next-item': -> @getModel().getActivePane().activateNextItem() + 'pane:show-previous-item': -> @getModel().getActivePane().activatePreviousItem() + 'pane:show-item-1': -> @getModel().getActivePane().activateItemAtIndex(0) + 'pane:show-item-2': -> @getModel().getActivePane().activateItemAtIndex(1) + 'pane:show-item-3': -> @getModel().getActivePane().activateItemAtIndex(2) + 'pane:show-item-4': -> @getModel().getActivePane().activateItemAtIndex(3) + 'pane:show-item-5': -> @getModel().getActivePane().activateItemAtIndex(4) + 'pane:show-item-6': -> @getModel().getActivePane().activateItemAtIndex(5) + 'pane:show-item-7': -> @getModel().getActivePane().activateItemAtIndex(6) + 'pane:show-item-8': -> @getModel().getActivePane().activateItemAtIndex(7) + 'pane:show-item-9': -> @getModel().getActivePane().activateItemAtIndex(8) + 'pane:move-item-right': -> @getModel().getActivePane().moveItemRight() + 'pane:move-item-left': -> @getModel().getActivePane().moveItemLeft() + 'window:increase-font-size': -> @getModel().increaseFontSize() + 'window:decrease-font-size': -> @getModel().decreaseFontSize() + 'window:reset-font-size': -> @getModel().resetFontSize() + 'application:about': -> ipc.send('command', 'application:about') + 'application:run-all-specs': -> ipc.send('command', 'application:run-all-specs') + 'application:show-preferences': -> ipc.send('command', 'application:show-settings') + 'application:show-settings': -> ipc.send('command', 'application:show-settings') + 'application:quit': -> ipc.send('command', 'application:quit') + 'application:hide': -> ipc.send('command', 'application:hide') + 'application:hide-other-applications': -> ipc.send('command', 'application:hide-other-applications') + 'application:install-update': -> ipc.send('command', 'application:install-update') + 'application:unhide-all-applications': -> ipc.send('command', 'application:unhide-all-applications') + 'application:new-window': -> ipc.send('command', 'application:new-window') + 'application:new-file': -> ipc.send('command', 'application:new-file') + 'application:open': -> ipc.send('command', 'application:open') + 'application:open-file': -> ipc.send('command', 'application:open-file') + 'application:open-folder': -> ipc.send('command', 'application:open-folder') + 'application:open-dev': -> ipc.send('command', 'application:open-dev') + 'application:open-safe': -> ipc.send('command', 'application:open-safe') + 'application:add-project-folder': -> atom.addProjectFolder() + 'application:minimize': -> ipc.send('command', 'application:minimize') + 'application:zoom': -> ipc.send('command', 'application:zoom') + 'application:bring-all-windows-to-front': -> ipc.send('command', 'application:bring-all-windows-to-front') + 'application:open-your-config': -> ipc.send('command', 'application:open-your-config') + 'application:open-your-init-script': -> ipc.send('command', 'application:open-your-init-script') + 'application:open-your-keymap': -> ipc.send('command', 'application:open-your-keymap') + 'application:open-your-snippets': -> ipc.send('command', 'application:open-your-snippets') + 'application:open-your-stylesheet': -> ipc.send('command', 'application:open-your-stylesheet') + 'application:open-license': -> @getModel().openLicense() + 'window:run-package-specs': -> @runPackageSpecs() + 'window:focus-next-pane': -> @getModel().activateNextPane() + 'window:focus-previous-pane': -> @getModel().activatePreviousPane() + 'window:focus-pane-above': -> @focusPaneViewAbove() + 'window:focus-pane-below': -> @focusPaneViewBelow() + 'window:focus-pane-on-left': -> @focusPaneViewOnLeft() + 'window:focus-pane-on-right': -> @focusPaneViewOnRight() + 'window:save-all': -> @getModel().saveAll() + 'window:toggle-invisibles': -> atom.config.set("editor.showInvisibles", not atom.config.get("editor.showInvisibles")) + 'window:log-deprecation-warnings': -> Grim.logDeprecations() + 'window:toggle-auto-indent': -> atom.config.set("editor.autoIndent", not atom.config.get("editor.autoIndent")) + 'pane:reopen-closed-item': -> @getModel().reopenItem() + 'core:close': -> @getModel().destroyActivePaneItemOrEmptyPane() + 'core:save': -> @getModel().saveActivePaneItem() + 'core:save-as': -> @getModel().saveActivePaneItemAs() + + if process.platform is 'darwin' + commandRegistry.add 'atom-workspace', 'window:install-shell-commands', -> @getModel().installShellCommands() + + commandRegistry.add 'atom-pane', + 'pane:save-items': -> @getModel().saveItems() + 'pane:split-left': -> @getModel().splitLeft(copyActiveItem: true) + 'pane:split-right': -> @getModel().splitRight(copyActiveItem: true) + 'pane:split-up': -> @getModel().splitUp(copyActiveItem: true) + 'pane:split-down': -> @getModel().splitDown(copyActiveItem: true) + 'pane:close': -> @getModel().close() + 'pane:close-other-items': -> @getModel().destroyInactiveItems() + 'pane:increase-size': -> @getModel().increaseSize() + 'pane:decrease-size': -> @getModel().decreaseSize() + + commandRegistry.add 'atom-text-editor', stopEventPropagation( + 'core:undo': -> @undo() + 'core:redo': -> @redo() + 'core:move-left': -> @moveLeft() + 'core:move-right': -> @moveRight() + 'core:select-left': -> @selectLeft() + 'core:select-right': -> @selectRight() + 'core:select-up': -> @selectUp() + 'core:select-down': -> @selectDown() + 'core:select-all': -> @selectAll() + 'editor:select-word': -> @selectWordsContainingCursors() + 'editor:consolidate-selections': (event) -> event.abortKeyBinding() unless @consolidateSelections() + 'editor:move-to-beginning-of-next-paragraph': -> @moveToBeginningOfNextParagraph() + 'editor:move-to-beginning-of-previous-paragraph': -> @moveToBeginningOfPreviousParagraph() + 'editor:move-to-beginning-of-screen-line': -> @moveToBeginningOfScreenLine() + 'editor:move-to-beginning-of-line': -> @moveToBeginningOfLine() + 'editor:move-to-end-of-screen-line': -> @moveToEndOfScreenLine() + 'editor:move-to-end-of-line': -> @moveToEndOfLine() + 'editor:move-to-first-character-of-line': -> @moveToFirstCharacterOfLine() + 'editor:move-to-beginning-of-word': -> @moveToBeginningOfWord() + 'editor:move-to-end-of-word': -> @moveToEndOfWord() + 'editor:move-to-beginning-of-next-word': -> @moveToBeginningOfNextWord() + 'editor:move-to-previous-word-boundary': -> @moveToPreviousWordBoundary() + 'editor:move-to-next-word-boundary': -> @moveToNextWordBoundary() + 'editor:move-to-previous-subword-boundary': -> @moveToPreviousSubwordBoundary() + 'editor:move-to-next-subword-boundary': -> @moveToNextSubwordBoundary() + 'editor:select-to-beginning-of-next-paragraph': -> @selectToBeginningOfNextParagraph() + 'editor:select-to-beginning-of-previous-paragraph': -> @selectToBeginningOfPreviousParagraph() + 'editor:select-to-end-of-line': -> @selectToEndOfLine() + 'editor:select-to-beginning-of-line': -> @selectToBeginningOfLine() + 'editor:select-to-end-of-word': -> @selectToEndOfWord() + 'editor:select-to-beginning-of-word': -> @selectToBeginningOfWord() + 'editor:select-to-beginning-of-next-word': -> @selectToBeginningOfNextWord() + 'editor:select-to-next-word-boundary': -> @selectToNextWordBoundary() + 'editor:select-to-previous-word-boundary': -> @selectToPreviousWordBoundary() + 'editor:select-to-next-subword-boundary': -> @selectToNextSubwordBoundary() + 'editor:select-to-previous-subword-boundary': -> @selectToPreviousSubwordBoundary() + 'editor:select-to-first-character-of-line': -> @selectToFirstCharacterOfLine() + 'editor:select-line': -> @selectLinesContainingCursors() + ) + + commandRegistry.add 'atom-text-editor', stopEventPropagationAndGroupUndo( + 'core:backspace': -> @backspace() + 'core:delete': -> @delete() + 'core:cut': -> @cutSelectedText() + 'core:copy': -> @copySelectedText() + 'core:paste': -> @pasteText() + 'editor:delete-to-previous-word-boundary': -> @deleteToPreviousWordBoundary() + 'editor:delete-to-next-word-boundary': -> @deleteToNextWordBoundary() + 'editor:delete-to-beginning-of-word': -> @deleteToBeginningOfWord() + 'editor:delete-to-beginning-of-line': -> @deleteToBeginningOfLine() + 'editor:delete-to-end-of-line': -> @deleteToEndOfLine() + 'editor:delete-to-end-of-word': -> @deleteToEndOfWord() + 'editor:delete-to-beginning-of-subword': -> @deleteToBeginningOfSubword() + 'editor:delete-to-end-of-subword': -> @deleteToEndOfSubword() + 'editor:delete-line': -> @deleteLine() + 'editor:cut-to-end-of-line': -> @cutToEndOfLine() + 'editor:cut-to-end-of-buffer-line': -> @cutToEndOfBufferLine() + 'editor:transpose': -> @transpose() + 'editor:upper-case': -> @upperCase() + 'editor:lower-case': -> @lowerCase() + 'editor:copy-selection': -> @copyOnlySelectedText() + ) + + commandRegistry.add 'atom-text-editor:not([mini])', stopEventPropagation( + 'core:move-up': -> @moveUp() + 'core:move-down': -> @moveDown() + 'core:move-to-top': -> @moveToTop() + 'core:move-to-bottom': -> @moveToBottom() + 'core:page-up': -> @pageUp() + 'core:page-down': -> @pageDown() + 'core:select-to-top': -> @selectToTop() + 'core:select-to-bottom': -> @selectToBottom() + 'core:select-page-up': -> @selectPageUp() + 'core:select-page-down': -> @selectPageDown() + 'editor:add-selection-below': -> @addSelectionBelow() + 'editor:add-selection-above': -> @addSelectionAbove() + 'editor:split-selections-into-lines': -> @splitSelectionsIntoLines() + 'editor:toggle-soft-tabs': -> @toggleSoftTabs() + 'editor:toggle-soft-wrap': -> @toggleSoftWrapped() + 'editor:fold-all': -> @foldAll() + 'editor:unfold-all': -> @unfoldAll() + 'editor:fold-current-row': -> @foldCurrentRow() + 'editor:unfold-current-row': -> @unfoldCurrentRow() + 'editor:fold-selection': -> @foldSelectedLines() + 'editor:fold-at-indent-level-1': -> @foldAllAtIndentLevel(0) + 'editor:fold-at-indent-level-2': -> @foldAllAtIndentLevel(1) + 'editor:fold-at-indent-level-3': -> @foldAllAtIndentLevel(2) + 'editor:fold-at-indent-level-4': -> @foldAllAtIndentLevel(3) + 'editor:fold-at-indent-level-5': -> @foldAllAtIndentLevel(4) + 'editor:fold-at-indent-level-6': -> @foldAllAtIndentLevel(5) + 'editor:fold-at-indent-level-7': -> @foldAllAtIndentLevel(6) + 'editor:fold-at-indent-level-8': -> @foldAllAtIndentLevel(7) + 'editor:fold-at-indent-level-9': -> @foldAllAtIndentLevel(8) + 'editor:log-cursor-scope': -> @logCursorScope() + 'editor:copy-path': -> @copyPathToClipboard() + 'editor:toggle-indent-guide': -> atom.config.set('editor.showIndentGuide', not atom.config.get('editor.showIndentGuide')) + 'editor:toggle-line-numbers': -> atom.config.set('editor.showLineNumbers', not atom.config.get('editor.showLineNumbers')) + 'editor:scroll-to-cursor': -> @scrollToCursorPosition() + ) + + commandRegistry.add 'atom-text-editor:not([mini])', stopEventPropagationAndGroupUndo( + 'editor:indent': -> @indent() + 'editor:auto-indent': -> @autoIndentSelectedRows() + 'editor:indent-selected-rows': -> @indentSelectedRows() + 'editor:outdent-selected-rows': -> @outdentSelectedRows() + 'editor:newline': -> @insertNewline() + 'editor:newline-below': -> @insertNewlineBelow() + 'editor:newline-above': -> @insertNewlineAbove() + 'editor:toggle-line-comments': -> @toggleLineCommentsInSelection() + 'editor:checkout-head-revision': -> @checkoutHeadRevision() + 'editor:move-line-up': -> @moveLineUp() + 'editor:move-line-down': -> @moveLineDown() + 'editor:duplicate-lines': -> @duplicateLines() + 'editor:join-lines': -> @joinLines() + ) + +stopEventPropagation = (commandListeners) -> + newCommandListeners = {} + for commandName, commandListener of commandListeners + do (commandListener) -> + newCommandListeners[commandName] = (event) -> + event.stopPropagation() + commandListener.call(@getModel(), event) + newCommandListeners + +stopEventPropagationAndGroupUndo = (commandListeners) -> + newCommandListeners = {} + for commandName, commandListener of commandListeners + do (commandListener) -> + newCommandListeners[commandName] = (event) -> + event.stopPropagation() + model = @getModel() + model.transact atom.config.get('editor.undoGroupingInterval'), -> + commandListener.call(model, event) + newCommandListeners diff --git a/src/text-editor-element.coffee b/src/text-editor-element.coffee index 405cf30e4..5f87bb6ff 100644 --- a/src/text-editor-element.coffee +++ b/src/text-editor-element.coffee @@ -313,141 +313,4 @@ class TextEditorElement extends HTMLElement getHeight: -> @offsetHeight -stopEventPropagation = (commandListeners) -> - newCommandListeners = {} - for commandName, commandListener of commandListeners - do (commandListener) -> - newCommandListeners[commandName] = (event) -> - event.stopPropagation() - commandListener.call(@getModel(), event) - newCommandListeners - -stopEventPropagationAndGroupUndo = (commandListeners) -> - newCommandListeners = {} - for commandName, commandListener of commandListeners - do (commandListener) -> - newCommandListeners[commandName] = (event) -> - event.stopPropagation() - model = @getModel() - model.transact atom.config.get('editor.undoGroupingInterval'), -> - commandListener.call(model, event) - newCommandListeners - -atom.commands.add 'atom-text-editor', stopEventPropagation( - 'core:undo': -> @undo() - 'core:redo': -> @redo() - 'core:move-left': -> @moveLeft() - 'core:move-right': -> @moveRight() - 'core:select-left': -> @selectLeft() - 'core:select-right': -> @selectRight() - 'core:select-up': -> @selectUp() - 'core:select-down': -> @selectDown() - 'core:select-all': -> @selectAll() - 'editor:select-word': -> @selectWordsContainingCursors() - 'editor:consolidate-selections': (event) -> event.abortKeyBinding() unless @consolidateSelections() - 'editor:move-to-beginning-of-next-paragraph': -> @moveToBeginningOfNextParagraph() - 'editor:move-to-beginning-of-previous-paragraph': -> @moveToBeginningOfPreviousParagraph() - 'editor:move-to-beginning-of-screen-line': -> @moveToBeginningOfScreenLine() - 'editor:move-to-beginning-of-line': -> @moveToBeginningOfLine() - 'editor:move-to-end-of-screen-line': -> @moveToEndOfScreenLine() - 'editor:move-to-end-of-line': -> @moveToEndOfLine() - 'editor:move-to-first-character-of-line': -> @moveToFirstCharacterOfLine() - 'editor:move-to-beginning-of-word': -> @moveToBeginningOfWord() - 'editor:move-to-end-of-word': -> @moveToEndOfWord() - 'editor:move-to-beginning-of-next-word': -> @moveToBeginningOfNextWord() - 'editor:move-to-previous-word-boundary': -> @moveToPreviousWordBoundary() - 'editor:move-to-next-word-boundary': -> @moveToNextWordBoundary() - 'editor:move-to-previous-subword-boundary': -> @moveToPreviousSubwordBoundary() - 'editor:move-to-next-subword-boundary': -> @moveToNextSubwordBoundary() - 'editor:select-to-beginning-of-next-paragraph': -> @selectToBeginningOfNextParagraph() - 'editor:select-to-beginning-of-previous-paragraph': -> @selectToBeginningOfPreviousParagraph() - 'editor:select-to-end-of-line': -> @selectToEndOfLine() - 'editor:select-to-beginning-of-line': -> @selectToBeginningOfLine() - 'editor:select-to-end-of-word': -> @selectToEndOfWord() - 'editor:select-to-beginning-of-word': -> @selectToBeginningOfWord() - 'editor:select-to-beginning-of-next-word': -> @selectToBeginningOfNextWord() - 'editor:select-to-next-word-boundary': -> @selectToNextWordBoundary() - 'editor:select-to-previous-word-boundary': -> @selectToPreviousWordBoundary() - 'editor:select-to-next-subword-boundary': -> @selectToNextSubwordBoundary() - 'editor:select-to-previous-subword-boundary': -> @selectToPreviousSubwordBoundary() - 'editor:select-to-first-character-of-line': -> @selectToFirstCharacterOfLine() - 'editor:select-line': -> @selectLinesContainingCursors() -) - -atom.commands.add 'atom-text-editor', stopEventPropagationAndGroupUndo( - 'core:backspace': -> @backspace() - 'core:delete': -> @delete() - 'core:cut': -> @cutSelectedText() - 'core:copy': -> @copySelectedText() - 'core:paste': -> @pasteText() - 'editor:delete-to-previous-word-boundary': -> @deleteToPreviousWordBoundary() - 'editor:delete-to-next-word-boundary': -> @deleteToNextWordBoundary() - 'editor:delete-to-beginning-of-word': -> @deleteToBeginningOfWord() - 'editor:delete-to-beginning-of-line': -> @deleteToBeginningOfLine() - 'editor:delete-to-end-of-line': -> @deleteToEndOfLine() - 'editor:delete-to-end-of-word': -> @deleteToEndOfWord() - 'editor:delete-to-beginning-of-subword': -> @deleteToBeginningOfSubword() - 'editor:delete-to-end-of-subword': -> @deleteToEndOfSubword() - 'editor:delete-line': -> @deleteLine() - 'editor:cut-to-end-of-line': -> @cutToEndOfLine() - 'editor:cut-to-end-of-buffer-line': -> @cutToEndOfBufferLine() - 'editor:transpose': -> @transpose() - 'editor:upper-case': -> @upperCase() - 'editor:lower-case': -> @lowerCase() - 'editor:copy-selection': -> @copyOnlySelectedText() -) - -atom.commands.add 'atom-text-editor:not([mini])', stopEventPropagation( - 'core:move-up': -> @moveUp() - 'core:move-down': -> @moveDown() - 'core:move-to-top': -> @moveToTop() - 'core:move-to-bottom': -> @moveToBottom() - 'core:page-up': -> @pageUp() - 'core:page-down': -> @pageDown() - 'core:select-to-top': -> @selectToTop() - 'core:select-to-bottom': -> @selectToBottom() - 'core:select-page-up': -> @selectPageUp() - 'core:select-page-down': -> @selectPageDown() - 'editor:add-selection-below': -> @addSelectionBelow() - 'editor:add-selection-above': -> @addSelectionAbove() - 'editor:split-selections-into-lines': -> @splitSelectionsIntoLines() - 'editor:toggle-soft-tabs': -> @toggleSoftTabs() - 'editor:toggle-soft-wrap': -> @toggleSoftWrapped() - 'editor:fold-all': -> @foldAll() - 'editor:unfold-all': -> @unfoldAll() - 'editor:fold-current-row': -> @foldCurrentRow() - 'editor:unfold-current-row': -> @unfoldCurrentRow() - 'editor:fold-selection': -> @foldSelectedLines() - 'editor:fold-at-indent-level-1': -> @foldAllAtIndentLevel(0) - 'editor:fold-at-indent-level-2': -> @foldAllAtIndentLevel(1) - 'editor:fold-at-indent-level-3': -> @foldAllAtIndentLevel(2) - 'editor:fold-at-indent-level-4': -> @foldAllAtIndentLevel(3) - 'editor:fold-at-indent-level-5': -> @foldAllAtIndentLevel(4) - 'editor:fold-at-indent-level-6': -> @foldAllAtIndentLevel(5) - 'editor:fold-at-indent-level-7': -> @foldAllAtIndentLevel(6) - 'editor:fold-at-indent-level-8': -> @foldAllAtIndentLevel(7) - 'editor:fold-at-indent-level-9': -> @foldAllAtIndentLevel(8) - 'editor:log-cursor-scope': -> @logCursorScope() - 'editor:copy-path': -> @copyPathToClipboard() - 'editor:toggle-indent-guide': -> atom.config.set('editor.showIndentGuide', not atom.config.get('editor.showIndentGuide')) - 'editor:toggle-line-numbers': -> atom.config.set('editor.showLineNumbers', not atom.config.get('editor.showLineNumbers')) - 'editor:scroll-to-cursor': -> @scrollToCursorPosition() -) - -atom.commands.add 'atom-text-editor:not([mini])', stopEventPropagationAndGroupUndo( - 'editor:indent': -> @indent() - 'editor:auto-indent': -> @autoIndentSelectedRows() - 'editor:indent-selected-rows': -> @indentSelectedRows() - 'editor:outdent-selected-rows': -> @outdentSelectedRows() - 'editor:newline': -> @insertNewline() - 'editor:newline-below': -> @insertNewlineBelow() - 'editor:newline-above': -> @insertNewlineAbove() - 'editor:toggle-line-comments': -> @toggleLineCommentsInSelection() - 'editor:checkout-head-revision': -> @checkoutHeadRevision() - 'editor:move-line-up': -> @moveLineUp() - 'editor:move-line-down': -> @moveLineDown() - 'editor:duplicate-lines': -> @duplicateLines() - 'editor:join-lines': -> @joinLines() -) - module.exports = TextEditorElement = document.registerElement 'atom-text-editor', prototype: TextEditorElement.prototype diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 1e9b6d993..e6719565c 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -54,8 +54,6 @@ GutterContainer = require './gutter-container' # soft wraps and folds to ensure your code interacts with them correctly. module.exports = class TextEditor extends Model - atom.deserializers.add(this) - callDisplayBufferCreatedHook: false registerEditor: false buffer: null diff --git a/src/workspace-element.coffee b/src/workspace-element.coffee index 378969481..c8ad1fe0d 100644 --- a/src/workspace-element.coffee +++ b/src/workspace-element.coffee @@ -102,53 +102,4 @@ class WorkspaceElement extends HTMLElement [projectPath] = atom.project.getPaths() ipc.send('run-package-specs', path.join(projectPath, 'spec')) if projectPath -atom.commands.add 'atom-workspace', - 'window:increase-font-size': -> @getModel().increaseFontSize() - 'window:decrease-font-size': -> @getModel().decreaseFontSize() - 'window:reset-font-size': -> @getModel().resetFontSize() - 'application:about': -> ipc.send('command', 'application:about') - 'application:run-all-specs': -> ipc.send('command', 'application:run-all-specs') - 'application:show-preferences': -> ipc.send('command', 'application:show-settings') - 'application:show-settings': -> ipc.send('command', 'application:show-settings') - 'application:quit': -> ipc.send('command', 'application:quit') - 'application:hide': -> ipc.send('command', 'application:hide') - 'application:hide-other-applications': -> ipc.send('command', 'application:hide-other-applications') - 'application:install-update': -> ipc.send('command', 'application:install-update') - 'application:unhide-all-applications': -> ipc.send('command', 'application:unhide-all-applications') - 'application:new-window': -> ipc.send('command', 'application:new-window') - 'application:new-file': -> ipc.send('command', 'application:new-file') - 'application:open': -> ipc.send('command', 'application:open') - 'application:open-file': -> ipc.send('command', 'application:open-file') - 'application:open-folder': -> ipc.send('command', 'application:open-folder') - 'application:open-dev': -> ipc.send('command', 'application:open-dev') - 'application:open-safe': -> ipc.send('command', 'application:open-safe') - 'application:add-project-folder': -> atom.addProjectFolder() - 'application:minimize': -> ipc.send('command', 'application:minimize') - 'application:zoom': -> ipc.send('command', 'application:zoom') - 'application:bring-all-windows-to-front': -> ipc.send('command', 'application:bring-all-windows-to-front') - 'application:open-your-config': -> ipc.send('command', 'application:open-your-config') - 'application:open-your-init-script': -> ipc.send('command', 'application:open-your-init-script') - 'application:open-your-keymap': -> ipc.send('command', 'application:open-your-keymap') - 'application:open-your-snippets': -> ipc.send('command', 'application:open-your-snippets') - 'application:open-your-stylesheet': -> ipc.send('command', 'application:open-your-stylesheet') - 'application:open-license': -> @getModel().openLicense() - 'window:run-package-specs': -> @runPackageSpecs() - 'window:focus-next-pane': -> @getModel().activateNextPane() - 'window:focus-previous-pane': -> @getModel().activatePreviousPane() - 'window:focus-pane-above': -> @focusPaneViewAbove() - 'window:focus-pane-below': -> @focusPaneViewBelow() - 'window:focus-pane-on-left': -> @focusPaneViewOnLeft() - 'window:focus-pane-on-right': -> @focusPaneViewOnRight() - 'window:save-all': -> @getModel().saveAll() - 'window:toggle-invisibles': -> atom.config.set("editor.showInvisibles", not atom.config.get("editor.showInvisibles")) - 'window:log-deprecation-warnings': -> Grim.logDeprecations() - 'window:toggle-auto-indent': -> atom.config.set("editor.autoIndent", not atom.config.get("editor.autoIndent")) - 'pane:reopen-closed-item': -> @getModel().reopenItem() - 'core:close': -> @getModel().destroyActivePaneItemOrEmptyPane() - 'core:save': -> @getModel().saveActivePaneItem() - 'core:save-as': -> @getModel().saveActivePaneItemAs() - -if process.platform is 'darwin' - atom.commands.add 'atom-workspace', 'window:install-shell-commands', -> @getModel().installShellCommands() - module.exports = WorkspaceElement = document.registerElement 'atom-workspace', prototype: WorkspaceElement.prototype diff --git a/src/workspace.coffee b/src/workspace.coffee index bda6e9b45..c8bbdc0c8 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -26,8 +26,6 @@ Task = require './task' # module.exports = class Workspace extends Model - atom.deserializers.add(this) - @deserialize: (state) -> return unless state?