Give editor-specific events the "editor:" prefix

This commit is contained in:
Nathan Sobo
2012-10-04 12:03:33 -10:00
parent 16bf8d3c3f
commit 9906dd41b4
7 changed files with 94 additions and 94 deletions

View File

@@ -157,7 +157,7 @@ describe "Editor", ->
editSession = editor.activeEditSession
spyOn(editSession, 'destroy').andCallThrough()
spyOn(editor, "remove").andCallThrough()
editor.trigger "close"
editor.trigger "core:close"
expect(editSession.destroy).toHaveBeenCalled()
expect(editor.remove).not.toHaveBeenCalled()
expect(editor.getBuffer()).toBe buffer
@@ -167,13 +167,13 @@ describe "Editor", ->
expect(editor.mini).toBeFalsy()
expect(editor.editSessions.length).toBe 1
spyOn(editor, 'remove').andCallThrough()
editor.trigger 'close'
editor.trigger 'core:close'
spyOn(editSession, 'destroy').andCallThrough()
expect(editor.remove).toHaveBeenCalled()
miniEditor = new Editor(mini: true)
spyOn(miniEditor, 'remove').andCallThrough()
miniEditor.trigger 'close'
miniEditor.trigger 'core:close'
expect(miniEditor.remove).not.toHaveBeenCalled()
describe "when buffer is modified", ->
@@ -181,7 +181,7 @@ describe "Editor", ->
spyOn(editor, 'remove').andCallThrough()
spyOn(atom, 'confirm')
editor.insertText("I AM CHANGED!")
editor.trigger "close"
editor.trigger "core:close"
expect(editor.remove).not.toHaveBeenCalled()
expect(atom.confirm).toHaveBeenCalled()
@@ -494,7 +494,7 @@ describe "Editor", ->
expect(editor.getCursorView().position()).toEqual { top: 5 * editor.lineHeight, left: 5 * editor.charWidth }
# ensure we clean up font size subscription
editor.trigger('close')
editor.trigger('core:close')
rootView.setFontSize(22)
expect(editor.css('font-size')).toBe '30px'
@@ -1707,7 +1707,7 @@ describe "Editor", ->
describe "when a fold-selection event is triggered", ->
it "folds the lines covered by the selection into a single line with a fold class", ->
editor.getSelection().setBufferRange(new Range([4, 29], [7, 4]))
editor.trigger 'fold-selection'
editor.trigger 'editor:fold-selection'
expect(editor.renderedLines.find('.line:eq(4)')).toHaveClass('fold')
expect(editor.renderedLines.find('.line:eq(5)').text()).toBe '8'
@@ -1718,7 +1718,7 @@ describe "Editor", ->
describe "when a fold placeholder line is clicked", ->
it "removes the associated fold and places the cursor at its beginning", ->
editor.setCursorBufferPosition([3,0])
editor.trigger 'fold-current-row'
editor.trigger 'editor:fold-current-row'
editor.find('.fold.line').mousedown()
@@ -1731,10 +1731,10 @@ describe "Editor", ->
describe "when the unfold-current-row event is triggered when the cursor is on a fold placeholder line", ->
it "removes the associated fold and places the cursor at its beginning", ->
editor.setCursorBufferPosition([3,0])
editor.trigger 'fold-current-row'
editor.trigger 'editor:fold-current-row'
editor.setCursorBufferPosition([3,0])
editor.trigger 'unfold-current-row'
editor.trigger 'editor:unfold-current-row'
expect(editor.find('.fold')).not.toExist()
expect(editor.renderedLines.find('.line:eq(4)').text()).toMatch /4-+/

View File

@@ -21,7 +21,7 @@ describe 'FuzzyFinder', ->
it "shows the FuzzyFinder or hides it and returns focus to the active editor if it already showing", ->
rootView.attachToDom()
expect(rootView.find('.fuzzy-finder')).not.toExist()
rootView.find('.editor').trigger 'split-right'
rootView.find('.editor').trigger 'editor:split-right'
[editor1, editor2] = rootView.find('.editor').map -> $(this).view()
rootView.trigger 'fuzzy-finder:toggle-file-finder'
@@ -96,7 +96,7 @@ describe 'FuzzyFinder', ->
it "shows the FuzzyFinder or hides it and returns focus to the active editor if it already showing", ->
rootView.attachToDom()
expect(rootView.find('.fuzzy-finder')).not.toExist()
rootView.find('.editor').trigger 'split-right'
rootView.find('.editor').trigger 'editor:split-right'
[editor1, editor2] = rootView.find('.editor').map -> $(this).view()
rootView.trigger 'fuzzy-finder:toggle-buffer-finder'

View File

@@ -113,46 +113,46 @@ class Editor extends View
'core:cut': @cutSelection
'core:copy': @copySelection
'core:paste': @paste
'move-to-next-word': @moveCursorToNextWord
'move-to-previous-word': @moveCursorToPreviousWord
'select-word': @selectWord
'newline': @insertNewline
'indent': @indent
'indent-selected-rows': @indentSelectedRows
'outdent-selected-rows': @outdentSelectedRows
'backspace-to-beginning-of-word': @backspaceToBeginningOfWord
'delete-to-end-of-word': @deleteToEndOfWord
'delete-line': @deleteLine
'cut-to-end-of-line': @cutToEndOfLine
'move-to-beginning-of-line': @moveCursorToBeginningOfLine
'move-to-end-of-line': @moveCursorToEndOfLine
'move-to-first-character-of-line': @moveCursorToFirstCharacterOfLine
'move-to-beginning-of-word': @moveCursorToBeginningOfWord
'move-to-end-of-word': @moveCursorToEndOfWord
'select-to-end-of-line': @selectToEndOfLine
'select-to-beginning-of-line': @selectToBeginningOfLine
'select-to-end-of-word': @selectToEndOfWord
'select-to-beginning-of-word': @selectToBeginningOfWord
'editor:move-to-next-word': @moveCursorToNextWord
'editor:move-to-previous-word': @moveCursorToPreviousWord
'editor:select-word': @selectWord
'editor:newline': @insertNewline
'editor:indent': @indent
'editor:indent-selected-rows': @indentSelectedRows
'editor:outdent-selected-rows': @outdentSelectedRows
'editor:backspace-to-beginning-of-word': @backspaceToBeginningOfWord
'editor:delete-to-end-of-word': @deleteToEndOfWord
'editor:delete-line': @deleteLine
'editor:cut-to-end-of-line': @cutToEndOfLine
'editor:move-to-beginning-of-line': @moveCursorToBeginningOfLine
'editor:move-to-end-of-line': @moveCursorToEndOfLine
'editor:move-to-first-character-of-line': @moveCursorToFirstCharacterOfLine
'editor:move-to-beginning-of-word': @moveCursorToBeginningOfWord
'editor:move-to-end-of-word': @moveCursorToEndOfWord
'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
unless @mini
_.extend editorBindings,
'save': @save
'newline-below': @insertNewlineBelow
'toggle-soft-wrap': @toggleSoftWrap
'fold-all': @foldAll
'unfold-all': @unfoldAll
'fold-current-row': @foldCurrentRow
'unfold-current-row': @unfoldCurrentRow
'fold-selection': @foldSelection
'split-left': @splitLeft
'split-right': @splitRight
'split-up': @splitUp
'split-down': @splitDown
'close': @close
'show-next-buffer': @loadNextEditSession
'show-previous-buffer': @loadPreviousEditSession
'toggle-line-comments': @toggleLineCommentsInSelection
'log-cursor-scope': @logCursorScope
'core:close': @close
'editor:save': @save
'editor:newline-below': @insertNewlineBelow
'editor:toggle-soft-wrap': @toggleSoftWrap
'editor:fold-all': @foldAll
'editor:unfold-all': @unfoldAll
'editor:fold-current-row': @foldCurrentRow
'editor:unfold-current-row': @unfoldCurrentRow
'editor:fold-selection': @foldSelection
'editor:split-left': @splitLeft
'editor:split-right': @splitRight
'editor:split-up': @splitUp
'editor:split-down': @splitDown
'editor:show-next-buffer': @loadNextEditSession
'editor:show-previous-buffer': @loadPreviousEditSession
'editor:toggle-line-comments': @toggleLineCommentsInSelection
'editor:log-cursor-scope': @logCursorScope
for name, method of editorBindings
do (name, method) =>

View File

@@ -5,13 +5,13 @@ window.keymap.bindKeys 'body'
'meta-shift-down': 'core:select-to-bottom'
window.keymap.bindKeys '.editor'
'meta-right': 'move-to-end-of-line'
'meta-left': 'move-to-beginning-of-line'
'alt-left': 'move-to-beginning-of-word'
'alt-right': 'move-to-end-of-word'
'meta-shift-left': 'select-to-beginning-of-line'
'meta-shift-right': 'select-to-end-of-line'
'alt-shift-left': 'select-to-beginning-of-word'
'alt-shift-right': 'select-to-end-of-word'
'alt-backspace': 'backspace-to-beginning-of-word'
'alt-delete': 'delete-to-end-of-word'
'meta-right': 'editor:move-to-end-of-line'
'meta-left': 'editor:move-to-beginning-of-line'
'alt-left': 'editor:move-to-beginning-of-word'
'alt-right': 'editor:move-to-end-of-word'
'meta-shift-left': 'editor:select-to-beginning-of-line'
'meta-shift-right': 'editor:select-to-end-of-line'
'alt-shift-left': 'editor:select-to-beginning-of-word'
'alt-shift-right': 'editor:select-to-end-of-word'
'alt-backspace': 'editor:backspace-to-beginning-of-word'
'alt-delete': 'editor:delete-to-end-of-word'

