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

Added mouseover propery evaluation

This commit is contained in:
Brian Fiete 2020-06-15 09:01:49 -07:00
parent 63dc33a970
commit 85943230b1
9 changed files with 75 additions and 23 deletions

View file

@ -83,9 +83,10 @@ namespace IDE.Debugger
DeselectCallStackIdx = 0x04,
AllowSideEffects = 0x08,
AllowCalls = 0x10,
MemoryAddress = 0x20,
MemoryWatch = 0x40,
Symbol = 0x80
AllowProperties = 0x20,
MemoryAddress = 0x40,
MemoryWatch = 0x80,
Symbol = 0x100
}
[Reflect]

View file

@ -123,6 +123,7 @@ namespace IDE
public List<String> mSymbolSearchPath = new .() ~ DeleteContainerAndItems!(_);
public List<String> mAutoFindPaths = new .() ~ DeleteContainerAndItems!(_);
public int32 mProfileSampleRate = 1000;
public bool mAutoEvaluateProperties = false;
public void Serialize(StructuredData sd)
{
@ -163,6 +164,7 @@ namespace IDE
sd.RemoveIfEmpty();
}
sd.Add("ProfileSampleRate", mProfileSampleRate);
sd.Add("AutoEvaluateProperties", mAutoEvaluateProperties);
}
public void Deserialize(StructuredData sd)
@ -201,6 +203,7 @@ namespace IDE
}
}
sd.Get("ProfileSampleRate", ref mProfileSampleRate);
sd.Get("AutoEvaluateProperties", ref mAutoEvaluateProperties);
}
public void Apply()

View file

