mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-24 21:21:56 +00:00
Merge remote-tracking branch
'origin/GP-3540-dragonmacher-copy-full-symbol' (Closes #5421)
This commit is contained in:
commit
691eb7c1da
@ -29,17 +29,21 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.ComponentProvider;
|
||||
import docking.dnd.StringTransferable;
|
||||
import docking.widgets.fieldpanel.Layout;
|
||||
import docking.widgets.fieldpanel.LayoutModel;
|
||||
import docking.widgets.fieldpanel.internal.PaintContext;
|
||||
import docking.widgets.fieldpanel.support.FieldRange;
|
||||
import docking.widgets.fieldpanel.support.FieldSelection;
|
||||
import ghidra.app.decompiler.ClangToken;
|
||||
import ghidra.app.decompiler.component.ClangTextField;
|
||||
import ghidra.app.decompiler.component.DecompilerPanel;
|
||||
import ghidra.app.decompiler.*;
|
||||
import ghidra.app.decompiler.component.*;
|
||||
import ghidra.app.services.ClipboardContentProviderService;
|
||||
import ghidra.app.util.ByteCopier;
|
||||
import ghidra.app.util.ClipboardType;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.program.model.symbol.Symbol;
|
||||
import ghidra.program.model.symbol.SymbolTable;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class DecompilerClipboardProvider extends ByteCopier
|
||||
@ -86,11 +90,10 @@ public class DecompilerClipboardProvider extends ByteCopier
|
||||
|
||||
@Override
|
||||
public Transferable copy(TaskMonitor monitor) {
|
||||
if (!copyFromSelectionEnabled) {
|
||||
return createStringTransferable(getCursorText());
|
||||
if (copyFromSelectionEnabled) {
|
||||
return copyTextFromSelection(monitor);
|
||||
}
|
||||
|
||||
return copyText(monitor);
|
||||
return new StringTransferable(getCursorText());
|
||||
}
|
||||
|
||||
private String getCursorText() {
|
||||
@ -100,6 +103,22 @@ public class DecompilerClipboardProvider extends ByteCopier
|
||||
return null;
|
||||
}
|
||||
|
||||
if (token instanceof ClangLabelToken) {
|
||||
Address a = token.getMinAddress();
|
||||
SymbolTable st = currentProgram.getSymbolTable();
|
||||
Symbol[] symbols = st.getSymbols(a);
|
||||
if (symbols.length > 0) {
|
||||
Symbol s = symbols[0];
|
||||
return s.getName();
|
||||
}
|
||||
}
|
||||
else if (token instanceof ClangFuncNameToken functionToken) {
|
||||
Function function = DecompilerUtils.getFunction(currentProgram, functionToken);
|
||||
if (function != null) {
|
||||
return function.getName();
|
||||
}
|
||||
}
|
||||
|
||||
String text = token.getText();
|
||||
return text;
|
||||
}
|
||||
@ -119,7 +138,7 @@ public class DecompilerClipboardProvider extends ByteCopier
|
||||
@Override
|
||||
public Transferable copySpecial(ClipboardType copyType, TaskMonitor monitor) {
|
||||
if (copyType == TEXT_TYPE) {
|
||||
return copyText(monitor);
|
||||
return copyTextFromSelection(monitor);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -161,7 +180,7 @@ public class DecompilerClipboardProvider extends ByteCopier
|
||||
return false;
|
||||
}
|
||||
|
||||
private Transferable copyText(TaskMonitor monitor) {
|
||||
private Transferable copyTextFromSelection(TaskMonitor monitor) {
|
||||
return createStringTransferable(getText());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user