Home Download Buy Blog Forum Support

Opening 2 column layout from plugin

Opening 2 column layout from plugin

Postby fcoury on Wed Dec 14, 2011 5:15 pm

I want to split the current editor view in 2 (like the Columns: 2 layout) and open one file in each side.

Any ideas how to achieve this in a Plugin?
fcoury
 
Posts: 17
Joined: Wed Dec 14, 2011 5:13 pm

Re: Opening 2 column layout from plugin

Postby wbond on Wed Dec 14, 2011 6:43 pm

If you look in the default key bindings, you can find the command that splits the screen. Then you'll need to write a plugin that uses sublime.Window.run_command() to execute the command you found through the key bindings file. http://www.sublimetext.com/docs/2/api_reference.html has details about the API. Taking a look at some existing plugins can always be of help to figure out how things work. The ones in the Default package tend to be fairly simple.

If you want more of a walk through, I wrote an article a while ago that talks about some of the details. http://net.tutsplus.com/tutorials/pytho ... -2-plugin/
wbond
 
Posts: 520
Joined: Mon Feb 28, 2011 5:33 am

Re: Opening 2 column layout from plugin

Postby fcoury on Wed Dec 14, 2011 7:29 pm

wbond,

Thank you!

I have this plugin started already, and will add the slipt window now:

http://github.com/webbynode/GoToSpec

Best,

-- Felipe.
fcoury
 
Posts: 17
Joined: Wed Dec 14, 2011 5:13 pm

Re: Opening 2 column layout from plugin

Postby fcoury on Wed Dec 14, 2011 7:49 pm

OK, I got as far as to open two columns:

Code: Select all
      self.window.run_command('set_layout',
         { "cols": [0.0, 0.5, 1.0], "rows": [0.0, 1.0], "cells": [[0,0,1,1],[1,0,2,1]] })


However, how can I open a file on an active group? I managed to do this:

Code: Select all
      self.window.focus_group(1)


To select the right-side editor, but when I run open_file, it opens on the left.

Any ideas?

Thanks,

-- Felipe
fcoury
 
Posts: 17
Joined: Wed Dec 14, 2011 5:13 pm

Re: Opening 2 column layout from plugin

Postby fcoury on Wed Dec 14, 2011 9:00 pm

Ok, I figured this one out.

Here's a video of my GoToSpec plugin in action:

http://www.youtube.com/watch?v=on6gR4aEl7k

And source code:

https://github.com/webbynode/GoToSpec

I will make a separate post to announce it.
fcoury
 
Posts: 17
Joined: Wed Dec 14, 2011 5:13 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 8 guests