mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
commit
ba4d29d28d
9 changed files with 1786 additions and 531 deletions
|
@ -243,9 +243,9 @@ namespace Beefy.theme.dark
|
|||
return mLineCoords[anchorLine + 1] == mLineCoords[checkLine + 1];
|
||||
}
|
||||
|
||||
protected override void AdjustCursorsAfterExternalEdit(int index, int ofs)
|
||||
protected override void AdjustCursorsAfterExternalEdit(int index, int ofs, int lineOfs)
|
||||
{
|
||||
base.AdjustCursorsAfterExternalEdit(index, ofs);
|
||||
base.AdjustCursorsAfterExternalEdit(index, ofs, lineOfs);
|
||||
mWantsCheckScrollPosition = true;
|
||||
}
|
||||
|
||||
|
@ -775,6 +775,96 @@ namespace Beefy.theme.dark
|
|||
}
|
||||
}
|
||||
|
||||
if (mEditWidget.mHasFocus)
|
||||
{
|
||||
void DrawSelection(int line, int startColumn, int endColumn)
|
||||
{
|
||||
float x = startColumn * mCharWidth;
|
||||
float y = mLineCoords[line];
|
||||
float width = Math.Abs(startColumn - endColumn) * mCharWidth;
|
||||
float height = mLineCoords[line + 1] - y;
|
||||
|
||||
using (g.PushColor(mHiliteColor))
|
||||
g.FillRect(x, y, width, height);
|
||||
}
|
||||
|
||||
void DrawSelection()
|
||||
{
|
||||
if (!HasSelection())
|
||||
return;
|
||||
|
||||
mSelection.Value.GetAsForwardSelect(var startPos, var endPos);
|
||||
GetLineColumnAtIdx(startPos, var startLine, var startColumn);
|
||||
GetLineColumnAtIdx(endPos, var endLine, var endColumn);
|
||||
|
||||
// Selection is on the single line
|
||||
if (startLine == endLine)
|
||||
{
|
||||
DrawSelection(startLine, startColumn, endColumn);
|
||||
return;
|
||||
}
|
||||
|
||||
// Selection goes across multiple lines
|
||||
|
||||
// First line
|
||||
GetLinePosition(startLine, ?, var firstLineEndIdx);
|
||||
GetLineColumnAtIdx(firstLineEndIdx, ?, var firstLineEndColumn);
|
||||
DrawSelection(startLine, startColumn, firstLineEndColumn + 1);
|
||||
|
||||
for (var lineIdx = startLine + 1; lineIdx < endLine; lineIdx++)
|
||||
{
|
||||
GetLinePosition(lineIdx, var lineStart, var lineEnd);
|
||||
GetLineColumnAtIdx(lineEnd, var line, var column);
|
||||
|
||||
if (column == 0)
|
||||
{
|
||||
// Blank line selected
|
||||
var y = mLineCoords[line];
|
||||
var height = mLineCoords[line + 1] - y;
|
||||
|
||||
using (g.PushColor(mHiliteColor))
|
||||
g.FillRect(0, y, 4, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawSelection(line, 0, column + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Last line
|
||||
DrawSelection(endLine, 0, endColumn);
|
||||
}
|
||||
|
||||
var prevTextCursor = mCurrentTextCursor;
|
||||
for (var cursor in mTextCursors)
|
||||
{
|
||||
if (cursor.mId == 0)
|
||||
continue;
|
||||
|
||||
SetTextCursor(cursor);
|
||||
DrawSelection();
|
||||
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
if (cursor.mVirtualCursorPos.HasValue)
|
||||
{
|
||||
x = cursor.mVirtualCursorPos.Value.mColumn * mCharWidth;
|
||||
y = mLineCoords[cursor.mVirtualCursorPos.Value.mLine];
|
||||
}
|
||||
else
|
||||
{
|
||||
GetLineCharAtIdx(cursor.mCursorTextPos, var eStartLine, var eStartCharIdx);
|
||||
GetColumnAtLineChar(eStartLine, eStartCharIdx, var column);
|
||||
x = column * mCharWidth;
|
||||
y = mLineCoords[eStartLine];
|
||||
}
|
||||
|
||||
using (g.PushColor(0xFF80FFB3))
|
||||
DrawCursor(x, y);
|
||||
}
|
||||
SetTextCursor(prevTextCursor);
|
||||
}
|
||||
|
||||
g.PopMatrix();
|
||||
|
||||
/*using (g.PushColor(0x4000FF00))
|
||||
|
|
|
@ -138,8 +138,47 @@ namespace Beefy.utils
|
|||
mCurCost = 0;
|
||||
}
|
||||
|
||||
bool TryMerge(UndoAction action)
|
||||
{
|
||||
var currentBatchEnd = action as UndoBatchEnd;
|
||||
if (currentBatchEnd == null)
|
||||
return false;
|
||||
|
||||
var currentBatchStart = currentBatchEnd.mBatchStart as UndoBatchStart;
|
||||
var prevBatchEndIdx = mUndoList.IndexOf(currentBatchStart) - 1;
|
||||
if (prevBatchEndIdx <= 0)
|
||||
return false;
|
||||
|
||||
var prevBatchEnd = mUndoList[prevBatchEndIdx] as UndoBatchEnd;
|
||||
if (prevBatchEnd == null)
|
||||
return false;
|
||||
|
||||
var prevBatchStart = prevBatchEnd.mBatchStart as UndoBatchStart;
|
||||
if (prevBatchStart == null)
|
||||
return false;
|
||||
if (prevBatchStart.Merge(currentBatchStart) == false)
|
||||
return false;
|
||||
|
||||
mUndoList.Remove(currentBatchStart);
|
||||
mUndoList.Remove(currentBatchEnd);
|
||||
|
||||
mUndoList.Remove(prevBatchEnd);
|
||||
mUndoList.Add(prevBatchEnd);
|
||||
|
||||
delete currentBatchStart;
|
||||
delete currentBatchEnd;
|
||||
|
||||
mUndoIdx = (.)mUndoList.Count;
|
||||
|
||||
Debug.WriteLine("SUCCESS: Merged");
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Add(UndoAction action, bool allowMerge = true)
|
||||
{
|
||||
if ((allowMerge) && (TryMerge(action)))
|
||||
return;
|
||||
|
||||
if (mFreezeDeletes == 0)
|
||||
mCurCost += action.GetCost();
|
||||
if (action is IUndoBatchStart)
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue