我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用sublime.DRAW_OUTLINED。
def update_view(self): self.clear() output = "" line = 0 dirtylist = [] for local in self.variables: output, line = local.format(line=line, dirty=dirtylist) self.add_line(output) self.update() regions = [] v = self.get_view() for dirty in dirtylist: regions.append(v.full_line(v.text_point(dirty.line, 0))) v.add_regions("sublimegdb.dirtyvariables", regions, get_setting("changed_variable_scope", "entity.name.class"), get_setting("changed_variable_icon", ""), sublime.DRAW_OUTLINED)
def run(self, edit, text, search_string): start_point = self.view.size() self.view.insert(edit, start_point, text) if search_string is not None: regions = self.view.find_all(search_string, sublime.LITERAL | sublime.IGNORECASE) self.view.add_regions('whoosh_regions', regions[1:], "text.find-in-files", "", sublime.DRAW_OUTLINED)
def _draw_regions(view, errs): regions = [view.full_line(view.text_point(tbck['line'] - 1, 0)) for tbck in errs] view.add_regions(REGIONS_MARKER, regions, REGIONS_STYLE, REGIONS_ICON, sublime.DRAW_OUTLINED)
def add_regions(self, regions): package_name = (PLUGIN_FOLDER.split(os.path.sep))[-1] if int(sublime.version()) >= 3000: icon = "Packages/" + package_name + "/warning.png" self.view.add_regions("solium_errors", regions, "keyword", icon, sublime.DRAW_EMPTY | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SQUIGGLY_UNDERLINE) else: icon = ".." + os.path.sep + package_name + os.path.sep + "warning" self.view.add_regions("solium_errors", regions, "keyword", icon, sublime.DRAW_EMPTY | sublime.DRAW_OUTLINED)
def ignoreProblem(p, v, self, edit): # change region associated with this problem to a 0-length region r = v.get_regions(p['regionKey'])[0] dummyRg = sublime.Region(r.a, r.a) v.add_regions(p['regionKey'], [dummyRg], hscope, "", sublime.DRAW_OUTLINED) # dummy edit to enable undoing ignore v.insert(edit, v.size(), "")
def recompHighlights(view): global problems for p in problems: rL = view.get_regions(p['regionKey']) if rL: regionScope = "" if problemSolved(view, p) else hscope view.add_regions(p['regionKey'], rL, regionScope, "", sublime.DRAW_OUTLINED)
def update_values(self): if not self.should_update(): return dirtylist = [] if self.values is None: names = self.get_names() vals = self.get_values() self.values = [] for i in range(len(vals)): idx = int(vals[i]["number"]) self.values.append(GDBRegister(names[idx], idx, vals[i]["value"])) else: dirtylist = regs = parse_result_line(run_cmd("-data-list-changed-registers", True))["changed-registers"] regvals = parse_result_line(run_cmd("-data-list-register-values x %s" % " ".join(regs), True))["register-values"] for i in range(len(regs)): reg = int(regvals[i]["number"]) if reg < len(self.values): self.values[reg].set_value(regvals[i]["value"]) pos = self.get_view().viewport_position() self.clear() line = 0 for item in self.values: output, line = item.format(line) self.add_line(output) self.set_viewport_position(pos) self.update() regions = [] v = self.get_view() for dirty in dirtylist: i = int(dirty) if i >= len(self.values): continue region = v.full_line(v.text_point(self.values[i].line, 0)) if self.values[i].lines > 1: region = region.cover(v.full_line(v.text_point(self.values[i].line + self.values[i].lines - 1, 0))) regions.append(region) v.add_regions("sublimegdb.dirtyregisters", regions, get_setting("changed_variable_scope", "entity.name.class"), get_setting("changed_variable_icon", ""), sublime.DRAW_OUTLINED)
def add_lint_marks(view, lines, **errors): """Adds lint marks to view on the given lines. """ erase_lint_marks(view) types = { 'warning': errors['warning_underlines'], 'illegal': errors['error_underlines'], 'violation': errors['violation_underlines'], } style = get_settings(view, 'anaconda_linter_mark_style', 'outline') show_underlines = get_settings(view, 'anaconda_linter_underlines', True) if show_underlines: for type_name, underlines in types.items(): if len(underlines) > 0: view.add_regions( 'anaconda-lint-underline-{}'.format(type_name), underlines, 'anaconda.underline.{}'.format(type_name), flags=sublime.DRAW_EMPTY_AS_OVERWRITE ) if len(lines) > 0: outline_style = { 'solid_underline': sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE, 'stippled_underline': sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_STIPPLED_UNDERLINE, 'squiggly_underline': sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SQUIGGLY_UNDERLINE, 'outline': sublime.DRAW_OUTLINED, 'none': sublime.HIDDEN, 'fill': None } gutter_theme = get_settings( view, 'anaconda_gutter_theme', 'basic').lower() package_name = os.path.dirname(__file__).rsplit(os.path.sep, 3)[1] ico_path = ( 'Packages/' + package_name + '/anaconda_lib/linting/' 'gutter_mark_themes/{theme}-{type}.png' ) for lint_type, lints in get_outlines(view).items(): if len(lints) > 0: if get_settings(view, 'anaconda_gutter_marks', False): if gutter_theme == 'basic': gutter_marks = marks[lint_type] else: gutter_marks = ico_path.format(theme=gutter_theme, type=lint_type) else: gutter_marks = '' args = [ 'anaconda-lint-outlines-{}'.format(lint_type), lints, 'anaconda.outline.{}'.format(lint_type), gutter_marks ] draw_style = outline_style.get(style, sublime.DRAW_OUTLINED) if draw_style is not None: args.append(draw_style) view.add_regions(*args)
def run(self, edit, forceServer = None): global problems global displayMode global ignored global hscope v = self.view settings = sublime.load_settings(lt_settings_file) server = getServer(settings, forceServer) displayMode = settings.get('display_mode', 'statusbar') hscope = settings.get("highlight-scope", "comment") ignored = loadIgnoredRules() strText = v.substr(sublime.Region(0, v.size())) checkRegion = v.sel()[0] if checkRegion.empty(): checkRegion = sublime.Region(0, v.size()) v.run_command("clear_language_problems") lang = getLanguage(v) ignoredIDs = [rule['id'] for rule in ignored] matches = LTServer.getResponse(server, strText, lang, ignoredIDs) if matches == None: setStatusBar('could not parse server response (may be due to quota if using http://languagetool.org)') return for match in matches: problem = { 'category': match['rule']['category']['name'], 'message': match['message'], 'replacements': [r['value'] for r in match['replacements']], 'rule' : match['rule']['id'], 'urls' : [w['value'] for w in match['rule'].get('urls', [])], } offset = match['offset'] length = match['length'] region = sublime.Region(offset, offset + length) if not checkRegion.contains(region): continue ignored_scopes = settings.get('ignored-scopes', []) # view.scope_name() returns a string of space-separated scope names # (ending with a space) pscopes = v.scope_name(region.a).split(' ')[0:-1] for ps in pscopes: if any([fnmatch.fnmatch(ps, i) for i in ignored_scopes]): ignored = True break else: # none of this region's scopes are ignored regionKey = str(len(problems)) v.add_regions(regionKey, [region], hscope, "", sublime.DRAW_OUTLINED) problem['orgContent'] = v.substr(region) problem['regionKey'] = regionKey problems.append(problem) if problems: selectProblem(v, problems[0]) else: setStatusBar("no language problems were found :-)")