private IEnumerable <IOleUndoUnit> GetUndoUnits(IOleUndoManager undoManager) { IEnumOleUndoUnits undoUnitEnumerator; try { // Unfortunately, EnumUndoable returns the units in oldest-first order. undoManager.EnumUndoable(out undoUnitEnumerator); } catch (COMException) { yield break; } const int BatchSize = 100; var fetchedUndoUnits = new IOleUndoUnit[BatchSize]; while (true) { undoUnitEnumerator.Next(BatchSize, fetchedUndoUnits, out var fetchedCount); for (var i = 0; i < fetchedCount; i++) { yield return(fetchedUndoUnits[i]); } if (fetchedCount < BatchSize) { break; } } }
private IEnumerable <IOleUndoUnit> GetUndoUnits(IOleUndoManager undoManager) { // Unfortunately, EnumUndoable returns the units in oldest-first order. undoManager.EnumUndoable(out var undoUnitEnumerator); if (undoUnitEnumerator == null) { yield break; } const int BatchSize = 100; while (true) { IOleUndoUnit[] fetchedUndoUnits = new IOleUndoUnit[BatchSize]; undoUnitEnumerator.Next(BatchSize, fetchedUndoUnits, out var fetchedCount); for (int i = 0; i < fetchedCount; i++) { yield return(fetchedUndoUnits[i]); } if (fetchedCount < BatchSize) { break; } } }
public int FindUnit(IOleUndoUnit pUU) { if (_children.Contains(pUU)) { return(VSConstants.S_OK); } return(VSConstants.S_FALSE); }
public int FindUnit(IOleUndoUnit pUU) { if (_children.Contains(pUU)) { return VSConstants.S_OK; } return VSConstants.S_FALSE; }
public void Add(IOleUndoUnit pUU) { // TODO AppDbproj If we initiate an XML Model transaction without a changescope, the // _parentUndoUnit will be null. This will go away once we introduce incremental changes if (_parentUndoUnit != null) { _parentUndoUnit.Add(pUU); } }
public void Add(IOleUndoUnit pUU) { pUU.GetDescription(out string description); #if DEBUGUNDOREDO Debug.WriteLine($@">>> ParentRecord.Add({Sequence}/{_unitDescription}): {description}"); #endif Children.Push(pUU); }
/// <summary> /// Called on click - when overriden, finds object in current selection and displayes dialog offering to move it. /// </summary> public override void Process() { base.Process(); // initialize basic variables T resultItem = GetCodeReferenceResultItem(); // get result item (language specific) if (resultItem != null) { try { int x, y; // get span of reference (may be complicated in case of references like <%= Resources.key %> ) TextSpan inlineSpan = resultItem.GetInlineReplaceSpan(false, out x, out y); // get string literal that can be inserted into the code (unescape...) string text = resultItem.GetInlineValue(); // perform the replacement int hr = textLines.ReplaceLines(inlineSpan.iStartLine, inlineSpan.iStartIndex, inlineSpan.iEndLine, inlineSpan.iEndIndex, Marshal.StringToBSTR(text), text.Length, null); Marshal.ThrowExceptionForHR(hr); hr = textView.SetSelection(inlineSpan.iStartLine, inlineSpan.iStartIndex, inlineSpan.iStartLine, inlineSpan.iStartIndex + text.Length); Marshal.ThrowExceptionForHR(hr); // create undo unit and put it in the undo stack CreateInlineUndoUnit(resultItem.FullReferenceText); } catch (Exception) { // rollback VLOutputWindow.VisualLocalizerPane.WriteLine("Exception caught, rolling back..."); IOleUndoUnit unit = undoManager.RemoveTopFromUndoStack(1)[0]; int itemsToRemove = 1; if (unit is AbstractUndoUnit) { itemsToRemove += ((AbstractUndoUnit)unit).AppendUnits.Count; } unit.Do(undoManager); undoManager.RemoveTopFromUndoStack(itemsToRemove); throw; } } else { throw new Exception("This part of code cannot be inlined"); } }
public override void Do(IOleUndoManager pUndoManager) { #if DEBUGUNDOREDO Debug.WriteLine($@">>> ParentRecord.Do({Sequence}/{_unitDescription}): begin"); #endif using (Controller.CreateAtomicGuiChangeBlock(_unitDescription)) { while (Children.Count > 0) { IOleUndoUnit child = Children.Pop(); child.Do(pUndoManager); } } #if DEBUGUNDOREDO Debug.WriteLine($@">>> ParentRecord.Do({Sequence}/{_unitDescription}): end"); #endif }
private string GetUndoUnitDescription(IOleUndoUnit undoUnit) { // get the description String description; undoUnit.GetDescription(out description); return description; }
public void Commit() { redoUnit = new SelectionOleRedoUnit(_markupServices, _selection); _editor.UndoManager.Add(redoUnit); committed = true; }
public SelectionUndoUnit(HtmlEditorControl editor, MarkupRange selection) { _editor = editor; _selection = selection; _markupServices = _editor.MshtmlEditor.MshtmlControl.MarkupServices; undoUnit = new SelectionOleUndoUnit(_markupServices, _selection); _editor.UndoManager.Add(undoUnit); }
private static List <IOleUndoUnit> RemoveTop(IOleUndoManager undoManager, IEnumOleUndoUnits enumerator, int count) { List <IOleUndoUnit> backupList = new List <IOleUndoUnit>(); List <IOleUndoUnit> returnList = new List <IOleUndoUnit>(); int hr; if (count > 0) { uint returned = 1; // backup all existing undo units while (returned > 0) { IOleUndoUnit[] units = new IOleUndoUnit[10]; hr = enumerator.Next((uint)units.Length, units, out returned); Marshal.ThrowExceptionForHR(hr); if (returned == 10) { backupList.AddRange(units); } else if (returned > 0) { for (int i = 0; i < returned; i++) { backupList.Add(units[i]); } } } // put units back except those which should be removed if (backupList.Count > 0) { PoisonPillUndoUnit pill = new PoisonPillUndoUnit(); undoManager.Add(pill); // clear stack undoManager.DiscardFrom(pill); // add units back for (int i = 0; i < backupList.Count - count; i++) { undoManager.Add(backupList[i]); } // return top "count" units or less, if there's not enough if (count <= backupList.Count) { returnList = backupList.GetRange(backupList.Count - count, count); } else { returnList = backupList; } } } returnList.Reverse(); return(returnList); }
public void Add(IOleUndoUnit pUU) { _children.Add(pUU); }
public void UndoTo(IOleUndoUnit pUU) { _wrappedUndoManager.UndoTo(pUU); }
/// <summary> /// Adds an undo unit to current document's undo stack /// </summary> public virtual void AddUndoUnit(IOleUndoUnit undoUnit) { UndoManager.Add(undoUnit); }
public void DiscardFrom(IOleUndoUnit pUU) { _wrappedUndoManager.DiscardFrom(pUU); }
public int FindUnit(IOleUndoUnit pUU) { throw new NotImplementedException(); }