Python sublime 模块,DRAW_SQUIGGLY_UNDERLINE 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用sublime.DRAW_SQUIGGLY_UNDERLINE

项目:gissues    作者:divinites    | 项目源码 | 文件源码
def highlight(view, flags_dict):
    content = view.substr(sublime.Region(0, view.size()))
    target_regions = []
    for word, value in flags_dict.items():
        if value:
            begin = content.find(word)
            if begin == -1:
                raise Exception("Cannot find the targe word!")
            end = begin + len(word)
            target_regions.append(sublime.Region(begin, end))
    view.add_regions("indicator", target_regions, "text", "dot",
                     sublime.DRAW_SQUIGGLY_UNDERLINE)


# def push_cursor(view, point):
#     new_cursor_position = point.a + 1
#     view.sel().clear()
#     view.sel().add(
#         sublime.Region(new_cursor_position,
#                        new_cursor_position))
项目:SubVale    作者:ValeLint    | 项目源码 | 文件源码
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
项目:DXMate    作者:jtowers    | 项目源码 | 文件源码
def update_diagnostics_regions(view: sublime.View, diagnostics: 'List[Diagnostic]', severity: int):
    region_name = "lsp_" + format_severity(severity)
    if show_diagnostics_phantoms and not view.is_dirty():
        regions = None
    else:
        regions = list(diagnostic.range.to_region(view) for diagnostic in diagnostics
                       if diagnostic.severity == severity)
    if regions:
        scope_name = diagnostic_severity_scopes[severity]
        view.add_regions(region_name, regions, scope_name, "dot",
                         sublime.DRAW_SQUIGGLY_UNDERLINE | UNDERLINE_FLAGS)
    else:
        view.erase_regions(region_name)
项目:gissues    作者:divinites    | 项目源码 | 文件源码
def on_selection_modified_async(self, view):
        if view.settings().get('list_flag'):
            view.add_regions('selected', [view.full_line(view.sel()[0])],
                             "text.issue.list", "dot",
                             sublime.DRAW_SQUIGGLY_UNDERLINE)
项目:sublime-solium-gutter    作者:sey    | 项目源码 | 文件源码
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)
项目:chains    作者:hc-12    | 项目源码 | 文件源码
def run(self, edit):

        today = datetime.date.today()
        month_name = calendar.month_name[today.month]
        # find line that match month and day in same line
        m_regex = (r"^\s+{month}\:.+[\s\.]{day}[{norm_sym}{done_sym}].*$"
                   .format(month=month_name,
                           day=today.day,
                           norm_sym=NORMAL_SYMBOL,
                           done_sym=DONE_SYMBOL))

        found_region = self.view.find(m_regex, 0)

        if found_region != NOT_FOUND:
            line_r = self.view.line(found_region)
            line = self.view.substr(line_r)
            day_format = get_weekday_format(today.year, today.month, today.day)
            with_symbol = ("{day}{done_sym} "
                           .format(day=day_format.rstrip(' '),
                                   done_sym=DONE_SYMBOL))

            if with_symbol in line:
                day_str = with_symbol
                scope = "today.done.chain"
            else:
                day_str = day_format
                scope = "today.chain"

            start_i = found_region.begin() + line.index(day_str)
            end_i = start_i + len(day_str)
            # highlight region, reversed start/end
            # so that the cursor starts from the beginning
            # regions.add(sublime.Region(end_i, start_i))
            self.view.erase_regions(TODAY_KEY)
            regions = [sublime.Region(end_i, start_i)]
            self.view.add_regions(
                TODAY_KEY,
                regions,
                scope,
                "dot",
                sublime.DRAW_SQUIGGLY_UNDERLINE
            )
项目:sublimeTextConfig    作者:luoye-fe    | 项目源码 | 文件源码
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)
项目:sublime-flowtype    作者:Pegase745    | 项目源码 | 文件源码
def handle_process(self, returncode, stdout, error):
        """Handle the output from the threaded process."""
        self.view.erase_regions('flow_type_uncovered')

        if type(error) is bytes:
            error = error.decode('utf-8')

        if returncode != 0:
            logger.logger.error('coverage %s' % error)
            return

        logger.logger.debug(stdout)

        if stdout:
            expressions = stdout['expressions']
            covered = expressions['covered_count']
            uncovered = expressions['uncovered_count']
            uncovered_locs = expressions['uncovered_locs']
            total = covered + uncovered
            percentage = (covered * 100.0) / total

            self.view.set_status(
                'flow_type',
                'Flow: {}% coverage with {}/{} uncovered lines'
                .format(round(percentage, 2), uncovered, covered))

            if len(uncovered_locs) > 0:
                # Uncovered regions
                regions = []
                for location in uncovered_locs:
                    row_start = int(location['start']['line']) - 1
                    col_start = int(location['start']['column']) - 1
                    row_end = int(location['end']['line']) - 1
                    col_end = int(location['end']['column'])

                    start = self.view.text_point(row_start, col_start)
                    stop = self.view.text_point(row_end, col_end)

                    regions.append(sublime.Region(start, stop))

                self.view.add_regions(
                    'flow_type_uncovered',
                    regions, 'comment', 'bookmark',
                    sublime.DRAW_SQUIGGLY_UNDERLINE
                )

        else:
            self.view.set_status('flow_type', 'Flow: coverage is not possible')