Home Download Buy Blog Forum Support

how can I tell when I'm inside a panel?

how can I tell when I'm inside a panel?

Postby sublimated on Mon Dec 26, 2011 12:19 am

I often need to switch back and forth between two files, and I have a very simple command to jump back to the last view.

Code: Select all
import sublime
import sublime_plugin

'''
Go back to the last view.  Useful for jumping back and forth between two views
'''

last_view = None

class LastViewRecorder(sublime_plugin.EventListener):
   """Keep track of last view
   """

   def on_deactivated(self, view):
      """When view is deactivated, record it
      """
      global last_view
      last_view = view

class LastViewCommand(sublime_plugin.WindowCommand):
   """Go back to last view. Useful for jumping back and forth between two views
      with a single key press
   """

   def run(self):
      global last_view
      if last_view is not None:
         self.window.focus_view(last_view)


It works fine, except when I bring up the console or a quick panel. I think the problem is I need to detect when I'm in the console or quick panel and not record the view. How can I do that?
sublimated
 
Posts: 13
Joined: Sun Dec 18, 2011 3:58 pm

Re: how can I tell when I'm inside a panel?

Postby jps on Mon Dec 26, 2011 2:48 am

You can use view.settings().get('is_widget')
jps
Site Admin
 
Posts: 3058
Joined: Wed Mar 19, 2008 12:33 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests