[Monodevelop-patches-list] r1426 - in trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor: . CodeCompletion Gui

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Fri Apr 9 18:00:39 EDT 2004


Author: tberman
Date: 2004-04-09 18:00:39 -0400 (Fri, 09 Apr 2004)
New Revision: 1426

Modified:
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CodeCompletionData.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CommentCompletionDataProvider.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CompletionWindow.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/ICompletionData.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/TemplateCompletionDataProvider.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorView.cs
Log:
xcode style typeahead completion. *very cool*


Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2004-04-09 19:34:10 UTC (rev 1425)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2004-04-09 22:00:39 UTC (rev 1426)
@@ -1,3 +1,16 @@
+2004-04-09  Todd Berman  <tberman at sevenl.net>
+
+	* Gui/SourceEditorBuffer.cs:
+	* Gui/SourceEditorView.cs:
+	* CodeCompletion/ICompletionData.cs:
+	* CodeCompletion/CodeCompletionData.cs:
+	* CodeCompletion/CompletionWindow.cs:
+	* CodeCompletion/CommentCompletionDataProvider.cs:
+	* CodeCompletion/TemplateCompletionDataProvider.cs:
+	add support for xcode style type ahead completion. It looks cool, and
+	is actually pretty useful.
+	
+
 2004-04-03  Todd Berman  <tberman at sevenl.net>
 
 	* Gui/SourceEditorView.cs:

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CodeCompletionData.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CodeCompletionData.cs	2004-04-09 19:34:10 UTC (rev 1425)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CodeCompletionData.cs	2004-04-09 22:00:39 UTC (rev 1426)
@@ -1,7 +1,7 @@
 // <file>
 //     <copyright see="prj:///doc/copyright.txt"/>
 //     <license see="prj:///doc/license.txt"/>
-//     <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+//     <owner name="Mike Kr�¼ger" email="mike at icsharpcode.net"/>
 //     <version value="$version"/>
 // </file>
 
@@ -42,7 +42,16 @@
 				return asvc;
 			}
 		}
+
+		public string CompletionString 
+		{
+			get 
+			{
+				return completionString;
+			}
+		}
 		
+		
 		public int Overloads
 		{
 			get {

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CommentCompletionDataProvider.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CommentCompletionDataProvider.cs	2004-04-09 19:34:10 UTC (rev 1425)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CommentCompletionDataProvider.cs	2004-04-09 22:00:39 UTC (rev 1426)
@@ -98,6 +98,14 @@
 					return new string[] { text };
 				}
 			}
+
+			public string CompletionString
+			{
+				get 
+				{
+					return "";
+				}
+			}
 			
 			public string Description
 			{

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CompletionWindow.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CompletionWindow.cs	2004-04-09 19:34:10 UTC (rev 1425)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CompletionWindow.cs	2004-04-09 22:00:39 UTC (rev 1426)
@@ -26,6 +26,7 @@
 		TreeStore store;
 		TextMark triggeringMark;
 		int origOffset;
+		int num_in = 0;
 		DeclarationViewWindow declarationviewwindow = new DeclarationViewWindow ();
 		
 		string GetTypedString ()
@@ -70,10 +71,12 @@
 					LostFocusListView (null, null);
 					return true;
 				case (char) Gdk.Key.BackSpace:
+					num_in--;
 					control.SimulateKeyPress (ref e);
 					if (insertLength <= -1) {
 						LostFocusListView (null, null);
 					}
+					RowActivated (null, null);
 					return true;
 				}
 				break;
@@ -126,6 +129,8 @@
 					break;
 			}
 
+			num_in++;
+
 			ShuffleSelection (false);
 	
 			ex.RetVal = true;
@@ -247,7 +252,7 @@
 			int tx, ty;
 			control.GdkWindow.GetOrigin (out tx, out ty);
 			//Console.WriteLine ("Moving to: " + (tx + wx) + " . " + (ty + wy));
-			System.Threading.Thread.Sleep (100);
+			//System.Threading.Thread.Sleep (50);
 			ShowAll ();
 			Move (tx + wx, ty + wy);
 			Present ();
@@ -298,6 +303,7 @@
 				TreeIter iter;
 				listView.Selection.GetSelected (out foo, out iter);
 				ICompletionData data = (ICompletionData) store.GetValue (iter, 2);
+				control.buf.DropCompleteAhead ();
 				DeleteInsertion ();
 				data.InsertAction (control);
 				LostFocusListView (null, null);
@@ -309,6 +315,7 @@
 			control.HasFocus = true;
 			declarationviewwindow.HideAll ();
 			this.Hide ();
+			control.buf.DropCompleteAhead ();
 		}
 		
 		void FillList (bool firstTime, char ch)
@@ -317,7 +324,7 @@
 			if (completionData == null || completionData.Length == 0) {
 				return;
 			}
-
+			
 			foreach (ICompletionData data in completionData) {
 				store.AppendValues (data.Text[0], data.Image, data);
 			}
