我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用sublime.MONOSPACE_FONT。
def run(self): # try: # self.dirs = setting.get_browser_setting() # dirs = [] # for dir in self.dirs: # dirs.append(dir[0]) # self.window.show_quick_panel(dirs, self.panel_done,sublime.MONOSPACE_FONT) # except Exception as e: # util.show_in_panel(e) # return # def panel_done(self, picked): # if 0 > picked < len(self.dirs): # return # self.browser = self.dirs[picked][0] # self.broswer_path = self.dirs[picked][1] thread = threading.Thread(target=self.main_handle) thread.start() util.handle_thread(thread)
def run(self): try: settings = setting.load() auth_type = settings["authentication"] self.dirs = [setting.AUTHENTICATION_OAUTH2, setting.AUTHENTICATION_PASSWORD, setting.AUTHENTICATION_MAVENSMATE] show_dirs = [] for dirstr in self.dirs: if auth_type == dirstr: show_dirs.append('[?]' + dirstr) else: show_dirs.append('[X]' + dirstr) self.window.show_quick_panel(show_dirs, self.panel_done,sublime.MONOSPACE_FONT) except Exception as e: util.show_in_panel(e) return
def run(self, edit): settings = setting.load() self.settings = settings projects = settings["projects"] default_project = settings["default_project"] dirs = [] dirs_result = [] for project_key in projects.keys(): project_value = projects[project_key] if default_project == project_key: tmp = '[?]' + project_key else: tmp = '[X]' + project_key dirs.append(tmp) dirs_result.append(project_key) self.results = dirs_result window = sublime.active_window() window.show_quick_panel(dirs, self.panel_done, sublime.MONOSPACE_FONT)
def run(self, edit): # get the cursor point sel = self.view.sel()[0] # get the current scope by cursor position current_scope = self.view.scope_name(sel.begin()) # print(current_file_source) tooltip_files_arr = self.get_tooltip_files(current_scope) # get user selection sel = self.get_user_selection(sel) # do match with user selection and return the result results = self.match_selection(sel, tooltip_files_arr) # print("len results: " + str(len(results))) for result in results: # get the correct link if there is link = self.has_link(result) # edit the result in html for tooltip window html_tooltip = Utilities.result_format(result['json_result'], self.keyorder, link) self.results_arr.append(html_tooltip) names = self.get_file_names(results) # print("len results_arr: " + str(len(self.results_arr))) if len(self.results_arr) == 1: self.show_popup_with_timeout(self.results_arr[0]) elif len(self.results_arr) > 1: sublime.active_window().show_quick_panel(names, self.on_done, sublime.MONOSPACE_FONT)
def show_abbreviations(self): abbrevs = ['{0} --> {1}'.format(item['trigger'], item['contents']) for item in abbrev.Store().get_all()] self.window.show_quick_panel(abbrevs, None, flags=MONOSPACE_FONT) # https://vimhelp.appspot.com/map.txt.html#:unabbreviate
def run(self, command_line): def show_lines(line_count): lines_display = '... [+{0}]'.format(line_count - 1) return lines_display if line_count > 1 else '' parsed = parse_command_line(command_line) # FIXME # noqa: F841 # TODO: implement arguments. pairs = [(k, v) for (k, v) in self.state.registers.to_dict().items() if v] pairs = [(k, repr(v[0]), len(v)) for (k, v) in pairs] pairs = ['"{0} {1} {2}'.format(k, v, show_lines(lines)) for (k, v, lines) in pairs] self.window.show_quick_panel(pairs, self.on_done, flags=MONOSPACE_FONT)
def show_matches(self, items): self.view.window().show_quick_panel(items, self.replace, MONOSPACE_FONT)
def show_quick_panel(self, items, on_done=None, font=sublime.MONOSPACE_FONT): self.defer_sync(lambda: self.window.show_quick_panel(items, on_done, font))
def run(self): settings = setting.load() self.settings = settings projects = settings["projects"] dirs = [] for project_key in projects.keys(): project_value = projects[project_key] dirs.append(project_key) self.results = dirs self.window.show_quick_panel(dirs, self.panel_done, sublime.MONOSPACE_FONT)
def run(self): try: self.sf = util.sf_login() self.settings = self.sf.settings dirs = [] self.results = [] for x in self.sf.describe()["sobjects"]: # dirs.append([util.xstr(x["name"]), util.xstr(x["label"])]) dirs.append(util.xstr(x["name"])+' : '+util.xstr(x["label"]) +' : Export to Tab ') self.results.append(util.xstr(x["name"])) self.window.show_quick_panel(dirs, self.panel_done,sublime.MONOSPACE_FONT) except RequestException as e: util.show_in_panel("Network connection timeout when issuing REST GET request") return except SalesforceExpiredSession as e: util.show_in_dialog('session expired') util.re_auth() return except SalesforceRefusedRequest as e: util.show_in_panel('The request has been refused.') return except SalesforceError as e: err = 'Error code: %s \nError message:%s' % (e.status,e.content) util.show_in_panel(err) return except Exception as e: util.show_in_panel(e) # util.show_in_dialog('Exception Error!') return
def run(self): try: self.sf = util.sf_login() dirs = [] self.results = [] for x in self.sf.describe()["sobjects"]: # dirs.append([util.xstr(x["name"]), util.xstr(x["label"])]) dirs.append(util.xstr(x["name"])+' : '+util.xstr(x["label"])) self.results.append(util.xstr(x["name"])) # print(x) self.window.show_quick_panel(dirs, self.panel_done,sublime.MONOSPACE_FONT) except RequestException as e: util.show_in_panel("Network connection timeout when issuing REST GET request") return except SalesforceExpiredSession as e: util.show_in_dialog('session expired') util.re_auth() return except SalesforceRefusedRequest as e: util.show_in_panel('The request has been refused.') return except SalesforceError as e: err = 'Error code: %s \nError message:%s' % (e.status,e.content) util.show_in_panel(err) return except Exception as e: util.show_in_panel(e) # util.show_in_dialog('Exception Error!') return
def run(self): try: self.dirs = setting.get_browser_setting2() dirs = [] for dir in self.dirs: dirs.append(dir[0]) self.window.show_quick_panel(dirs, self.panel_done,sublime.MONOSPACE_FONT) except Exception as e: util.show_in_panel(e) return
def show_directory_selection(self): ''' Open quick selection window with paths ''' self.view.window().show_quick_panel( # pylint: disable=no-member self.paths, self.open_selected_direcotory, sublime.MONOSPACE_FONT )
def run(self, edit): """Show all errors available in this view. This function shows all errors that are available from within a view. Note that the errors can be from different files. """ if not Tools.is_valid_view(self.view): return config_manager = EasyClangComplete.view_config_manager if not config_manager: log.error("No ViewConfigManager available.") return config = config_manager.get_from_cache(self.view) log.debug("config: %s", config) if not config: log.error("No ViewConfig for view: %s.", self.view.buffer_id()) return if not config.completer: log.error("No Completer for view: %s.", self.view.buffer_id()) handler = QuickPanelHandler(self.view, config.completer.latest_errors) start_idx = 0 self.view.window().show_quick_panel( handler.items_to_show(), handler.on_done, sublime.MONOSPACE_FONT, start_idx, handler.on_highlighted) print(config.completer.latest_errors)
def show_abbreviations(self): abbrevs = ['{0} --> {1}'.format(item['trigger'], item['contents']) for item in abbrev.Store().get_all()] self.window.show_quick_panel(abbrevs, None, # Simply show the list. flags=sublime.MONOSPACE_FONT)
def run(self, command_line): def show_lines(line_count): lines_display = '... [+{0}]'.format(line_count - 1) return lines_display if line_count > 1 else '' parsed = parse_command_line(command_line) # TODO: implement arguments. pairs = [(k, v) for (k, v) in self.state.registers.to_dict().items() if v] pairs = [(k, repr(v[0]), len(v)) for (k, v) in pairs] pairs = ['"{0} {1} {2}'.format(k, v, show_lines(lines)) for (k, v, lines) in pairs] self.window.show_quick_panel(pairs, self.on_done, flags=sublime.MONOSPACE_FONT)
def show_matches(self, items): self.view.window().show_quick_panel(items, self.replace, sublime.MONOSPACE_FONT)
def run(self, edit): self.selection = self.view.sel() self.pos = self.view.sel()[0] if self.view.sel()[0].a == self.view.sel()[0].b: self.view.run_command("expand_selection", {"to": "word"}) phrase = self.view.substr(self.selection[0]).lower() if not phrase: return # nothing selected try: word2vec_rst = word2vec_topn_outproc(self.word2vec_port, phrase, self.topn) except URLError: print('FancyWord: word2vec-api server is not reachable') print('FancyWord: Will start word2vec-api server') word2vec_rst = [] wordnet_rst = wordnet_topn(phrase, self.topn, self.lang) self.suggestions = [] self.index_suggestions = [] if word2vec_rst: self.index_suggestions += ['{}: {}'.format(idx + 1, sug) + (''.join( [' ' * 4, '=' * 4, ' Word2Vec results:']) if idx == 0 else '') for idx, sug in enumerate(word2vec_rst)] self.suggestions += word2vec_rst len_word2vec_sug = len(word2vec_rst) if wordnet_rst: self.index_suggestions += ['{}: {}'.format(idx + len_word2vec_sug + 1, sug) + (''.join( [' ' * 4, '=' * 4, ' Wordnet results:']) if idx == 0 else '') for idx, sug in enumerate(wordnet_rst)] self.suggestions += wordnet_rst if self.suggestions: self.view.window().show_quick_panel(self.index_suggestions, self.on_done, sublime.MONOSPACE_FONT) else: sublime.status_message( "FancyWord: can't find similar words for {}!".format(phrase)) self.on_done(-1)
def run(self, edit): s = sublime.load_settings('phpfmt.sublime-settings') php_bin = s.get("php_bin", "php") formatter_path = os.path.join(dirname(realpath(sublime.packages_path())), "Packages", "phpfmt", "fmt.phar") cmd_passes = [php_bin,formatter_path,'--list-simple']; print_debug(cmd_passes) if os.name == 'nt': startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW p = subprocess.Popen(cmd_passes, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, startupinfo=startupinfo) else: p = subprocess.Popen(cmd_passes, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) out, err = p.communicate() descriptions = out.decode("utf-8").strip().split(os.linesep) def on_done(i): if i >= 0 : s = sublime.load_settings('phpfmt.sublime-settings') passes = s.get('passes', []) chosenPass = descriptions[i].split(' ') option = chosenPass[0] passDesc = option if option in passes: passes.remove(option) msg = "phpfmt: "+passDesc+" disabled" print_debug(msg) sublime.status_message(msg) else: passes.append(option) msg = "phpfmt: "+passDesc+" enabled" print_debug(msg) sublime.status_message(msg) s.set('passes', passes) sublime.save_settings('phpfmt.sublime-settings') self.view.window().show_quick_panel(descriptions, on_done, sublime.MONOSPACE_FONT)
def run(self, edit): s = sublime.load_settings('phpfmt.sublime-settings') php_bin = s.get("php_bin", "php") formatter_path = os.path.join(dirname(realpath(sublime.packages_path())), "Packages", "phpfmt", "fmt.phar") cmd_passes = [php_bin,formatter_path,'--list-simple']; print_debug(cmd_passes) if os.name == 'nt': startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW p = subprocess.Popen(cmd_passes, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, startupinfo=startupinfo) else: p = subprocess.Popen(cmd_passes, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) out, err = p.communicate() descriptions = out.decode("utf-8").strip().split(os.linesep) def on_done(i): if i >= 0 : s = sublime.load_settings('phpfmt.sublime-settings') excludes = s.get('excludes', []) chosenPass = descriptions[i].split(' ') option = chosenPass[0] passDesc = option if option in excludes: excludes.remove(option) msg = "phpfmt: "+passDesc+" disabled" print_debug(msg) sublime.status_message(msg) else: excludes.append(option) msg = "phpfmt: "+passDesc+" enabled" print_debug(msg) sublime.status_message(msg) s.set('excludes', excludes) sublime.save_settings('phpfmt.sublime-settings') self.view.window().show_quick_panel(descriptions, on_done, sublime.MONOSPACE_FONT)
def run(self, edit): if CURRENT_VERSION: # get the cursor point sel = self.selEvent if self.selEvent != None else self.view.sel()[0].begin() # get the current scope of cursor position current_scope = self.view.scope_name(sel) # update scope in status bar sublime.status_message("scope: %s" % current_scope) # get user selection in string sel = self.get_user_selection(sel) tooltip_files_arr = self.get_tooltip_files(current_scope) # do match with user selection and return the result results = self.match_selection(sel, tooltip_files_arr, current_scope) for result in results: # get the correct link if there is link = self.has_link(result) location = "" file_name = "" if 'location' in result: location = result['location'] file_name = result['file_name'] html_tooltip = Utilities.result_format(result['json_result'], self.keyorder, link, self.style, location, file_name) else: html_tooltip = Utilities.result_format(result['json_result'], self.keyorder, link, self.style) # edit the result in html for tooltip window self.results_arr.append(html_tooltip) # this names will be in the output panel names = self.get_file_names(results) # write logging to logger file if self.has_debug: print(self.logger_msg) num_of_results = len(self.results_arr) if num_of_results == 1: self.show_tooltip_popup(self.results_arr[0]) elif num_of_results > 1: if self.last_choosen_fun != sel: self.last_index = 0 self.last_choosen_fun = sel sublime.active_window().show_quick_panel(names, self.on_done, sublime.MONOSPACE_FONT, self.last_index) else: print("documentation not exist") # self.show_tooltip_popup("documentation not exist") # <doc> # des: pp # </doc>