def test_append(): view = mock.Mock() edit = object() view.begin_edit.return_value = edit view.size.return_value = 100 su_lib_view.append(view, "new text") assert view.insert.call_args == ((edit, 100, "new text"),)
def test_append(): view = mock.Mock() edit = object() view.begin_edit.return_value = edit view.size.return_value = 100 su_lib_view.append(view, "new text") assert view.insert.call_args == ((edit, 100, "new text"), )
def run(self, edit): self.window = self.view.window() v = self.window.show_input_panel('Sublime CMD:', '', self.on_done, None, None) # Remember last command. content = getattr(self, 'last_cmd', '') if content: append(v, content) v.sel().add(sublime.Region(0, v.size()))
def run(self, edit): all_ = sublime_plugin.all_command_classes all_cmds = [] for gr in all_: for cmd in gr: cli = "run" if issubclass(cmd, sublime_plugin.TextCommand) else "run:w" all_cmds.append("%s\t%s" % (cli, cmd.__name__)) txt = '\n'.join(sorted(all_cmds)) txt = re.sub(r"([a-z])([A-Z])", r"\1_\2", txt).lower() txt = re.sub(r"(.*)_command", r"\1", txt) v = self.view.window().new_file() v.set_scratch(True) vlib.append(v, txt)
def run(self, edit): all_ = sublime_plugin.all_command_classes all_cmds = [] for gr in all_: for cmd in gr: cli = "run" if issubclass( cmd, sublime_plugin.TextCommand) else "run:w" all_cmds.append("%s\t%s" % (cli, cmd.__name__)) txt = '\n'.join(sorted(all_cmds)) txt = re.sub(r"([a-z])([A-Z])", r"\1_\2", txt).lower() txt = re.sub(r"(.*)_command", r"\1", txt) v = self.view.window().new_file() v.set_scratch(True) vlib.append(v, txt)
def on_done(self, view, edit, userPoShCmd, as_filter=True): # Exit if user doesn't actually want to filter anything. if self._parse_intrinsic_commands(userPoShCmd, view): return # Run command, don't modify the buffer, output to output panel. if not as_filter: self.output_view = self.view.window().new_file() self.output_view.set_scratch(True) self.output_view.set_name("Powershell - Output") out, error = run_posh_command(userPoShCmd) if out or error: if out: append(self.output_view, out) if error: append(self.output_view, error) return try: PoShOutput, PoShErrInfo = filter_thru_posh(regions_to_posh_array(view, view.sel()), userPoShCmd) except EnvironmentError, e: sublime.error_message("Windows error. Possible causes:\n\n" + "* Is Powershell in your %PATH%?\n" + "* Use Start-Process to start ST from Powershell.\n\n%s" % e) return
def run(self, edit, syntax, pattern): settings_name, _ = os.path.splitext(syntax) settings = get_merged_settings(settings_name + '.sublime-settings') out_view = self.view.window().new_file() out_view.set_scratch(True) vlib.append(out_view, "=" * 79 + "\n") vlib.append(out_view, "Settings for: %s\n" % self.view.file_name()) vlib.append(out_view, "-" * 79) vlib.append(out_view, '\n') for k, v in settings.iteritems(): if fnmatch.fnmatch(k, pattern): vlib.append(out_view, k + ":\n") last = None for location, value in v: location = location[location.find('Packages'):] vlib.append(out_view, "\t%s\t\t\t%s\n" % (value, location)) last = value session_value = self.view.settings().get(k) if session_value != last: vlib.append(out_view, "\t%s\t\t\t%s\n" % _ (self.view.settings().get(k), "Session")) vlib.append(out_view, '\n') vlib.append(out_view, "=" * 79)
def run(self, edit, syntax, pattern): settings_name, _ = os.path.splitext(syntax) settings = get_merged_settings(settings_name + '.sublime-settings') out_view = self.view.window().new_file() out_view.set_scratch(True) vlib.append(out_view, "=" * 79 + "\n") vlib.append(out_view, "Settings for: %s\n" % self.view.file_name()) vlib.append(out_view, "-" * 79) vlib.append(out_view, '\n') for k, v in settings.iteritems(): if fnmatch.fnmatch(k, pattern): vlib.append(out_view, k + ":\n") last = None for location, value in v: location = location[location.find('Packages'):] vlib.append(out_view, "\t%s\t\t\t%s\n" % (value, location)) last = value session_value = self.view.settings().get(k) if session_value != last: vlib.append( out_view, "\t%s\t\t\t%s\n" % _(self.view.settings().get(k), "Session")) vlib.append(out_view, '\n') vlib.append(out_view, "=" * 79)