Python sublime_plugin.TextCommand() Examples

The following are 6 code examples of sublime_plugin.TextCommand(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sublime_plugin , or try the search function .
Example #1
Source File: Glue.py    From glue with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        self.settings = sublime.load_settings('Glue.sublime-settings')
        self.stdout = ""
        self.stderr = ""
        self.exitcode = 1
        self.userpath = self.settings.get('glue_userpath')
        self.shellpath = self.settings.get('glue_shellpath')
        self.original_env_path = os.environ['PATH']
        self.ps1 = self.settings.get('glue_ps1')
        self.start_dirpath = ""
        self.current_dirpath = self.settings.get('glue_working_directory')
        self.current_filepath = ""
        self.attr_lock = threading.Lock() # thread lock for attribute reads/writes
        sublime_plugin.TextCommand.__init__(self, *args, **kwargs)

    #------------------------------------------------------------------------------
    # [ run method ] - plugin start method
    #------------------------------------------------------------------------------ 
Example #2
Source File: PyYapf.py    From PyYapf with Apache License 2.0 6 votes vote down vote up
def run(self, edit):
        """Sublime Text executes this when you trigger the TextCommand."""
        with Yapf(self.view) as yapf:
            # no selection?
            no_selection = all(s.empty() for s in self.view.sel())
            if no_selection:
                if not yapf.get_setting("use_entire_file_if_no_selection"):
                    sublime.error_message('A selection is required')
                    return

                # format entire document
                with PreserveSelectionAndView(self.view):
                    yapf.format(edit)
                return

            # otherwise format all (non-empty) ones
            with PreserveSelectionAndView(self.view) as pv:
                pv.sel = []
                for s in self.view.sel():
                    if not s.empty():
                        new_s = yapf.format(edit, s)
                        pv.sel.append(new_s if new_s else s) 
Example #3
Source File: __init__.py    From tandem with Apache License 2.0 5 votes vote down vote up
def __init__(self, param):
        # no super() call! this would get the references confused
        if isinstance(param, sublime.Window):
            self.window = param
            self._window_command = True  # probably called from build system
            self.typ = WindowCommand
        elif isinstance(param, sublime.View):
            self.view   = param
            self._window_command = False
            self.typ = TextCommand
        else:
            raise TypeError("Something really bad happened and you are responsible")

        self._update_members() 
Example #4
Source File: Glue.py    From glue with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        self.settings = sublime.load_settings('Glue.sublime-settings')
        self.ps1 = self.settings.get('glue_ps1')
        self.show_path = self.settings.get('glue_display_path')
        self.exit_message = self.settings.get('glue_exit_message')
        sublime_plugin.TextCommand.__init__(self, *args, **kwargs) 
Example #5
Source File: PyYapf.py    From PyYapf with Apache License 2.0 5 votes vote down vote up
def run(self, edit):
        """Sublime Text executes this when you trigger the TextCommand."""
        with PreserveSelectionAndView(self.view):
            with Yapf(self.view) as yapf:
                yapf.format(edit) 
Example #6
Source File: SublimePhpCsFixer.py    From SublimePhpCsFixer with MIT License 5 votes vote down vote up
def __init__(self, view):
        sublime_plugin.TextCommand.__init__(self, view)
        self.settings = load_settings()