mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-01 03:03:09 +03:00
Make Pane handle split commands instead of Editor
This commit is contained in:
parent
fee835f899
commit
7d147dd2ce
@ -384,29 +384,6 @@ describe "Editor", ->
|
||||
editor.scrollTop(50)
|
||||
expect(editor.scrollTop()).toBe 50
|
||||
|
||||
describe "split methods", ->
|
||||
describe "when inside a pane", ->
|
||||
fakePane = null
|
||||
beforeEach ->
|
||||
fakePane = { splitUp: jasmine.createSpy('splitUp').andReturn({}), remove: -> }
|
||||
spyOn(editor, 'pane').andReturn(fakePane)
|
||||
|
||||
it "calls the corresponding split method on the containing pane with a new editor containing a copy of the active edit session", ->
|
||||
editor.edit project.buildEditSession("sample.txt")
|
||||
editor.splitUp()
|
||||
expect(fakePane.splitUp).toHaveBeenCalled()
|
||||
[newEditor] = fakePane.splitUp.argsForCall[0]
|
||||
expect(newEditor.editSessions.length).toEqual 1
|
||||
expect(newEditor.activeEditSession.buffer).toBe editor.activeEditSession.buffer
|
||||
newEditor.remove()
|
||||
|
||||
describe "when not inside a pane", ->
|
||||
it "does not split the editor, but doesn't throw an exception", ->
|
||||
editor.splitUp()
|
||||
editor.splitDown()
|
||||
editor.splitLeft()
|
||||
editor.splitRight()
|
||||
|
||||
describe "editor:attached event", ->
|
||||
it 'only triggers an editor:attached event when it is first added to the DOM', ->
|
||||
openHandler = jasmine.createSpy('openHandler')
|
||||
|
@ -172,10 +172,6 @@ class Editor extends View
|
||||
'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-buffer-1': => @setActiveEditSessionIndex(0) if @editSessions[0]
|
||||
'editor:show-buffer-2': => @setActiveEditSessionIndex(1) if @editSessions[1]
|
||||
@ -789,20 +785,17 @@ class Editor extends View
|
||||
@updateLayerDimensions()
|
||||
@requestDisplayUpdate()
|
||||
|
||||
newSplitEditor: (editSession) ->
|
||||
new Editor { editSession: editSession ? @activeEditSession.copy() }
|
||||
|
||||
splitLeft: (editSession) ->
|
||||
@pane()?.splitLeft(@newSplitEditor(editSession)).currentItem
|
||||
@pane()?.splitLeft()
|
||||
|
||||
splitRight: (editSession) ->
|
||||
@pane()?.splitRight(@newSplitEditor(editSession)).currentItem
|
||||
@pane()?.splitRight()
|
||||
|
||||
splitUp: (editSession) ->
|
||||
@pane()?.splitUp(@newSplitEditor(editSession)).currentItem
|
||||
@pane()?.splitUp()
|
||||
|
||||
splitDown: (editSession) ->
|
||||
@pane()?.splitDown(@newSplitEditor(editSession)).currentItem
|
||||
@pane()?.splitDown()
|
||||
|
||||
pane: ->
|
||||
@closest('.pane').view()
|
||||
|
@ -30,6 +30,12 @@
|
||||
'ctrl-tab': 'window:focus-next-pane'
|
||||
'ctrl-meta-f': 'window:toggle-full-screen'
|
||||
|
||||
'.pane':
|
||||
'ctrl-|': 'pane:split-right'
|
||||
'ctrl-w v': 'pane:split-right'
|
||||
'ctrl--': 'pane:split-down'
|
||||
'ctrl-w s': 'pane:split-down'
|
||||
|
||||
'.tool-panel':
|
||||
'meta-escape': 'tool-panel:unfocus'
|
||||
'escape': 'core:close'
|
||||
|
@ -15,10 +15,6 @@
|
||||
'ctrl-{': 'editor:fold-all'
|
||||
'ctrl-}': 'editor:unfold-all'
|
||||
'alt-meta-ctrl-f': 'editor:fold-selection'
|
||||
'ctrl-|': 'editor:split-right'
|
||||
'ctrl-w v': 'editor:split-right'
|
||||
'ctrl--': 'editor:split-down'
|
||||
'ctrl-w s': 'editor:split-down'
|
||||
'shift-tab': 'editor:outdent-selected-rows'
|
||||
'meta-[': 'editor:outdent-selected-rows'
|
||||
'meta-]': 'editor:indent-selected-rows'
|
||||
|
@ -22,6 +22,10 @@ class Pane extends View
|
||||
|
||||
@command 'pane:show-next-item', @showNextItem
|
||||
@command 'pane:show-previous-item', @showPreviousItem
|
||||
@command 'pane:split-left', => @splitLeft()
|
||||
@command 'pane:split-right', => @splitRight()
|
||||
@command 'pane:split-up', => @splitUp()
|
||||
@command 'pane:split-down', => @splitDown()
|
||||
@on 'focus', => @viewForCurrentItem().focus()
|
||||
|
||||
getItems: ->
|
||||
|
Loading…
Reference in New Issue
Block a user