1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-11 04:52:21 +02:00

Minor IDE modifications

This commit is contained in:
Brian Fiete 2019-09-29 07:44:23 -07:00
parent f8d4d0ded0
commit 908dbe1a6e
8 changed files with 97 additions and 31 deletions

View file

@ -248,6 +248,11 @@ namespace Beefy.widgets
SetFocus(); SetFocus();
} }
public virtual void WindowCreated()
{
}
public virtual void PopupWindow(WidgetWindow parentWindow, float offsetX = 0, float offsetY = 0) public virtual void PopupWindow(WidgetWindow parentWindow, float offsetX = 0, float offsetY = 0)
{ {
if (mClosed) if (mClosed)
@ -295,6 +300,7 @@ namespace Beefy.widgets
widgetWindow.mOnWindowCloseQuery.Add(windowCloseHandler); widgetWindow.mOnWindowCloseQuery.Add(windowCloseHandler);
widgetWindow.mOnWindowKeyDown.Add(new => WindowKeyDown); widgetWindow.mOnWindowKeyDown.Add(new => WindowKeyDown);
WindowCreated();
} }
public virtual bool HandleTab(int dir) public virtual bool HandleTab(int dir)

View file

@ -104,7 +104,8 @@ namespace IDE
public enum ContextFlags public enum ContextFlags
{ {
None = 0, None = 0,
Editor = 1 MainWindow = 1,
Editor = 2,
} }
public String mName ~ delete _; public String mName ~ delete _;
@ -158,7 +159,7 @@ namespace IDE
}; };
public CommandMap mKeyMap = new .() ~ delete _; public CommandMap mKeyMap = new .() ~ delete _;
void Add(StringView name, Action act, IDECommand.ContextFlags contextFlags = .None) void Add(StringView name, Action act, IDECommand.ContextFlags contextFlags = .MainWindow)
{ {
let cmd = new IDECommand(); let cmd = new IDECommand();
cmd.mName = new String(name); cmd.mName = new String(name);
@ -170,7 +171,7 @@ namespace IDE
public void Init() public void Init()
{ {
Add("About", new => gApp.ShowAbout); Add("About", new => gApp.ShowAbout);
Add("Autocomplete", new => gApp.Cmd_ShowAutoComplete); Add("Autocomplete", new => gApp.Cmd_ShowAutoComplete, .None);
Add("Bookmark Next", new => gApp.Cmd_NextBookmark, .Editor); Add("Bookmark Next", new => gApp.Cmd_NextBookmark, .Editor);
Add("Bookmark Prev", new => gApp.Cmd_PrevBookmark, .Editor); Add("Bookmark Prev", new => gApp.Cmd_PrevBookmark, .Editor);
Add("Bookmark Toggle", new => gApp.Cmd_ToggleBookmark, .Editor); Add("Bookmark Toggle", new => gApp.Cmd_ToggleBookmark, .Editor);

View file

@ -1,4 +1,6 @@
using System; //abc using System;
using System.Security.Cryptography;
using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.IO; using System.IO;
@ -10,7 +12,6 @@ using Beefy.widgets;
using Beefy.gfx; using Beefy.gfx;
using Beefy.theme; using Beefy.theme;
using Beefy.theme.dark; using Beefy.theme.dark;
using IDE.ui;
using Beefy.sys; using Beefy.sys;
using Beefy.events; using Beefy.events;
using Beefy.geom; using Beefy.geom;
@ -20,8 +21,7 @@ using Beefy.utils;
using IDE.Debugger; using IDE.Debugger;
using IDE.Compiler; using IDE.Compiler;
using IDE.Util; using IDE.Util;
using System.Security.Cryptography; using IDE.ui;
using System.Text;
using IDE.util; using IDE.util;
[AttributeUsage(.Method, .ReflectAttribute | .AlwaysIncludeTarget, ReflectUser=.All)] [AttributeUsage(.Method, .ReflectAttribute | .AlwaysIncludeTarget, ReflectUser=.All)]
@ -3363,12 +3363,10 @@ namespace IDE
[IDECommand] [IDECommand]
public void Cmd_ShowAutoComplete() public void Cmd_ShowAutoComplete()
{ {
var activeTextPanel = GetActivePanel() as TextPanel; var sewc = GetActiveSourceEditWidgetContent();
if (activeTextPanel != null) if (sewc != null)
{ {
var sewc = activeTextPanel.EditWidget.mEditWidgetContent as SourceEditWidgetContent; sewc.ShowAutoComplete(true);
if (sewc != null)
sewc.ShowAutoComplete(true);
} }
} }
@ -4885,7 +4883,7 @@ namespace IDE
IDETabbedView CreateTabbedView() IDETabbedView CreateTabbedView()
{ {
var tabbedView = new IDETabbedView(); var tabbedView = new IDETabbedView();
tabbedView.mSharedData.mOpenNewWindowDelegate.Add(new (fromTabbedView, newWindow) => SetupNewWindow(newWindow)); tabbedView.mSharedData.mOpenNewWindowDelegate.Add(new (fromTabbedView, newWindow) => SetupNewWindow(newWindow, true));
tabbedView.mSharedData.mTabbedViewClosed.Add(new (tabbedView) => tabbedView.mSharedData.mTabbedViewClosed.Add(new (tabbedView) =>
{ {
if (tabbedView == mActiveDocumentsTabbedView) if (tabbedView == mActiveDocumentsTabbedView)
@ -4894,10 +4892,11 @@ namespace IDE
return tabbedView; return tabbedView;
} }
void SetupNewWindow(WidgetWindow window) public void SetupNewWindow(WidgetWindow window, bool isMainWindow)
{ {
window.mOnWindowKeyDown.Add(new => SysKeyDown); window.mOnWindowKeyDown.Add(new => SysKeyDown);
window.mOnWindowCloseQuery.Add(new => SecondaryAllowClose); if (isMainWindow)
window.mOnWindowCloseQuery.Add(new => SecondaryAllowClose);
} }
DarkTabbedView FindDocumentTabbedView() DarkTabbedView FindDocumentTabbedView()
@ -5045,6 +5044,28 @@ namespace IDE
return null; return null;
} }
public SourceEditWidgetContent GetActiveSourceEditWidgetContent()
{
let activeWindow = GetActiveWindow();
if (activeWindow.mFocusWidget != null)
{
if (let editWidget = activeWindow.mFocusWidget as EditWidget)
{
let sewc = editWidget.mEditWidgetContent as SourceEditWidgetContent;
if (sewc != null)
return sewc;
}
}
var activeTextPanel = GetActivePanel() as TextPanel;
if (activeTextPanel != null)
{
return activeTextPanel.EditWidget.mEditWidgetContent as SourceEditWidgetContent;
}
return null;
}
public WidgetWindow GetActiveWindow() public WidgetWindow GetActiveWindow()
{ {
for (let window in mWindows) for (let window in mWindows)
@ -6345,7 +6366,7 @@ namespace IDE
} }
else else
mWorkspace.mDir = fullDir; mWorkspace.mDir = fullDir;
case "-path": case "-file":
String.NewOrSet!(mDeferredOpenFileName, value); String.NewOrSet!(mDeferredOpenFileName, value);
if (mDeferredOpenFileName.EndsWith(".bfdbg", .OrdinalIgnoreCase)) if (mDeferredOpenFileName.EndsWith(".bfdbg", .OrdinalIgnoreCase))
mDeferredOpen = .DebugSession; mDeferredOpen = .DebugSession;
@ -6584,11 +6605,26 @@ namespace IDE
void SysKeyDown(KeyDownEvent evt) void SysKeyDown(KeyDownEvent evt)
{ {
if (evt.mHandled)
return;
var window = (WidgetWindow)evt.mSender; var window = (WidgetWindow)evt.mSender;
IDECommand.ContextFlags useFlags = .None;
var activeWindow = GetActiveWindow();
bool isMainWindow = activeWindow.mRootWidget is MainFrame;
var activePanel = GetActivePanel() as Panel;
if (activePanel is SourceViewPanel)
useFlags |= .Editor;
else if (activePanel is DisassemblyPanel)
useFlags |= .Editor;
if (isMainWindow)
useFlags |= .MainWindow;
if (evt.mKeyCode == .Tab) if (evt.mKeyCode == .Tab)
{ {
var activePanel = GetActivePanel() as Panel;
if (activePanel != null) if (activePanel != null)
{ {
if (activePanel.HandleTab(window.IsKeyDown(.Shift) ? -1 : 1)) if (activePanel.HandleTab(window.IsKeyDown(.Shift) ? -1 : 1))
@ -6620,20 +6656,19 @@ namespace IDE
} }
else if (var command = commandBase as IDECommand) else if (var command = commandBase as IDECommand)
{ {
IDECommand.ContextFlags useFlags = .None;
var activePanel = GetActivePanel();
if (activePanel is SourceViewPanel)
useFlags |= .Editor;
else if (activePanel is DisassemblyPanel)
useFlags |= .Editor;
bool foundMatch = false; bool foundMatch = false;
if (useFlags != .None) if (useFlags != .None)
{ {
var checkCommand = command; var checkCommand = command;
while (checkCommand != null) while (checkCommand != null)
{ {
if (checkCommand.mContextFlags.HasFlag(useFlags)) bool matches = checkCommand.mContextFlags == .None;
if (checkCommand.mContextFlags.HasFlag(.Editor))
matches |= useFlags.HasFlag(.Editor);
if (checkCommand.mContextFlags.HasFlag(.MainWindow))
matches |= useFlags.HasFlag(.MainWindow);
if (matches)
{ {
checkCommand.mAction(); checkCommand.mAction();
foundMatch = true; foundMatch = true;

View file

@ -12,6 +12,12 @@ namespace IDE.ui
public DarkButton mNextButton; public DarkButton mNextButton;
public SettingHistoryManager mSettingHistoryManager; public SettingHistoryManager mSettingHistoryManager;
public override void WindowCreated()
{
base.WindowCreated();
gApp.SetupNewWindow(mWidgetWindow, false);
}
public void CreatePrevNextButtons() public void CreatePrevNextButtons()
{ {
mPrevButton = new DarkButton(); mPrevButton = new DarkButton();

View file

@ -1908,6 +1908,14 @@ namespace IDE.ui
gApp.mWorkspace.SetChanged(); gApp.mWorkspace.SetChanged();
} }
}); });
item = menu.AddItem("Rename");
item.mOnMenuItemSelected.Add(new (item) =>
{
var projectItem = GetSelectedProjectItem();
if (projectItem != null)
RenameItem(projectItem);
});
item = menu.AddItem("Refresh"); item = menu.AddItem("Refresh");
item.mOnMenuItemSelected.Add(new (item) => item.mOnMenuItemSelected.Add(new (item) =>

View file

@ -908,10 +908,17 @@ namespace IDE.ui
protected override bool ApplyChanges() protected override bool ApplyChanges()
{ {
if (mApplyButton.mDisabled)
return true;
if (mProject.mLocked) if (mProject.mLocked)
{ {
let dialog = gApp.Fail( let dialog = gApp.Fail(
"This project is locked because it may be a shared library, and editing shared libraries may have unwanted effects on other programs that use it.\n\nIf you are sure you want to edit this project then you can unlock it with the lock icon in the lower left of the", """
This project is locked because it may be a shared library, and editing shared libraries may have unwanted effects on other programs that use it.
If you are sure you want to edit this project then you can unlock it with the lock icon in the lower left of the properties dialog.
""",
null, mWidgetWindow); null, mWidgetWindow);
dialog.mWindowFlags |= .Modal; dialog.mWindowFlags |= .Modal;
if (dialog != null) if (dialog != null)
@ -1090,6 +1097,7 @@ namespace IDE.ui
{ {
mProject.mLocked = !mProject.mLocked; mProject.mLocked = !mProject.mLocked;
gApp.mWorkspace.SetChanged(); gApp.mWorkspace.SetChanged();
gApp.mProjectPanel.MarkDirty();
}); });
if (mProject.mLocked) if (mProject.mLocked)
menuItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check); menuItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);

View file

@ -3057,7 +3057,11 @@ namespace IDE.ui
menuItem = menu.AddItem("Go to Definition"); menuItem = menu.AddItem("Go to Definition");
menuItem.SetDisabled(!hasText); menuItem.SetDisabled(!hasText);
menuItem.mOnMenuItemSelected.Add(new (evt) => IDEApp.sApp.GoToDefinition()); menuItem.mOnMenuItemSelected.Add(new (evt) => gApp.GoToDefinition());
menuItem = menu.AddItem("Rename Symbol");
menuItem.SetDisabled(!hasText);
menuItem.mOnMenuItemSelected.Add(new (evt) => gApp.Cmd_RenameSymbol());
menuItem = menu.AddItem("Add Watch"); menuItem = menu.AddItem("Add Watch");
menuItem.SetDisabled(!hasText); menuItem.SetDisabled(!hasText);

View file

@ -24,8 +24,7 @@ namespace IDE.ui
var editText = scope String(); var editText = scope String();
GetText(editText); GetText(editText);
int cursorPos = doAutoComplete ? mEditWidgetContent.CursorTextPos - 1 : -1; int cursorPos = doAutoComplete ? mEditWidgetContent.CursorTextPos : -1;
#unwarn
int editOffset = 0; int editOffset = 0;
if (cursorPos > 0) if (cursorPos > 0)
@ -54,8 +53,7 @@ namespace IDE.ui
{ {
mEditWidgetContent.mData.mText[editOffset + ofs].mDisplayTypeId = isValid ? 0 : 1; mEditWidgetContent.mData.mText[editOffset + ofs].mDisplayTypeId = isValid ? 0 : 1;
} }
//mColors[0] = isValid ? 0xFFFFFFFF : 0xFFFF8080;
if (doAutoComplete) if (doAutoComplete)
{ {
String autocompleteInfo = scope String(); String autocompleteInfo = scope String();