Skip to content

Commit

Permalink
Closes issue #61
Browse files Browse the repository at this point in the history
- Added support for "create and focus" commands
  • Loading branch information
23maverick23 committed Feb 9, 2015
1 parent 1c087ea commit 1b22683
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Origami.sublime-commands
Expand Up @@ -19,6 +19,11 @@
{ "command": "create_pane", "args": {"direction": "down"}, "caption": "Origami: Create Pane Below" },
{ "command": "create_pane", "args": {"direction": "left"}, "caption": "Origami: Create Pane on the Left" },

{ "command": "create_pane", "args": {"direction": "up", "give_focus": true}, "caption": "Origami: Create and Focus Pane Above" },
{ "command": "create_pane", "args": {"direction": "right", "give_focus": true}, "caption": "Origami: Create and Focus Pane on the Right" },
{ "command": "create_pane", "args": {"direction": "down", "give_focus": true}, "caption": "Origami: Create and Focus Pane Below" },
{ "command": "create_pane", "args": {"direction": "left", "give_focus": true}, "caption": "Origami: Create and Focus Pane on the Left" },

{ "command": "destroy_pane", "args": {"direction": "up"}, "caption": "Origami: Destroy Pane Above" },
{ "command": "destroy_pane", "args": {"direction": "right"}, "caption": "Origami: Destroy Pane on the Right" },
{ "command": "destroy_pane", "args": {"direction": "down"}, "caption": "Origami: Destroy Pane Below" },
Expand Down
14 changes: 11 additions & 3 deletions origami.py
Expand Up @@ -367,7 +367,7 @@ def toggle_zoom(self, fraction):
self.unzoom_pane()


def create_pane(self, direction):
def create_pane(self, direction, give_focus=False):
window = self.window
rows, cols, cells = self.get_layout()
current_group = window.active_group()
Expand Down Expand Up @@ -399,6 +399,9 @@ def create_pane(self, direction):
layout = {"cols": cols, "rows": rows, "cells": cells}
fixed_set_layout(window, layout)

if give_focus:
self.travel_to_pane(direction)

def destroy_current_pane(self):
#Out of the four adjacent panes, one was split to create this pane.
#Find out which one, move to it, then destroy this pane.
Expand Down Expand Up @@ -512,29 +515,34 @@ class ZoomPaneCommand(PaneCommand):
def run(self, fraction=None):
self.zoom_pane(fraction)


class UnzoomPaneCommand(PaneCommand):
def run(self):
self.unzoom_pane()


class ToggleZoomPaneCommand(PaneCommand):
def run(self, fraction=None):
self.toggle_zoom(fraction)


class CreatePaneCommand(PaneCommand):
def run(self, direction):
self.create_pane(direction)
def run(self, direction, give_focus=False):
self.create_pane(direction, give_focus)


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


class ResizePaneCommand(PaneCommand):
def run(self, orientation, mode = None):
if mode == None:
mode = "NEAREST"
self.resize_panes(orientation, mode)


class ReorderPaneCommand(PaneCommand):
def run(self):
self.reorder_panes()
Expand Down

0 comments on commit 1b22683

Please sign in to comment.