Python sublime.DRAW_NO_OUTLINE Examples

The following are 29 code examples of sublime.DRAW_NO_OUTLINE(). 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: sublime_terminal_buffer.py    From TerminalView with MIT License 6 votes vote down vote up
def _update_line_colors(self, line_no, line_color_map):
        # Note this function has been optimized quite a bit. Calls to the ST3
        # API has been left out on purpose as they are slower than the
        # alternative.
        view_region_cache = self._sub_buffer.view_region_cache()
        view_content_cache = self._sub_buffer.view_content_cache()

        for idx, field in line_color_map.items():
            length = field["field_length"]
            color_scope = "terminalview.%s_%s" % (field["color"][0], field["color"][1])

            # Get text point where color should start
            line_start, _ = view_content_cache.get_line_start_and_end_points(line_no)
            color_start = line_start + idx

            # Make region that should be colored
            buffer_region = sublime.Region(color_start, color_start + length)
            region_key = "%i,%s" % (line_no, idx)

            # Add the region
            flags = sublime.DRAW_NO_OUTLINE | sublime.PERSISTENT
            self.view.add_regions(region_key, [buffer_region], color_scope, flags=flags)
            view_region_cache.add(line_no, region_key) 
Example #2
Source File: window_view.py    From JavaScriptEnhancements with MIT License 6 votes vote down vote up
def add_input(self, value=" ", label=None, key="input", scope="javascriptenhancements.input", icon="", flags=sublime.DRAW_EMPTY | sublime.DRAW_NO_OUTLINE, region_id="", padding=1, display_block=False, insert_point=None, replace_points=[]):

    if not region_id:
      raise Exception("Error: ID isn't setted.")

    if region_id in self.region_input_ids:
      raise Exception("Error: ID "+region_id+" already used.")

    if value == None:
      value = " "

    if label:
      self.add(label)

    self.region_input_ids.append(region_id)
    self.add(value, key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=padding, display_block=display_block, insert_point=insert_point, replace_points=replace_points) 
Example #3
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 #4
Source File: bookmarks.py    From JavaScriptEnhancements with MIT License 6 votes vote down vote up
def update_bookmarks(set_dot = False, erase_regions = True):
  global bookmarks
  path = ""
  view = sublime.active_window().active_view()

  if util.is_project_view(view) and util.is_javascript_project() :
    project_settings = util.get_project_settings()
    path = os.path.join(project_settings["settings_dir_name"], 'bookmarks.json')
  else :
    sublime.error_message("Can't recognize JavaScript Project.")
    return

  with open(path, 'w+', encoding="utf-8") as bookmarks_json:
    bookmarks_json.write(json.dumps(bookmarks))

  if erase_regions:
    view.erase_regions("javascript_enhancements_region_bookmarks")
    if set_dot :
      lines = []
      lines = [view.line(view.text_point(bookmark_line, 0)) for bookmark_line in search_bookmarks_by_view(view)]
      view.add_regions("javascript_enhancements_region_bookmarks", lines,  "code", "bookmark", sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE) 
Example #5
Source File: bookmarks.py    From JavaScriptEnhancements with MIT License 6 votes vote down vote up
def set_bookmarks(set_dot = False, erase_regions = True):
  global bookmarks
  view = sublime.active_window().active_view()
  
  if util.is_project_view(view) and util.is_javascript_project() :
    project_settings = util.get_project_settings()
    bookmarks = util.open_json(os.path.join(project_settings["settings_dir_name"], 'bookmarks.json')) or dict()
  else :
    sublime.error_message("Can't recognize JavaScript Project.")
    return

  if erase_regions:
    view.erase_regions("javascript_enhancements_region_bookmarks")
    if set_dot :
      lines = []
      lines = [view.line(view.text_point(bookmark_line, 0)) for bookmark_line in search_bookmarks_by_view(view, is_from_set = True)]
      view.add_regions("javascript_enhancements_region_bookmarks", lines,  "code", "bookmark", sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE) 
