Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _generate_color_regions(self, point):
self._regions = []
region = sublime.Region(point, point)
normalized_region = NormalizedRegion(region)
for line in self._view.lines(region):
for (region, color, _) in self._color_searcher.search(self._view, NormalizedRegion(line)):
if intersects(region, normalized_region):
self._regions.append(region)
yield (region, color)
def __eq__(self, other):
"""Compare normalized regions for equality."""
if not isinstance(other, NormalizedRegion):
return False
return self.a == other.a and self.b == other.b
def on_selection_modified(self):
"""on_selection_modified event."""
new_selection = [NormalizedRegion(region) for region in self._view.sel()]
if self._selection != new_selection:
self._selection = new_selection
self._on_selection_really_modified()
def _generate_lines(view, regions):
for region in regions:
for line in view.lines(region):
yield NormalizedRegion(line)
def _generate_lines_for_selection(self):
for region in self._view.sel():
for line in self._view.lines(region):
yield NormalizedRegion(line)
def _generate_color_regions(self, point):
self._regions = []
region = sublime.Region(point, point)
normalized_region = NormalizedRegion(region)
for line in self._view.lines(region):
for (region, color, _) in self._color_searcher.search(self._view, NormalizedRegion(line)):
if intersects(region, normalized_region):
self._regions.append(region)
yield (region, color)
def _generate_color_regions(view, color_searcher, regions):
normalized_regions = [NormalizedRegion(region) for region in regions]
for line in deduplicate_regions(_generate_lines(view, regions)):
for color_data in color_searcher.search(view, line):
if intersects_any(color_data[0], normalized_regions):
yield color_data
def _generate_lines(self):
for line in self._view.lines(NormalizedRegion(0, self._view.size()).region()):
yield NormalizedRegion(line)