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;
		}
예제 #2
0
 public virtual void Redo(HexEditorData data)
 {
     if (redoNode == null)
     {
         throw new NullReferenceException("redoNode == null");
     }
     data.pieceTable.tree.Root = redoNode;
     redoCaret.Set(data.Caret);
 }
예제 #3
0
 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;
			}
		}
예제 #9
0
		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);
		}
예제 #10
0
		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);
			}
		}
예제 #11
0
		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);
			}
		}
예제 #12
0
			public UndoGroup (HexEditorData data)
			{
				if (data == null)
					throw new ArgumentNullException ("data");
				this.data = data;
				data.BeginAtomicUndo ();
			}
예제 #13
0
		public static void MoveLineEnd (HexEditorData data)
		{
			Select (data, CaretMoveActions.LineEnd);
		}
예제 #14
0
		public static void EndSelection (HexEditorData data)
		{
			data.ExtendSelectionTo (data.Caret.Offset);
//			data.Caret.AutoScrollToCaret = true;
			data.Caret.PreserveSelection = false;
		}
예제 #15
0
		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);
		}
예제 #16
0
		public static void ToDocumentEnd (HexEditorData data)
		{
			data.Caret.Offset = data.Length - 1;
		}
예제 #17
0
		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);
		}
예제 #18
0
 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);
		}
예제 #20
0
			public PositionChangedHandler (HexEditorData data)
			{
				this.data = data;
			}
예제 #21
0
		public static void Down (HexEditorData data)
		{
			data.Caret.Offset = System.Math.Min (data.Length, data.Caret.Offset + data.BytesInRow);
		}
예제 #22
0
		public static void Up (HexEditorData data)
		{
			data.Caret.Offset = System.Math.Max (0, data.Caret.Offset - data.BytesInRow);
		}
예제 #23
0
		public static void SwitchSide (HexEditorData data)
		{
			data.Caret.InTextEditor = !data.Caret.InTextEditor;
			data.UpdateLine (data.Caret.Line);
		}
예제 #24
0
			public void Dispose ()
			{
				if (data != null) {
					data.EndAtomicUndo ();
					data = null;
				}
			}
예제 #25
0
		public static void MovePageDown (HexEditorData data)
		{
			Select (data, CaretMoveActions.PageDown);
		}
예제 #26
0
 public override byte[] GetBytes(HexEditorData hexEditorData, long myOffset, long offset, int count)
 {
     return(hexEditorData.buffer.GetBytes(BufferOffset + offset - myOffset, count));
 }
예제 #27
0
		public static void ToDocumentStart (HexEditorData data)
		{
			data.Caret.Offset = 0;
		}
		public static void Redo (HexEditorData data)
		{
			data.Redo ();
		}
예제 #29
0
		public static void StartLineSelection (HexEditorData data)
		{
			data.Caret.PreserveSelection = true;
			if (!data.IsSomethingSelected)
				data.MainSelection = new Selection (data.Caret.Offset, data.Caret.Offset);
		}
예제 #30
0
 public abstract byte[] GetBytes(HexEditorData hexEditorData, long myOffset, long offset, int count);
예제 #31
0
		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 ();
		}
예제 #33
0
		public static void MoveToDocumentEnd (HexEditorData data)
		{
			Select (data, CaretMoveActions.ToDocumentEnd);
		}
예제 #34
0
		public Caret (HexEditorData data)
		{
			this.data = data;
			PreserveSelection = false;
			AutoScrollToCaret = true;
		}
예제 #35
0
		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;
		}