Example #6
Source File: drawing_flags.py    From sublime-GitConflictResolver with MIT License 6 votes vote down vote up
def visible():
    fill = settings.get('fill_conflict_area')
    outline = settings.get('outline_conflict_area')

    flags = 0
    if _st_version < 3000:
        # If fill is set then outline is ignored; ST2 doesn't provide a combination
        if not (fill or outline):
            flags = sublime.HIDDEN
        elif not fill and outline:
            flags = sublime.DRAW_OUTLINED
    else:
        if not fill:
            flags |= sublime.DRAW_NO_FILL
        if not outline:
            flags |= sublime.DRAW_NO_OUTLINE

    return flags 
Example #7
Source File: window_view.py    From JavaScriptEnhancements with MIT License 5 votes vote down vote up
def add_select(self, default_option, options, label=None, key="select", scope="javascriptenhancements.input", icon="", flags=sublime.DRAW_EMPTY | sublime.DRAW_NO_OUTLINE, region_id="", padding=1, display_block=False, insert_point=None, replace_points=[]):

    if not region_id:
      raise Exception("Error: ID isn't setted.")

    if region_id in self.region_input_ids:
      raise Exception("Error: ID "+region_id+" already used.")

    if label:
      self.add(label)
    self.region_input_ids.append(region_id)
    self.add(options[default_option] + " ▼", key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=padding, display_block=display_block, insert_point=insert_point, replace_points=replace_points)

    self.add_event_listener("drag_select", key+"."+scope, lambda view: sublime.set_timeout_async(lambda: self.view.window().show_quick_panel(options, lambda index: self.update_select(index, options, key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=padding, display_block=display_block, insert_point=insert_point, replace_points=replace_points)))) 
Example #8
Source File: window_view.py    From JavaScriptEnhancements with MIT License 5 votes vote down vote up
def update_input(self, value, key="input", scope="javascriptenhancements.input", icon="", flags=sublime.DRAW_EMPTY | sublime.DRAW_NO_OUTLINE, region_id="", padding=1, display_block=False, insert_point=None, replace_points=[]):

    self.replace_by_id(region_id, value, key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=padding, display_block=display_block, insert_point=insert_point, replace_points=replace_points)

    if not region_id:
      raise Exception("Error: ID isn't setted.")

    if region_id in self.region_input_ids:
      raise Exception("Error: ID "+region_id+" already used.")

    self.region_input_ids.append(region_id)
    self.update_input_state() 
Example #9
Source File: window_view.py    From JavaScriptEnhancements with MIT License 5 votes vote down vote up
def add_button(self, text, scope, callback=None, key="click", icon="", flags=sublime.DRAW_EMPTY | sublime.DRAW_NO_OUTLINE, region_id="", padding=1, display_block=False, insert_point=None, replace_points=[]):
    self.add(text, key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=padding, display_block=display_block, insert_point=insert_point, replace_points=replace_points)

    if callback:
      self.add_event_listener("drag_select", key+"."+scope, lambda view: callback(view)) 
Example #10
Source File: window_view.py    From JavaScriptEnhancements with MIT License 5 votes vote down vote up
def add_sub_title(self, text, key="", scope="javascriptenhancements.subtitle", icon="", flags=sublime.DRAW_EMPTY | sublime.DRAW_NO_OUTLINE, region_id="", padding=1, display_block=True, insert_point=None, replace_points=[]):
    self.add(text, key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=padding, display_block=display_block, insert_point=insert_point, replace_points=replace_points) 
Example #11
Source File: window_view.py    From JavaScriptEnhancements with MIT License 5 votes vote down vote up
def add_title(self, text, key="", scope="javascriptenhancements.title", icon="", flags=sublime.DRAW_EMPTY | sublime.DRAW_NO_OUTLINE, region_id="", padding=2, display_block=True, insert_point=None, replace_points=[]):
    space_padding = (" "*int(padding))
    space_row = (" "*len(text))+(" "*int(padding)*2)
    text = space_row+"\n"+space_padding+text+space_padding+"\n"+space_row+" "
    self.add(text, key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=0, display_block=display_block, insert_point=insert_point, replace_points=replace_points)

    self.add("\n\nNOTE: See the keymap ")
    self.add_link(text="here", link="https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki/WindowView", scope="link")
    self.add(". ") 
