[Monodevelop-patches-list] r848 - in trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor: Commands Gui

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Mon Feb 9 18:27:35 EST 2004


Author: benm
Date: 2004-02-09 18:27:35 -0500 (Mon, 09 Feb 2004)
New Revision: 848

Modified:
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ToolCommands.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
Log:
get color working

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ToolCommands.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ToolCommands.cs	2004-02-09 22:13:27 UTC (rev 847)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ToolCommands.cs	2004-02-09 23:27:35 UTC (rev 848)
@@ -27,6 +27,7 @@
 using ICSharpCode.SharpDevelop.Gui;
 using ICSharpCode.SharpDevelop.Gui.HtmlControl;
 using ICSharpCode.Core.Services;
+using MonoDevelop.SourceEditor.Gui;
 
 using Gtk;
 using GtkSharp;
@@ -65,45 +66,23 @@
 	{
 		public override void Run()
 		{
-			Console.WriteLine ("Not Ported to the new editor yet");
+			IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+			if (window == null)
+				return;
 
-			/*IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
-			if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
+			SourceEditorDisplayBindingWrapper w = window.ViewContent as SourceEditorDisplayBindingWrapper;
+			if (w == null)
 				return;
-			}
-			//TextEditorControl textarea = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
+
 			//FIXME:  
 			// - The return sting value is not the same choosen in the Dialog
                         // - Return color name (not color value) if it IsKnownColor but it's still not implemented for System.Drawing.Color
-			ColorDialog dialog  = new ColorDialog ();
-			if ( dialog.Run () == (int) ResponseType.Ok) {
-				string ColorStr = dialog.ColorStr();
-				//string ColorStr = dialog.ColorSelection.CurrentColor.ToString();
-				//textarea.Document.Insert(textarea.ActiveTextAreaControl.Caret.Offset, ColorStr);
-				//int lineNumber = textarea.Document.GetLineNumberForOffset(textarea.ActiveTextAreaControl.Caret.Offset);
-				//textarea.ActiveTextAreaControl.Caret.Column += ColorStr.Length;
-				//textarea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, new Point(0, lineNumber)));
-				//textarea.Document.CommitUpdate();
+			using (ColorDialog dialog = new ColorDialog ()) {
+				if (dialog.Run () != (int) ResponseType.Ok)
+					return;
 				
-
-			};
-			dialog.Hide();
-
-			*/
-			/*using (ColorDialog cd = new ColorDialog()) {
-				if (cd.ShowDialog() == DialogResult.OK) {
-					string colorstr = "#" + cd.Color.ToArgb().ToString("X");
-					if (cd.Color.IsKnownColor) {
-						colorstr = cd.Color.ToKnownColor().ToString();
-					}
-					
-					textarea.Document.Insert(textarea.ActiveTextAreaControl.Caret.Offset, colorstr);
-					int lineNumber = textarea.Document.GetLineNumberForOffset(textarea.ActiveTextAreaControl.Caret.Offset);
-					textarea.ActiveTextAreaControl.Caret.Column += colorstr.Length;
-					textarea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, new Point(0, lineNumber)));
-					textarea.Document.CommitUpdate();
-				}
-			}*/
+				w.InsertAtCursor (dialog.ColorStr ());
+			}
 		}
 	}
 	

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2004-02-09 22:13:27 UTC (rev 847)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2004-02-09 23:27:35 UTC (rev 848)
@@ -169,6 +169,13 @@
 
 		}
 		
+		public void InsertAtCursor (string s)
+		{
+			se.Buffer.InsertAtCursor (s);
+			se.View.ScrollMarkOnscreen (se.Buffer.InsertMark);
+			
+		}
+		
 		public void LoadString (string mime, string val)
 		{
 			if (mime != null)




More information about the Monodevelop-patches-list mailing list