Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit fa5b7a54b05556b2ee57e6420e773636ef854d22 0 parents
Nick Fisher authored
Showing with 113 additions and 0 deletions.
  1. +3 −0  Default.sublime-keymap
  2. +63 −0 README.md
  3. +47 −0 split_screen.py
3  Default.sublime-keymap
@@ -0,0 +1,3 @@
+[
+ { "keys": ["alt+shift+s"], "command": "split_screen" }
+]
63 README.md
@@ -0,0 +1,63 @@
+SplitScreen is a [Sublime Text 2][sublime] plugin which allows you to define custom ratios for split screen editing.
+
+---
+
+By default, Sublime has some predefined split-window configuration, accessible via the <kbd>Alt+Shift+&lt;number&gt;</kbd> hotkeys, however, if you want something other than these presets, it is quite difficult to create your own. Enter SplitScreen!
+
+1. To activate, press the hotkey, <kbd>Alt+Shift+S</kbd>, and an input box will appear at the bottom of the screen.
+
+2. Enter some ratios, horizontal (columns) first, and then vertical (rows) second. Numbers are treated as a ratio, so `50:50` is identical to `1:1`. Separate columns and rows with a comma. If you want only one row or column, then that can be left blank.
+
+For example:
+
+
+ 50:50
+ (2 columns, equal width. 1 row)
+
+ --------------------
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ --------------------
+
+ 1:2
+ (2 columns, one twice the width of the other. 1 row)
+
+ --------------------
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ --------------------
+
+ ,1:1
+ (1 column, two rows equal width)
+
+ --------------------
+ | |
+ | |
+ --------------------
+ | |
+ | |
+ --------------------
+
+ 70:30,2:1
+ (2 columns, 2 rows)
+
+ --------------------
+ | | |
+ | | |
+ | | |
+ | | |
+ --------------------
+ | | |
+ | | |
+ --------------------
+
+**Tip**: To go back to just one window, you can enter an empty string, or a single number, or simply use the built-in hotkey <kbd>Alt+Shift+1</kbd>.
+
+[sublime]: http://www.sublimetext.com/
47 split_screen.py
@@ -0,0 +1,47 @@
+"""
+SplitScreen v1.0.0
+by Nick Fisher
+https://github.com/spadgos/sublime-SplitScreen
+"""
+import sublime_plugin
+import re
+
+
+def addUp(lst):
+ out = [0.0]
+ for i in lst:
+ out.append(out[-1] + i)
+
+ return out
+
+
+class SplitScreenCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ self.window.show_input_panel("Split ratios", "70:30", self.splitWindow, None, None)
+
+ def splitWindow(self, inp):
+ parts = re.split("\\s*,\\s*", inp)
+
+ horiz = parts[0] or "1"
+ vert = parts[1] or "1" if len(parts) > 1 else "1"
+
+ vert = map(float, re.split(":", vert))
+ horiz = map(float, re.split(":", horiz))
+ vertTotal = sum(vert)
+ horizTotal = sum(horiz)
+ vert = map((lambda x: x / vertTotal), vert)
+ horiz = map((lambda x: x / horizTotal), horiz)
+
+ cols = addUp(horiz)
+ rows = addUp(vert)
+
+ cells = []
+ for x, val1 in enumerate(horiz):
+ for y, val2 in enumerate(vert):
+ cells.append([x, y, x + 1, y + 1])
+
+ self.window.run_command('set_layout', {
+ "cols": cols,
+ "rows": rows,
+ "cells": cells
+ })
Please sign in to comment.
Something went wrong with that request. Please try again.