Example #12
Source File: mouse.py    From Terminus with MIT License 5 votes vote down vote up
def on_hover(self, view, point, hover_zone):
        terminal = Terminal.from_id(view.id())
        if not terminal:
            return
        if hover_zone != sublime.HOVER_TEXT:
            return
        url = find_url(view, pt=point)

        if not url:
            return

        def on_navigate(action):
            if action == "open":
                webbrowser.open_new_tab(url)

        def on_hide():
            if link_key:
                view.erase_regions(link_key)

        url_region = find_url_region(view, pt=point)
        link_key = None
        if url_region:
            link_key = highlight_key(view)
            view.add_regions(
                link_key,
                [sublime.Region(*url_region)],
                "meta",
                flags=sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE)

        view.show_popup(
            URL_POPUP,
            sublime.HIDE_ON_MOUSE_MOVE_AWAY,
            location=point,
            on_navigate=on_navigate, on_hide=on_hide) 
Example #13
Source File: window_view.py    From JavaScriptEnhancements with MIT License 5 votes vote down vote up
def update_select(self, index, options, key="select", scope="javascriptenhancements.input", icon="", flags=sublime.DRAW_EMPTY | sublime.DRAW_NO_OUTLINE, region_id="", padding=1, display_block=False, insert_point=None, replace_points=[]):
    if index < 0:
      return

    self.replace_by_id(region_id, options[index] + " ▼", key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=padding, display_block=display_block, insert_point=insert_point, replace_points=replace_points)

    if not region_id:
      raise Exception("Error: ID isn't setted.")

    if region_id in self.region_input_ids:
      raise Exception("Error: ID "+region_id+" already used.")

    self.region_input_ids.append(region_id)
    self.update_input_state() 
Example #14
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 #15
Source File: window_view.py    From JavaScriptEnhancements with MIT License 5 votes vote down vote up
def add_link(self, text, link, scope, key="click", icon="", flags=sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE, region_id="", padding=0, display_block=False, insert_point=None, replace_points=[]):
    self.add(text, key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=padding, display_block=display_block, insert_point=insert_point, replace_points=replace_points)

    self.add_event_listener("drag_select", key+"."+scope, lambda view: sublime.active_window().run_command("open_url", args={"url": link})) 
Example #16
Source File: code_actions.py    From LSP with MIT License 5 votes vote down vote up
def show_bulb(self) -> None:
        region = self.view.sel()[0]
        flags = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE
        self.view.add_regions('lsp_bulb', [region], 'markup.changed', 'Packages/LSP/icons/lightbulb.png', flags) 
Example #17
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 #18
Source File: ChromeREPL.py    From ChromeREPL with MIT License 5 votes vote down vote up
def run(self, edit):
    connection = ChromeREPLConnection.get_instance(self.view)

    # store selection for later restoration
    prev = []
    for sel in self.view.sel():
      prev.append(sel)

    success = True
    # evaluate selections in Chrome
    for sel in self.view.sel():
      if sel.a == sel.b:  # the 'selection' is a single point
        sel = self.view.line(sel)
        self.view.sel().add(sel)

      try:
        expression = self.view.substr(sel)
        connection.execute(expression)
      except Exception as e:
        success = False

    if success:
      # highlight
      self.view.add_regions(self.HIGHLIGHT_KEY,
                            self.view.sel(),
                            self.HIGHLIGHT_SCOPE,
                            flags=sublime.DRAW_NO_OUTLINE)

      # clear selection so highlighting will be visible
      self.view.sel().clear()

      # do highlighting
      sublime.set_timeout(lambda: self.view.sel().add_all(prev), 10)

      # remove highlight and restore original selection
      sublime.set_timeout(lambda: self.view.erase_regions(self.HIGHLIGHT_KEY), 50) 
