public static void StartSelection (HexEditorData data) { data.Caret.PreserveSelection = true; if (!data.IsSomethingSelected) { data.MainSelection = new Selection (data.Caret.Offset, data.Caret.Offset); } // data.Caret.AutoScrollToCaret = false; }
public virtual void Redo(HexEditorData data) { if (redoNode == null) { throw new NullReferenceException("redoNode == null"); } data.pieceTable.tree.Root = redoNode; redoCaret.Set(data.Caret); }
public override byte[] GetBytes(HexEditorData hexEditorData, long myOffset, long offset, int count) { byte[] result = new byte[count]; for (int i = 0, j = (int)(AddBufferOffset + offset - myOffset); i < result.Length; i++, j++) { result[i] = hexEditorData.addBuffer [j]; } return(result); }
public static void Right (HexEditorData data) { if (!data.Caret.InTextEditor && data.Caret.SubPosition < data.Caret.MaxSubPosition) { data.Caret.SubPosition++; return; } long newOffset = System.Math.Min (data.Length, data.Caret.Offset + 1); if (newOffset != data.Caret.Offset) { data.Caret.Offset = newOffset; } }
public static void Select (HexEditorData data, Action<HexEditorData> caretMoveAction) { PositionChangedHandler handler = new PositionChangedHandler (data); data.Caret.OffsetChanged += handler.DataCaretPositionChanged; StartSelection (data); caretMoveAction (data); data.Caret.OffsetChanged -= handler.DataCaretPositionChanged; data.Caret.AutoScrollToCaret = true; data.Caret.PreserveSelection = false; }
public static void Backspace (HexEditorData data) { if (data.IsSomethingSelected) { data.DeleteSelection (); return; } if (data.Caret.Offset == 0) return; data.Remove (data.Caret.Offset - 1, 1); data.Caret.Offset--; }
public static void Delete (HexEditorData data) { if (data.IsSomethingSelected) { data.DeleteSelection (); return; } if (data.Caret.Offset >= data.Length) return; data.Remove (data.Caret.Offset, 1); data.UpdateLine (data.Caret.Line); }
public static void Left (HexEditorData data) { if (!data.Caret.InTextEditor && data.Caret.SubPosition > 0) { data.Caret.SubPosition--; return; } long newOffset = System.Math.Max (0, data.Caret.Offset - 1); if (newOffset != data.Caret.Offset) { data.Caret.Offset = newOffset; data.Caret.SubPosition = data.Caret.MaxSubPosition; } }
public static void Toggle (HexEditorData data) { long line = data.Caret.Offset / data.BytesInRow; foreach (long bookmark in data.Bookmarks) { if (line * data.BytesInRow <= bookmark && bookmark < line * data.BytesInRow + data.BytesInRow) { data.Bookmarks.Remove (bookmark); return; } } data.Bookmarks.Add (data.Caret.Offset); data.UpdateMargin (typeof (IconMargin), data.Caret.Line); }
public static void GotoPrevious (HexEditorData data) { data.Bookmarks.Sort (); long cur = -1; for (int i = 0; i < data.Bookmarks.Count; i++) { if (data.Bookmarks[i] < data.Caret.Offset && cur < data.Bookmarks[i]) cur = data.Bookmarks[i]; } if (cur == -1 && data.Bookmarks.Count > 0) cur = data.Bookmarks[data.Bookmarks.Count - 1]; if (cur != -1) { data.Caret.Offset = cur; data.UpdateLine (data.Caret.Offset / data.BytesInRow); } }
public static void GotoNext (HexEditorData data) { data.Bookmarks.Sort (); long cur = long.MaxValue; for (int i = 0; i < data.Bookmarks.Count; i++) { if (data.Bookmarks[i] > data.Caret.Offset && cur > data.Bookmarks[i]) cur = data.Bookmarks[i]; } if (cur == long.MaxValue && data.Bookmarks.Count > 0) cur = data.Bookmarks[0]; if (cur != long.MaxValue) { data.Caret.Offset = cur; data.UpdateLine (data.Caret.Offset / data.BytesInRow); } }
public UndoGroup (HexEditorData data) { if (data == null) throw new ArgumentNullException ("data"); this.data = data; data.BeginAtomicUndo (); }
public static void MoveLineEnd (HexEditorData data) { Select (data, CaretMoveActions.LineEnd); }
public static void EndSelection (HexEditorData data) { data.ExtendSelectionTo (data.Caret.Offset); // data.Caret.AutoScrollToCaret = true; data.Caret.PreserveSelection = false; }
public static void PageUp (HexEditorData data) { data.VAdjustment.Value = System.Math.Max (data.VAdjustment.LowerValue, data.VAdjustment.Value - data.VAdjustment.PageSize); int pageLines = (int)(data.VAdjustment.PageSize + ((int)data.VAdjustment.Value % data.LineHeight) / data.LineHeight); data.Caret.Offset = (long)System.Math.Max (0, data.Caret.Offset - data.BytesInRow * pageLines); }
public static void ToDocumentEnd (HexEditorData data) { data.Caret.Offset = data.Length - 1; }
public static void PageDown (HexEditorData data) { data.VAdjustment.Value = System.Math.Min (data.VAdjustment.UpperValue - data.VAdjustment.PageSize, data.VAdjustment.Value + data.VAdjustment.PageSize); int pageLines = (int)(data.VAdjustment.PageSize + ((int)data.VAdjustment.Value % data.LineHeight) / data.LineHeight); data.Caret.Offset = (long)System.Math.Min (data.Length, data.Caret.Offset + data.BytesInRow * pageLines); }
public Caret(HexEditorData data) { this.data = data; PreserveSelection = false; AutoScrollToCaret = true; }
public static void SwitchCaretMode (HexEditorData data) { data.Caret.IsInsertMode = !data.Caret.IsInsertMode; data.UpdateLine (data.Caret.Line); }
public PositionChangedHandler (HexEditorData data) { this.data = data; }
public static void Down (HexEditorData data) { data.Caret.Offset = System.Math.Min (data.Length, data.Caret.Offset + data.BytesInRow); }
public static void Up (HexEditorData data) { data.Caret.Offset = System.Math.Max (0, data.Caret.Offset - data.BytesInRow); }
public static void SwitchSide (HexEditorData data) { data.Caret.InTextEditor = !data.Caret.InTextEditor; data.UpdateLine (data.Caret.Line); }
public void Dispose () { if (data != null) { data.EndAtomicUndo (); data = null; } }
public static void MovePageDown (HexEditorData data) { Select (data, CaretMoveActions.PageDown); }
public override byte[] GetBytes(HexEditorData hexEditorData, long myOffset, long offset, int count) { return(hexEditorData.buffer.GetBytes(BufferOffset + offset - myOffset, count)); }
public static void ToDocumentStart (HexEditorData data) { data.Caret.Offset = 0; }
public static void Redo (HexEditorData data) { data.Redo (); }
public static void StartLineSelection (HexEditorData data) { data.Caret.PreserveSelection = true; if (!data.IsSomethingSelected) data.MainSelection = new Selection (data.Caret.Offset, data.Caret.Offset); }
public abstract byte[] GetBytes(HexEditorData hexEditorData, long myOffset, long offset, int count);
public static void LineHome (HexEditorData data) { data.Caret.Offset -= data.Caret.Offset % data.BytesInRow; data.Caret.SubPosition = 0; }
public static void Undo (HexEditorData data) { data.Undo (); }
public static void MoveToDocumentEnd (HexEditorData data) { Select (data, CaretMoveActions.ToDocumentEnd); }
public Caret (HexEditorData data) { this.data = data; PreserveSelection = false; AutoScrollToCaret = true; }
public static void LineEnd (HexEditorData data) { data.Caret.Offset = System.Math.Min (data.Length - 1, data.Caret.Offset + data.BytesInRow - 1 - data.Caret.Offset % data.BytesInRow); data.Caret.SubPosition = 0; }