diff --git a/ivette/src/frama-c/plugins/dive/index.tsx b/ivette/src/frama-c/plugins/dive/index.tsx index 77dd2a9f9aa1316c467648d7493450d287645c96..6abe4e5627022f93f7ad6b0b8b745aadf9be3b6e 100644 --- a/ivette/src/frama-c/plugins/dive/index.tsx +++ b/ivette/src/frama-c/plugins/dive/index.tsx @@ -139,6 +139,7 @@ class Dive { // Add new listeners enableDoubleClickEvents(this.cy); this.cy.on('click', 'node', (event) => this.clickNode(event.target)); + this.cy.on('click', 'edge', (event) => this.clickEdge(event.target)); this.cy.on('double-click', '$node > node', // compound nodes (event) => this.doubleClickNode(event.target)); @@ -527,6 +528,18 @@ class Dive { node.unselectify(); } + async clickEdge(edge: Cytoscape.EdgeSingular): Promise<void> { + // Unselect everything + this.cy.$(':selected').forEach(unselect); + this.cy.$('.multiple-selection').removeClass('multiple-selection'); + this.cy.$('.selection').removeClass('selection'); + + // Update Ivette selection + const origins = edge.data()?.origins; + if (origins && origins.length) + this.onSelect?.(origins); + } + doubleClickNode(node: Cytoscape.NodeSingular): void { this.cy.animate({ fit: { eles: node, padding: 10 } }); }