Example #19
Source File: abbreviation.py    From sublime-text-plugin with MIT License 5 votes vote down vote up
def mark(editor: sublime.View, tracker: AbbreviationTracker):
    "Marks tracker in given view"
    scope = get_settings('marker_scope', 'region.accent')
    mark_opt = sublime.DRAW_SOLID_UNDERLINE | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE
    editor.erase_regions(ABBR_REGION_ID)
    editor.add_regions(ABBR_REGION_ID, [tracker.region], scope, '', mark_opt)
    if isinstance(tracker, AbbreviationTrackerValid) and tracker.forced:
        phantoms = [
            sublime.Phantom(tracker.region, forced_indicator('⋮>'), sublime.LAYOUT_INLINE)
        ]

        key = editor.id()
        if key not in _forced_indicator:
            _forced_indicator[key] = sublime.PhantomSet(editor, ABBR_REGION_ID)
        _forced_indicator[key].update(phantoms) 
Example #20
Source File: tracker.py    From sublime-text-plugin with MIT License 5 votes vote down vote up
def mark(self, view: sublime.View):
        "Marks tracker in given view"
        scope = emmet.get_settings('marker_scope', 'region.accent')
        mark_opt = sublime.DRAW_SOLID_UNDERLINE | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE
        view.erase_regions(ABBR_REGION_ID)
        view.add_regions(ABBR_REGION_ID, [self.region], scope, '', mark_opt)
        if self.forced:
            phantoms = [sublime.Phantom(self.region, forced_indicator('⋮>'), sublime.LAYOUT_INLINE)]
            if not self.forced_indicator:
                self.forced_indicator = sublime.PhantomSet(view, ABBR_REGION_ID)
            self.forced_indicator.update(phantoms) 
Example #21
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 #22
Source File: view_hover.py    From sublime_debugger with MIT License 5 votes vote down vote up
def on_hover(self, event: Tuple[sublime.View, int, int]):
		(view, point, hover_zone) = event
		if hover_zone != sublime.HOVER_TEXT or not self.project.is_source_file(view):
			return

		session = self.sessions.active

		r = session.adapter_configuration.on_hover_provider(view, point)
		if not r:
			return
		word_string, region = r
		
		try:
			response = await session.adapter.Evaluate(word_string, session.selected_frame, 'hover')
			await core.sleep(0.25)
			variable = dap.Variable("", response.result, response.variablesReference)
			view.add_regions('selected_hover', [region], scope="comment", flags=sublime.DRAW_NO_OUTLINE)

			def on_close() -> None:
				view.erase_regions('selected_hover')

			component = VariableComponent(Variable(session, variable))
			component.toggle_expand()
			ui.Popup(component, view, region.a, on_close=on_close)

		# errors trying to evaluate a hover expression should be ignored
		except dap.Error as e:
			core.log_error("adapter failed hover evaluation", e) 
Example #23
Source File: _generated_2018_02_11_at_20_21_24.py    From JavaScript-Completions with MIT License 5 votes vote down vote up
def run(self, edit) :
      global region_selected
      view = self.view
      lines = view.lines(region_selected)
      view.add_regions("region-dot", [lines[0], lines[-1:][0]],  "code", "dot", sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE)
      #view.add_regions("region-body", [region_selected],  "code", "", sublime.DRAW_NO_FILL) 
Example #24
Source File: SwiftKitten.py    From SwiftKitten with MIT License 5 votes vote down vote up
def on_idle(self, view):
        """
        """
        structure_info = self._get_structure_info(view)
        linting = self.get_settings(view, "linting", True)

        # linting
        if linting and "key.diagnostics" in structure_info:
            diagnostics = structure_info["key.diagnostics"]
            self.errors = {}

            for entry in diagnostics:
                description = entry["key.description"]
                #level = entry['key.severity']
                row, col = entry["key.line"], entry["key.column"]
                pos = view.text_point(row-1,col-1)

                self.errors[pos] = description

            view.add_regions(
                "swiftkitten.diagnostics",
                [Region(pos,pos+1) for pos in self.errors.keys()],
                "constant",
                "",
                sublime.DRAW_STIPPLED_UNDERLINE | sublime.DRAW_NO_OUTLINE | sublime.DRAW_NO_FILL
            )

            self._update_linting_status(view) 
Example #25
Source File: drawing_flags.py    From sublime-GitConflictResolver with MIT License 5 votes vote down vote up
def hidden():
    flags = 0
    if _st_version < 3000:
        flags = sublime.HIDDEN
    else:
        flags = (sublime.DRAW_NO_FILL |
                 sublime.DRAW_NO_OUTLINE)

    return (flags | sublime.HIDE_ON_MINIMAP) 