@@ -329,11 +336,28 @@
 		{
 			Gtk.TreeIter iter;
 			Gtk.TreeModel model;
-	
+			
 			if (listView.Selection.GetSelected (out model, out iter)){
 				ICompletionData data = (ICompletionData) store.GetValue (iter, 2);
 				if (data == null)
 					return;
+				
+				int inst = insertLength;
+				if (inst == -1) {
+					LostFocusListView (null, null);
+					return;
+				}
+				if (inst >= 1) {
+					DeleteInsertion ();
+					int l = inst > data.CompletionString.Length ? data.CompletionString.Length : inst;
+					control.buf.InsertAtCursor (data.CompletionString.Substring (0, l));
+				}
+				control.buf.DropCompleteAhead ();
+				if (data.CompletionString.Length > inst) {
+					control.buf.DropCompleteAhead ();
+					control.buf.CompleteAhead (data.CompletionString.Substring(inst));
+				}
+					
 				// This code is for sizing the treeview properly.
 				Gtk.TreePath path = store.GetPath (iter);
 				Gdk.Rectangle backRect = listView.GetBackgroundArea (path, (Gtk.TreeViewColumn)listView.Columns[0]);
@@ -342,7 +366,8 @@
 
 				// FIXME: This code is buggy, and generates a bad placement sometimes when you jump a lot.
 				// but it is better than 0,0
-                                // This code is for sizing the treeview properly.
+				// This code is for sizing the treeview properly.
+				
 				Gdk.Rectangle rect = listView.GetCellArea (path, (Gtk.TreeViewColumn)listView.Columns[0]);
 				int listpos_x = 0, listpos_y = 0;
 				while (listpos_x == 0)

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/ICompletionData.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/ICompletionData.cs	2004-04-09 19:34:10 UTC (rev 1425)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/ICompletionData.cs	2004-04-09 22:00:39 UTC (rev 1426)
@@ -27,6 +27,11 @@
 		string Description {
 			get;
 		}
+
+		string CompletionString 
+		{
+			get;
+		}
 		
 		void InsertAction(SourceEditorView control);
 	}

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/TemplateCompletionDataProvider.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/TemplateCompletionDataProvider.cs	2004-04-09 19:34:10 UTC (rev 1425)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/TemplateCompletionDataProvider.cs	2004-04-09 22:00:39 UTC (rev 1426)
@@ -50,6 +50,14 @@
 					return Stock.Method;
 				}
 			}
+
+			public string CompletionString
+			{
+				get 
+				{
+					return "";
+				}
+			}
 			
 			public string[] Text
 			{

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs	2004-04-09 19:34:10 UTC (rev 1425)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs	2004-04-09 22:00:39 UTC (rev 1426)
@@ -62,12 +62,18 @@
 	{	
 		SourceLanguagesManager slm = new SourceLanguagesManager ();
 		TextTag markup;
+		TextTag complete_ahead;
+		TextMark complete_end;
 		
 		public SourceEditorBuffer () : base (new SourceTagTable ())
 		{
 			markup = new TextTag ("breakpoint");
 			markup.Background = "yellow";
 			TagTable.Add (markup);
+			complete_ahead = new TextTag ("complete_ahead");
+			complete_ahead.Foreground = "grey";
+			TagTable.Add (complete_ahead);
+			complete_end = CreateMark (null, StartIter, true);
 		}
 		
 		public void MarkupLine (int linenumber)
@@ -85,6 +91,26 @@
 			RemoveTag (markup, StartIter, EndIter);
 		}
 
+		public void DropCompleteAhead ()
+		{
+			if (GetIterAtMark (complete_end).Offset == 0)
+				return;
+			RemoveTag (complete_ahead, GetIterAtMark (InsertMark), GetIterAtMark (complete_end));
+			Delete (GetIterAtMark (InsertMark), GetIterAtMark (complete_end));
+			MoveMark (complete_end, GetIterAtOffset (0));
+		}
+
+		public void CompleteAhead (string what)
+		{
+			DropCompleteAhead ();
+			InsertWithTags (GetIterAtMark (InsertMark), what, new TextTag[] 
+							{ complete_ahead });
+			TextIter it = GetIterAtMark (InsertMark);
+			MoveMark (complete_end, it);
+			it.BackwardChars (what.Length);
+			PlaceCursor (it);
+		}
+		
 		public void LoadFile (string file, string mime)
 		{
 			LoadText (File.OpenText (file).ReadToEnd (), mime);		

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorView.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorView.cs	2004-04-09 19:34:10 UTC (rev 1425)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorView.cs	2004-04-09 22:00:39 UTC (rev 1426)
@@ -23,7 +23,7 @@
 		private static GLib.GType gtype;
 		public readonly SourceEditor ParentEditor;
 		internal IFormattingStrategy fmtr;
-		SourceEditorBuffer buf;
+		public SourceEditorBuffer buf;
 		int lineToMark = -1;
 		CompletionWindow completionWnd;
 		bool codeCompleteEnabled;




More information about the Monodevelop-patches-list mailing list