Skip to content

Commit

Permalink
Split single command out into multiple commands
Browse files Browse the repository at this point in the history
  • Loading branch information
singingwolfboy authored and Nikolaus Wittenstein committed Jun 27, 2012
1 parent af91540 commit 950633b
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 81 deletions.
40 changes: 20 additions & 20 deletions Default (Linux).sublime-keymap
@@ -1,26 +1,26 @@
[
{ "keys": ["super+k", "up"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "up"} },
{ "keys": ["super+k", "right"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "right"} },
{ "keys": ["super+k", "down"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "down"} },
{ "keys": ["super+k", "left"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "left"} },
{ "keys": ["super+k", "up"], "command": "travel_to_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "right"], "command": "travel_to_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "down"], "command": "travel_to_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "left"], "command": "travel_to_pane", "args": {"direction": "left"} },

{ "keys": ["super+k", "shift+up"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "up"} },
{ "keys": ["super+k", "shift+right"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "right"} },
{ "keys": ["super+k", "shift+down"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "down"} },
{ "keys": ["super+k", "shift+left"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "left"} },
{ "keys": ["super+k", "shift+up"], "command": "carry_file_to_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "shift+right"], "command": "carry_file_to_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "shift+down"], "command": "carry_file_to_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "shift+left"], "command": "carry_file_to_pane", "args": {"direction": "left"} },

{ "keys": ["super+k", "alt+up"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "up"} },
{ "keys": ["super+k", "alt+right"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "right"} },
{ "keys": ["super+k", "alt+down"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "down"} },
{ "keys": ["super+k", "alt+left"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "left"} },
{ "keys": ["super+k", "alt+up"], "command": "clone_file_to_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "alt+right"], "command": "clone_file_to_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "alt+down"], "command": "clone_file_to_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "alt+left"], "command": "clone_file_to_pane", "args": {"direction": "left"} },

{ "keys": ["super+k", "super+up"], "command": "split_pane", "args": {"create_pane_in_direction": "up"} },
{ "keys": ["super+k", "super+right"], "command": "split_pane", "args": {"create_pane_in_direction": "right"} },
{ "keys": ["super+k", "super+down"], "command": "split_pane", "args": {"create_pane_in_direction": "down"} },
{ "keys": ["super+k", "super+left"], "command": "split_pane", "args": {"create_pane_in_direction": "left"} },
{ "keys": ["super+k", "super+up"], "command": "create_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "super+right"], "command": "create_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "super+down"], "command": "create_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "super+left"], "command": "create_pane", "args": {"direction": "left"} },

{ "keys": ["super+k", "super+shift+up"], "command": "split_pane", "args": {"destroy_pane_in_direction": "up"} },
{ "keys": ["super+k", "super+shift+right"], "command": "split_pane", "args": {"destroy_pane_in_direction": "right"} },
{ "keys": ["super+k", "super+shift+down"], "command": "split_pane", "args": {"destroy_pane_in_direction": "down"} },
{ "keys": ["super+k", "super+shift+left"], "command": "split_pane", "args": {"destroy_pane_in_direction": "left"} }
{ "keys": ["super+k", "super+shift+up"], "command": "destroy_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "super+shift+right"], "command": "destroy_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "super+shift+down"], "command": "destroy_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "super+shift+left"], "command": "destroy_pane", "args": {"direction": "left"} }
]
40 changes: 20 additions & 20 deletions Default (OSX).sublime-keymap
@@ -1,26 +1,26 @@
[
{ "keys": ["super+k", "up"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "up"} },
{ "keys": ["super+k", "right"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "right"} },
{ "keys": ["super+k", "down"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "down"} },
{ "keys": ["super+k", "left"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "left"} },
{ "keys": ["super+k", "up"], "command": "travel_to_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "right"], "command": "travel_to_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "down"], "command": "travel_to_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "left"], "command": "travel_to_pane", "args": {"direction": "left"} },

{ "keys": ["super+k", "shift+up"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "up"} },
{ "keys": ["super+k", "shift+right"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "right"} },
{ "keys": ["super+k", "shift+down"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "down"} },
{ "keys": ["super+k", "shift+left"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "left"} },
{ "keys": ["super+k", "shift+up"], "command": "carry_file_to_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "shift+right"], "command": "carry_file_to_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "shift+down"], "command": "carry_file_to_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "shift+left"], "command": "carry_file_to_pane", "args": {"direction": "left"} },

{ "keys": ["super+k", "alt+up"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "up"} },
{ "keys": ["super+k", "alt+right"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "right"} },
{ "keys": ["super+k", "alt+down"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "down"} },
{ "keys": ["super+k", "alt+left"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "left"} },
{ "keys": ["super+k", "alt+up"], "command": "clone_file_to_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "alt+right"], "command": "clone_file_to_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "alt+down"], "command": "clone_file_to_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "alt+left"], "command": "clone_file_to_pane", "args": {"direction": "left"} },

{ "keys": ["super+k", "super+up"], "command": "split_pane", "args": {"create_pane_in_direction": "up"} },
{ "keys": ["super+k", "super+right"], "command": "split_pane", "args": {"create_pane_in_direction": "right"} },
{ "keys": ["super+k", "super+down"], "command": "split_pane", "args": {"create_pane_in_direction": "down"} },
{ "keys": ["super+k", "super+left"], "command": "split_pane", "args": {"create_pane_in_direction": "left"} },
{ "keys": ["super+k", "super+up"], "command": "create_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "super+right"], "command": "create_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "super+down"], "command": "create_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "super+left"], "command": "create_pane", "args": {"direction": "left"} },

{ "keys": ["super+k", "super+shift+up"], "command": "split_pane", "args": {"destroy_pane_in_direction": "up"} },
{ "keys": ["super+k", "super+shift+right"], "command": "split_pane", "args": {"destroy_pane_in_direction": "right"} },
{ "keys": ["super+k", "super+shift+down"], "command": "split_pane", "args": {"destroy_pane_in_direction": "down"} },
{ "keys": ["super+k", "super+shift+left"], "command": "split_pane", "args": {"destroy_pane_in_direction": "left"} }
{ "keys": ["super+k", "super+shift+up"], "command": "destroy_pane", "args": {"direction": "up"} },
{ "keys": ["super+k", "super+shift+right"], "command": "destroy_pane", "args": {"direction": "right"} },
{ "keys": ["super+k", "super+shift+down"], "command": "destroy_pane", "args": {"direction": "down"} },
{ "keys": ["super+k", "super+shift+left"], "command": "destroy_pane", "args": {"direction": "left"} }
]
40 changes: 20 additions & 20 deletions Default (Windows).sublime-keymap
@@ -1,26 +1,26 @@
[
{ "keys": ["ctrl+k", "up"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "up"} },
{ "keys": ["ctrl+k", "right"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "right"} },
{ "keys": ["ctrl+k", "down"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "down"} },
{ "keys": ["ctrl+k", "left"], "command": "split_pane", "args": {"travel_to_pane_in_direction": "left"} },
{ "keys": ["ctrl+k", "up"], "command": "travel_to_pane", "args": {"direction": "up"} },
{ "keys": ["ctrl+k", "right"], "command": "travel_to_pane", "args": {"direction": "right"} },
{ "keys": ["ctrl+k", "down"], "command": "travel_to_pane", "args": {"direction": "down"} },
{ "keys": ["ctrl+k", "left"], "command": "travel_to_pane", "args": {"direction": "left"} },

{ "keys": ["ctrl+k", "shift+up"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "up"} },
{ "keys": ["ctrl+k", "shift+right"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "right"} },
{ "keys": ["ctrl+k", "shift+down"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "down"} },
{ "keys": ["ctrl+k", "shift+left"], "command": "split_pane", "args": {"carry_file_to_pane_in_direction": "left"} },
{ "keys": ["ctrl+k", "shift+up"], "command": "carry_file_to_pane", "args": {"direction": "up"} },
{ "keys": ["ctrl+k", "shift+right"], "command": "carry_file_to_pane", "args": {"direction": "right"} },
{ "keys": ["ctrl+k", "shift+down"], "command": "carry_file_to_pane", "args": {"direction": "down"} },
{ "keys": ["ctrl+k", "shift+left"], "command": "carry_file_to_pane", "args": {"direction": "left"} },

{ "keys": ["ctrl+k", "alt+up"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "up"} },
{ "keys": ["ctrl+k", "alt+right"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "right"} },
{ "keys": ["ctrl+k", "alt+down"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "down"} },
{ "keys": ["ctrl+k", "alt+left"], "command": "split_pane", "args": {"clone_file_to_pane_in_direction": "left"} },
{ "keys": ["ctrl+k", "alt+up"], "command": "clone_file_to_pane", "args": {"direction": "up"} },
{ "keys": ["ctrl+k", "alt+right"], "command": "clone_file_to_pane", "args": {"direction": "right"} },
{ "keys": ["ctrl+k", "alt+down"], "command": "clone_file_to_pane", "args": {"direction": "down"} },
{ "keys": ["ctrl+k", "alt+left"], "command": "clone_file_to_pane", "args": {"direction": "left"} },

{ "keys": ["ctrl+k", "ctrl+up"], "command": "split_pane", "args": {"create_pane_in_direction": "up"} },
{ "keys": ["ctrl+k", "ctrl+right"], "command": "split_pane", "args": {"create_pane_in_direction": "right"} },
{ "keys": ["ctrl+k", "ctrl+down"], "command": "split_pane", "args": {"create_pane_in_direction": "down"} },
{ "keys": ["ctrl+k", "ctrl+left"], "command": "split_pane", "args": {"create_pane_in_direction": "left"} },
{ "keys": ["ctrl+k", "ctrl+up"], "command": "create_pane", "args": {"direction": "up"} },
{ "keys": ["ctrl+k", "ctrl+right"], "command": "create_pane", "args": {"direction": "right"} },
{ "keys": ["ctrl+k", "ctrl+down"], "command": "create_pane", "args": {"direction": "down"} },
{ "keys": ["ctrl+k", "ctrl+left"], "command": "create_pane", "args": {"direction": "left"} },

{ "keys": ["ctrl+k", "ctrl+shift+up"], "command": "split_pane", "args": {"destroy_pane_in_direction": "up"} },
{ "keys": ["ctrl+k", "ctrl+shift+right"], "command": "split_pane", "args": {"destroy_pane_in_direction": "right"} },
{ "keys": ["ctrl+k", "ctrl+shift+down"], "command": "split_pane", "args": {"destroy_pane_in_direction": "down"} },
{ "keys": ["ctrl+k", "ctrl+shift+left"], "command": "split_pane", "args": {"destroy_pane_in_direction": "left"} }
{ "keys": ["ctrl+k", "ctrl+shift+up"], "command": "destroy_pane", "args": {"direction": "up"} },
{ "keys": ["ctrl+k", "ctrl+shift+right"], "command": "destroy_pane", "args": {"direction": "right"} },
{ "keys": ["ctrl+k", "ctrl+shift+down"], "command": "destroy_pane", "args": {"direction": "down"} },
{ "keys": ["ctrl+k", "ctrl+shift+left"], "command": "destroy_pane", "args": {"direction": "left"} }
]
51 changes: 30 additions & 21 deletions origami.py
Expand Up @@ -43,7 +43,9 @@ def cells_adjacent_to_cell_in_direction(cells, cell, direction):
return [c for c in cells if fn(cell, c)]
return None

