Ghidra is a software reverse engineering (SRE) framework
GP-4947 - Function Graph - Added an action to toggle between the Listing and Function Graph views (ctrl-space)
dragonmacherf133c6c971cf
diff --git a/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html b/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.htmlindex 2ea00b278f..3be4d20758 100644--- a/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html+++ b/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html@@ -32,6 +32,15 @@"#Satellite_View">Satellite View</A>. There is also a group of <A href="#Function_Graph_Actions">actions</A> that apply to the entire graph.</P></BLOCKQUOTE>++ <BLOCKQUOTE>+ <BLOCKQUOTE>+ <A NAME="Toggle_Listing_and_Function_Graph"></A>+ <P><IMG src="help/shared/tip.png" alt="" border="0"><B><I>Ctrl-Space</I></B> will toggle+ between the full Listing view and the Function Graph view. The <CODE>Toggle Listing and+ Function Graph</CODE> action's key binding can be changed in the tool options.</P>+ </BLOCKQUOTE>+ </BLOCKQUOTE><H2><A name="Primary_View"></A>Primary View</H2>diff --git a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FunctionGraphPlugin.java b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FunctionGraphPlugin.javaindex d8a5cd9298..9fe1e3601e 100644--- a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FunctionGraphPlugin.java+++ b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FunctionGraphPlugin.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -21,6 +21,9 @@ import javax.swing.Icon;import org.jdom.Element;+import docking.ComponentProvider;+import docking.DockingWindowManager;+import docking.action.builder.ActionBuilder;import docking.options.OptionsService;import docking.tool.ToolConstants;import generic.theme.GIcon;@@ -36,6 +39,7 @@ import ghidra.app.plugin.core.functiongraph.mvc.FunctionGraphOptions;import ghidra.app.plugin.core.marker.MarginProviderSupplier;import ghidra.app.services.*;import ghidra.app.util.viewer.format.FormatManager;+import ghidra.app.util.viewer.listingpanel.ListingPanel;import ghidra.framework.model.DomainFile;import ghidra.framework.options.*;import ghidra.framework.plugintool.PluginInfo;@@ -86,6 +90,29 @@ public class FunctionGraphPlugin extends ProgramPluginsuper(tool);colorProvider = new IndependentColorProvider(tool);++ new ActionBuilder("Toggle Listing and Function Graph", getName())+ .keyBinding("control space")+ .onAction(c -> toggleView())+ .buildAndInstall(tool);+ }++ private void toggleView() {++ CodeViewerService cvService = tool.getService(CodeViewerService.class);++ ListingPanel lp = cvService.getListingPanel();+ DockingWindowManager dwm = DockingWindowManager.getInstance(lp);+ ComponentProvider cvProvider = dwm.getComponentProvider(lp);+ if (cvProvider.isFocusedProvider()) {+ connectedProvider.setVisible(true);+ }+ else {+ // Either the Function Graph is focused or some other provider has focus. Just jump to+ // the code viewer in this case. The user can perform the action again to get to the+ // graph.+ cvProvider.setVisible(true);+ }}@Overridediff --git a/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java b/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.javaindex bfe6395582..5609532fa5 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java@@ -248,6 +248,8 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContextreturn;}+ // this call is needed to bring tabbed providers to the front+ toFront();if (defaultFocusComponent != null) {DockingWindowManager.requestFocus(defaultFocusComponent);return;