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

Merge pull request #2107 from kallisto56/master

Feature: Errors Panel now has a copy to clipboard feature
This commit is contained in:
Brian Fiete 2025-01-25 09:15:43 -08:00 committed by GitHub
commit 7c44950ba0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,6 +26,52 @@ namespace IDE.ui
public int mLine;
public int mColumn;
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, origX, origY, btn);
if (btn == 1)
{
Menu menu = new Menu();
var menuItemCopySingle = menu.AddItem("Copy");
menuItemCopySingle.mOnMenuItemSelected.Add(new (evt) =>
{
var item = (ErrorsListViewItem)this.GetSubItem(0);
var buffer = item.CopyError(.. scope String());
gApp.SetClipboardText(buffer);
});
var menuItemCopyAll = menu.AddItem("Copy All");
menuItemCopyAll.mOnMenuItemSelected.Add(new (evt) =>
{
var buffer = scope String();
var root = this.mListView.GetRoot();
var childCount = root.GetChildCount();
for (var n = 0; n < childCount; n++)
{
var row = (ErrorsListViewItem)root.GetChildAtIndex(n);
row.CopyError(buffer);
}
gApp.SetClipboardText(buffer);
});
MenuWidget menuWidget = DarkTheme.sDarkTheme.CreateMenuWidget(menu);
menuWidget.Init(this, x, y);
}
}
public void CopyError (String buffer)
{
var preffix = scope String();
Font.StrRemoveColors(this.mSubItems[0].mLabel, preffix);
preffix.ToUpper();
var description = this.mSubItems[1].mLabel;
buffer.AppendF("{}: {} at line {}:{} in {}\n", preffix, description, this.mLine, this.mColumn, this.mFilePath);
}
public override void DrawSelect(Graphics g)
{
bool hasFocus = mListView.mHasFocus;