Python sublime.DRAW_SQUIGGLY_UNDERLINE Examples

The following are 7 code examples of sublime.DRAW_SQUIGGLY_UNDERLINE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sublime , or try the search function .
Example #1
Source File: Completion.py    From YcmdCompletion with MIT License 6 votes vote down vote up
def highlight_problems(self, view, problems):
        view.erase_regions('clang-code-errors')
        view_id = view.id()
        view_cache = {}
        regions = []
        for problem in problems:
            lineno = problem['location']['line_num']
            colno = problem['location']['column_num']
            line_regions = view_cache.setdefault(lineno - 1, {})
            message = ERROR_MESSAGE_TEMPLATE.format(**problem)
            print(PRINT_ERROR_MESSAGE_TEMPLATE.format(message, lineno, colno))
            region = view.word(view.text_point(lineno - 1, colno - 1))
            regions.append(region)
            line_regions[(region.a, region.b)] = message
        self.view_cache[view_id] = view_cache
        style = (sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE |
                 sublime.DRAW_SQUIGGLY_UNDERLINE)
        view.add_regions(
            'clang-code-errors', regions, 'invalid', ERROR_MARKER_IMG, style) 
Example #2
Source File: build_results.py    From Fuse.SublimePlugin with MIT License 5 votes vote down vote up
def append(self, data):
		view = self.buildResultPanel
		view.run_command("append", {"characters": data})

		codePoints = view.find_by_selector("constant.numeric.line-number.match.find-in-files")
		lines = []
		for codePoint in codePoints:
			lines.append(view.line(codePoint))

		view.add_regions("errors", lines, "keyword", "bookmark", 
			sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.PERSISTENT | sublime.DRAW_SQUIGGLY_UNDERLINE) 
Example #3
Source File: highlights.py    From LSP with MIT License 5 votes vote down vote up
def _handle_response(self, response: Optional[List]) -> None:
        if not response:
            return
        kind2regions = {}  # type: Dict[str, List[sublime.Region]]
        for kind in range(0, 4):
            kind2regions[_kind2name[kind]] = []
        for highlight in response:
            r = range_to_region(Range.from_lsp(highlight["range"]), self.view)
            kind = highlight.get("kind", DocumentHighlightKind.Unknown)
            if kind is not None:
                kind2regions[_kind2name[kind]].append(r)
        if settings.document_highlight_style == "fill":
            flags = 0
        elif settings.document_highlight_style == "box":
            flags = sublime.DRAW_NO_FILL
        else:
            flags = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE
            if settings.document_highlight_style == "underline":
                flags |= sublime.DRAW_SOLID_UNDERLINE
            elif settings.document_highlight_style == "stippled":
                flags |= sublime.DRAW_STIPPLED_UNDERLINE
            elif settings.document_highlight_style == "squiggly":
                flags |= sublime.DRAW_SQUIGGLY_UNDERLINE

        self._clear_regions()
        for kind_str, regions in kind2regions.items():
            if regions:
                scope = settings.document_highlight_scopes.get(kind_str, None)
                if scope:
                    self.view.add_regions("lsp_highlight_{}".format(kind_str),
                                          regions, scope=scope, flags=flags) 
Example #4
Source File: highlight_problems.py    From CppYCM with MIT License 5 votes vote down vote up
def highlight_problems(self, view, problems):
        view.erase_regions('clang-code-errors')
        view_id = view.id()
        view_cache = {}
        regions = []
        # erase output panel
        self.output_panel.set_read_only(False)
        self.output_panel.run_command('select_all')
        self.output_panel.run_command('right_delete')
        for problem in problems:
            lineno = problem['location']['line_num']
            colno = problem['location']['column_num']
            line_regions = view_cache.setdefault(lineno - 1, {})
            message = MsgTemplates.ERROR_MESSAGE_TEMPLATE.format(**problem)
            problem_output = MsgTemplates.PRINT_ERROR_MESSAGE_TEMPLATE.format(
                message, lineno, colno)
            self.output_panel.run_command(
                'insert', {'characters': problem_output}
            )

            region = view.word(view.text_point(lineno - 1, colno - 1))
            regions.append(region)
            line_regions[(region.a, region.b)] = message

        self.output_panel.set_read_only(True)
        self.output_panel.run_command(
            'move_to', {'to': 'bof', 'extend': False})
        if problems:
            self.window.run_command(
                'show_panel', {'panel': self.output_panel_name})
        # self.view_cache[view_id] = view_cache
        style = (sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE |
                 sublime.DRAW_SQUIGGLY_UNDERLINE)
        view.add_regions(
            key='clang-code-errors',
            regions=regions,
            scope='invalid',
            flags=style) 