Example #26
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 #27
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 #28
Source File: coverage.py    From FlowIDE with MIT License 4 votes vote down vote up
def run_coverage(self, view):
        settings = find_flow_settings(view.window().project_data())
        if not settings.get('show_coverage'):
            return

        result = None
        try:
            result = CLI(view).coverage()
        except InvalidContext:
            view.erase_regions('flow_error')
            view.erase_regions('flow_uncovered')
        except Exception as e:
            display_unknown_error(self.view, e)

        if not result:
            return

        regions = []

        for line in result['expressions']['uncovered_locs']:
            start = line['start']
            end = line['end']
            row = int(start['line']) - 1
            col = int(start['column']) - 1
            endrow = int(end['line']) - 1
            endcol = int(end['column'])
            regions.append(
                rowcol_to_region(view, row, col, endcol, endrow)
            )

        view.add_regions(
            'flow_uncovered', regions, 'comment', '',
            sublime.DRAW_STIPPLED_UNDERLINE +
            sublime.DRAW_NO_FILL +
            sublime.DRAW_NO_OUTLINE
        )

        uncovered_count = result['expressions']['uncovered_count']
        covered_count_text = 'Flow coverage: {} line{} uncovered'.format(
            uncovered_count, '' if uncovered_count is 1 else 's'
        )
        view.set_status('flow_coverage', covered_count_text) 
Example #29
Source File: TabNine.py    From tabnine-sublime with MIT License 4 votes vote down vote up
def run(
        self, edit, *,
        region_begin, region_end, substitution, new_cursor_pos,
        prefix, old_prefix, expected_prefix, highlight
    ):
        normalize_offset = -self.view.sel()[0].begin()
        def normalize(x, sel):
            if isinstance(x, sublime.Region):
                return sublime.Region(normalize(x.begin(), sel), normalize(x.end(), sel))
            else:
                return normalize_offset + x + sel.begin() 
        observed_prefixes = [
            self.view.substr(sublime.Region(normalize(region_begin, sel), sel.begin()))
            for sel in self.view.sel()
        ]
        if old_prefix is not None:
            for i in range(len(self.view.sel())):
                sel = self.view.sel()[i]
                t_region_end = normalize(region_end, sel)
                self.view.sel().subtract(sel)
                self.view.insert(edit, t_region_end, old_prefix)
                self.view.sel().add(t_region_end)
        normalize_offset = -self.view.sel()[0].begin()
        region_end += len(prefix)
        region = sublime.Region(region_begin, region_end)
        modified_regions = []
        for i in range(len(self.view.sel())):
            sel = self.view.sel()[i]
            t_region = normalize(region, sel)
            observed_prefix = observed_prefixes[i]
            if observed_prefix != expected_prefix:
                new_begin = self.view.word(sel).begin()
                print(
                    'TabNine expected prefix "{}" but found prefix "{}", falling back to substituting from word beginning: "{}"'
                        .format(expected_prefix, observed_prefix, self.view.substr(sublime.Region(new_begin, sel.begin())))
                )
                t_region = sublime.Region(new_begin, t_region.end())
            self.view.sel().subtract(sel)
            self.view.erase(edit, t_region)
            self.view.insert(edit, t_region.begin(), substitution)
            self.view.sel().add(t_region.begin() + new_cursor_pos)
            modified_regions.append(sublime.Region(t_region.begin(), t_region.begin() + new_cursor_pos))
        if highlight:
            global GLOBAL_HIGHLIGHT_COUNTER
            GLOBAL_HIGHLIGHT_COUNTER += 1
            expected_counter = GLOBAL_HIGHLIGHT_COUNTER
            self.view.add_regions(
                'tabnine_highlight', modified_regions, 'string',
                flags=sublime.DRAW_NO_OUTLINE,
            )
            def erase():
                if GLOBAL_HIGHLIGHT_COUNTER == expected_counter:
                    self.view.erase_regions('tabnine_highlight')
            sublime.set_timeout(erase, 250)