mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-30 05:15:59 +02:00
Feature: Multi-Cursors
This commit is contained in:
parent
1e528cba95
commit
c6fa2b8e79
9 changed files with 1776 additions and 530 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue