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

Embedded string view in watch window, series watch format

This commit is contained in:
Brian Fiete 2022-05-18 13:23:10 -07:00
parent c925d7ccc2
commit 1b9e0490f2
13 changed files with 521 additions and 116 deletions

View file

@ -531,10 +531,23 @@ namespace Beefy.theme.dark
}
}
var darkListView = mListView as DarkListView;
float height = darkListView.mFont.GetLineSpacing();
uint32 color = Focused ? mFocusColor : mSelectColor;
using (g.PushColor(color))
g.DrawButton(DarkTheme.sDarkTheme.GetImage(Focused ? DarkTheme.ImageIdx.MenuSelect : DarkTheme.ImageIdx.MenuNonFocusSelect),
hiliteX, 0, Math.Max(lastStrWidth + GS!(16), mWidth - GS!(4) - hiliteX));
{
if (Math.Abs(height - mSelfHeight) < height * 0.5f)
{
g.DrawButton(DarkTheme.sDarkTheme.GetImage(Focused ? DarkTheme.ImageIdx.MenuSelect : DarkTheme.ImageIdx.MenuNonFocusSelect),
hiliteX, 0, Math.Max(lastStrWidth + GS!(16), mWidth - GS!(4) - hiliteX));
}
else
{
g.DrawBox(DarkTheme.sDarkTheme.GetImage(Focused ? DarkTheme.ImageIdx.MenuSelect : DarkTheme.ImageIdx.MenuNonFocusSelect),
hiliteX, 0, Math.Max(lastStrWidth + GS!(16), mWidth - GS!(4) - hiliteX), mSelfHeight);
}
}
}
int FindItemAtY(float y)

View file

@ -3469,7 +3469,19 @@ namespace Beefy.widgets
GetTextCoordAtLineChar(line, lineChar, out x, out y);
int coordLine;
GetLineAndColumnAtCoord(x, y, out coordLine, out lineColumn);
if (!GetLineAndColumnAtCoord(x, y, out coordLine, out lineColumn))
{
GetLinePosition(line, var lineStart, var lineEnd);
lineColumn = 0;
int checkTextPos = lineStart;
for (int i < lineChar)
{
let c32 = mData.GetChar32(ref checkTextPos);
if (!c32.IsCombiningMark)
lineColumn++;
}
}
}
public virtual void MoveCursorTo(int line, int charIdx, bool centerCursor = false, int movingDir = 0, CursorMoveKind cursorMoveKind = .Unknown)

View file

@ -3665,6 +3665,11 @@ namespace System
return String.Unquote(Ptr, Length, outString);
}
public Result<void> Unescape(String outString)
{
return String.Unescape(Ptr, Length, outString);
}
[NoDiscard]
public StringView Substring(int pos)
{

View file

@ -100,6 +100,7 @@ namespace IDE.Debugger
Symbol = 0x100,
StepIntoCall = 0x200,
RawStr = 0x400,
AllowStringView = 0x800
}
[Reflect]
@ -205,10 +206,10 @@ namespace IDE.Debugger
static extern void* Debugger_CreateStepFilter(char8* filter, bool isGlobal, StepFilterKind stepFilterKind);
[CallingConvention(.Stdcall),CLink]
static extern void Debugger_SetDisplayTypes(char8* referenceId, IntDisplayType intDisplayType, MmDisplayType mmDisplayType, FloatDisplayType floatDisplayType);
static extern void Debugger_SetDisplayTypes(char8* referenceId, char8* formatStr, IntDisplayType intDisplayType, MmDisplayType mmDisplayType, FloatDisplayType floatDisplayType);
[CallingConvention(.Stdcall),CLink]
static extern bool Debugger_GetDisplayTypes(char8* referenceId, out IntDisplayType intDisplayType, out MmDisplayType mmDisplayType, out FloatDisplayType floatDisplayType);
static extern char8* Debugger_GetDisplayTypes(char8* referenceId, out IntDisplayType intDisplayType, out MmDisplayType mmDisplayType, out FloatDisplayType floatDisplayType, out bool foundSpecific);
[CallingConvention(.Stdcall),CLink]
static extern char8* Debugger_GetDisplayTypeNames();
@ -1100,14 +1101,17 @@ namespace IDE.Debugger
Debugger_WriteMemory(addr, size, data.CArray());
}
public void SetDisplayTypes(String referenceId, IntDisplayType intDisplayType, MmDisplayType mmDisplayType, FloatDisplayType floatDisplayType)
public void SetDisplayTypes(String referenceId, String formatStr, IntDisplayType intDisplayType, MmDisplayType mmDisplayType, FloatDisplayType floatDisplayType)
{
Debugger_SetDisplayTypes(referenceId, intDisplayType, mmDisplayType, floatDisplayType);
Debugger_SetDisplayTypes(referenceId, formatStr, intDisplayType, mmDisplayType, floatDisplayType);
}
public bool GetDisplayTypes(String referenceId, out IntDisplayType intDisplayType, out MmDisplayType mmDisplayType, out FloatDisplayType floatDisplayType)
public bool GetDisplayTypes(String referenceId, String formatStr, out IntDisplayType intDisplayType, out MmDisplayType mmDisplayType, out FloatDisplayType floatDisplayType)
{
return Debugger_GetDisplayTypes(referenceId, out intDisplayType, out mmDisplayType, out floatDisplayType);
bool foundSpecific = false;
char8* result = Debugger_GetDisplayTypes(referenceId, out intDisplayType, out mmDisplayType, out floatDisplayType, out foundSpecific);
formatStr.Append(result);
return foundSpecific;
}
public void GetDisplayTypeNames(String outDisplayTypeNames)

View file

@ -1923,9 +1923,12 @@ namespace IDE
DebugManager.IntDisplayType intDisplayType;
DebugManager.MmDisplayType mmDisplayType;
DebugManager.FloatDisplayType floatDisplayType;
mDebugger.GetDisplayTypes(referenceId, out intDisplayType, out mmDisplayType, out floatDisplayType);
String formatStr = scope .();
mDebugger.GetDisplayTypes(referenceId, formatStr, out intDisplayType, out mmDisplayType, out floatDisplayType);
using (sd.CreateObject(referenceId))
{
if (!formatStr.IsEmpty)
sd.Add("FormatStr", formatStr);
sd.ConditionalAdd("IntDisplayType", intDisplayType);
sd.ConditionalAdd("MmDisplayType", mmDisplayType);
sd.ConditionalAdd("FloatDisplayType", floatDisplayType);
@ -3310,11 +3313,13 @@ namespace IDE
var referenceIdStr = scope String(referenceId);
if (referenceIdStr.Length == 0)
referenceIdStr = null;
String formatStr = scope .();
data.GetString("FormatStr", formatStr);
var intDisplayType = data.GetEnum<DebugManager.IntDisplayType>("IntDisplayType");
var mmDisplayType = data.GetEnum<DebugManager.MmDisplayType>("MmDisplayType");
var floatDisplayType = data.GetEnum<DebugManager.FloatDisplayType>("FloatDisplayType");
mDebugger.SetDisplayTypes(referenceIdStr, intDisplayType, mmDisplayType, floatDisplayType);
mDebugger.SetDisplayTypes(referenceIdStr, formatStr, intDisplayType, mmDisplayType, floatDisplayType);
}
for (data.Enumerate("StepFilters"))

View file

