Skip to content

Commit

Permalink
Enable search in subgraph labels
Browse files Browse the repository at this point in the history
refs #90
  • Loading branch information
tlk authored and jrfonseca committed Jul 14, 2023
1 parent e8529e6 commit dc9e8e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions xdot/ui/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,10 @@ def __init__(self, width=1, height=1, shapes=(), nodes=(), edges=(), outputorder
def get_size(self):
return self.width, self.height

def _draw_shapes(self, cr, bounding):
def _draw_shapes(self, cr, bounding, highlight_items):
for shape in self.shapes:
if bounding is None or shape._intersects(bounding):
shape._draw(cr, highlight=False, bounding=bounding)
shape._draw(cr, highlight=(shape in highlight_items), bounding=bounding)

def _draw_nodes(self, cr, bounding, highlight_items):
highlight_nodes = []
Expand Down Expand Up @@ -690,7 +690,8 @@ def draw(self, cr, highlight_items=None, bounding=None):
cr.set_line_cap(cairo.LINE_CAP_BUTT)
cr.set_line_join(cairo.LINE_JOIN_MITER)

self._draw_shapes(cr, bounding)
self._draw_shapes(cr, bounding, highlight_items)

if self.outputorder == 'edgesfirst':
self._draw_edges(cr, bounding, highlight_items)
self._draw_nodes(cr, bounding, highlight_items)
Expand Down
2 changes: 1 addition & 1 deletion xdot/ui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def find_text(self, entry_text):
except re.error as err:
sys.stderr.write('warning: re.compile() failed with error "%s"\n' % err)
return []
for element in dot_widget.graph.nodes + dot_widget.graph.edges:
for element in dot_widget.graph.nodes + dot_widget.graph.edges + dot_widget.graph.shapes:
if element.search_text(regexp):
found_items.append(element)
return sorted(found_items, key=operator.methodcaller('get_text'))
Expand Down

0 comments on commit dc9e8e7

Please sign in to comment.