mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
GP-3329 - Search Highlights - Major update and refactor of the way Listing highlights work. Highlights are now more closely coupled with the fields that will paint them.
This commit is contained in:
parent
a21c2c4347
commit
84650030d0
130 changed files with 1096 additions and 919 deletions
|
@ -20,10 +20,11 @@ import java.util.*;
|
|||
|
||||
import docking.widgets.fieldpanel.support.Highlight;
|
||||
import generic.theme.GColor;
|
||||
import ghidra.app.plugin.core.codebrowser.ListingHighlightProvider;
|
||||
import ghidra.app.util.HighlightProvider;
|
||||
import ghidra.app.plugin.core.codebrowser.ListingMiddleMouseHighlightProvider;
|
||||
import ghidra.app.util.ListingHighlightProvider;
|
||||
import ghidra.app.util.viewer.field.*;
|
||||
import ghidra.app.util.viewer.listingpanel.ListingPanel;
|
||||
import ghidra.app.util.viewer.proxy.ProxyObj;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.markuptype.*;
|
||||
import ghidra.feature.vt.api.stringable.*;
|
||||
|
@ -37,7 +38,7 @@ import ghidra.program.model.listing.*;
|
|||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.AssertException;
|
||||
|
||||
public class VTDualListingHighlightProvider implements HighlightProvider {
|
||||
public class VTDualListingHighlightProvider implements ListingHighlightProvider {
|
||||
|
||||
private static Color APPLIED_MARKUP_COLOR =
|
||||
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.applied");
|
||||
|
@ -60,7 +61,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
|
|||
new HashMap<>();
|
||||
private final VTController controller;
|
||||
private ListingPanel listingPanel;
|
||||
private ListingHighlightProvider listingHighlighter;
|
||||
private ListingMiddleMouseHighlightProvider listingHighlighter;
|
||||
|
||||
private VTMarkupItem currentMarkupItem;
|
||||
private boolean isSource;
|
||||
|
@ -80,7 +81,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
|
|||
|
||||
if (listingPanel != null) {
|
||||
this.listingHighlighter =
|
||||
new ListingHighlightProvider(controller.getTool(), listingPanel);
|
||||
new ListingMiddleMouseHighlightProvider(controller.getTool(), listingPanel);
|
||||
listingPanel.removeButtonPressedListener(listingHighlighter);
|
||||
listingPanel.addButtonPressedListener(listingHighlighter);
|
||||
}
|
||||
|
@ -128,8 +129,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Highlight[] getHighlights(String text, Object obj,
|
||||
Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
|
||||
public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
|
||||
|
||||
VTSession session = controller.getSession();
|
||||
if (session == null) {
|
||||
|
@ -141,8 +141,11 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
|
|||
if (matchInfo == null) {
|
||||
return new Highlight[0];
|
||||
}
|
||||
Highlight[] highlights = new Highlight[0];
|
||||
|
||||
ProxyObj<?> proxy = field.getProxy();
|
||||
Object obj = proxy.getObject();
|
||||
Highlight[] highlights = new Highlight[0];
|
||||
Class<? extends FieldFactory> fieldFactoryClass = field.getFieldFactory().getClass();
|
||||
if (fieldFactoryClass == FunctionSignatureFieldFactory.class) {
|
||||
highlights = getFunctionSignatureHighlights(text, obj, cursorTextOffset);
|
||||
}
|
||||
|
@ -217,19 +220,21 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
|
|||
highlightList.add(highlight);
|
||||
}
|
||||
|
||||
highlightList.addAll(getListingHighlights(text, obj, fieldFactoryClass, cursorTextOffset));
|
||||
highlightList.addAll(
|
||||
getListingHighlights(text, obj, fieldFactoryClass, field, cursorTextOffset));
|
||||
|
||||
return highlightList.toArray(new Highlight[highlightList.size()]);
|
||||
}
|
||||
|
||||
private Collection<? extends Highlight> getListingHighlights(String text, Object obj,
|
||||
Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
|
||||
Class<? extends FieldFactory> fieldFactoryClass, ListingField field,
|
||||
int cursorTextOffset) {
|
||||
if (listingHighlighter == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Arrays.asList(listingHighlighter.getHighlights(text, obj, fieldFactoryClass,
|
||||
cursorTextOffset));
|
||||
return Arrays.asList(
|
||||
listingHighlighter.createHighlights(text, field, cursorTextOffset));
|
||||
}
|
||||
|
||||
private Color getMarkupBackgroundColor(int cursorTextOffset, VTMarkupItem vtMarkupItem,
|
||||
|
|
|
@ -18,7 +18,7 @@ package ghidra.feature.vt.gui.duallisting;
|
|||
import javax.swing.Icon;
|
||||
|
||||
import ghidra.app.nav.*;
|
||||
import ghidra.app.util.HighlightProvider;
|
||||
import ghidra.app.util.ListingHighlightProvider;
|
||||
import ghidra.app.util.viewer.listingpanel.ListingCodeComparisonPanel;
|
||||
import ghidra.app.util.viewer.listingpanel.ListingPanel;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
@ -147,12 +147,12 @@ public class VTListingNavigator implements Navigatable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
|
||||
public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
|
||||
// currently unsupported
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHighlightProvider(HighlightProvider highlightProvider, Program program) {
|
||||
public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
|
||||
// currently unsupported
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue