def run(self, edit): if sublime.platform() == 'linux': term = self.view.settings().get('vintageex_linux_terminal') term = term or os.environ.get('COLORTERM') or os.environ.get("TERM") if not term: sublime.status_message("VintageEx: Not terminal name found.") return try: self.open_shell([term, '-e', 'bash']).wait() except Exception as e: print e sublime.status_message("VintageEx: Error while executing command through shell.") return elif sublime.platform() == 'osx': term = self.view.settings().get('vintageex_osx_terminal') term = term or os.environ.get('COLORTERM') or os.environ.get("TERM") if not term: sublime.status_message("VintageEx: Not terminal name found.") return try: self.open_shell([term, '-e', 'bash']).wait() except Exception as e: print e sublime.status_message("VintageEx: 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, 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( "VintageEx: 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( "VintageEx: Error while executing command through shell." ) return 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
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, 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( "VintageEx: 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( "VintageEx: Error while executing command through shell." ) return 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: # 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, 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("VintageEx: 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("VintageEx: Error while executing command through shell.") return 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
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): if sublime.platform() == "linux": term = self.view.settings().get("vintageex_linux_terminal") term = term or os.environ.get("COLORTERM") or os.environ.get("TERM") if not term: sublime.status_message("VintageEx: Not terminal name found.") return try: self.open_shell([term, "-e", "bash"]).wait() except Exception as e: print e sublime.status_message("VintageEx: 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, 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("VintageEx: 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("VintageEx: Error while executing command through shell.") return 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: # 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