我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用sublime.DRAW_SOLID_UNDERLINE。
def _postprocess_help(view): """ Perform post processing on a loaded help view to do any transformations needed on the help content before control is handed back to the user to interact with it. """ _postprocess_header(view) # Underlink all links. # TODO: Populate via a setting only? view.add_regions("_hh_link", view.find_by_selector("meta.link"), "storage", flags=sublime.DRAW_SOLID_UNDERLINE|sublime.DRAW_NO_FILL|sublime.DRAW_NO_OUTLINE)
def get_draw_style(self): """Get the region styling. """ underlined = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE style = self.get('vale_alert_style') if style == 'solid_underline': return sublime.DRAW_SOLID_UNDERLINE | underlined elif style == 'stippled_underline': return sublime.DRAW_STIPPLED_UNDERLINE | underlined elif style == 'squiggly_underline': return sublime.DRAW_SQUIGGLY_UNDERLINE | underlined return sublime.DRAW_OUTLINED
def update_icons(view): file = view.file_name() modules = [] installed = [] other = [] result = [] if file not in data: view.run_command('npm_install', {'action': 'initial'}) else: modules = data[file] for region in view.find_all(MODULE): m = re.search(MODULE, view.substr(region)) a, b = m.span(1) module = m.group(1) reg = Region(a + region.begin(), b + region.begin()) if module in modules or module in CORE: installed.append(reg) else: other.append(reg) result.append(module) flags = sublime.HIDE_ON_MINIMAP | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE view.add_regions('require-on', installed, 'request', ICON % 'on', flags) view.add_regions('require-off', other, 'request', ICON % 'off', flags) return result
def draw_t1(self, edit, view, item, indent): created = item.get('created_utc', None) if created is not None: created = datetime.datetime.fromtimestamp( created).strftime('%A, %d. %B %Y %I:%M%p') title_start = view.size() view.insert(edit, view.size(), '%s# [%d] [%s] %s' % ( indent[2:], item.get('score', 0), item.get('author', ''), created)) title_end = view.size() view.insert(edit, view.size(), '\n\n') view.add_regions( 'thread-%s-title' % (item.get('id', '')), [sublime.Region(title_start, title_end)], 'thread-title', 'dot', flags=sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE ) content = wrap(unescape(item.get('body', '')).strip(), indent) content_start = view.size() view.insert(edit, view.size(), content) content_end = view.size() - 1 view.insert(edit, view.size(), '\n\n') view.add_regions( 'thread-%s-body' % item.get('id', ''), [sublime.Region(content_start, content_end)], 'thread-body', flags=sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.HIDE_ON_MINIMAP ) replies = item.get('replies', {}) if isinstance(replies, dict): for child in replies.get('data', {}).get('children', []): self.draw_item(edit, view, child, indent + ' ')
def draw_t3(self, edit, view, item, indent): title_start = view.size() view.insert(edit, view.size(), '# [%s] [%5d] %s' % ( item.get('id', ''), item.get('score', 0), item.get('title', '???'))) title_end = view.size() view.insert(edit, view.size(), '\n\n') view.add_regions( 'thread-%s-title' % (item.get('id', '')), [sublime.Region(title_start, title_end)], 'thread-title', 'bookmark', flags=sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE ) content = wrap(unescape(item.get('selftext', '')).strip(), indent) content_start = view.size() view.insert(edit, view.size(), content) content_end = view.size() - 1 view.insert(edit, view.size(), '\n\n') view.add_regions( 'thread-%s-body' % item.get('id', ''), [sublime.Region(content_start, content_end)], 'thread-body', flags=sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.HIDE_ON_MINIMAP )
def plugin_loaded(): # Is there a way to get a reference to the plugin instance here? # It would be nice to avoid having to use the global user_whitelist variable. HighlightDodgyChars.getSettings() class HighlightDodgyChars(sublime_plugin.EventListener): def getSettings(): global users_whitelist settings = sublime.load_settings('HighlightDodgyChars.sublime-settings') users_whitelist = settings.get('whitelist_chars') if isinstance(users_whitelist, list): users_whitelist = ''.join(users_whitelist) if users_whitelist is None: users_whitelist = '' # for some reason the sublime.IGNORECASE -flag did not work so lets # duplicate the chars as lower and upper :( users_whitelist += users_whitelist.upper() def on_modified_async(self, view): self.highlight(view) def on_load_async(self, view): # load highlights as soon as the file is opened self.highlight(view) def highlight(self, view): highlights = [] whitelist = u'\n\u0009' # allow newline, forward-tick and tabulator # search for non-ascii characters that are not on the whitelist needle = '[^\x00-\x7F'+whitelist+users_whitelist+']' # search the view for pos in view.find_all(needle): highlights.append(pos) # if something dodgy was found, highlight the dodgy parts if highlights: view.add_regions('zero-width-and-bad-chars', highlights, 'invalid', '', sublime.DRAW_SOLID_UNDERLINE) else: view.erase_regions('zero-width-and-bad-chars')
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 on_post_text_command(self, view, command_name, args): window = view.window() env = Env.For(window) if not env or view != env.terminal: # Not a console window - nothing to do return selected_line = view.substr(view.line(view.sel()[0])) cp_error_pattern = re.compile(self.CLICKABLE_CP_ERROR_PATTERN) rt_error_pattern = re.compile(self.CLICKABLE_RT_ERROR_PATTERN) orig_file = None orig_line = None cp_match = cp_error_pattern.match(selected_line) if cp_match: # Compilation error message orig_file = cp_match.group(1) orig_line = int(cp_match.group(2)) - 1 else: rt_match = rt_error_pattern.match(selected_line) if rt_match: # Runtime error message orig_file = rt_match.group(1) orig_line = int(rt_match.group(2)) - 1 log_debug("Selected line: " + selected_line + ", original file name: " + str(orig_file) + " orig_line: " + str(orig_line)) if orig_file is not None and orig_line is not None: source_dir = os.path.join(os.path.dirname(window.project_file_name()), PR_SOURCE_DIRECTORY) file_name = os.path.join(source_dir, orig_file) if not os.path.exists(file_name): return file_view = window.open_file(file_name) def select_region(): if file_view.is_loading(): sublime.set_timeout_async(select_region, 0) return # First, erase all previous error marks file_view.erase_regions(PL_ERROR_REGION_KEY) # Create a new error mark pt = file_view.text_point(orig_line, 0) error_region = sublime.Region(pt) file_view.add_regions(PL_ERROR_REGION_KEY, [error_region], scope="keyword", icon="circle", flags=sublime.DRAW_SOLID_UNDERLINE) file_view.show(error_region) attempt = 0 max_attempts = 3 while attempt < max_attempts: attempt += 1 sublime.set_timeout(select_region, 100) if not file_view.is_loading(): break