mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Bookmark panel tweaks
This commit is contained in:
parent
9daae6baa6
commit
ebcaffbae9
7 changed files with 204 additions and 24 deletions
|
@ -4,6 +4,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using IDE.ui;
|
using IDE.ui;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace IDE
|
namespace IDE
|
||||||
{
|
{
|
||||||
|
@ -65,7 +66,7 @@ namespace IDE
|
||||||
public List<Bookmark> mBookmarkList = new List<Bookmark>() ~ delete _;
|
public List<Bookmark> mBookmarkList = new List<Bookmark>() ~ delete _;
|
||||||
|
|
||||||
/// Gets or Sets whether every bookmark in this folder is disabled or not.
|
/// Gets or Sets whether every bookmark in this folder is disabled or not.
|
||||||
public bool IsDisabled
|
public bool AreAllDisabled
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -84,6 +85,25 @@ namespace IDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AreAllEnabled
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
for (var bookmark in mBookmarkList)
|
||||||
|
if (bookmark.mIsDisabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
for (var bookmark in mBookmarkList)
|
||||||
|
bookmark.mIsDisabled = !value;
|
||||||
|
|
||||||
|
gApp.mBookmarkManager.BookmarksChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds the given bookmark to this folder. If needed, removes it from its old folder.
|
/// Adds the given bookmark to this folder. If needed, removes it from its old folder.
|
||||||
internal void AddBookmark(Bookmark bookmark)
|
internal void AddBookmark(Bookmark bookmark)
|
||||||
{
|
{
|
||||||
|
@ -125,9 +145,9 @@ namespace IDE
|
||||||
private int mBookmarkCount;
|
private int mBookmarkCount;
|
||||||
|
|
||||||
/// Number of bookmarks created, used to generate the names.
|
/// Number of bookmarks created, used to generate the names.
|
||||||
private int32 _createdBookmarks;
|
private int32 sBookmarkId;
|
||||||
/// Number of folders created, used to generate the names.
|
/// Number of folders created, used to generate the names.
|
||||||
private int32 _createdFolders;
|
private int32 sFolderId;
|
||||||
|
|
||||||
/// Gets or sets whether all bookmarks are disabled or not.
|
/// Gets or sets whether all bookmarks are disabled or not.
|
||||||
public bool AllBookmarksDisabled
|
public bool AllBookmarksDisabled
|
||||||
|
@ -136,7 +156,7 @@ namespace IDE
|
||||||
{
|
{
|
||||||
for (var folder in mBookmarkFolders)
|
for (var folder in mBookmarkFolders)
|
||||||
{
|
{
|
||||||
if (!folder.IsDisabled)
|
if (!folder.AreAllDisabled)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +166,7 @@ namespace IDE
|
||||||
{
|
{
|
||||||
for (var folder in mBookmarkFolders)
|
for (var folder in mBookmarkFolders)
|
||||||
{
|
{
|
||||||
folder.IsDisabled = value;
|
folder.AreAllDisabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
BookmarksChanged();
|
BookmarksChanged();
|
||||||
|
@ -172,7 +192,7 @@ namespace IDE
|
||||||
BookmarkFolder folder = new .();
|
BookmarkFolder folder = new .();
|
||||||
|
|
||||||
if (title == null)
|
if (title == null)
|
||||||
folder.mTitle = new $"Folder {_createdFolders++}";
|
folder.mTitle = new $"Folder {++sFolderId}";
|
||||||
else
|
else
|
||||||
folder.mTitle = new String(title);
|
folder.mTitle = new String(title);
|
||||||
|
|
||||||
|
@ -247,7 +267,36 @@ namespace IDE
|
||||||
bookmark.mColumn = (int32)wantColumn;
|
bookmark.mColumn = (int32)wantColumn;
|
||||||
|
|
||||||
if (title == null)
|
if (title == null)
|
||||||
bookmark.mTitle = new $"Bookmark {_createdBookmarks++}";
|
{
|
||||||
|
String baseName = Path.GetFileNameWithoutExtension(fileName, .. scope .());
|
||||||
|
|
||||||
|
if (IDEApp.IsSourceCode(fileName))
|
||||||
|
{
|
||||||
|
var bfSystem = IDEApp.sApp.mBfResolveSystem;
|
||||||
|
if (bfSystem != null)
|
||||||
|
{
|
||||||
|
String content = scope .();
|
||||||
|
gApp.LoadTextFile(fileName, content).IgnoreError();
|
||||||
|
|
||||||
|
var parser = bfSystem.CreateEmptyParser(null);
|
||||||
|
defer delete parser;
|
||||||
|
parser.SetSource(content, fileName, -1);
|
||||||
|
var passInstance = bfSystem.CreatePassInstance();
|
||||||
|
defer delete passInstance;
|
||||||
|
parser.Parse(passInstance, IDEApp.IsBeefFile(fileName));
|
||||||
|
parser.Reduce(passInstance);
|
||||||
|
|
||||||
|
String name = parser.GetLocationName(wantLineNum, wantColumn, .. scope .());
|
||||||
|
if (!name.IsEmpty)
|
||||||
|
bookmark.mTitle = new $"#{++sBookmarkId} {name}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bookmark.mTitle == null)
|
||||||
|
{
|
||||||
|
bookmark.mTitle = new $"#{++sBookmarkId} {baseName}";
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
bookmark.mTitle = new String(title);
|
bookmark.mTitle = new String(title);
|
||||||
|
|
||||||
|
@ -517,5 +566,33 @@ namespace IDE
|
||||||
|
|
||||||
MovedToBookmark(bookmark);
|
MovedToBookmark(bookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RecalcCurId()
|
||||||
|
{
|
||||||
|
sBookmarkId = 0;
|
||||||
|
sFolderId = 0;
|
||||||
|
|
||||||
|
for (var folder in mBookmarkFolders)
|
||||||
|
{
|
||||||
|
if (folder.mTitle?.StartsWith("Folder ") == true)
|
||||||
|
{
|
||||||
|
if (int32 curId = int32.Parse(folder.mTitle.Substring("Folder ".Length)))
|
||||||
|
sFolderId = Math.Max(sFolderId, curId);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var bookmark in folder.mBookmarkList)
|
||||||
|
{
|
||||||
|
if (bookmark.mTitle.StartsWith("#"))
|
||||||
|
{
|
||||||
|
int spacePos = bookmark.mTitle.IndexOf(' ');
|
||||||
|
if (spacePos != -1)
|
||||||
|
{
|
||||||
|
if (int32 curId = int32.Parse(bookmark.mTitle.Substring(1, spacePos - 1)))
|
||||||
|
sBookmarkId = Math.Max(sBookmarkId, curId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,9 @@ namespace IDE.Compiler
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern void BfParser_SetCompleteParse(void* bfParser);
|
static extern void BfParser_SetCompleteParse(void* bfParser);
|
||||||
|
|
||||||
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
static extern char8* BfSystem_GetParserLocationName(void* bfParser, int32 line, int32 column);
|
||||||
|
|
||||||
public BfSystem mSystem;
|
public BfSystem mSystem;
|
||||||
public void* mNativeBfParser;
|
public void* mNativeBfParser;
|
||||||
public bool mIsUsed;
|
public bool mIsUsed;
|
||||||
|
@ -419,5 +422,12 @@ namespace IDE.Compiler
|
||||||
var md5Hash;
|
var md5Hash;
|
||||||
BfParser_SetHashMD5(mNativeBfParser, ref md5Hash);
|
BfParser_SetHashMD5(mNativeBfParser, ref md5Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GetLocationName(int line, int column, String outBuffer)
|
||||||
|
{
|
||||||
|
var ptr = BfSystem_GetParserLocationName(mNativeBfParser, (.)line, (.)column);
|
||||||
|
if (ptr != null)
|
||||||
|
outBuffer.Append(ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3382,6 +3382,7 @@ namespace IDE
|
||||||
mBookmarkManager.CreateBookmark(absPath, lineNum, column, isDisabled, bookmarkTitle, folder);
|
mBookmarkManager.CreateBookmark(absPath, lineNum, column, isDisabled, bookmarkTitle, folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mBookmarkManager.RecalcCurId();
|
||||||
|
|
||||||
for (var referenceId in data.Enumerate("DebuggerDisplayTypes"))
|
for (var referenceId in data.Enumerate("DebuggerDisplayTypes"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,13 +124,12 @@ namespace IDE.ui
|
||||||
|
|
||||||
mBookmarksListView.mOnItemMouseDown.Add(new (item, x, y, btnNum, btnCount) =>
|
mBookmarksListView.mOnItemMouseDown.Add(new (item, x, y, btnNum, btnCount) =>
|
||||||
{
|
{
|
||||||
|
ListViewItemMouseDown(item, x, y, btnNum, btnCount);
|
||||||
if ((btnNum == 0) && (btnCount == 2))
|
if ((btnNum == 0) && (btnCount == 2))
|
||||||
{
|
{
|
||||||
let mainItem = (BookmarksListViewItem)item.GetSubItem(0);
|
let mainItem = (BookmarksListViewItem)item.GetSubItem(0);
|
||||||
mainItem.Goto();
|
mainItem.Goto();
|
||||||
}
|
}
|
||||||
|
|
||||||
ListViewItemMouseDown(item, x, y, btnNum, btnCount);
|
|
||||||
});
|
});
|
||||||
mBookmarksListView.mOnItemMouseClicked.Add(new => ListViewItemMouseClicked);
|
mBookmarksListView.mOnItemMouseClicked.Add(new => ListViewItemMouseClicked);
|
||||||
mBookmarksListView.mOnKeyDown.Add(new => BookmarksLV_OnKeyDown);
|
mBookmarksListView.mOnKeyDown.Add(new => BookmarksLV_OnKeyDown);
|
||||||
|
@ -207,6 +206,8 @@ namespace IDE.ui
|
||||||
if (source == target)
|
if (source == target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
target.Open(true, true);
|
||||||
|
|
||||||
List<BookmarksListViewItem> selectedItems = scope .();
|
List<BookmarksListViewItem> selectedItems = scope .();
|
||||||
mBookmarksListView.GetRoot().WithSelectedItems(scope [&] (selectedItem) =>
|
mBookmarksListView.GetRoot().WithSelectedItems(scope [&] (selectedItem) =>
|
||||||
{
|
{
|
||||||
|
@ -394,11 +395,11 @@ namespace IDE.ui
|
||||||
if (mBookmarksDirty)
|
if (mBookmarksDirty)
|
||||||
UpdateBookmarks();
|
UpdateBookmarks();
|
||||||
|
|
||||||
ShowTooltip(mBtnCreateBookmarkFolder, "Create a new folder.");
|
ShowTooltip(mBtnCreateBookmarkFolder, "Create new folder");
|
||||||
ShowTooltip(mBtnPrevBookmark, "Move the cursor to the previous bookmark.");
|
ShowTooltip(mBtnPrevBookmark, "Previous bookmark");
|
||||||
ShowTooltip(mBtnNextBookmark, "Move the cursor to the next bookmark.");
|
ShowTooltip(mBtnNextBookmark, "Next bookmark");
|
||||||
ShowTooltip(mBtnPrevBookmarkInFolder, "Move the cursor to the previous bookmark in the current folder.");
|
ShowTooltip(mBtnPrevBookmarkInFolder, "Previous bookmark in folder");
|
||||||
ShowTooltip(mBtnNextBookmarkInFolder, "Move the cursor to the next bookmark in the current folder.");
|
ShowTooltip(mBtnNextBookmarkInFolder, "Next bookmark in folder");
|
||||||
|
|
||||||
base.Update();
|
base.Update();
|
||||||
}
|
}
|
||||||
|
@ -479,20 +480,23 @@ namespace IDE.ui
|
||||||
private BookmarksListViewItem AddFolderToListView(BookmarksListViewItem parent, BookmarkFolder folder)
|
private BookmarksListViewItem AddFolderToListView(BookmarksListViewItem parent, BookmarkFolder folder)
|
||||||
{
|
{
|
||||||
var listViewItem = (BookmarksListViewItem)parent.CreateChildItem();
|
var listViewItem = (BookmarksListViewItem)parent.CreateChildItem();
|
||||||
|
listViewItem.MakeParent();
|
||||||
listViewItem.RefObject = folder;
|
listViewItem.RefObject = folder;
|
||||||
listViewItem.AllowDragging = true;
|
listViewItem.AllowDragging = true;
|
||||||
|
|
||||||
var subViewItem = (DarkListViewItem)listViewItem.GetOrCreateSubItem(0);
|
var subViewItem = (DarkListViewItem)listViewItem.GetOrCreateSubItem(0);
|
||||||
|
|
||||||
|
if (!folder.mBookmarkList.IsEmpty)
|
||||||
|
{
|
||||||
DarkCheckBox cb = new DarkCheckBox();
|
DarkCheckBox cb = new DarkCheckBox();
|
||||||
cb.Checked = !folder.IsDisabled;
|
cb.State = folder.AreAllDisabled ? .Unchecked : folder.AreAllEnabled ? .Checked : .Indeterminate;
|
||||||
cb.Resize(GS!(-16), 0, GS!(22), GS!(22));
|
cb.Resize(GS!(-16), 0, GS!(22), GS!(22));
|
||||||
cb.mOnValueChanged.Add(new () =>
|
cb.mOnValueChanged.Add(new () =>
|
||||||
{
|
{
|
||||||
folder.IsDisabled = !cb.Checked;
|
folder.AreAllEnabled = cb.State != .Unchecked;
|
||||||
});
|
});
|
||||||
subViewItem.AddWidget(cb);
|
subViewItem.AddWidget(cb);
|
||||||
|
}
|
||||||
|
|
||||||
subViewItem.Label = folder.mTitle;
|
subViewItem.Label = folder.mTitle;
|
||||||
subViewItem.Resize(GS!(22), 0, 0, 0);
|
subViewItem.Resize(GS!(22), 0, 0, 0);
|
||||||
|
@ -516,6 +520,7 @@ namespace IDE.ui
|
||||||
cb.mOnValueChanged.Add(new () =>
|
cb.mOnValueChanged.Add(new () =>
|
||||||
{
|
{
|
||||||
bookmark.mIsDisabled = !cb.Checked;
|
bookmark.mIsDisabled = !cb.Checked;
|
||||||
|
mBookmarksDirty = true;
|
||||||
});
|
});
|
||||||
subViewItem.AddWidget(cb);
|
subViewItem.AddWidget(cb);
|
||||||
|
|
||||||
|
|
|
@ -452,6 +452,26 @@ void BfParser::GetLineCharAtIdx(int idx, int& line, int& lineChar)
|
||||||
mParserData->GetLineCharAtIdx(idx, line, lineChar);
|
mParserData->GetLineCharAtIdx(idx, line, lineChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BfParser::GetIndexAtLine(int line)
|
||||||
|
{
|
||||||
|
if (line == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int curLine = 0;
|
||||||
|
for (int i = 0; i < mSrcLength; i++)
|
||||||
|
{
|
||||||
|
char c = mSrc[i];
|
||||||
|
if (c == '\n')
|
||||||
|
{
|
||||||
|
curLine++;
|
||||||
|
if (line == curLine)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void BfParser::Fail(const StringImpl& error, int offset)
|
void BfParser::Fail(const StringImpl& error, int offset)
|
||||||
{
|
{
|
||||||
mPassInstance->FailAt(error, mSourceData, mSrcIdx + offset);
|
mPassInstance->FailAt(error, mSourceData, mSrcIdx + offset);
|
||||||
|
|
|
@ -230,6 +230,7 @@ public:
|
||||||
virtual BfParser* ToParser() override { return this; }
|
virtual BfParser* ToParser() override { return this; }
|
||||||
|
|
||||||
void GetLineCharAtIdx(int idx, int& line, int& lineChar);
|
void GetLineCharAtIdx(int idx, int& line, int& lineChar);
|
||||||
|
int GetIndexAtLine(int line);
|
||||||
|
|
||||||
void Fail(const StringImpl& error, int offset = -1);
|
void Fail(const StringImpl& error, int offset = -1);
|
||||||
void TokenFail(const StringImpl& error, int offset = -1);
|
void TokenFail(const StringImpl& error, int offset = -1);
|
||||||
|
|
|
@ -4090,6 +4090,72 @@ BF_EXPORT void BF_CALLTYPE BfSystem_DeleteParser(BfSystem* bfSystem, BfParser* b
|
||||||
//bfSystem->mParserDeleteQueue.push_back(bfParser);
|
//bfSystem->mParserDeleteQueue.push_back(bfParser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BfLocationNameVisitor : public BfElementVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int mIndex;
|
||||||
|
String mName;
|
||||||
|
|
||||||
|
bool TryNode(BfAstNode* node)
|
||||||
|
{
|
||||||
|
if ((mIndex >= node->mSrcStart) && (mIndex < node->mSrcEnd))
|
||||||
|
{
|
||||||
|
if (!mName.IsEmpty())
|
||||||
|
mName += ".";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Visit(BfTypeDeclaration* typeDeclaration)
|
||||||
|
{
|
||||||
|
if ((typeDeclaration->mNameNode != NULL) && (TryNode(typeDeclaration)))
|
||||||
|
{
|
||||||
|
typeDeclaration->mNameNode->ToString(mName);
|
||||||
|
}
|
||||||
|
|
||||||
|
BfElementVisitor::Visit(typeDeclaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Visit(BfMethodDeclaration* methodDeclaration)
|
||||||
|
{
|
||||||
|
if ((methodDeclaration->mNameNode != NULL) && (TryNode(methodDeclaration)))
|
||||||
|
{
|
||||||
|
if (methodDeclaration->mNameNode != NULL)
|
||||||
|
methodDeclaration->mNameNode->ToString(mName);
|
||||||
|
}
|
||||||
|
|
||||||
|
BfElementVisitor::Visit(methodDeclaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Visit(BfPropertyDeclaration* propertyDeclaration)
|
||||||
|
{
|
||||||
|
if ((propertyDeclaration->mNameNode != NULL) && (TryNode(propertyDeclaration)))
|
||||||
|
{
|
||||||
|
if (propertyDeclaration->mNameNode != NULL)
|
||||||
|
propertyDeclaration->mNameNode->ToString(mName);
|
||||||
|
}
|
||||||
|
|
||||||
|
BfElementVisitor::Visit(propertyDeclaration);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BF_EXPORT const char* BfSystem_GetParserLocationName(BfParser* parser, int line, int column)
|
||||||
|
{
|
||||||
|
int idx = parser->GetIndexAtLine(line);
|
||||||
|
if (idx == -1)
|
||||||
|
return NULL;
|
||||||
|
idx += column;
|
||||||
|
|
||||||
|
BfLocationNameVisitor visitor;
|
||||||
|
visitor.mIndex = idx;
|
||||||
|
visitor.VisitMembers(parser->mRootNode);
|
||||||
|
|
||||||
|
String& outString = *gTLStrReturn.Get();
|
||||||
|
outString = visitor.mName;
|
||||||
|
return outString.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
BF_EXPORT BfCompiler* BF_CALLTYPE BfSystem_CreateCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
BF_EXPORT BfCompiler* BF_CALLTYPE BfSystem_CreateCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
||||||
{
|
{
|
||||||
return bfSystem->CreateCompiler(isResolveOnly);
|
return bfSystem->CreateCompiler(isResolveOnly);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue