1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-20 17:08:00 +02:00

Separate Close Panel and Close Document

This commit is contained in:
Brian Fiete 2020-09-28 05:56:09 -07:00
parent 077ebe2659
commit da508156c1
3 changed files with 50 additions and 6 deletions

View file

@ -190,7 +190,8 @@ namespace IDE
Add("Clean", new => gApp.Cmd_Clean); Add("Clean", new => gApp.Cmd_Clean);
Add("Close All Panels", new () => { gApp.[Friend]TryCloseAllDocuments(true); }); Add("Close All Panels", new () => { gApp.[Friend]TryCloseAllDocuments(true); });
Add("Close All Panels Except", new () => { gApp.[Friend]TryCloseAllDocuments(false); }); Add("Close All Panels Except", new () => { gApp.[Friend]TryCloseAllDocuments(false); });
Add("Close Panel", new () => { gApp.[Friend]TryCloseCurrentDocument(); }); Add("Close Document", new () => { gApp.[Friend]TryCloseCurrentDocument(); });
Add("Close Panel", new () => { gApp.[Friend]TryCloseCurrentPanel(); });
Add("Close Workspace", new => gApp.[Friend]Cmd_CloseWorkspaceAndSetupNew); Add("Close Workspace", new => gApp.[Friend]Cmd_CloseWorkspaceAndSetupNew);
Add("Comment Selection", new => gApp.[Friend]CommentSelection); Add("Comment Selection", new => gApp.[Friend]CommentSelection);
Add("Compile File", new => gApp.Cmd_CompileFile); Add("Compile File", new => gApp.Cmd_CompileFile);

View file

@ -5065,6 +5065,11 @@ namespace IDE
menu.SetDisabled(GetActiveDocumentPanel() == null); menu.SetDisabled(GetActiveDocumentPanel() == null);
} }
public void UpdateMenuItem_HasLastActiveDocument(IMenu menu)
{
menu.SetDisabled(GetLastActiveDocumentPanel() == null);
}
public void UpdateMenuItem_HasWorkspace(IMenu menu) public void UpdateMenuItem_HasWorkspace(IMenu menu)
{ {
menu.SetDisabled(!gApp.mWorkspace.IsInitialized); menu.SetDisabled(!gApp.mWorkspace.IsInitialized);
@ -5377,7 +5382,8 @@ namespace IDE
////////// //////////
mWindowMenu = root.AddMenuItem("&Window"); mWindowMenu = root.AddMenuItem("&Window");
AddMenuItem(mWindowMenu, "&Close", "Close Panel", new => UpdateMenuItem_HasActivePanel); AddMenuItem(mWindowMenu, "&Close Document", "Close Document", new => UpdateMenuItem_HasLastActiveDocument);
AddMenuItem(mWindowMenu, "Close &Panel", "Close Panel", new => UpdateMenuItem_HasActivePanel);
AddMenuItem(mWindowMenu, "&Close All", "Close All Panels"); AddMenuItem(mWindowMenu, "&Close All", "Close All Panels");
AddMenuItem(mWindowMenu, "Close All Except Current", "Close All Panels Except"); AddMenuItem(mWindowMenu, "Close All Except Current", "Close All Panels Except");
AddMenuItem(mWindowMenu, "&New View into File", "View New", new => UpdateMenuItem_HasActiveDocument); AddMenuItem(mWindowMenu, "&New View into File", "View New", new => UpdateMenuItem_HasActiveDocument);
@ -5588,6 +5594,24 @@ namespace IDE
return null; return null;
} }
public Widget GetLastActiveDocumentPanel()
{
var activePanel = GetActiveDocumentPanel();
if (activePanel != null)
return activePanel;
if (mActiveDocumentsTabbedView != null)
{
let activeTab = mActiveDocumentsTabbedView.GetActiveTab();
if (activeTab != null)
{
var lastActivePanel = activeTab.mContent;
if ((lastActivePanel is SourceViewPanel) || (lastActivePanel is DisassemblyPanel))
return lastActivePanel;
}
}
return null;
}
public void WithTabs(delegate void(TabbedView.TabButton) func) public void WithTabs(delegate void(TabbedView.TabButton) func)
{ {
WithDocumentTabbedViews(scope (documentTabbedView) => WithDocumentTabbedViews(scope (documentTabbedView) =>
@ -6513,6 +6537,21 @@ namespace IDE
} }
void TryCloseCurrentDocument() void TryCloseCurrentDocument()
{
var activeDocumentPanel = GetLastActiveDocumentPanel();
if (activeDocumentPanel != null)
{
if (activeDocumentPanel is SourceViewPanel)
{
var sourceViewPanel = (SourceViewPanel)activeDocumentPanel;
DocumentCloseClicked(sourceViewPanel);
return;
}
CloseDocument(activeDocumentPanel);
}
}
void TryCloseCurrentPanel()
{ {
var activeDocumentPanel = GetActiveDocumentPanel(); var activeDocumentPanel = GetActiveDocumentPanel();
if (activeDocumentPanel != null) if (activeDocumentPanel != null)

View file

@ -670,7 +670,7 @@ namespace IDE
Add("Breakpoint Toggle Thread", "Shift+F9"); Add("Breakpoint Toggle Thread", "Shift+F9");
Add("Build Solution", "F7"); Add("Build Solution", "F7");
Add("Cancel Build", "Ctrl+Break"); Add("Cancel Build", "Ctrl+Break");
Add("Close Panel", "Ctrl+W"); Add("Close Document", "Ctrl+W");
Add("Compile File", "Ctrl+F7"); Add("Compile File", "Ctrl+F7");
Add("Comment Selection", "Ctrl+K, Ctrl+C"); Add("Comment Selection", "Ctrl+K, Ctrl+C");
Add("Duplicate Line", "Ctrl+D"); Add("Duplicate Line", "Ctrl+D");
@ -890,6 +890,10 @@ namespace IDE
let entry = new Entry(); let entry = new Entry();
entry.mCommand = new String(cmdStr); entry.mCommand = new String(cmdStr);
// Fix for command rename
if ((cmdStr == "Close Panel") && (!sd.Contains("Close Document")))
entry.mCommand.Set("Close Document");
let keyList = scope List<KeyState>(); let keyList = scope List<KeyState>();
KeyState.Parse(keyStr, keyList); KeyState.Parse(keyStr, keyList);