@ -1084,10 +1084,13 @@ namespace IDE.ui
return true;
}
[DisableChecks]
public override void ApplyTextFlags(int index, String text, uint8 typeNum, uint8 flags)
{
uint8 curTypeNum = typeNum;
Runtime.Assert((index >= 0) && (index + text.Length < mData.mText.Count));
for (int i = 0; i < text.Length; i++)
{
char8 c = text[i];

View file

@ -269,24 +269,43 @@ namespace IDE.ui
g.SetFont(DarkTheme.sDarkTheme.mSmallFont);
bool showIndex = gApp.mSettings.mEnableDevMode;
EditWidget activeEditWidget = null;
var activeDocument = gApp.GetActiveDocumentPanel();
if (activeDocument is SourceViewPanel)
{
var sourceViewPanel = (SourceViewPanel)activeDocument;
sourceViewPanel = sourceViewPanel.GetActivePanel();
activeEditWidget = sourceViewPanel.mEditWidget;
}
else
{
for (var window in gApp.mWindows)
{
if ((window.mHasFocus) && (var widgetWindow = window as WidgetWindow))
{
if (var editWidget = widgetWindow.mFocusWidget as WatchStringEditWidget)
{
activeEditWidget = editWidget;
showIndex = true;
}
}
}
}
int32 line;
int32 column;
sourceViewPanel.GetCursorPosition(out line, out column);
if (activeEditWidget != null)
{
var lineAndColumn = activeEditWidget.mEditWidgetContent.CursorLineAndColumn;
using (g.PushColor(DarkTheme.COLOR_TEXT))
{
if (gApp.mSettings.mEnableDevMode)
g.DrawString(StackStringFormat!("Idx {0}", sourceViewPanel.mEditWidget.Content.CursorTextPos), mWidth - GS!(240), 0);
g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(150), 0);
g.DrawString(StackStringFormat!("Col {0}", column + 1), mWidth - GS!(78), 0);
if (showIndex)
g.DrawString(StackStringFormat!("Idx {0}", activeEditWidget.Content.CursorTextPos), mWidth - GS!(240), 0);
g.DrawString(StackStringFormat!("Ln {0}", lineAndColumn.mLine + 1), mWidth - GS!(150), 0);
g.DrawString(StackStringFormat!("Col {0}", lineAndColumn.mColumn + 1), mWidth - GS!(78), 0);
}
}
}
using (g.PushColor(0xFF101010))
{

View file

@ -28,7 +28,7 @@ namespace IDE.ui
TypeValueType = 0x100,
Namespace = 0x200,
Text = 0x400,
RawText = 0x800
RawText = 0x800,
}
public class WatchEntry
@ -49,6 +49,7 @@ namespace IDE.ui
public bool mIsPending;
public int mMemoryBreakpointAddr;
public int32 mHadStepCount;
public String mStringView ~ delete _;
public String mReferenceId ~ delete _;
public String mResultTypeStr ~ delete _;
public String mAction ~ delete _;
@ -417,7 +418,7 @@ namespace IDE.ui
{
using (g.PushColor(0x60404040))
g.FillRect(0, 0, mWidth, mHeight);
}
}
}
}
@ -511,11 +512,34 @@ namespace IDE.ui
DarkTooltipManager.CloseTooltip();
}
public override void RecalcSize()
/*public override void RecalcSize()
{
base.RecalcSize();
if (mWatchStringEdit.mMoreButton != null)
mHeight += GS!(32);
}*/
public override void GetTextData()
{
base.GetTextData();
}
public override void CheckLineCoords()
{
bool changed = (mLineCoordTextVersionId != mData.mCurTextVersionId);
base.CheckLineCoords();
if ((changed) && (!mLineCoords.IsEmpty) && (mWatchStringEdit.mMoreButton != null))
{
mLineCoords.Back += GS!(32);
var dewc = mEditWidget.mEditWidgetContent as DarkEditWidgetContent;
dewc.mHeight = mLineCoords.Back;
mWatchStringEdit.RehupSize();
}
}
public override void CursorToEnd()
@ -554,6 +578,17 @@ namespace IDE.ui
return;
}
}
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, origX, origY, btn);
if (btn == 1)
{
SelfToOtherTranslate(mWatchStringEdit, x, y, var transX, var transY);
mWatchStringEdit.[Friend]ShowMenu(transX, transY);
}
}
}
public class WatchStringEditWidget : DarkEditWidget
@ -583,11 +618,16 @@ namespace IDE.ui
public QuickFind mQuickFind;
public DarkTabbedView.DarkTabMenuButton mMenuButton;
public bool mViewWhiteSpace;
public bool mIsEmbedded;
public bool mShowStatusBar;
public this(String text, String evalStr)
public this(String text, String evalStr, bool isEmbedded = false)
{
scope AutoBeefPerf("WatchStringEdit.this");
mIsEmbedded = isEmbedded;
mShowStatusBar = !mIsEmbedded;
let editWidgetContent = new WatchStringEditWidgetContent();
editWidgetContent.mWatchStringEdit = this;
@ -597,6 +637,9 @@ namespace IDE.ui
mEditWidget.Content.mWordWrap = text.Length < cWordWrapMax;
mEditWidget.Content.mAllowMaximalScroll = false;
if (mIsEmbedded)
mEditWidget.InitScrollbars(false, true);
bool needsStrCleaning = false;
for (let c in text.RawChars)
@ -626,37 +669,78 @@ namespace IDE.ui
if (evalStr != null)
mEvalString.Set(evalStr);
mMenuButton = new DarkTabbedView.DarkTabMenuButton();
AddWidget(mMenuButton);
if (!mIsEmbedded)
{
mMenuButton = new DarkTabbedView.DarkTabMenuButton();
AddWidget(mMenuButton);
mMenuButton.mOnMouseDown.Add(new (evt) =>
{
float x = mMenuButton.mX + GS!(14);
float y = mMenuButton.mY + GS!(6);
Menu menu = new Menu();
var menuItem = menu.AddItem("Show Whitespace");
if (mViewWhiteSpace)
menuItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);
menuItem.mOnMenuItemSelected.Add(new (menu) =>
{
mViewWhiteSpace = !mViewWhiteSpace;
var darkEditWidgetContent = (DarkEditWidgetContent)mEditWidget.Content;
darkEditWidgetContent.mViewWhiteSpaceColor = mViewWhiteSpace ? SourceEditWidgetContent.sTextColors[(int)SourceElementType.VisibleWhiteSpace] : 0;
});
MenuWidget menuWidget = DarkTheme.sDarkTheme.CreateMenuWidget(menu);
menuWidget.Init(this, x, y, .AllowScrollable);
menu.mOnMenuClosed.Add(new (menu, itemSelected) =>
{
if (DarkTooltipManager.sTooltip != null)
DarkTooltipManager.sTooltip.mAutoCloseDelay = 90;
});
//menuWidget.mWidgetWindow.mOnWindowClosed.Add(new => MenuClosed);
});
mMenuButton.mOnMouseDown.Add(new (evt) =>
{
float x = mMenuButton.mX + GS!(14);
float y = mMenuButton.mY + GS!(6);
ShowMenu(x, y);
//menuWidget.mWidgetWindow.mOnWindowClosed.Add(new => MenuClosed);
});
}
}
void ShowMenu(float x, float y)
{
Menu menu = new Menu();
var menuItem = menu.AddItem("Show Whitespace");
if (mViewWhiteSpace)
menuItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);
menuItem.mOnMenuItemSelected.Add(new (menu) =>
{
mViewWhiteSpace = !mViewWhiteSpace;
var darkEditWidgetContent = (DarkEditWidgetContent)mEditWidget.Content;
darkEditWidgetContent.mViewWhiteSpaceColor = mViewWhiteSpace ? SourceEditWidgetContent.sTextColors[(int)SourceElementType.VisibleWhiteSpace] : 0;
});
if (mIsEmbedded)
{
menuItem = menu.AddItem("Show Status Bar");
if (mShowStatusBar)
menuItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);
menuItem.mOnMenuItemSelected.Add(new (menu) =>
{
mShowStatusBar = !mShowStatusBar;
MarkDirty();
RehupSize();
});
}
MenuWidget menuWidget = DarkTheme.sDarkTheme.CreateMenuWidget(menu);
menuWidget.Init(this, x, y, .AllowScrollable);
menu.mOnMenuClosed.Add(new (menu, itemSelected) =>
{
if (DarkTooltipManager.sTooltip != null)
DarkTooltipManager.sTooltip.mAutoCloseDelay = 90;
});
}
public void UpdateString(String str)
{
var dewc = (DarkEditWidgetContent)mEditWidget.mEditWidgetContent;
String oldText = scope .();
mEditWidget.GetText(oldText);
if (oldText == str)
{
dewc.mFont = DarkTheme.sDarkTheme.mSmallFont;
return;
}
bool scrollbarAtBottom = (mEditWidget.mVertPos.mDest > 0) && (mEditWidget.mVertPos.mDest >= (mEditWidget.mVertScrollbar.mContentSize - mEditWidget.mVertScrollbar.mPageSize - 0.1f));
mEditWidget.SetText(str);
if (scrollbarAtBottom)
mEditWidget.VertScrollTo(mEditWidget.mVertScrollbar.mContentSize - mEditWidget.mVertScrollbar.mPageSize);
dewc.mFont = DarkTheme.sDarkTheme.mSmallBoldFont;
}
public void ShowQuickFind(bool isReplace)
{
if (mQuickFind != null)
@ -708,6 +792,13 @@ namespace IDE.ui
{
ShowMore();
});
var dewc = mEditWidget.mEditWidgetContent as DarkEditWidgetContent;
if (!dewc.mLineCoords.IsEmpty)
{
dewc.mLineCoords.Back += GS!(32);
dewc.mHeight += GS!(32);
}
}
public override void DrawAll(Graphics g)
@ -790,9 +881,12 @@ namespace IDE.ui
textPosString.Append(charStr);
}
g.DrawString(textPosString, 16, textY, .Left, mWidth - GS!(140), .Ellipsis);
g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(130), textY);
g.DrawString(StackStringFormat!("Col {0}", col + 1), mWidth - GS!(70), textY);
if (mShowStatusBar)
{
g.DrawString(textPosString, 16, textY, .Left, mWidth - GS!(140), .Ellipsis);
g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(130), textY);
g.DrawString(StackStringFormat!("Col {0}", col + 1), mWidth - GS!(70), textY);
}
//using (g.PushColor(0xD0FFFFFF))
base.DrawAll(g);
@ -802,11 +896,17 @@ namespace IDE.ui
{
base.Resize(x, y, width, height);
mEditWidget.Resize(0, 0, width, height - GS!(16));
mEditWidget.Resize(0, 0, width, height - (mShowStatusBar ? GS!(16) : GS!(0)));
if (mQuickFind != null)
mQuickFind.ResizeSelf();
mMenuButton.Resize(width - GS!(26), height - GS!(12), GS!(16), GS!(16));
if (mIsEmbedded)
mMenuButton?.Resize(width + GS!(-4), height - GS!(18), GS!(16), GS!(16));
else
mMenuButton?.Resize(width - GS!(26), height - GS!(12), GS!(16), GS!(16));
var dewc = mEditWidget.mEditWidgetContent as DarkEditWidgetContent;
mMoreButton?.Resize(GS!(4), dewc.mHeight - GS!(24), GS!(68), GS!(20));
}
public float GetWantHeight(float wantWidth)
@ -834,6 +934,69 @@ namespace IDE.ui
}
}
public class ResizeHandleWidget : Widget
{
public float mDownX;
public float mDownY;
public override void Draw(Graphics g)
{
g.Draw(DarkTheme.sDarkTheme.GetImage(.ResizeGrabber), 0, 0);
}
public override void MouseEnter()
{
base.MouseEnter();
gApp.SetCursor(.SizeNWSE);
}
public override void MouseLeave()
{
base.MouseLeave();
if (!mMouseDown)
gApp.SetCursor(.Pointer);
}
public override void RehupScale(float oldScale, float newScale)
{
base.RehupScale(oldScale, newScale);
mWidth = GS!(20);
mHeight = GS!(20);
}
public override void MouseDown(float x, float y, int32 btn, int32 btnCount)
{
base.MouseDown(x, y, btn, btnCount);
mDownX = x;
mDownY = y;
}
public override void MouseMove(float x, float y)
{
base.MouseMove(x, y);
if (mMouseDown)
{
var listViewItem = mParent as WatchListViewItem;
SelfToOtherTranslate(listViewItem.mListView, x, y, var lvX, var lvY);
listViewItem.mListView.mColumns[1].mWidth = Math.Max(GS!(40), lvX - mDownX - listViewItem.mListView.mColumns[0].mWidth + GS!(4));
listViewItem.mListView.mListSizeDirty = true;
var rootItem = listViewItem.GetSubItem(0) as WatchListViewItem;
rootItem.mSelfHeight = Math.Max(GS!(40), mY + y - mDownY + GS!(20));
}
}
public override void MouseUp(float x, float y, int32 btn)
{
base.MouseUp(x, y, btn);
if (!mMouseOver)
gApp.SetCursor(.Pointer);
}
}
public class WatchListViewItem : IDEListViewItem
{
public IWatchOwner mWatchOwner;
@ -843,7 +1006,6 @@ namespace IDE.ui
public int32 mErrorEnd;
public WatchSeriesInfo mWatchSeriesInfo;
//public bool mOwnsWatchSeriesInfo;
public int32 mSeriesMemberIdx;
public WatchListViewItem mPrevPlaceholder;
@ -858,7 +1020,8 @@ namespace IDE.ui
public ActionButton mActionButton;
public String mTextAction ~ delete _;
public bool mMustUpdateBeforeEvaluate;
public Widget mCustomContentWidget;
public override bool Selected
{
get
@ -893,6 +1056,12 @@ namespace IDE.ui
{
mWatchSeriesInfo.ReleaseRef();
}
if (mCustomContentWidget != null)
{
mCustomContentWidget.RemoveSelf();
delete mCustomContentWidget;
}
}
public virtual WatchListViewItem GetWatchListViewItemParent()
@ -1057,6 +1226,13 @@ namespace IDE.ui
var typeSubItem = (WatchListViewItem)GetSubItem(1);
mActionButton.Resize(typeSubItem.Font.GetWidth(typeSubItem.mLabel) + 8, 0, 20, 20);
}
if (mColumnIdx == 0)
{
var dataItem = (WatchListViewItem)GetSubItem(1);
if (dataItem.mCustomContentWidget != null)
mSelfHeight = dataItem.mCustomContentWidget.mHeight;
}
}
public void SetDisabled(bool disabled, bool allowRefresh)
@ -1093,6 +1269,15 @@ namespace IDE.ui
mTextAreaLengthOffset = -16;
else
mTextAreaLengthOffset = 0;
if (mCustomContentWidget != null)
{
if (mColumnIdx == 1)
mCustomContentWidget.Resize(0, 0, mWidth, mHeight);
else
mCustomContentWidget.Resize(-GS!(6), mHeight - mCustomContentWidget.mHeight, mCustomContentWidget.mWidth, mCustomContentWidget.mHeight);
}
return retVal;
}
@ -1466,7 +1651,17 @@ namespace IDE.ui
if (curWatchListViewItem != null)
prevY = curY;
curY += itemHeight;
if (curWatchListViewItem != null)
{
var dataItem = curWatchListViewItem.GetSubItem(1) as WatchListViewItem;
if (dataItem.mCustomContentWidget != null)
curY += curWatchListViewItem.mSelfHeight;
else
curY += itemHeight;
}
else
curY += itemHeight;
if (curWatchListViewItem != null)
{
curY += curWatchListViewItem.mChildAreaHeight;
@ -2138,7 +2333,7 @@ namespace IDE.ui
{
DarkListViewItem widget = (DarkListViewItem)item;
float clickX = x;
float clickY = widget.mHeight + GS!(2);
float clickY = Math.Max(y + GS!(2), GS!(19));
widget.SelfToOtherTranslate(mListView.GetRoot(), clickX, clickY, var aX, var aY);
ShowRightClickMenu(mListView, aX, aY);
}
@ -2214,6 +2409,17 @@ namespace IDE.ui
listViewItem.mErrorEnd = 0;
var watch = listViewItem.mWatchEntry;
bool doProfile = false;//watch.mResultType.HasFlag(.Text);
ProfileInstance pi = default;
if (doProfile)
pi = Profiler.StartSampling("UpdateWatch").GetValueOrDefault();
defer
{
if (pi.HasValue)
pi.Dispose();
}
bool wasNewExpression = watch.mIsNewExpression;
String val = scope String();
if (watch.mIsPending)
@ -2227,20 +2433,19 @@ namespace IDE.ui
evalStr.Append(",refid=", watch.mReferenceId);
//gApp.DebugEvaluate(watch.mResultTypeStr, evalStr, val, -1, watch.mIsNewExpression, watch.mIsNewExpression);
//TODO: Why did we have the mResultTypeStr in there?
DebugManager.EvalExpressionFlags flags = default;
DebugManager.EvalExpressionFlags flags = .AllowStringView;
if (watch.mIsNewExpression)
flags |= .AllowSideEffects | .AllowCalls;
gApp.DebugEvaluate(null, evalStr, val, -1, watch.mLanguage, flags);
watch.mIsNewExpression = false;
}
watch.mIsPending = false;
DeleteAndNullify!(watch.mStringView);
var valViews = scope List<StringView>(val.Split('\n'));
StringView valSV = val;
var vals = scope List<StringView>(valSV.Split('\n'));
var vals = scope List<String>();
for (var strView in valViews)
vals.Add(scope:: String(strView));
var valueSubItem = (WatchListViewItem)listViewItem.GetSubItem(1);
if (vals[0].StartsWith("!", StringComparison.Ordinal))
{
@ -2282,7 +2487,7 @@ namespace IDE.ui
else
{
listViewItem.SetDisabled(false, false);
String newVal = vals[0];
StringView newVal = vals[0];
if (watch.mHadStepCount == 1)
valueSubItem.mValueChanged = (newVal != valueSubItem.mLabel) || (valueSubItem.mFailed);
@ -2488,6 +2693,12 @@ namespace IDE.ui
gApp.OutputLineSmart("WARNING: {0}", memberVals[1]);
}
}
else if (memberVals0 == ":stringView")
{
watch.mResultType |= .Text;
if (memberVals.Count > 1)
watch.mStringView = memberVals[1].Unescape(.. new .());
}
else
watch.ParseCmd(memberVals);
continue;
@ -2549,6 +2760,50 @@ namespace IDE.ui
if (watch.mEvalStr.Length == 0)
watch.mResultType = WatchResultType.None;
var dataItem = listViewItem.GetSubItem(1) as WatchListViewItem;
var typeItem = listViewItem.GetSubItem(2) as WatchListViewItem;
void RemoveCustomContent()
{
if (dataItem.mCustomContentWidget != null)
{
dataItem.mCustomContentWidget.RemoveSelf();
DeleteAndNullify!(dataItem.mCustomContentWidget);
mListView.mListSizeDirty = true;
listViewItem.mSelfHeight = mListView.mFont.GetLineSpacing();
}
if (typeItem.mCustomContentWidget != null)
{
typeItem.mCustomContentWidget.RemoveSelf();
DeleteAndNullify!(typeItem.mCustomContentWidget);
}
}
if (watch.mStringView != null)
{
dataItem.Label = "";
if (var watchStringEdit = dataItem.mCustomContentWidget as WatchStringEdit)
{
watchStringEdit.UpdateString(watch.mStringView);
}
else if (dataItem.mCustomContentWidget == null)
{
dataItem.mCustomContentWidget = new WatchStringEdit(watch.mStringView, watch.mEvalStr, true);
dataItem.AddWidget(dataItem.mCustomContentWidget);
listViewItem.mSelfHeight = GS!(80);
mListView.mListSizeDirty = true;
typeItem.mCustomContentWidget = new ResizeHandleWidget();
typeItem.mCustomContentWidget.Resize(0, 0, GS!(20), GS!(20));
typeItem.AddWidget(typeItem.mCustomContentWidget);
}
}
else
{
RemoveCustomContent();
}
watch.mHasValue = true;
watch.mHadValue = true;
}
@ -2641,21 +2896,23 @@ namespace IDE.ui
menuItem.mOnMenuItemSelected.Add(new (imenu) => action() ~ { delete action; });
}
public static void SetDisplayType(String referenceId, DebugManager.IntDisplayType intDisplayType, DebugManager.MmDisplayType mmDisplayType, DebugManager.FloatDisplayType floatDisplayType)
public static void SetDisplayType(String referenceId, String formatStr, DebugManager.IntDisplayType intDisplayType, DebugManager.MmDisplayType mmDisplayType, DebugManager.FloatDisplayType floatDisplayType)
{
gApp.mDebugger.SetDisplayTypes(referenceId, intDisplayType, mmDisplayType, floatDisplayType);
gApp.mDebugger.SetDisplayTypes(referenceId, (formatStr == null) ? null : formatStr, intDisplayType, mmDisplayType, floatDisplayType);
gApp.RefreshWatches();
}
public static bool AddDisplayTypeMenu(String label, Menu menu, WatchResultType watchResultType, String referenceId, bool includeDefault)
{
bool hasInt = watchResultType.HasFlag(WatchResultType.Int);
bool hasFloat = watchResultType.HasFlag(WatchResultType.Float);
bool hasMM128 = watchResultType.HasFlag(WatchResultType.MM128);
bool canSetFormat = hasInt || hasFloat || hasMM128;
bool hasInt = watchResultType.HasFlag(.Int);
bool hasFloat = watchResultType.HasFlag(.Float);
bool hasMM128 = watchResultType.HasFlag(.MM128);
bool hasText = watchResultType.HasFlag(.Text) && (referenceId != null) && (!referenceId.EndsWith(".[]"));
bool canSetFormat = hasInt || hasFloat || hasMM128 || hasText;
var debugger = IDEApp.sApp.mDebugger;
bool foundSpecific = debugger.GetDisplayTypes(referenceId, var intDisplayType, var mmDisplayType, var floatDisplayType);
String formatStr = scope .();
bool foundSpecific = debugger.GetDisplayTypes(referenceId, formatStr, var intDisplayType, var mmDisplayType, var floatDisplayType);
if ((referenceId != null) && (!foundSpecific))
{
intDisplayType = .Default;
@ -2665,8 +2922,26 @@ namespace IDE.ui
if (!canSetFormat)
return false;
Menu parentItem = menu.AddItem(label);
var referenceId;
if (referenceId != null)
{
referenceId = new String(referenceId);
menu.mOnMenuClosed.Add(new (menu, itemSelected) =>
{
gApp.DeferDelete(referenceId);
});
}
Menu parentItem = menu.AddItem(label);
if (hasText)
{
AddSelectableMenuItem(parentItem, "Default", formatStr.IsEmpty,
new () => SetDisplayType(referenceId, "", intDisplayType, mmDisplayType, floatDisplayType));
AddSelectableMenuItem(parentItem, "String", formatStr == "str",
new () => SetDisplayType(referenceId, "str", intDisplayType, mmDisplayType, floatDisplayType));
}
if (hasInt)
{
for (DebugManager.IntDisplayType i = default; i < DebugManager.IntDisplayType.COUNT; i++)
@ -2680,7 +2955,7 @@ namespace IDE.ui
var toType = i;
AddSelectableMenuItem(parentItem, ToStackString!(i), intDisplayType == i,
new () => SetDisplayType(referenceId, toType, mmDisplayType, floatDisplayType));
new () => SetDisplayType(referenceId, null, toType, mmDisplayType, floatDisplayType));
}
}
@ -2697,7 +2972,7 @@ namespace IDE.ui
var toType = i;
AddSelectableMenuItem(parentItem, ToStackString!(i), floatDisplayType == i,
new () => SetDisplayType(referenceId, intDisplayType, mmDisplayType, toType));
new () => SetDisplayType(referenceId, null, intDisplayType, mmDisplayType, toType));
}
}
@ -2707,7 +2982,7 @@ namespace IDE.ui
{
var toType = i;
AddSelectableMenuItem(parentItem, ToStackString!(i), mmDisplayType == i,
new () => SetDisplayType(referenceId, intDisplayType, toType, floatDisplayType));
new () => SetDisplayType(referenceId, null, intDisplayType, toType, floatDisplayType));
}
}
return true;
@ -2754,8 +3029,17 @@ namespace IDE.ui
anItem = menu.AddItem();
if (watchEntry.mReferenceId != null)
{
AddDisplayTypeMenu("Watch Display", menu, listViewItem.mWatchEntry.mResultType, watchEntry.mReferenceId, true);
int arrayPos = watchEntry.mReferenceId.IndexOf(".[]$");
if (arrayPos != -1)
{
var refId = scope String(watchEntry.mReferenceId, 0, arrayPos + 3);
AddDisplayTypeMenu("Series Watch Display", menu, listViewItem.mWatchEntry.mResultType, refId, true);
}
}
anItem = menu.AddItem("Add Watch");
anItem.mOnMenuItemSelected.Add(new (menu) =>
{

View file

@ -192,6 +192,7 @@ struct DwFormatInfo
bool mNoVisualizers;
bool mNoMembers;
bool mRawString;
bool mAllowStringView;
bool mNoEdit;
DbgTypeKindFlags mTypeKindFlags;
intptr mArrayLength;
@ -213,6 +214,7 @@ struct DwFormatInfo
mHidePointers = false;
mIgnoreDerivedClassInfo = false;
mRawString = false;
mAllowStringView = false;
mNoVisualizers = false;
mNoMembers = false;
mNoEdit = false;

View file

@ -1168,32 +1168,37 @@ BF_EXPORT void BF_CALLTYPE Debugger_Update()
gDebugger->Update();
}
BF_EXPORT void BF_CALLTYPE Debugger_SetDisplayTypes(const char* referenceId, int8 intDisplayType, int8 mmDisplayType, int8 floatDisplayType)
BF_EXPORT void BF_CALLTYPE Debugger_SetDisplayTypes(const char* referenceId, const char* formatStr, int8 intDisplayType, int8 mmDisplayType, int8 floatDisplayType)
{
DwDisplayInfo displayInfo;
displayInfo.mIntDisplayType = (DwIntDisplayType)intDisplayType;
displayInfo.mMmDisplayType = (DwMmDisplayType)mmDisplayType;
displayInfo.mFloatDisplayType = (DwFloatDisplayType)floatDisplayType;
AutoCrit autoCrit(gDebugManager->mCritSect);
DwDisplayInfo* displayInfo = NULL;
if (referenceId == NULL)
{
gDebugManager->mDefaultDisplayInfo = displayInfo;
}
else if ((displayInfo.mIntDisplayType == DwIntDisplayType_Default) &&
(displayInfo.mMmDisplayType == DwMmDisplayType_Default) &&
(displayInfo.mFloatDisplayType == DwFloatDisplayType_Default))
displayInfo = &gDebugManager->mDefaultDisplayInfo;
else
gDebugManager->mDisplayInfos.TryAdd(referenceId, NULL, &displayInfo);
if (formatStr != NULL)
displayInfo->mFormatStr = formatStr;
displayInfo->mIntDisplayType = (DwIntDisplayType)intDisplayType;
displayInfo->mMmDisplayType = (DwMmDisplayType)mmDisplayType;
displayInfo->mFloatDisplayType = (DwFloatDisplayType)floatDisplayType;
if ((referenceId != NULL) &&
(displayInfo->mFormatStr.IsEmpty()) &&
(displayInfo->mIntDisplayType == DwIntDisplayType_Default) &&
(displayInfo->mMmDisplayType == DwMmDisplayType_Default) &&
(displayInfo->mFloatDisplayType == DwFloatDisplayType_Default))
{
gDebugManager->mDisplayInfos.Remove(referenceId);
}
else
{
gDebugManager->mDisplayInfos[referenceId] = displayInfo;
}
}
BF_EXPORT bool BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int8* intDisplayType, int8* mmDisplayType, int8* floatDisplayType)
BF_EXPORT const char* BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int8* intDisplayType, int8* mmDisplayType, int8* floatDisplayType, bool* foundSpecific)
{
bool foundSpecific = false;
AutoCrit autoCrit(gDebugManager->mCritSect);
*foundSpecific = false;
DwDisplayInfo* displayInfo = &gDebugManager->mDefaultDisplayInfo;
if (referenceId != NULL)
{
@ -1206,18 +1211,20 @@ BF_EXPORT bool BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int
if (gDebugManager->mDisplayInfos.TryGetValue(referenceId, &displayInfo))
{
foundSpecific = true;
*foundSpecific = true;
}
}
*intDisplayType = (int8)displayInfo->mIntDisplayType;
*mmDisplayType = (int8)displayInfo->mMmDisplayType;
*floatDisplayType = (int8)displayInfo->mFloatDisplayType;
return foundSpecific;
return displayInfo->mFormatStr.c_str();
}
BF_EXPORT const char* BF_CALLTYPE Debugger_GetDisplayTypeNames()
{
AutoCrit autoCrit(gDebugManager->mCritSect);
String& outString = *gTLStrReturn.Get();
outString.clear();
for (auto& displayInfoEntry : gDebugManager->mDisplayInfos)

View file

@ -127,11 +127,13 @@ enum DwEvalExpressionFlags : int16
DwEvalExpressionFlag_MemoryWatch = 0x80,
DwEvalExpressionFlag_Symbol = 0x100,
DwEvalExpressionFlag_StepIntoCalls = 0x200,
DwEvalExpressionFlag_RawStr = 0x400
DwEvalExpressionFlag_RawStr = 0x400,
DwEvalExpressionFlag_AllowStringView = 0x800
};
struct DwDisplayInfo
{
String mFormatStr;
DwIntDisplayType mIntDisplayType;
DwMmDisplayType mMmDisplayType;
DwFloatDisplayType mFloatDisplayType;

View file

@ -2711,7 +2711,7 @@ bool WinDebugger::DoUpdate()
DwFormatInfo formatInfo;
formatInfo.mRawString = true;
String nameStr = ReadString(DbgType_SChar, (intptr)threadNameInfo->szName, false, 1024, formatInfo);
String nameStr = ReadString(DbgType_SChar, (intptr)threadNameInfo->szName, false, 1024, formatInfo, false);
WdThreadInfo* namingThreadInfo = threadInfo;
if (threadNameInfo->dwThreadID != (DWORD)-1)
@ -2739,7 +2739,7 @@ bool WinDebugger::DoUpdate()
FailMessage failMessage = ReadMemory<FailMessage>(exceptionRecord->ExceptionInformation[2]);
DwFormatInfo formatInfo;
String failStr = ReadString(DbgType_SChar16, failMessage.mErrorStr, false, 8192, formatInfo);
String failStr = ReadString(DbgType_SChar16, failMessage.mErrorStr, false, 8192, formatInfo, false);
mDebugManager->mOutMessages.push_back(StrFormat("error Run-Time Check Failure %d - %s", exceptionRecord->ExceptionInformation[6], failStr.c_str()));
mRunState = RunState_Paused;
@ -6283,7 +6283,15 @@ DwDisplayInfo* WinDebugger::GetDisplayInfo(const StringImpl& referenceId)
DwDisplayInfo* displayInfo = &mDebugManager->mDefaultDisplayInfo;
if (!referenceId.empty())
{
mDebugManager->mDisplayInfos.TryGetValue(referenceId, &displayInfo);
if (!mDebugManager->mDisplayInfos.TryGetValue(referenceId, &displayInfo))
{
int dollarIdx = referenceId.LastIndexOf('$');
if ((dollarIdx > 0) && (referenceId[dollarIdx - 1] == ']'))
{
// Try getting series displayinfo
mDebugManager->mDisplayInfos.TryGetValueWith(StringView(referenceId, 0, dollarIdx), &displayInfo);
}
}
}
return displayInfo;
}
@ -6351,7 +6359,7 @@ DebugVisualizerEntry* WinDebugger::FindVisualizerForType(DbgType* dbgType, Array
#define GET_FROM(ptr, T) *((T*)(ptr += sizeof(T)) - 1)
String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAddr, intptr maxLength, DwFormatInfo& formatInfo)
String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAddr, intptr maxLength, DwFormatInfo& formatInfo, bool wantStringView)
{
int origMaxLength = maxLength;
if (addr == 0)
@ -6364,6 +6372,11 @@ String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAd
String valString;
intptr maxShowSize = 255;
if (wantStringView)
{
NOP;
}
if (maxLength == -1)
maxLength = formatInfo.mOverrideCount;
else if (formatInfo.mOverrideCount != -1)
@ -6373,9 +6386,15 @@ String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAd
if (maxLength == -1)
maxLength = 8 * 1024 * 1024; // Is 8MB crazy?
if (!formatInfo.mRawString)
if ((!formatInfo.mRawString) && (!wantStringView))
maxLength = BF_MIN(maxLength, maxShowSize);
if (wantStringView)
{
// Limit the original string view to 1MB, reevaluate on "More"
maxLength = BF_MIN(maxLength, 1024 * 1024);
}
//EnableMemCache();
bool readFailed = false;
intptr strPtr = addr;
@ -6494,7 +6513,7 @@ String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAd
// valString = UTF8Encode(ToWString(valString));
// }
if (formatInfo.mRawString)
if ((formatInfo.mRawString) || (wantStringView))
{
if ((formatInfo.mDisplayType == DwDisplayType_Utf8) || (!hasHighAscii))
return valString;
@ -6520,7 +6539,7 @@ String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAd
retVal += SlashString(valString, true, true, formatInfo.mLanguage == DbgLanguage_Beef);
// We could go over 'maxShowSize' if we have a lot of slashed chars. An uninitialized string can be filled with '\xcc' chars
if ((!formatInfo.mRawString) && ((int)retVal.length() > maxShowSize))
if ((!formatInfo.mRawString) && (!wantStringView) && ((int)retVal.length() > maxShowSize))
{
retVal = retVal.Substring(0, maxShowSize);
wasTerminated = false;
@ -6640,8 +6659,10 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
bool isEnum = false;
int64 enumVal = 0;
String result;
String stringViewData;
DwDisplayInfo* displayInfo = GetDisplayInfo(formatInfo.mReferenceId);
bool wantStringView = (displayInfo->mFormatStr == "str") && (formatInfo.mAllowStringView);
DbgType* origValueType = typedValue.mType;
bool origHadRef = false;
@ -7232,16 +7253,23 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
}
SetAndRestoreValue<intptr> prevOverrideLen(formatInfo.mOverrideCount, strLen);
String strResult = ReadString(unmodInnerType->mTypeCode, typedValue.mLocalIntPtr, typedValue.mIsLiteral, strLen, formatInfo);
String strResult = ReadString(unmodInnerType->mTypeCode, typedValue.mLocalIntPtr, typedValue.mIsLiteral, strLen, formatInfo, wantStringView);
if (formatInfo.mRawString)
return strResult;
if (!strResult.IsEmpty())
{
if (!retVal.IsEmpty())
retVal += " ";
retVal += strResult;
if (!wantStringView)
retVal += strResult;
}
retVal += "\n" + origValueType->ToString(language);
retVal += "\n:stringView";
if (wantStringView)
{
retVal += "\t";
retVal += SlashString(strResult, false, false, true);
}
return retVal;
}
else if ((unmodInnerType != NULL) &&
@ -7436,7 +7464,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
if (innerType->IsChar(language))
{
String strVal = ReadString(innerType->mTypeCode, typedValue.mSrcAddress, false, arraySize, formatInfo);
String strVal = ReadString(innerType->mTypeCode, typedValue.mSrcAddress, false, arraySize, formatInfo, false);
if (formatInfo.mRawString)
return strVal;
retVal += strVal;
@ -7927,7 +7955,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
bool hadCustomDisplayString = false;
if (debugVis != NULL)
{
auto& displayStringList = formatInfo.mRawString ? debugVis->mStringViews : debugVis->mDisplayStrings;
auto& displayStringList = (formatInfo.mRawString || wantStringView) ? debugVis->mStringViews : debugVis->mDisplayStrings;
for (auto displayEntry : displayStringList)
{
@ -7941,7 +7969,15 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
String displayStr = mDebugManager->mDebugVisualizers->DoStringReplace(displayEntry->mString, dbgVisWildcardCaptures);
if (displayString.length() > 0)
displayString += " ";
ProcessEvalString(dbgCompileUnit, useTypedValue, displayStr, displayString, formatInfo, debugVis, true);
if (wantStringView)
{
DwFormatInfo strFormatInfo = formatInfo;
strFormatInfo.mRawString = true;
ProcessEvalString(dbgCompileUnit, useTypedValue, displayStr, stringViewData, strFormatInfo, debugVis, true);
}
else
ProcessEvalString(dbgCompileUnit, useTypedValue, displayStr, displayString, formatInfo, debugVis, true);
if (formatInfo.mRawString)
return displayString;
@ -8309,8 +8345,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
}
if (formatInfo.mExpandItemDepth > 0)
return retVal;
return retVal;
if (isAppendBfObject)
retVal += "\n:appendAlloc";
if (isStackBfObject)
@ -8331,6 +8366,15 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
retVal += "\n:editVal\t" + EncodeDataPtr(ptrVal, true);
}
if (((debugVis != NULL) && (!debugVis->mStringViews.IsEmpty())) || (wantStringView))
retVal += "\n:stringView";
if (wantStringView)
{
retVal += "\t";
retVal += SlashString(stringViewData, false, false, true);
}
return retVal;
}
@ -8512,7 +8556,7 @@ void WinDebugger::HandleCustomExpandedItems(String& retVal, DbgCompileUnit* dbgC
else
{
String evalStr = "*(" + debugVisualizers->DoStringReplace(debugVis->mValuePointer, dbgVisWildcardCaptures) + " + {0}), this=" + ptrUseDataStr;
evalStr += ", refid=\"" + referenceId + ".[]\"";
evalStr += ", refid=\"" + referenceId + ".[]${0}\"";
if (isReadOnly)
evalStr += ", ne";
retVal += "\n:repeat" + StrFormat("\t%d\t%lld\t%d", 0, sizeValue.GetInt64(), 50000) +
@ -9576,6 +9620,11 @@ String WinDebugger::Evaluate(const StringImpl& expr, DwFormatInfo formatInfo, in
formatInfo.mRawString = true;
}
if ((expressionFlags & DwEvalExpressionFlag_AllowStringView) != 0)
{
formatInfo.mAllowStringView = true;
}
auto dbgModule = GetCallStackDbgModule(callStackIdx);
auto dbgSubprogram = GetCallStackSubprogram(callStackIdx);
DbgCompileUnit* dbgCompileUnit = NULL;

View file

@ -502,7 +502,7 @@ public:
bool EvalCondition(DebugVisualizerEntry* debugVis, DbgCompileUnit* dbgCompileUnit, DbgTypedValue typedVal, DwFormatInfo& formatInfo, const StringImpl& condition, const Array<String>& dbgVisWildcardCaptures, String& errorStr);
DwDisplayInfo* GetDisplayInfo(const StringImpl& referenceId);
void ProcessEvalString(DbgCompileUnit* dbgCompileUnit, DbgTypedValue useTypedValue, String& evalStr, String& displayString, DwFormatInfo& formatInfo, DebugVisualizerEntry* debugVis, bool limitLength);
String ReadString(DbgTypeCode charType, intptr addr, bool isLocalAddr, intptr maxLength, DwFormatInfo& formatInfo);
String ReadString(DbgTypeCode charType, intptr addr, bool isLocalAddr, intptr maxLength, DwFormatInfo& formatInfo, bool wantStringView);
String DbgTypedValueToString(const DbgTypedValue& typedValue, const StringImpl& expr, DwFormatInfo& formatFlags, DbgExprEvaluator* optEvaluator, bool fullPrecision = false);
bool ShouldShowStaticMember(DbgType* dbgType, DbgVariable* member);
String GetMemberList(DbgType* dbgType, const StringImpl& expr, bool isPtr, bool isStatic, bool forceCast = false, bool isSplat = false, bool isReadOnly = false);