我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用sublime.TRANSIENT。
def run_async(self): result = None try: result = CLI(self.view).get_def() except InvalidContext: print('Invalid context') pass except Exception as e: display_unknown_error(self.view, e) return print(result) if not result or not result.get('path'): return sublime.active_window().open_file( result['path'] + ':' + str(result['line']) + ':' + str(result['start']), sublime.ENCODED_POSITION | sublime.TRANSIENT )
def show_preview(self, index): node = self.nodes[index] self.window.open_file("%s:%i" % (node["file"], node["line"]), sublime.ENCODED_POSITION | sublime.TRANSIENT)
def show_preview(self, index): if index >= 0: file_path = self.files[index] sublime.active_window().open_file(file_path, sublime.TRANSIENT)
def show_preview(self, index): if index >= 0: file_path = os.path.join(INFOS.addon.media_path, self.files[index]) sublime.active_window().open_file(file_path, sublime.TRANSIENT)
def open_in_transient(self, index): if self.no_browser_action is False and index < 2: return if not os.path.isfile(os.path.join(self.browser.path, self.browser.items[index])): return self.window.open_file(os.path.join(self.browser.path, self.browser.items[index]), sublime.TRANSIENT)
def open_usage(view, usage, is_transient = False): view = view.window().open_file(usage['path'], is_transient and sublime.TRANSIENT or 0) if view.is_loading(): open_callbacks.append({ 'view': view, 'callback': lambda view, cb: show_usage(view, usage, is_transient) }) else: show_usage(view, usage, is_transient)
def jump(self, transient: bool=False) -> None: """Jump to the selection """ flags = sublime.ENCODED_POSITION if transient is True: flags |= sublime.TRANSIENT get_jump_history_for_view(self.view).push_selection(self.view) sublime.active_window().open_file(self.position, flags) if not transient: self._toggle_indicator()
def _jump(self, filename: Union[int, str], lineno: int =None, columno: int =None, transient: bool =False) -> None: """Jump to a window """ # process jumps from options window if type(filename) is int: if filename == -1: # restore view view = self.text.view point = self.point sublime.active_window().focus_view(view) view.show(point) if view.sel()[0] != point: view.sel().clear() view.sel().add(point) return opts = self.options[filename] if len(self.options[filename]) == 4: opts = opts[1:] filename, lineno, columno = opts flags = sublime.ENCODED_POSITION if transient: flags |= sublime.TRANSIENT sublime.active_window().open_file( '{}:{}:{}'.format(filename, lineno or 0, columno or 0), flags ) self._toggle_indicator(lineno, columno)
def run(self, view, path): window = self.view.window() groups = groups_on_preview(window) window.focus_group(groups[1]) # Get directory preview view. preview_id = self.view.settings().get('preview_id') preview_view = first(window.views(), lambda v: v.id() == preview_id) if os.path.isfile(path): if preview_view : window.focus_view(preview_view) window.run_command('close_file') window.open_file(path, sublime.TRANSIENT) try : window.active_view().set_read_only(True) window.active_view().set_scratch(True) except : pass elif os.path.isdir(path): if not preview_view : show(window, path) else : show(window, path, view_id=preview_id) window.active_view().set_name("Preview: " + window.active_view().name()) self.view.settings().set('preview_id' , window.active_view().id()) window.focus_group(groups[0])
def on_highlighted(self, index): path = os.path.join(self.SNIPPETS_PATH, self.all_snippets[index]) self.window.open_file(path, sublime.TRANSIENT)