Example #5
Source File: popup_error_vis.py    From EasyClangComplete with MIT License 4 votes vote down vote up
def __init__(self, settings):
        """Initialize error visualization.

        Args:
            mark_gutter (bool): add a mark to the gutter for error regions
        """
        gutter_style = settings.gutter_style
        mark_style = settings.linter_mark_style
        self.settings = settings

        self.err_regions = {}
        if gutter_style == SettingsStorage.GUTTER_COLOR_STYLE:
            self.gutter_mark_error = PATH_TO_ICON.format(
                icon="error.png")
            self.gutter_mark_warning = PATH_TO_ICON.format(
                icon="warning.png")
        elif gutter_style == SettingsStorage.GUTTER_MONO_STYLE:
            self.gutter_mark_error = PATH_TO_ICON.format(
                icon="error_mono.png")
            self.gutter_mark_warning = PATH_TO_ICON.format(
                icon="warning_mono.png")
        elif gutter_style == SettingsStorage.GUTTER_DOT_STYLE:
            self.gutter_mark_error = PATH_TO_ICON.format(
                icon="error_dot.png")
            self.gutter_mark_warning = PATH_TO_ICON.format(
                icon="warning_dot.png")
        else:
            log.error("Unknown option for gutter_style: %s", gutter_style)
            self.gutter_mark_error = ""
            self.gutter_mark_warning = ""

        if mark_style == SettingsStorage.MARK_STYLE_OUTLINE:
            self.draw_flags = sublime.DRAW_EMPTY | sublime.DRAW_NO_FILL
        elif mark_style == SettingsStorage.MARK_STYLE_FILL:
            self.draw_flags = 0
        elif mark_style == SettingsStorage.MARK_STYLE_SOLID_UNDERLINE:
            self.draw_flags = sublime.DRAW_NO_FILL | \
                sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE
        elif mark_style == SettingsStorage.MARK_STYLE_STIPPLED_UNDERLINE:
            self.draw_flags = sublime.DRAW_NO_FILL | \
                sublime.DRAW_NO_OUTLINE | sublime.DRAW_STIPPLED_UNDERLINE
        elif mark_style == SettingsStorage.MARK_STYLE_SQUIGGLY_UNDERLINE:
            self.draw_flags = sublime.DRAW_NO_FILL | \
                sublime.DRAW_NO_OUTLINE | sublime.DRAW_SQUIGGLY_UNDERLINE
        else:
            self.draw_flags = sublime.HIDDEN 
Example #6
Source File: syntax.py    From omnisharp-sublime with MIT License 4 votes vote down vote up
def _handle_codeerrors(self, data):
        print('handling Errors')
        if data is None:
            print('no data')
            return
        
        self.data = data
        self.underlines = []
        self.warninglines = []
        self.errlines = []
        oops_map = {}

        if "QuickFixes" in self.data and self.data["QuickFixes"] != None and len(self.data["QuickFixes"]) > 0:
            self.data["QuickFixes"].sort(key = lambda a:(a['Line'],a['Column']))
            self.outputpanel.write_line("File: "+self.data["QuickFixes"][0]["FileName"]+"\n")
            suppressHidden = bool(helpers.get_settings(self.view,'omnisharp_suppresshidden'))
            for i in self.data["QuickFixes"]:
                point = self.view.text_point(i["Line"]-1, i["Column"]-1)
                reg = self.view.word(point)
                region_that_would_be_looked_up = self.view.word(reg.begin())
                if region_that_would_be_looked_up.begin() != reg.begin() or region_that_would_be_looked_up.end() != reg.end():
                    reg = sublime.Region(point, point+1)
                # self.underlines.append(reg)

                if i["LogLevel"] == "Hidden" and suppressHidden:
                    continue
                if i["LogLevel"] == "Warning" :
                    self.warninglines.append(reg)
                if i["LogLevel"] == "Error" :
                    self.errlines.append(reg)
                key = "%s,%s" % (reg.a, reg.b)
                oops_map[key] = i["Text"].strip()
                self.outputpanel.write_line(i["LogLevel"] + " : " + i["Text"].strip() + " - (" + str(i["Line"]) + ", " + str(i["Column"]) + ")")
            showErrorPanel = bool(helpers.get_settings(self.view,'omnisharp_showerrorwindows'))
            showWarningPanel = bool(helpers.get_settings(self.view,'omnisharp_showwarningwindows'))
            haveError = len(self.errlines) > 0
            if haveError:
                # print('underlines')
                self.view.settings().set("oops", oops_map)
                self.view.add_regions("oops", self.errlines, "sublimelinter.mark.error", "circle",  sublime.DRAW_NO_FILL|sublime.DRAW_NO_OUTLINE|sublime.DRAW_SOLID_UNDERLINE )
                if showErrorPanel:
                    self.view.window().run_command("show_panel", {"panel": "output.variable_get"})
            if len(self.warninglines) > 0:
                # print('underlines')
                self.view.settings().set("oops", oops_map)
                self.view.add_regions("oops", self.warninglines, "sublimelinter.mark.warning", "dot", sublime.DRAW_NO_FILL + sublime.DRAW_NO_OUTLINE + sublime.DRAW_SQUIGGLY_UNDERLINE )
                if (not haveError or not showErrorPanel) and showWarningPanel:
                    self.view.window().run_command("show_panel", {"panel": "output.variable_get"})

        self.data = None

        # Make error panel be scrolled to top so that we can see the first error:
        self.outputpanel.view.set_viewport_position((0,0)) 
Example #7
Source File: coverage.py    From sublime-flowtype with MIT License 4 votes vote down vote up
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")