View File

@@ -1,6 +1,6 @@
window.keymap.bindKeys 'body'
'meta-w': 'close'
'alt-meta-i': 'toggle-dev-tools'
'meta-w': 'core:close'
up: 'core:move-up'
down: 'core:move-down'
left: 'core:move-left'

View File

@@ -1,27 +1,27 @@
window.keymap.bindKeys '.editor',
'meta-s': 'save'
'enter': 'newline'
'meta-enter': 'newline-below'
'tab': 'indent'
'meta-d': 'delete-line'
'alt-meta-w': 'toggle-soft-wrap'
'ctrl-[': 'fold-current-row'
'ctrl-]': 'unfold-current-row'
'ctrl-{': 'fold-all'
'ctrl-}': 'unfold-all'
'alt-meta-ctrl-f': 'fold-selection'
'alt-meta-left': 'split-left'
'alt-meta-right': 'split-right'
'alt-meta-up': 'split-up'
'alt-meta-down': 'split-down'
'shift-tab': 'outdent-selected-rows'
'meta-[': 'outdent-selected-rows'
'meta-]': 'indent-selected-rows'
'meta-{': 'show-previous-buffer'
'meta-}': 'show-next-buffer'
'meta-+': 'increase-font-size'
'meta--': 'decrease-font-size'
'meta-/': 'toggle-line-comments'
'ctrl-w w': 'focus-next-pane'
'ctrl-W': 'select-word'
'meta-alt-p': 'log-cursor-scope'
'meta-s': 'editor:save'
'enter': 'editor:newline'
'meta-enter': 'editor:newline-below'
'tab': 'editor:indent'
'meta-d': 'editor:delete-line'
'alt-meta-w': 'editor:toggle-soft-wrap'
'ctrl-[': 'editor:fold-current-row'
'ctrl-]': 'editor:unfold-current-row'
'ctrl-{': 'editor:fold-all'
'ctrl-}': 'editor:unfold-all'
'alt-meta-ctrl-f': 'editor:fold-selection'
'alt-meta-left': 'editor:split-left'
'alt-meta-right': 'editor:split-right'
'alt-meta-up': 'editor:split-up'
'alt-meta-down': 'editor:split-down'
'shift-tab': 'editor:outdent-selected-rows'
'meta-[': 'editor:outdent-selected-rows'
'meta-]': 'editor:indent-selected-rows'
'meta-{': 'editor:show-previous-buffer'
'meta-}': 'editor:show-next-buffer'
'meta-+': 'editor:increase-font-size'
'meta--': 'editor:decrease-font-size'
'meta-/': 'editor:toggle-line-comments'
'ctrl-w w': 'editor:focus-next-pane'
'ctrl-W': 'editor:select-word'
'meta-alt-p': 'editor:log-cursor-scope'

View File

@@ -11,12 +11,12 @@ window.keymap.bindKeys 'body',
'ctrl-d': 'core:delete'
window.keymap.bindKeys '.editor',
'alt-f': 'move-to-end-of-word'
'alt-F': 'select-to-end-of-word'
'alt-b': 'move-to-beginning-of-word'
'alt-B': 'select-to-beginning-of-word'
'ctrl-a': 'move-to-first-character-of-line'
'ctrl-e': 'move-to-end-of-line'
'alt-h': 'backspace-to-beginning-of-word'
'alt-d': 'delete-to-end-of-word'
'ctrl-k': 'cut-to-end-of-line'
'alt-f': 'editor:move-to-end-of-word'
'alt-F': 'editor:select-to-end-of-word'
'alt-b': 'editor:move-to-beginning-of-word'
'alt-B': 'editor:select-to-beginning-of-word'
'ctrl-a': 'editor:move-to-first-character-of-line'
'ctrl-e': 'editor:move-to-end-of-line'
'alt-h': 'editor:backspace-to-beginning-of-word'
'alt-d': 'editor:delete-to-end-of-word'
'ctrl-k': 'editor:cut-to-end-of-line'