def run(self, edit, line_range=None, shell_cmd=''): try: if line_range['text_range']: shell.filter_thru_shell(view=self.view, edit=edit, regions=get_region_by_range( self.view, line_range=line_range), cmd=shell_cmd) else: # TODO: Read output into output panel. # shell.run_and_wait(self.view, shell_cmd) out = shell.run_and_read(self.view, shell_cmd) output_view = self.view.window().create_output_panel('vi_out') output_view.settings().set("line_numbers", False) output_view.settings().set("gutter", False) output_view.settings().set("scroll_past_end", False) output_view = self.view.window().create_output_panel('vi_out') output_view.run_command('append', { 'characters': out, 'force': True, 'scroll_to_end': True }) self.view.window().run_command("show_panel", {"panel": "output.vi_out"}) except NotImplementedError: ex_error.handle_not_implemented()
def run(self): if sublime.platform() == 'linux': term = self.view.settings().get('VintageousEx_linux_terminal') term = term or os.environ.get('COLORTERM') or os.environ.get("TERM") if not term: sublime.status_message("Vintageous: Not terminal name found.") return try: self.open_shell([term, '-e', 'bash']).wait() except Exception as e: print(e) sublime.status_message("Vintageous: Error while executing command through shell.") return elif sublime.platform() == 'osx': term = self.view.settings().get('VintageousEx_osx_terminal') term = term or os.environ.get('COLORTERM') or os.environ.get("TERM") if not term: sublime.status_message("Vintageous: Not terminal name found.") return try: self.open_shell([term, '-e', 'bash']).wait() except Exception as e: print(e) sublime.status_message("Vintageous: Error while executing command through shell.") return elif sublime.platform() == 'windows': self.open_shell(['cmd.exe', '/k']).wait() else: # XXX OSX (make check explicit) ex_error.handle_not_implemented()
def run(self): if sublime.platform() == 'linux': term = self.view.settings().get('VintageousEx_linux_terminal') term = term or os.environ.get('COLORTERM') or os.environ.get( "TERM") if not term: sublime.status_message("Vintageous: Not terminal name found.") return try: self.open_shell([term, '-e', 'bash']).wait() except Exception as e: print(e) sublime.status_message( "Vintageous: Error while executing command through shell.") return elif sublime.platform() == 'osx': term = self.view.settings().get('VintageousEx_osx_terminal') term = term or os.environ.get('COLORTERM') or os.environ.get( "TERM") if not term: sublime.status_message("Vintageous: Not terminal name found.") return try: self.open_shell([term, '-e', 'bash']).wait() except Exception as e: print(e) sublime.status_message( "Vintageous: Error while executing command through shell.") return elif sublime.platform() == 'windows': self.open_shell(['cmd.exe', '/k']).wait() else: # XXX OSX (make check explicit) ex_error.handle_not_implemented()
def run(self): if sublime.platform() == "linux": term = self.view.settings().get("VintageousEx_linux_terminal") term = term or os.environ.get("COLORTERM") or os.environ.get("TERM") if not term: sublime.status_message("Vintageous: Not terminal name found.") return try: self.open_shell([term, "-e", "bash"]).wait() except Exception as e: print(e) sublime.status_message("Vintageous: Error while executing command through shell.") return elif sublime.platform() == "osx": term = self.view.settings().get("VintageousEx_osx_terminal") term = term or os.environ.get("COLORTERM") or os.environ.get("TERM") if not term: sublime.status_message("Vintageous: Not terminal name found.") return try: self.open_shell([term, "-e", "bash"]).wait() except Exception as e: print(e) sublime.status_message("Vintageous: Error while executing command through shell.") return elif sublime.platform() == "windows": self.open_shell(["cmd.exe", "/k"]).wait() else: # XXX OSX (make check explicit) ex_error.handle_not_implemented()
def run(self, option=None, operator=None, value=None): if option.endswith('?'): ex_error.handle_not_implemented() return try: set_global(self.view, option, value) except KeyError: sublime.status_message("Vintageuos: No such option.") except ValueError: sublime.status_message("Vintageous: Invalid value for option.")
def run(self, forced=False): # todo: restore active line_nr too if forced or not self.view.is_dirty(): self.view.run_command('revert') return elif self.view.is_dirty(): ex_error.display_error(ex_error.ERR_UNSAVED_CHANGES) return ex_error.handle_not_implemented()
def run(self, option=None, operator=None, value=None): if option.endswith('?'): ex_error.handle_not_implemented() return try: set_global(self.view, option, value) except KeyError: sublime.status_message("Vintageuos: No such option.") except ValueError: sublime.status_message("Vintageous: Invalid value for option.")
def run(self, forced=False): # todo: restore active line_nr too if forced or not self.view.is_dirty(): self.view.run_command('revert') return elif self.view.is_dirty(): ex_error.display_error(ex_error.ERR_UNSAVED_CHANGES) return ex_error.handle_not_implemented()
def run(self, edit, line_range=None, shell_cmd=''): try: if line_range['text_range']: shell.filter_thru_shell( view=self.view, regions=get_region_by_range(self.view, line_range=line_range), cmd=shell_cmd) else: shell.run_and_wait(self.view, shell_cmd) except NotImplementedError: ex_error.handle_not_implemented()
def run(self, edit, line_range=None, shell_cmd=''): try: if line_range['text_range']: shell.filter_thru_shell(view=self.view, regions=get_region_by_range( self.view, line_range=line_range), cmd=shell_cmd) else: shell.run_and_wait(self.view, shell_cmd) except NotImplementedError: ex_error.handle_not_implemented()
def run(self, edit, line_range=None, name='', plusplus_args='', forced=False): target_line = self.view.line(self.view.sel()[0].begin()) if line_range['text_range']: range = max( ex_range.calculate_range(self.view, line_range=line_range)[0]) target_line = self.view.line(self.view.text_point(range, 0)) target_point = min(target_line.b + 1, self.view.size()) # Cheat a little bit to get the parsing right: # - forced == True means we need to execute a command if forced: if sublime.platform() == 'linux': for s in self.view.sel(): # TODO: make shell command configurable. the_shell = self.view.settings().get('linux_shell') the_shell = the_shell or os.path.expandvars("$SHELL") if not the_shell: sublime.status_message( "Vintageous: No shell name found.") return try: p = subprocess.Popen([the_shell, '-c', name], stdout=subprocess.PIPE) except Exception as e: print(e) sublime.status_message( "Vintageous: Error while executing command through shell." ) return self.view.insert(edit, s.begin(), p.communicate()[0][:-1].decode('utf-8')) elif sublime.platform() == 'windows': for s in self.view.sel(): p = subprocess.Popen(['cmd.exe', '/C', name], stdout=subprocess.PIPE, startupinfo=get_startup_info()) cp = 'cp' + get_oem_cp() rv = p.communicate()[0].decode(cp)[:-2].strip() self.view.insert(edit, s.begin(), rv) else: ex_error.handle_not_implemented() # Read a file into the current view. else: # According to Vim's help, :r should read the current file's content # if no file name is given, but Vim doesn't do that. # TODO: implement reading a file into the buffer. ex_error.handle_not_implemented() return
def run(self, edit, line_range=None, forced=False): # TODO: implement this if forced: ex_error.handle_not_implemented() return if self.view.is_read_only(): sublime.status_message("Can't write a read-only buffer.") return if not self.view.file_name(): sublime.status_message("Can't save a file without name.") return self.view.run_command('save') self.view.window().run_command('ex_quit')
def run(self, edit, line_range=None, forced=False): # TODO: implement this if forced: ex_error.handle_not_implemented() return if self.view.is_read_only(): sublime.status_message("Can't write a read-only buffer.") return if not self.view.file_name(): sublime.status_message("Can't save a file without name.") return self.view.run_command('save') self.view.window().run_command('ex_quit')
def run(self, edit, line_range=None, name='', plusplus_args='', forced=False): target_line = self.view.line(self.view.sel()[0].begin()) if line_range['text_range']: range = max(ex_range.calculate_range(self.view, line_range=line_range)[0]) target_line = self.view.line(self.view.text_point(range, 0)) target_point = min(target_line.b + 1, self.view.size()) # Cheat a little bit to get the parsing right: # - forced == True means we need to execute a command if forced: if sublime.platform() == 'linux': for s in self.view.sel(): # TODO: make shell command configurable. the_shell = self.view.settings().get('linux_shell') the_shell = the_shell or os.path.expandvars("$SHELL") if not the_shell: sublime.status_message("Vintageous: No shell name found.") return try: p = subprocess.Popen([the_shell, '-c', name], stdout=subprocess.PIPE) except Exception as e: print(e) sublime.status_message("Vintageous: Error while executing command through shell.") return self.view.insert(edit, s.begin(), p.communicate()[0][:-1].decode('utf-8')) elif sublime.platform() == 'windows': for s in self.view.sel(): p = subprocess.Popen(['cmd.exe', '/C', name], stdout=subprocess.PIPE, startupinfo=get_startup_info() ) cp = 'cp' + get_oem_cp() rv = p.communicate()[0].decode(cp)[:-2].strip() self.view.insert(edit, s.begin(), rv) else: ex_error.handle_not_implemented() # Read a file into the current view. else: # According to Vim's help, :r should read the current file's content # if no file name is given, but Vim doesn't do that. # TODO: implement reading a file into the buffer. ex_error.handle_not_implemented() return
def run(self, edit, line_range=None, shell_cmd=""): try: if line_range["text_range"]: shell.filter_thru_shell( view=self.view, edit=edit, regions=get_region_by_range(self.view, line_range=line_range), cmd=shell_cmd, ) else: # TODO: Read output into output panel. # shell.run_and_wait(self.view, shell_cmd) out = shell.run_and_read(self.view, shell_cmd) output_view = self.view.window().create_output_panel("vi_out") output_view.settings().set("line_numbers", False) output_view.settings().set("gutter", False) output_view.settings().set("scroll_past_end", False) output_view = self.view.window().create_output_panel("vi_out") output_view.run_command("append", {"characters": out, "force": True, "scroll_to_end": True}) self.view.window().run_command("show_panel", {"panel": "output.vi_out"}) except NotImplementedError: ex_error.handle_not_implemented()