class SplitPaneCommand(sublime_plugin.TextCommand):
class PaneCommand(sublime_plugin.WindowCommand):
"Abstract base class for commands."

def get_layout(self):
layout = self.window.get_layout()
print layout
Expand All @@ -62,7 +64,7 @@ def travel_to_pane(self, direction):
window.focus_group(new_view_index)

def carry_file_to_pane(self, direction):
view = self.view
view = self.window.active_view()
window = self.window
group = self.travel_to_pane(direction)
window.set_view_index(view, window.active_group(), 0)
Expand Down Expand Up @@ -146,22 +148,29 @@ def destroy_pane(self, direction):
layout = {"cols": cols, "rows": rows, "cells": cells}
print layout
window.set_layout(layout)

def run(self, edit, travel_to_pane_in_direction=None,
carry_file_to_pane_in_direction=None,
clone_file_to_pane_in_direction=None,
create_pane_in_direction=None,
destroy_pane_in_direction=None):

# keep track of the window so that cloning works
self.window = self.view.window()
if travel_to_pane_in_direction:
self.travel_to_pane(travel_to_pane_in_direction)
elif carry_file_to_pane_in_direction:
self.carry_file_to_pane(carry_file_to_pane_in_direction)
elif clone_file_to_pane_in_direction:
self.clone_file_to_pane(clone_file_to_pane_in_direction)
elif create_pane_in_direction:
self.create_pane(create_pane_in_direction)
elif destroy_pane_in_direction:
self.destroy_pane(destroy_pane_in_direction)


class TravelToPaneCommand(PaneCommand):
def run(self, direction):
self.travel_to_pane(direction)


class CarryFileToPaneCommand(PaneCommand):
def run(self, direction):
self.carry_file_to_pane(direction)


class CloneFileToPaneCommand(PaneCommand):
def run(self, direction):
self.clone_file_to_pane(direction)


class CreatePaneCommand(PaneCommand):
def run(self, direction):
print "creating"
self.create_pane(direction)


class DestroyPaneCommand(PaneCommand):
def run(self, direction):
self.destroy_pane(direction)

0 comments on commit 950633b

Please sign in to comment.