@ -436,6 +436,21 @@ namespace IDE.ui
{
base.Update();
for (let item in mListView.GetRoot().mChildItems)
{
let listViewItem = (HoverListViewItem)item;
if (listViewItem.mWatchEntry?.mIsPending == true)
{
if ((gApp.mDebugger.IsPaused(true)) && (!gApp.mDebugger.HasMessages()))
{
let listView = (HoverListView)listViewItem.mListView;
DoListViewItem(listView, listViewItem, listViewItem.mWatchEntry.mName, listViewItem.mWatchEntry.mEvalStr, true);
FinishListView(listView, listView.mX, listView.mY, true);
gApp.RefreshVisibleViews();
}
}
}
if (mCloseDelay > 1)
mCloseDelay--;
if (mCloseCountdown > 0)
@ -591,6 +606,7 @@ namespace IDE.ui
public void Refresh()
{
mAllowSideEffects = true;
if (mListView != null)
RefreshListView(mListView);
MarkDirty();
@ -606,8 +622,15 @@ namespace IDE.ui
DoListViewItem(hoverListView, (HoverListViewItem)listViewItem, name, evalStr, false);
}
void RefreshWatch()
{
Refresh();
}
HoverListViewItem DoListViewItem(HoverListView listView, HoverListViewItem listViewItem, String displayString, String evalString, bool isPending, WatchEntry parentWatchEntry = null)
{
Debug.WriteLine("{} {}", evalString, isPending);
if ((displayString.StartsWith(":")) && (displayString.Contains('\n')))
{
HoverListViewItem headListView = null;
@ -719,6 +742,8 @@ namespace IDE.ui
flags |= DebugManager.EvalExpressionFlags.DeselectCallStackIdx;
if (mAllowSideEffects)
flags |= .AllowSideEffects | .AllowCalls;
if (gApp.mSettings.mDebuggerSettings.mAutoEvaluateProperties)
flags |= .AllowProperties;
DebugManager.Language language = mLanguage;
if (parentWatchEntry != null)
@ -731,11 +756,26 @@ namespace IDE.ui
valueSubItem.Label = "";
return useListViewItem;
}
watch.mIsPending = false;
}
var vals = scope List<StringView>(val.Split('\n'));
String.NewOrSet!(valueSubItem.mLabel, vals[0]);
if (valueSubItem.mLabel.StartsWith("!", StringComparison.Ordinal))
if (vals[0] == "!sideeffects")
{
if (useListViewItem.mWatchRefreshButton == null)
{
useListViewItem.mWatchRefreshButton = new WatchRefreshButton();
useListViewItem.mWatchRefreshButton.Resize(GS!(-22), 0, GS!(20), GS!(20));
useListViewItem.mWatchRefreshButton.mOnMouseDown.Add(new (evt) => RefreshWatch());
valueSubItem.AddWidget(useListViewItem.mWatchRefreshButton);
mListView.mListSizeDirty = true;
}
valueSubItem.mFailed = false;
valueSubItem.Label = "";
}
else if (valueSubItem.mLabel.StartsWith("!", StringComparison.Ordinal))
{
var errorVals = scope List<StringView>(scope String(valueSubItem.mLabel, 1).Split('\t'));
if (errorVals.Count > 1)
@ -1052,9 +1092,10 @@ namespace IDE.ui
//TODO:
FontMetrics fontMetrics = .();
float nameHeight = font.Draw(null, listViewItem.mLabel, 0, 0, -1, 0, FontOverflowMode.Clip, &fontMetrics);
nameWidth = Math.Max(nameWidth, fontMetrics.mMaxWidth);
//listViewItem.mSelfHeight += nameHeight - font.GetLineSpacing();
//listViewItem.mSelfHeight = nameHeight;
float thisNameWidth = fontMetrics.mMaxWidth;
if (listViewItem.mWatchRefreshButton != null)
thisNameWidth += GS!(18);
nameWidth = Math.Max(nameWidth, thisNameWidth);
float addHeight = nameHeight - listView.mFont.GetLineSpacing();
childHeights += addHeight;

View file

@ -269,6 +269,7 @@ namespace IDE.ui
AddPropertiesItem(root, "Symbol File Locations", "mSymbolSearchPath");
AddPropertiesItem(root, "Auto Find Paths", "mAutoFindPaths");
AddPropertiesItem(root, "Profile Sample Rate", "mProfileSampleRate");
AddPropertiesItem(root, "Auto Evaluate Properties", "mAutoEvaluateProperties");
}
protected override void ResetSettings()

View file

@ -1005,12 +1005,13 @@ namespace IDE.ui
public void AddRefreshButton()
{
if ((mWatchRefreshButton == null) && (mColumnIdx == 0) && (mSubItems.Count >= 3))
int columnIdx = 2;
if ((mWatchRefreshButton == null) && (mColumnIdx == 0) && (columnIdx < mSubItems.Count))
{
mWatchRefreshButton = new WatchRefreshButton();
mWatchRefreshButton.Resize(-16, 0, 20, 20);
mWatchRefreshButton.Resize(GS!(-16), 0, GS!(20), GS!(20));
mWatchRefreshButton.mOnMouseDown.Add(new (evt) => RefreshWatch());
var typeSubItem = GetSubItem(2);
var typeSubItem = GetSubItem(columnIdx);
typeSubItem.AddWidget(mWatchRefreshButton);
mListView.mListSizeDirty = true;
}
@ -2237,10 +2238,11 @@ namespace IDE.ui
var errStr = scope String(vals[0]);
errStr.Remove(0);
bool hadSideEffects = vals[0] == "!sideeffects";
bool hadPropertyEval = vals[0] == "!property";
if ((!wasNewExpression) && (isTopLevel))
{
if (((!valueSubItem.mFailed) && (watch.mHadValue)) || (hadSideEffects))
if (((!valueSubItem.mFailed) && (watch.mHadValue)) || (hadSideEffects) || (hadPropertyEval))
{
watch.mHasValue = true;
listViewItem.SetDisabled(true, hadSideEffects);

View file

@ -4085,6 +4085,9 @@ DbgTypedValue DbgExprEvaluator::GetResult()
// }
// }
SetAndRestoreValue<DwEvalExpressionFlags> prevFlags(mExpressionFlags);
if ((mExpressionFlags & DwEvalExpressionFlag_AllowPropertyEval) != 0)
mExpressionFlags = (DwEvalExpressionFlags)(mExpressionFlags | DwEvalExpressionFlag_AllowCalls);
mResult = CreateCall(mPropSrc, mPropTarget, mPropGet, false, mIndexerExprValues, mIndexerValues);
}
}

View file

@ -105,10 +105,11 @@ enum DwEvalExpressionFlags : int16
DwEvalExpressionFlag_DeselectCallStackIdx = 0x04,
DwEvalExpressionFlag_AllowSideEffects = 0x08,
DwEvalExpressionFlag_AllowCalls = 0x10,
DwEvalExpressionFlag_MemoryAddress = 0x20,
DwEvalExpressionFlag_MemoryWatch = 0x40,
DwEvalExpressionFlag_Symbol = 0x80,
DwEvalExpressionFlag_StepIntoCalls = 0x100,
DwEvalExpressionFlag_AllowPropertyEval = 0x20,
DwEvalExpressionFlag_MemoryAddress = 0x40,
DwEvalExpressionFlag_MemoryWatch = 0x80,
DwEvalExpressionFlag_Symbol = 0x100,
DwEvalExpressionFlag_StepIntoCalls = 0x200,
};
struct DwDisplayInfo