Home Download Buy Blog Forum Support

open folder in new window

open folder in new window

Postby edubkendo on Mon Jan 28, 2013 5:42 pm

So, I'm developing the JRubyFX plugin, and I'm trying to add a "create new JRubyFX project" that will create a directory structure for the project, laid out according to a few conventions which will make it easier for me to add support for some of the other tools, like building and packaging. Got that part done, and now I want this folder to either open in a new window, or replace the project in the current window, but cannot seem to find the command for doing this. I seem to be dancing all around this, but not getting what I want. Thanks in advance for your help.
edubkendo
 
Posts: 30
Joined: Fri May 18, 2012 2:43 pm
Location: Nashville

Re: open folder in new window

Postby edubkendo on Tue Jan 29, 2013 1:45 am

So, for anyone searching for this in the future, I've spent all day poring over every bit of documentation on API, commands. looking through the default package, taking dozens of guesses at likely method names, and finally pouring over tons and tons of other plugins looking for something that might be useful. The only thing I've found is the the SideBarOpenInNewWindowCommand for the SideBarEnhancements Plugin, which shells out to the sublime text executable and fires up a new process. It seems like surely there would be some way to do this via sublime's own API, since sublime itself does it when you open a project file or folder. But it is either something left unexposed, or it is completely undocumented. Fortunately, the SideBarEnhancements plugin which I mentioned will save me the trouble of having to figure out all these variations and whatnot on my own, so that's a plus! Image

My hope is that I've missed something obvious, and someone will reply to my post telling me exactly how to do either of the things I desire, but if not, I wanted to come back and hopefully save someone else the hours of time spent looking.

EDIT: I had totally given up when I took a look at one more plugin SublimeFiles and what do you know, this guy's found something that works. Apparently he's come across it in the work of wbond, who, I believe, makes the package manager. It doesn't open the project in a new window, but with it I can add the new project folder to the current window. Going to experiment a bit and see what all I can get it to do for me. Very happy. Wish I'd looked more closely at this one hours and hours ago, the first time my eyes brushed over it.
edubkendo
 
Posts: 30
Joined: Fri May 18, 2012 2:43 pm
Location: Nashville

Re: open folder in new window

Postby ionutvmi on Tue Aug 20, 2013 10:23 pm

You can try and do it like this

Code: Select all
   def openInNewWindow(self, path):
      if sublime.platform() == 'osx':
         try:
            subprocess.Popen(['subl', '.'], cwd=path)
         except:
            try:
               subprocess.Popen(['sublime', '.'], cwd=path)
            except:
               subprocess.Popen(['/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl', '.'], cwd=path)
      elif sublime.platform() == 'windows':
         try:
            subprocess.Popen(['subl', '.'], cwd=path, shell=True)
         except:
            try:
               subprocess.Popen(['sublime', '.'], cwd=path, shell=True)
            except:
               subprocess.Popen(['/Program Files/Sublime Text 3/sublime_text.exe', '.'], cwd=path, shell=True)
      else:
         try:
            subprocess.Popen(['subl', '.'], cwd=path)
         except:
            subprocess.Popen(['sublime', '.'], cwd=path)
ionutvmi
 
Posts: 2
Joined: Tue Aug 20, 2013 10:19 pm

Re: open folder in new window

Postby tito on Wed Aug 21, 2013 5:49 am

Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 706
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: open folder in new window

Postby tito on Wed Aug 21, 2013 5:51 am

I had to recognize that the magic line is this one there
Code: Select all
for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames():
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 706
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: open folder in new window

Postby tito on Wed Aug 21, 2013 5:54 am

Oh yeah, there was something strange there, is old code, the new one is much better

https://github.com/titoBouzout/SideBarE ... r.py#L1447
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 706
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 9 guests

cron