def run(self, edit, range="", shell_cmd=""): try: if range: shell.filter_thru_shell(view=self.view, regions=get_region_by_range(self.view, range), cmd=shell_cmd) else: shell.run_and_wait(shell_cmd) except NotImplementedError: ex_error.handle_not_implemented()
def run(self, edit): if sublime.platform() == 'linux': term = os.environ.get('COLORTERM') or os.environ.get("TERM") self.open_shell([term, '-e', 'bash']).wait() 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, edit): if sublime.platform() == "linux": term = os.path.expandvars("$COLORTERM") or os.path.expandvars("$TERM") self.open_shell([term, "-e", "bash"]).wait() 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, 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, range='', shell_cmd=''): try: if range: shell.filter_thru_shell(view=self.view, regions=get_region_by_range( self.view, range), cmd=shell_cmd) else: shell.run_and_wait(shell_cmd) except NotImplementedError: ex_error.handle_not_implemented()
def run(self, edit, range='.', 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, range='', name='', plusplus_args='', forced=False): target_line = self.view.line(self.view.sel()[0].begin()) if range: range = max(ex_range.calculate_range(self.view, 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(): the_shell = os.path.expandvars("$SHELL") p = subprocess.Popen([the_shell, '-c', name], stdout=subprocess.PIPE) self.view.insert(edit, s.begin(), p.communicate()[0][:-1]) 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: # Read the current buffer's contents and insert below current line. if not name: new_contents = self.view.substr( sublime.Region(0, self.view.size())) if self.view.substr(target_line.b) != '\n': new_contents = '\n' + new_contents self.view.insert(edit, target_point, new_contents) return # XXX read file "name" # we need proper filesystem autocompletion here else: ex_error.handle_not_implemented() return