Browse Source

* TextBox.cs:
* RichTextBox.cs:
* TextControl.cs: Starting to merge in some pieces of my older
undo work. Basically just some slight cleanup of the undo API.


svn path=/trunk/mcs/; revision=71309

Jackson Harper 19 years ago
parent
commit
f7983dc177

+ 7 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,10 @@
+2007-01-18  Jackson Harper  <[email protected]>
+
+	* TextBox.cs:
+	* RichTextBox.cs:
+	* TextControl.cs: Starting to merge in some pieces of my older
+	undo work.  Basically just some slight cleanup of the undo API.
+
 2007-01-18  Rolf Bjarne Kvinge  <[email protected]>
 
 	* TrackBar.cs: Fix signature of RightToLeftLayout.

+ 6 - 11
mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs

@@ -41,11 +41,8 @@ namespace System.Windows.Forms {
 		#region Local Variables
 		internal bool		auto_word_select;
 		internal int		bullet_indent;
-		internal bool		can_redo;
 		internal bool		detect_urls;
-		internal string		redo_action_name;
 		internal int		margin_right;
-		internal string		undo_action_name;
 		internal float		zoom;
 
 		private RTF.TextMap	rtf_text_map;
@@ -67,12 +64,9 @@ namespace System.Windows.Forms {
 			accepts_return = true;
 			auto_word_select = false;
 			bullet_indent = 0;
-			can_redo = false;
 			detect_urls = true;
 			max_length = Int32.MaxValue;
-			redo_action_name = string.Empty;
 			margin_right = 0;
-			undo_action_name = string.Empty;
 			zoom = 1;
 			base.Multiline = true;
 			document.CRLFSize = 1;
@@ -159,7 +153,7 @@ namespace System.Windows.Forms {
 		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 		public bool CanRedo {
 			get {
-				return can_redo;
+				return document.undo.CanRedo;
 			}
 		}
 
@@ -237,7 +231,7 @@ namespace System.Windows.Forms {
 		[MonoTODO]
 		public string RedoActionName {
 			get {
-				return redo_action_name;
+				return document.undo.RedoActionName;
 			}
 		}
 
@@ -657,7 +651,7 @@ namespace System.Windows.Forms {
 		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 		public string UndoActionName {
 			get {
-				return document.undo.UndoName;
+				return document.undo.UndoActionName;
 			}
 		}
 
@@ -915,8 +909,9 @@ namespace System.Windows.Forms {
 			base.Paste(Clipboard.GetDataObject(), clipFormat, false);
 		}
 
-		[MonoTODO()]
-		public void Redo() {
+		public void Redo()
+		{
+			document.undo.Redo ();
 		}
 
 		public void SaveFile(Stream data, RichTextBoxStreamType fileType) {

+ 1 - 1
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs

@@ -271,7 +271,7 @@ namespace System.Windows.Forms {
 		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 		public bool CanUndo {
 			get {
-				return document.undo.UndoLevels != 0;
+				return document.undo.CanUndo;
 			}
 		}
 

+ 22 - 14
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs

@@ -4622,6 +4622,9 @@ namespace System.Windows.Forms {
 			Mark,
 			CompoundBegin,
 			CompoundEnd,
+
+			UserActionBegin,
+			UserActionEnd
 		}
 
 		internal class Action {
@@ -4636,8 +4639,6 @@ namespace System.Windows.Forms {
 		private Stack		undo_actions;
 		private Stack		redo_actions;
 
-		private int undo_levels;
-		private int redo_levels;
 		private int		caret_line;
 		private int		caret_pos;
 		#endregion	// Local Variables
@@ -4651,19 +4652,28 @@ namespace System.Windows.Forms {
 		#endregion	// Constructors
 
 		#region Properties
-		internal int UndoLevels {
+		internal bool CanUndo {
 			get {
-				return undo_levels;
+				foreach (Action action in undo_actions) {
+					if (action.type == ActionType.UserActionEnd)
+						return true;
+				}
+				return false;
 			}
 		}
 
-		internal int RedoLevels {
+		internal bool CanRedo {
 			get {
-				return redo_levels;
+				foreach (Action action in undo_actions) {
+					if (action.type == ActionType.UserActionBegin)
+						return true;
+				}
+				return false;
 			}
 		}
 
-		internal string UndoName {
+		internal string UndoActionName
+		{
 			get {
 				Action action;
 
@@ -4702,8 +4712,11 @@ namespace System.Windows.Forms {
 			}
 		}
 
-		internal string RedoName() {
-			return null;
+		internal string RedoActionName
+		{
+			get {
+				return null;
+			}
 		}
 		#endregion	// Properties
 
@@ -4711,8 +4724,6 @@ namespace System.Windows.Forms {
 		internal void Clear() {
 			undo_actions.Clear();
 			redo_actions.Clear();
-			undo_levels = 0;
-			redo_levels = 0;
 		}
 
 		internal void Undo() {
@@ -4739,8 +4750,6 @@ namespace System.Windows.Forms {
 
 				case ActionType.CompoundBegin:
 					compound_stack--;
-					undo_levels--;
-					redo_levels++;
 					break;
 
 				case ActionType.InsertString:
@@ -4809,7 +4818,6 @@ namespace System.Windows.Forms {
 			ce.type = ActionType.CompoundEnd;
 
 			undo_actions.Push (ce);
-			undo_levels++;
 		}
 
 		// pos = 1-based