Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.

Commit 4aba8f6

Browse files
committed
move window operations
1 parent c40cf4f commit 4aba8f6

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

keymaps/vim-mode.cson

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
'ctrl-w c': 'pane:close'
106106
'ctrl-w ctrl-q': 'core:close'
107107
'ctrl-w q': 'core:close'
108+
'ctrl-w H': 'vim-mode:move-pane-view-to-far-left'
109+
'ctrl-w L': 'vim-mode:move-pane-view-to-far-right'
110+
'ctrl-w K': 'vim-mode:move-pane-view-to-very-top'
111+
'ctrl-w J': 'vim-mode:move-pane-view-to-very-bottom'
108112
'g t': 'pane:show-next-item'
109113
'g T': 'pane:show-previous-item'
110114

lib/panes.coffee

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,41 @@ class FocusPreviousPaneView extends FocusAction
3434
atom.workspace.activatePreviousPane()
3535
@focusCursor()
3636

37+
class MovePane
38+
isComplete: -> true
39+
isRecordable: -> false
40+
constructor: (@orientation, @pos) ->
41+
42+
execute: ->
43+
rootContainer = atom.workspace.paneContainer
44+
activePane = atom.workspace.getActivePane()
45+
# nothing to do if there's only one pane
46+
return if activePane.parent is rootContainer
47+
48+
# hack: PaneAxis is not in Atom API
49+
PaneAxis = activePane.parent.constructor
50+
51+
activePane.parent.removeChild activePane
52+
53+
rootPane = rootContainer.root
54+
if rootPane.orientation isnt @orientation
55+
newPane = new PaneAxis
56+
container: rootContainer
57+
orientation: @orientation
58+
children: [rootPane]
59+
rootContainer.replaceChild(rootPane, newPane)
60+
rootPane = newPane
61+
62+
rootPane.addChild activePane, switch @pos
63+
when 'begin' then 0
64+
when 'end' then null
65+
66+
activePane.activate()
67+
activePane.getActiveItem()?.scrollToCursorPosition()
68+
69+
70+
3771
module.exports = { FocusPaneViewOnLeft, FocusPaneViewOnRight,
38-
FocusPaneViewAbove, FocusPaneViewBelow, FocusPreviousPaneView }
72+
FocusPaneViewAbove, FocusPaneViewBelow,
73+
FocusPreviousPaneView,
74+
MovePane }

lib/vim-state.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ class VimState
142142
'focus-pane-view-above': => new Panes.FocusPaneViewAbove()
143143
'focus-pane-view-below': => new Panes.FocusPaneViewBelow()
144144
'focus-previous-pane-view': => new Panes.FocusPreviousPaneView()
145+
'move-pane-view-to-far-left': => new Panes.MovePane('horizontal', 'begin')
146+
'move-pane-view-to-far-right': => new Panes.MovePane('horizontal', 'end')
147+
'move-pane-view-to-very-top': => new Panes.MovePane('vertical', 'begin')
148+
'move-pane-view-to-very-bottom': => new Panes.MovePane('vertical', 'end')
145149
'move-to-mark': (e) => new Motions.MoveToMark(@editor, @)
146150
'move-to-mark-literal': (e) => new Motions.MoveToMark(@editor, @, false)
147151
'mark': (e) => new Operators.Mark(@editor, @)

0 commit comments

Comments
 (0)