我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用sublime.KEEP_OPEN_ON_FOCUS_LOST。
def run(self, edit, languageName=None, set_fallback=False, is_init=False): view = self.view global currentView currentView = view if self.downloading: sublime.message_dialog('Another progress is working for checkout ' + self.downloading + '. Please try again later.') return self.languageList, index = getLanguageList(languageName) self.set_fallback = set_fallback if languageName: self.updateLanguage(index) else: currentView.window().show_quick_panel(self.languageList, self.updateLanguage, sublime.KEEP_OPEN_ON_FOCUS_LOST)
def choose_layout(self): def on_done(index): if index >= 0: layout = files[index] self.load_layout_from_file(layout) elif self.preview: if index == -1: self.layout_from_json(self.temp_layout, mode="layout") def on_highlight(index): if self.preview: if index >= 0: self.collapse_layout() layout = files[index] self.layout_preview(layout) # build layouts list path = layouts_path() files = [] for entry in os.listdir(path): if os.path.isfile(os.path.join(path, entry)): # remove .layout extension from filename entry = entry[0:(len(entry) - 7)] files.append(entry) self.window.show_quick_panel( files, on_done, sublime.KEEP_OPEN_ON_FOCUS_LOST, 0, on_highlight)
def browsing_on_done(self, index=None): if index == -1: return self.input_on_cancel() if self.no_browser_action is False and index == 0: # create from the position in the browser self.create_from = self.browser.path self.path_to_create_choosed_from_browsing = True if self.browser_action.get('func', None) is None: return self.create_input() else: return self.browser_action['func'](self.create_from, None) elif (self.no_browser_action is True and index == 0) or ( index == 1 and self.no_browser_action is False): self.browser.path = os.path.normpath( os.path.join(self.browser.path, '..')) elif index is not None: self.browser.path = os.path.join(self.browser.path, self.browser.items[index]) if os.path.isfile(self.browser.path): set_status(self.view, self.STATUS_KEY, '') return self.window.open_file(self.browser.path) folders, files = [], [] for item in os.listdir(self.browser.path): if os.path.isdir(os.path.join(self.browser.path, item)): folders.append(item + '/') else: files.append(item) if self.no_browser_action: self.browser.items = ['[cmd] ..'] + folders + files elif self.browser_action.get('title', None) is not None: self.browser.items = [ '[cmd] ' + self.browser_action['title'], '[cmd] ..' ] + folders + files else: self.browser.items = ['[cmd] Create from here', '[cmd] ..' ] + folders + files set_status(self.view, self.STATUS_KEY, 'Browsing at: {0}'.format(user_friendly(self.browser.path))) if self.browser_index is not None: index = self.browser_index elif self.no_browser_action: index = 1 else: index = 2 self.window.show_quick_panel(self.browser.items, self.browsing_on_done, sublime.KEEP_OPEN_ON_FOCUS_LOST, index, self.open_in_transient)
def run(self, with_confirmation=True): build_folder = sublime.expand_variables( self.window.project_data()["settings"]["cmake"]["build_folder"], self.window.extract_variables()) files_to_remove = [] dirs_to_remove = [] cmakefiles_dir = os.path.join(build_folder, 'CMakeFiles') if os.path.exists(cmakefiles_dir): for root, dirs, files in os.walk(cmakefiles_dir, topdown=False): files_to_remove.extend([os.path.join(root, name) for name in files]) dirs_to_remove.extend([os.path.join(root, name) for name in dirs]) dirs_to_remove.append(cmakefiles_dir) def append_file_to_remove(relative_name): abs_path = os.path.join(build_folder, relative_name) if os.path.exists(abs_path): files_to_remove.append(abs_path) for file in TRY_TO_REMOVE: append_file_to_remove(file) if not with_confirmation: self.remove(files_to_remove, dirs_to_remove) return panel = self.window.create_output_panel('files_to_be_deleted') self.window.run_command('show_panel', {'panel': 'output.files_to_be_deleted'}) panel.run_command('insert', {'characters': 'Files to remove:\n' + '\n'.join(files_to_remove + dirs_to_remove)}) def on_done(selected): if selected != 0: return self.remove(files_to_remove, dirs_to_remove) panel.run_command('append', {'characters': '\nCleared CMake cache files!', 'scroll_to_end': True}) self.window.show_quick_panel(['Do it', 'Cancel'], on_done, sublime.KEEP_OPEN_ON_FOCUS_LOST)
def run(self, edit, *args, **kwargs): self.window = self.view.window() self.selection = sublime.Selection(self.view.id()) self.settings = self.view.settings() group_index, view_index = self.window.get_view_index(self.view) error = True def build(view): main_group_index, main_view_index = self.window.get_view_index(view) view_to_focus = None if main_group_index != group_index: view_to_focus = self.window.active_view_in_group(main_group_index) self.window.focus_view(view) self.window.run_command('build') if view_to_focus is not None: self.window.focus_view(view_to_focus) self.window.focus_view(self.view) if self.can_be_run(self.view): build(self.view) return for view in self.window.views(): if self.can_be_run(view): build(view) error = False return if error is True: self.window.show_quick_panel( [ [ 'Error: no "_main.py" is open.', 'The plugin won\'t do anything.' ], [ 'Forget it buddy, run this file', self.view.file_name() ], ], self.on_done, sublime.KEEP_OPEN_ON_FOCUS_LOST, 1)