mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Improved #region collapse behavior
This commit is contained in:
parent
5fc95f8f07
commit
6fe9c97649
3 changed files with 45 additions and 17 deletions
|
@ -219,9 +219,6 @@ namespace IDE.ui
|
|||
|
||||
public void FixAfterUpdate() mut
|
||||
{
|
||||
if (mKind == .Region)
|
||||
mStartLine++;
|
||||
|
||||
if (mAnchorLine == mEndLine)
|
||||
{
|
||||
mDeleted = true;
|
||||
|
@ -5073,6 +5070,8 @@ namespace IDE.ui
|
|||
int32 closeDepth = 0;
|
||||
int32 curAnimLineIdx = 0;
|
||||
bool inAnim = false;
|
||||
int checkOpenIdx = 0;
|
||||
|
||||
for (int line < data.mLineStarts.Count)
|
||||
{
|
||||
while (curIdx < mOrderedCollapseEntries.Count)
|
||||
|
@ -5086,27 +5085,30 @@ namespace IDE.ui
|
|||
|
||||
if (entry.mAnchorLine > line)
|
||||
break;
|
||||
|
||||
checkOpenIdx = Math.Min(checkOpenIdx, collapseStack.Count);
|
||||
collapseStack.Add(curIdx);
|
||||
curIdx++;
|
||||
}
|
||||
|
||||
bool deferClose = false;
|
||||
|
||||
if (!collapseStack.IsEmpty)
|
||||
while (checkOpenIdx < collapseStack.Count)
|
||||
{
|
||||
int32 activeIdx = collapseStack.Back;
|
||||
var entry = mOrderedCollapseEntries[activeIdx];
|
||||
if (line == entry.mStartLine)
|
||||
int32 checkIdx = collapseStack[checkOpenIdx];
|
||||
var entry = mOrderedCollapseEntries[checkIdx];
|
||||
if (line != entry.mStartLine)
|
||||
break;
|
||||
|
||||
checkOpenIdx++;
|
||||
if (checkIdx == animIdx)
|
||||
inAnim = true;
|
||||
if ((!entry.mIsOpen) && (checkIdx != animIdx))
|
||||
{
|
||||
if (activeIdx == animIdx)
|
||||
inAnim = true;
|
||||
if ((!entry.mIsOpen) && (activeIdx != animIdx))
|
||||
{
|
||||
if ((closeDepth == 0) && (entry.mAnchorLine == entry.mStartLine))
|
||||
deferClose = true;
|
||||
else
|
||||
closeDepth++;
|
||||
}
|
||||
if ((closeDepth == 0) && (entry.mAnchorLine == entry.mStartLine))
|
||||
deferClose = true;
|
||||
else
|
||||
closeDepth++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4380,6 +4380,18 @@ namespace IDE.ui
|
|||
{
|
||||
var entry = ewc.mOrderedCollapseEntries[collapseIdx & CollapseRegionView.cIdMask];
|
||||
g.Draw(DarkTheme.sDarkTheme.GetImage(entry.mIsOpen ? .CollapseOpened : .CollapseClosed), editX - GS!(16), ewc.mLineCoords[lineIdx] + boxAdjustTop + GS!(2));
|
||||
|
||||
int nextCollapseIdx = (collapseIdx & CollapseRegionView.cIdMask) + 1;
|
||||
if ((entry.mIsOpen) && (nextCollapseIdx < ewc.mOrderedCollapseEntries.Count))
|
||||
{
|
||||
// Draw line between two collapse boxes in a row
|
||||
var nextEntry = ewc.mOrderedCollapseEntries[nextCollapseIdx];
|
||||
if (nextEntry.mAnchorLine == lineIdx + 1)
|
||||
{
|
||||
using (g.PushColor(0xFFA5A5A5))
|
||||
g.FillRect(editX - (int)GS!(7.5f), ewc.mLineCoords[lineIdx] + boxAdjustTop + (int)GS!(15.5f), (int)GS!(1.5f), (lineSpacing - GS!(10)) + GS!(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((collapseIdx & CollapseRegionView.cEndFlag) != 0)
|
||||
{
|
||||
|
|
|
@ -9201,8 +9201,21 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
|||
mStartSeriesIdx = -1;
|
||||
}
|
||||
|
||||
int GetLineStartAfter(int startIdx)
|
||||
{
|
||||
for (int i = startIdx; i < mParser->mSrcLength - 1; i++)
|
||||
{
|
||||
if (mParser->mSrc[i] == '\n')
|
||||
return i + 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Add(int anchor, int start, int end, char kind = '?')
|
||||
{
|
||||
if ((anchor == -1) || (start == -1) || (end == -1))
|
||||
return;
|
||||
|
||||
bool isMultiline = false;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
|
@ -9396,7 +9409,8 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
|||
regionStart = preprocessorNode->mCommand;
|
||||
else if (sv == "endregion")
|
||||
{
|
||||
collapseVisitor.Add(regionStart, regionStart, preprocessorNode->mCommand, 'R');
|
||||
if (regionStart != NULL)
|
||||
collapseVisitor.Add(regionStart->mSrcStart, collapseVisitor.GetLineStartAfter(regionStart->mSrcStart), preprocessorNode->mCommand->mSrcStart, 'R');
|
||||
regionStart = NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue