1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-16 23:34:10 +02:00

Fixed constExprs with ints, hover for enum values, _ for enums

This commit is contained in:
Brian Fiete 2019-12-24 13:13:04 -08:00
parent 4087bf8e2a
commit 4dcd7f9c6a
21 changed files with 293 additions and 142 deletions

View file

@ -1335,7 +1335,7 @@ namespace IDE.ui
else
{
mHoverWatch = new HoverWatch();
if (mHoverWatch.Show(this, x, y, debugExpr))
if (mHoverWatch.Show(this, x, y, debugExpr, debugExpr))
{
mHoverWatch.mOpenMousePos = DarkTooltipManager.sLastRelMousePos;
mHoverWatch.mEvalString.Set(debugExpr); // Set to old debugStr for comparison

View file

@ -63,7 +63,7 @@ namespace IDE.ui
if (mColumnIdx == 0)
{
var hoverListView = (HoverListView)mListView;
if ((mWatchEntry.mResultType == WatchResultType.TypeClass) || (mWatchEntry.mResultType == WatchResultType.TypeValueType))
if ((mWatchEntry.mResultType.HasFlag(WatchResultType.TypeClass)) || (mWatchEntry.mResultType.HasFlag(WatchResultType.TypeValueType)))
return false;
return mouseX < LabelX + hoverListView.mFont.GetWidth(mLabel) + GS!(2);
}
@ -226,8 +226,9 @@ namespace IDE.ui
}
}
public String mDisplayString = new String() ~ delete _;
public String mOrigEvalString = new String() ~ delete _;
public String mEvalString = new String() ~ delete _;
public String mOrigEvalString = new String() ~ delete _;
public TextPanel mTextPanel;
public HoverListView mListView;
public Point mOpenMousePos;
@ -1382,7 +1383,7 @@ namespace IDE.ui
theEvent.mHandled = true;
}
public HoverListViewItem Eval(String evalString, bool isPending)
public HoverListViewItem Eval(String displayString, String evalString, bool isPending)
{
Debug.Assert(evalString != null);
mOrigEvalString.Set(evalString);
@ -1390,7 +1391,7 @@ namespace IDE.ui
mListView = CreateListView();
else
mListView.GetRoot().Clear();
return DoListViewItem(mListView, null, evalString, evalString, isPending);
return DoListViewItem(mListView, null, displayString, evalString, isPending);
}
public void SetListView(HoverListView listView)
@ -1405,7 +1406,7 @@ namespace IDE.ui
Close();
}
public bool Show(TextPanel textPanel, float x, float y, String evalString)
public bool Show(TextPanel textPanel, float x, float y, String displayString, String evalString)
{
if (mIsShown)
Clear();
@ -1434,6 +1435,11 @@ namespace IDE.ui
if (mTextPanel.mHoverWatch != null)
Debug.Assert(mTextPanel.mHoverWatch == this);
mTextPanel.mHoverWatch = this;
if (displayString == null)
mDisplayString.Clear();
else
mDisplayString.Set(displayString);
if (evalString == null)
mEvalString.Clear();
else
@ -1447,7 +1453,7 @@ namespace IDE.ui
if (evalString != null)
{
if (Eval(evalString, false).Failed)
if (Eval(displayString, evalString, false).Failed)
{
if (mListView.mParent != null)
mListView.RemoveSelf();
@ -1529,7 +1535,7 @@ namespace IDE.ui
widgetWindow.mRootWidget = null; // Detach root
//Debug.WriteLine("Hoverwatch showing");
mClosed = false;
Show(sourceViewPanel, mOrigX, mOrigY, mOrigEvalString);
Show(sourceViewPanel, mOrigX, mOrigY, mDisplayString, mOrigEvalString);
sourceViewPanel.mHoverWatch = this;
for (int32 listIdx = 0; listIdx < openYList.Count; listIdx++)

View file

@ -198,7 +198,7 @@ namespace IDE.ui
hoverWatch.mAllowSideEffects = true;
hoverWatch.mOrigEvalString.Set(mImmediateWidget.mResultHoverWatch.mOrigEvalString);
hoverWatch.SetListView(mImmediateWidget.mResultHoverWatch.mListView);
hoverWatch.Show(mImmediateWidget.mPanel, mX + GS!(2), mY + GS!(3), null);
hoverWatch.Show(mImmediateWidget.mPanel, mX + GS!(2), mY + GS!(3), null, null);
hoverWatch.mRehupEvent.Add(new () =>
{
mImmediateWidget.RehupResult();
@ -316,7 +316,7 @@ namespace IDE.ui
{
// Is a continuation
if (mLastEvalString != null)
result = mResultHoverWatch.Eval(mLastEvalString, true);
result = mResultHoverWatch.Eval(mLastEvalString, mLastEvalString, true);
gApp.mIsImmediateDebugExprEval = true;
}
else
@ -341,7 +341,7 @@ namespace IDE.ui
gApp.mScriptManager.QueueCommands(StringView(cmdText, 1), "Immediate", .NoLines | .NoWait);
}
else
result = mResultHoverWatch.Eval(cmdText, false);
result = mResultHoverWatch.Eval(cmdText, cmdText, false);
mLastTextVersionId = mEditWidgetContent.mData.mCurTextVersionId;
gApp.mIsImmediateDebugExprEval = true;
}

View file

@ -67,7 +67,7 @@ namespace IDE.ui
//hoverWatch.SetListView(mImmediateWidget.mResultHoverWatch.mListView);
//hoverWatch.Show(mTextPanel, mX + 2, mY + 3, evalStr);
hoverWatch.mOpenMousePos = DarkTooltipManager.sLastRelMousePos;
hoverWatch.Show(mOutputPanel, mX, mY, evalStr);
hoverWatch.Show(mOutputPanel, mX, mY, evalStr, evalStr);
mOutputPanel.mHoverWatch = hoverWatch;
}
}

View file

@ -1609,9 +1609,9 @@ namespace IDE.ui
{
resolveParams.mNavigationData = new String(autocompleteInfo);
}
else if (resolveType == ResolveType.GetVarType)
else if (resolveType == ResolveType.GetResultString)
{
resolveParams.mTypeDef = new String(autocompleteInfo);
resolveParams.mResultString = new String(autocompleteInfo);
}
else if (resolveType == ResolveType.GetCurrentLocation)
{
@ -4819,7 +4819,33 @@ namespace IDE.ui
if (debugExpr != null)
triedShow = true;
if ((debugExpr == null) || (isOverMessage) || (!mHoverWatch.Show(this, x, y, debugExpr)))
bool didShow = false;
//if ((debugExpr == "var") || (debugExpr == "let"))
String origDebugExpr = null;
if ((debugExpr != null) || (isOverMessage))
{
let resolveParams = scope ResolveParams();
resolveParams.mOverrideCursorPos = (int32)textIdx;
Classify(ResolveType.GetResultString, resolveParams);
if (!String.IsNullOrEmpty(resolveParams.mResultString))
{
origDebugExpr = scope:: String();
origDebugExpr.Set(debugExpr);
debugExpr.Set(resolveParams.mResultString);
}
if (!triedShow)
{
mHoverWatch.Show(this, x, y, debugExpr, debugExpr);
triedShow = true;
}
}
if ((!didShow) &&
((debugExpr == null) || (isOverMessage) || (!mHoverWatch.Show(this, x, y, origDebugExpr ?? debugExpr, debugExpr))))
{
#if IDE_C_SUPPORT
if ((mIsClang) && (textIdx != -1))
@ -4918,7 +4944,7 @@ namespace IDE.ui
if (showMouseoverString != null)
{
triedShow = true;
mHoverWatch.Show(this, x, y, showMouseoverString);
mHoverWatch.Show(this, x, y, showMouseoverString, showMouseoverString);
if (debugExpr != null)
mHoverWatch.mEvalString.Set(debugExpr); // Set to old debugStr for comparison
}
@ -4928,25 +4954,6 @@ namespace IDE.ui
}
if (!hasHoverWatchOpen)
mHoverWatch.mOpenMousePos = DarkTooltipManager.sLastRelMousePos;
if ((debugExpr == "var") || (debugExpr == "let"))
{
let resolveParams = scope ResolveParams();
resolveParams.mOverrideCursorPos = (int32)textIdx;
Classify(ResolveType.GetVarType, resolveParams);
if (resolveParams.mTypeDef != null)
{
debugExpr.Set(resolveParams.mTypeDef);
if (!debugExpr.IsEmpty)
debugExpr.Insert(0, ":");
}
if (!triedShow)
{
mHoverWatch.Show(this, x, y, debugExpr);
triedShow = true;
}
}
}
// Not used?

View file

@ -128,7 +128,7 @@ namespace IDE.ui
{
base.MouseDown(x, y, btn, btnCount);
if (x >= mListView.mParent.mWidth - LabelX - GS!(34))
if ((x >= mListView.mParent.mWidth - LabelX - GS!(34)) && (mParentItem != null))
{
PopupCallStackPanel();
}

View file

@ -16,16 +16,16 @@ namespace IDE.ui
{
public enum WatchResultType
{
None,
Value,
Int,
MM128,
Object,
Pointer,
TypeClass,
TypeValueType,
Namespace,
Text
None = 0,
Value = 1,
Int = 2,
MM128 = 4,
Object = 8,
Pointer = 0x10,
TypeClass = 0x20,
TypeValueType = 0x40,
Namespace = 0x80,
Text = 0x100
}
public class WatchEntry
@ -54,6 +54,18 @@ namespace IDE.ui
public int32 mSeriesFirstVersion = -1;
public int32 mSeriesVersion = -1;
public bool IsConstant
{
get
{
if (mEvalStr.IsEmpty)
return true;
if (mEvalStr[0].IsNumber)
return true;
return false;
}
}
public bool ParseCmd(List<StringView> cmd)
{
switch (scope String(cmd[0]))
@ -62,25 +74,25 @@ namespace IDE.ui
switch (scope String(cmd[1]))
{
case "object":
mResultType = WatchResultType.Object;
mResultType |= WatchResultType.Object;
return true;
case "pointer":
mResultType = WatchResultType.Pointer;
mResultType |= WatchResultType.Pointer;
return true;
case "class":
mResultType = WatchResultType.TypeClass;
mResultType |= WatchResultType.TypeClass;
return true;
case "valuetype":
mResultType = WatchResultType.TypeValueType;
mResultType |= WatchResultType.TypeValueType;
return true;
case "namespace":
mResultType = WatchResultType.Namespace;
mResultType |= WatchResultType.Namespace;
return true;
case "int":
mResultType = WatchResultType.Int;
mResultType |= WatchResultType.Int;
return true;
case "mm128":
mResultType = WatchResultType.MM128;
mResultType |= WatchResultType.MM128;
return true;
}
break;
@ -1131,26 +1143,26 @@ namespace IDE.ui
{
imageIdx = .RedDot;
}
else if (mWatchEntry.mResultType == WatchResultType.Object)
else if (mWatchEntry.mResultType.HasFlag(WatchResultType.Object))
{
if (mWatchEntry.mIsDeleted)
imageIdx = .IconObjectDeleted;
else
imageIdx = .IconObject;
}
else if (mWatchEntry.mResultType == WatchResultType.TypeClass)
else if (mWatchEntry.mResultType.HasFlag(WatchResultType.TypeClass))
{
imageIdx = .Type_Class;
}
else if (mWatchEntry.mResultType == WatchResultType.TypeValueType)
else if (mWatchEntry.mResultType.HasFlag(WatchResultType.TypeValueType))
{
imageIdx = .Type_ValueType;
}
else if (mWatchEntry.mResultType == WatchResultType.Namespace)
else if (mWatchEntry.mResultType.HasFlag(WatchResultType.Namespace))
{
imageIdx = .Namespace;
}
else if (mWatchEntry.mResultType == WatchResultType.Pointer)
else if (mWatchEntry.mResultType.HasFlag(WatchResultType.Pointer))
{
imageIdx = .IconPointer;
}
@ -2587,9 +2599,9 @@ namespace IDE.ui
public static bool AddDisplayTypeMenu(String label, Menu menu, WatchResultType watchResultType, String referenceId, bool includeDefault)
{
bool isInt = watchResultType == WatchResultType.Int;
bool isMM128 = watchResultType == WatchResultType.MM128;
bool canSetFormat = isInt || isMM128;
bool hasInt = watchResultType.HasFlag(WatchResultType.Int);
bool hasMM128 = watchResultType.HasFlag(WatchResultType.MM128);
bool canSetFormat = hasInt || hasMM128;
var debugger = IDEApp.sApp.mDebugger;
DebugManager.IntDisplayType intDisplayType;
@ -2606,7 +2618,7 @@ namespace IDE.ui
Menu parentItem = menu.AddItem(label);
//anItem.mIconImage = DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.Check);
if (isInt)
if (hasInt)
{
for (DebugManager.IntDisplayType i = default; i < DebugManager.IntDisplayType.COUNT; i++)
{
@ -2622,8 +2634,9 @@ namespace IDE.ui
new () => SetDisplayType(referenceId, toType, mmDisplayType));
}
}
else if (isMM128)
{
if (hasMM128)
{
for (DebugManager.MmDisplayType i = default; i < DebugManager.MmDisplayType.COUNT; i++)
{
var toType = i;
@ -2677,49 +2690,52 @@ namespace IDE.ui
if (watchEntry.mReferenceId != null)
AddDisplayTypeMenu("Watch Display", menu, listViewItem.mWatchEntry.mResultType, watchEntry.mReferenceId, true);
anItem = menu.AddItem("Break When Value Changes");
if (watchEntry.mMemoryBreakpointAddr == 0)
if (!watchEntry.IsConstant)
{
anItem.mOnMenuItemSelected.Add(new (evt) =>
{
String evalStr = scope String();
CompactChildExpression(listViewItem, evalStr);
evalStr.Insert(0, "&");
gApp.mBreakpointPanel.CreateMemoryBreakpoint(evalStr);
gApp.MarkDirty();
});
}
else
{
anItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);
anItem.mOnMenuItemSelected.Add(new (evt) =>
{
for (int breakIdx < gApp.mDebugger.mBreakpointList.Count)
anItem = menu.AddItem("Break When Value Changes");
if (watchEntry.mMemoryBreakpointAddr == 0)
{
anItem.mOnMenuItemSelected.Add(new (evt) =>
{
let breakpoint = gApp.mDebugger.mBreakpointList[breakIdx];
if (breakpoint.mMemoryAddress == watchEntry.mMemoryBreakpointAddr)
String evalStr = scope String();
CompactChildExpression(listViewItem, evalStr);
evalStr.Insert(0, "&");
gApp.mBreakpointPanel.CreateMemoryBreakpoint(evalStr);
gApp.MarkDirty();
});
}
else
{
anItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);
anItem.mOnMenuItemSelected.Add(new (evt) =>
{
for (int breakIdx < gApp.mDebugger.mBreakpointList.Count)
{
gApp.mDebugger.DeleteBreakpoint(breakpoint);
gApp.RefreshWatches();
breakIdx--;
let breakpoint = gApp.mDebugger.mBreakpointList[breakIdx];
if (breakpoint.mMemoryAddress == watchEntry.mMemoryBreakpointAddr)
{
gApp.mDebugger.DeleteBreakpoint(breakpoint);
gApp.RefreshWatches();
breakIdx--;
}
}
}
});
});
let configItem = menu.AddItem("Configure Breakpoint");
configItem.mOnMenuItemSelected.Add(new (evt) =>
{
for (int breakIdx < gApp.mDebugger.mBreakpointList.Count)
let configItem = menu.AddItem("Configure Breakpoint");
configItem.mOnMenuItemSelected.Add(new (evt) =>
{
let breakpoint = gApp.mDebugger.mBreakpointList[breakIdx];
if (breakpoint.mMemoryAddress == watchEntry.mMemoryBreakpointAddr)
for (int breakIdx < gApp.mDebugger.mBreakpointList.Count)
{
ConditionDialog dialog = new ConditionDialog();
dialog.Init(breakpoint);
dialog.PopupWindow(listView.mWidgetWindow);
let breakpoint = gApp.mDebugger.mBreakpointList[breakIdx];
if (breakpoint.mMemoryAddress == watchEntry.mMemoryBreakpointAddr)
{
ConditionDialog dialog = new ConditionDialog();
dialog.Init(breakpoint);
dialog.PopupWindow(listView.mWidgetWindow);
}
}
}
});
});
}
}
if (watchEntry.mResultType == .Pointer)