sublime-SplitScreen icon indicating copy to clipboard operation
sublime-SplitScreen copied to clipboard

ST3 support? (hangs on ST3)

Open arnab opened this issue 12 years ago • 3 comments

First of all, thanks for this awesome plugin.

Are you planning on ST3 support? Right now this plugin makes ST3 hang and then crash on Mac OSX. Details:

Environment

  • OS: Mac OSX 10.8.3 (latest)
  • Sublime Text 3 Build 3033 (latest release)

Steps to reproduce

  • Start Sublime
  • Alt+Shift+S
  • Enter some ratio, like 7:3
  • The editor hangs indefinitely (OSX rainbow wheel)

arnab avatar May 15 '13 07:05 arnab

BTW I'm more than happy to help out - but need some pointers as to where to start regarding the upgrading.

arnab avatar May 15 '13 07:05 arnab

I'm not a python developer but it turned out this was easy fix. Just googled these two links - link one and link two. So the ST3 version would look something like this

class SplitScreenCommand(sublime_plugin.WindowCommand):

    def run(self):
        win = self.window

        # Group check
        if win.num_groups() == 1:
            win.show_input_panel("Split ratios", "60:40", 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"

        # Python 3 fix        
        vert = list(map(float, re.split(":", vert)))
        horiz = list(map(float, re.split(":", horiz)))

        vertTotal = sum(vert)
        horizTotal = sum(horiz)

        # Python 3 fix
        vert = list(map((lambda x: x / vertTotal), vert))
        horiz = list(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])

        # Toggle sidebar
        self.window.run_command('toggle_side_bar')

        # Set layout
        self.window.run_command("set_layout", {
            "cols": cols,
            "rows": rows,
            "cells": cells
        })

        # Leave focus on current group
        self.window.run_command("focus_group", { "group": 0 })

You can just comment lines you dont need, like sidebar toogle and focus. I added this because this correspond to my common workflow!

gecbla avatar Oct 28 '13 21:10 gecbla

Thanks for replying @gecbla . However, since I have moved back to emacs I won't be attempting this fix :(

arnab avatar Oct 29 '13 05:10 arnab