Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST3 support? (hangs on ST3) #1

Open
arnab opened this issue May 15, 2013 · 3 comments
Open

ST3 support? (hangs on ST3) #1

arnab opened this issue May 15, 2013 · 3 comments

Comments

@arnab
Copy link

arnab commented May 15, 2013

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
Copy link
Author

arnab commented May 15, 2013

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

@gecbla
Copy link

gecbla commented Oct 28, 2013

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!

@arnab
Copy link
Author

arnab commented Oct 29, 2013

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

Gil-Tayar added a commit to Gil-Tayar/sublime-SplitScreen that referenced this issue Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants