[Monodevelop-patches-list] r497 - in trunk/MonoDevelop/src: AddIns/BackendBindings/CSharpBinding AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow Main/Base/Services/AmbienceService

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Fri Jan 16 12:30:16 EST 2004


Author: benm
Date: 2004-01-16 12:30:16 -0500 (Fri, 16 Jan 2004)
New Revision: 497

Modified:
   trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/CSharpAmbience.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs
   trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/CompletionWindow.cs
   trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/DeclarationViewWindow.cs
   trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/ICompletionData.cs
   trunk/MonoDevelop/src/Main/Base/Services/AmbienceService/AbstractAmbience.cs
   trunk/MonoDevelop/src/Main/Base/Services/AmbienceService/IAmbience.cs
Log:
get pango beautification on the decl view window

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/CSharpAmbience.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/CSharpAmbience.cs	2004-01-16 06:55:16 UTC (rev 496)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/CSharpAmbience.cs	2004-01-16 17:30:16 UTC (rev 497)
@@ -80,29 +80,19 @@
 		
 		string GetModifier(IDecoration decoration)
 		{	
-			string ret = "";
+			string mod;
 			
-			if (IncludeHTMLMarkup) {
-				ret += "<i>";
-			}
+			if (decoration.IsStatic)        mod = "static ";
+			else if (decoration.IsFinal)    mod = "final ";
+			else if (decoration.IsVirtual)  mod = "virtual ";
+			else if (decoration.IsOverride) mod = "override ";
+			else if (decoration.IsNew)      mod = "new ";
+			else return "";
 			
-			if (decoration.IsStatic) {
-				ret += "static ";
-			} else if (decoration.IsFinal) {
-				ret += "final ";
-			} else if (decoration.IsVirtual) {
-				ret += "virtual ";
-			} else if (decoration.IsOverride) {
-				ret += "override ";
-			} else if (decoration.IsNew) {
-				ret += "new ";
-			}
-			
-			if (IncludeHTMLMarkup) {
-				ret += "</i>";
-			}
-			
-			return ret;
+			if (IncludeHTMLMarkup | IncludePangoMarkup)
+				return "<i>" + mod + "</i>";
+			else
+				return mod;
 		}
 		
 		
@@ -110,12 +100,8 @@
 		{
 			StringBuilder builder = new StringBuilder();
 			
-			builder.Append(Convert(c.Modifiers));
+			builder.Append(Convert(c.Modifiers));
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<i>");
-			}
-			
 			if (ShowModifiers) {
 				if (c.IsSealed) {
 					switch (c.ClassType) {
@@ -125,18 +111,14 @@
 							break;
 						
 						default:
-							builder.Append("sealed ");
+							AppendPangoHtmlTag (builder, "sealed ", "i");
 							break;
 					}
 				} else if (c.IsAbstract && c.ClassType != ClassType.Interface) {
-					builder.Append("abstract ");
+					AppendPangoHtmlTag (builder, "abstract ", "i");
 				}
 			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</i>");
-			}
-			
 			if (ShowModifiers) {
 				switch (c.ClassType) {
 					case ClassType.Delegate:
@@ -165,22 +147,14 @@
 					builder.Append(Convert(m.ReturnType));
 					builder.Append(' ');
 				}
-			}
+			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<b>");
-			}
+			if (UseFullyQualifiedMemberNames)
+				AppendPangoHtmlTag (builder, c.FullyQualifiedName, "b");
+			else
+				AppendPangoHtmlTag (builder, c.Name, "b");
 			
-	    	if (UseFullyQualifiedMemberNames) {
-				builder.Append(c.FullyQualifiedName);
-			} else {
-				builder.Append(c.Name);
-			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</b>");
-			}
-			
 			if (c.ClassType == ClassType.Delegate) {
 				builder.Append(" (");
 				if (IncludeHTMLMarkup) builder.Append("<br>");
@@ -227,47 +201,29 @@
 		{
 			StringBuilder builder = new StringBuilder();
 			
-			builder.Append(Convert(field.Modifiers));
+			builder.Append(Convert(field.Modifiers));
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<i>");
-			}
-			
 			if (ShowModifiers) {
-				if (field.IsStatic && field.IsLiteral) {
-					builder.Append("const ");
-				} else if (field.IsStatic) {
-					builder.Append("static ");
-				}
+				if (field.IsStatic && field.IsLiteral)
+					AppendPangoHtmlTag (builder, "const ", "i");
+				else if (field.IsStatic)
+					AppendPangoHtmlTag (builder, "static ", "i");
 				
 				if (field.IsReadonly) {
-					builder.Append("readonly ");
+					AppendPangoHtmlTag (builder, "readonly ", "i");
 				}
 			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</i>");
-			}
-			
 			if (field.ReturnType != null) {
 				builder.Append(Convert(field.ReturnType));
 				builder.Append(' ');
 			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<b>");
-			}
+			if (UseFullyQualifiedMemberNames)
+				AppendPangoHtmlTag (builder, field.FullyQualifiedName, "b");
+			else
+				AppendPangoHtmlTag (builder, field.Name, "b");
 			
-			if (UseFullyQualifiedMemberNames) {
-				builder.Append(field.FullyQualifiedName);
-			} else {
-				builder.Append(field.Name);
-			}
-			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</b>");
-			}
-			
 			if (IncludeBodies) builder.Append(";");
 			
 			return builder.ToString();			
@@ -288,20 +244,11 @@
 				builder.Append(' ');
 			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<b>");
-			}
+			if (UseFullyQualifiedMemberNames)
+				AppendPangoHtmlTag (builder, property.FullyQualifiedName, "b");
+			else
+				AppendPangoHtmlTag (builder, property.Name, "b");
 			
-			if (UseFullyQualifiedMemberNames) {
-				builder.Append(property.FullyQualifiedName);
-			} else {
-				builder.Append(property.Name);
-			}
-			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</b>");
-			}
-			
 			if (property.Parameters.Count > 0) {
 				builder.Append(" (");
 				if (IncludeHTMLMarkup) builder.Append("<br>");
@@ -347,20 +294,11 @@
 				builder.Append(' ');
 			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<b>");
-			}
+			if (UseFullyQualifiedMemberNames)
+				AppendPangoHtmlTag (builder, e.FullyQualifiedName, "b");
+			else
+				AppendPangoHtmlTag (builder, e.Name, "b");
 			
-			if (UseFullyQualifiedMemberNames) {
-				builder.Append(e.FullyQualifiedName);
-			} else {
-				builder.Append(e.Name);
-			}
-			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</b>");
-			}
-			
 			if (IncludeBodies) builder.Append(";");
 			
 			return builder.ToString();
@@ -371,39 +309,19 @@
 			StringBuilder builder = new StringBuilder();
 			builder.Append(Convert(m.Modifiers));
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<i>");
-			}
+			if (ShowModifiers && m.IsStatic)
+				AppendPangoHtmlTag (builder, "static", "i");
 			
-			if (ShowModifiers) {
-				if (m.IsStatic) {
-					builder.Append("static ");
-				}
-			}
-			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</i>");
-			}
-			
 			if (m.ReturnType != null) {
 				builder.Append(Convert(m.ReturnType));
 				builder.Append(' ');
 			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<b>");
-			}
+			if (UseFullyQualifiedMemberNames)
+				AppendPangoHtmlTag (builder, m.FullyQualifiedName, "b");
+			else
+				AppendPangoHtmlTag (builder, m.Name, "b");
 			
-			if (UseFullyQualifiedMemberNames) {
-				builder.Append(m.FullyQualifiedName);
-			} else {
-				builder.Append(m.Name);
-			}
-			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</b>");
-			}
-			
 			builder.Append(" [");
 			if (IncludeHTMLMarkup) builder.Append("<br>");
 
@@ -435,30 +353,20 @@
 			if (m.ReturnType != null) {
 				builder.Append(Convert(m.ReturnType));
 				builder.Append(' ');
-			}
+			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<b>");
-			}
-			
 			if (m.IsConstructor) {
-				if (m.DeclaringType != null) {
-					builder.Append(m.DeclaringType.Name);
-				} else {
-					builder.Append(m.Name);
-				}
+				if (m.DeclaringType != null)
+					AppendPangoHtmlTag (builder, m.DeclaringType.Name, "b");
+				else
+					AppendPangoHtmlTag (builder, m.Name, "b");
 			} else {
-				if (UseFullyQualifiedMemberNames) {
-					builder.Append(m.FullyQualifiedName);
-				} else {
-					builder.Append(m.Name);
-				}
+				if (UseFullyQualifiedMemberNames)
+					AppendPangoHtmlTag (builder, m.FullyQualifiedName, "b");
+				else
+					AppendPangoHtmlTag (builder, m.Name, "b");
 			}
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</b>");
-			}
-			
 			builder.Append(" (");
 			if (IncludeHTMLMarkup) builder.Append("<br>");
 			
@@ -543,24 +451,15 @@
 		
 		public override string Convert(IParameter param)
 		{
-			StringBuilder builder = new StringBuilder();
+			StringBuilder builder = new StringBuilder();
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("<i>");
-			}
-						
-			if (param.IsRef) {
-				builder.Append("ref ");
-			} else if (param.IsOut) {
-				builder.Append("out ");
-			} else if (param.IsParams) {
-				builder.Append("params ");
-			}
+			if (param.IsRef)
+				AppendPangoHtmlTag (builder, "ref ", "i");
+			else if (param.IsOut)
+				AppendPangoHtmlTag (builder, "out ", "i");
+			else if (param.IsParams)
+				AppendPangoHtmlTag (builder, "params ", "i");
 			
-			if (IncludeHTMLMarkup) {
-				builder.Append("</i>");
-			}
-			
 			builder.Append(Convert(param.ReturnType));
 			
 			if (ShowParameterNames) {
@@ -568,6 +467,19 @@
 				builder.Append(param.Name);
 			}
 			return builder.ToString();
+		}
+		
+		// pango has some problems with
+		// <i>static </i>bool <b>Equals</b> (<i></i>object a, <i></i>object b)
+		// it will make "object a" italics. so rather tan appending a markup
+		// tag if there might be a modifier, we only do it if there is.
+		void AppendPangoHtmlTag (StringBuilder sb, string str, string tag)
+		{
+			if (IncludeHTMLMarkup | IncludePangoMarkup) sb.Append ('<').Append (tag).Append ('>');
+			
+			sb.Append (str);
+			
+			if (IncludeHTMLMarkup | IncludePangoMarkup) sb.Append ("</").Append (tag).Append ('>');
 		}
 		
 		public override string WrapAttribute(string attribute)

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs	2004-01-16 06:55:16 UTC (rev 496)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs	2004-01-16 17:30:16 UTC (rev 497)
@@ -19,7 +19,7 @@
 
 namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
 {
-	class CodeCompletionData : ICompletionData
+	class CodeCompletionData : ICompletionDataWithMarkup
 	{
 		static ClassBrowserIconsService classBrowserIconService = (ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService));
 		static IParserService           parserService           = (IParserService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IParserService));
@@ -28,11 +28,20 @@
 		int      imageIndex;
 		int      overloads;
 		string   text;
-		string   description;
+		string   description;
+		string   pango_description;
 		string   documentation;
 		string   completionString;
 		IClass   c;
-		bool     convertedDocumentation = false;
+		bool     convertedDocumentation = false;
+		
+		static IAmbience PangoAmbience {
+			get {
+				IAmbience asvc = ambienceService.CurrentAmbience;
+				asvc.ConversionFlags |= ConversionFlags.IncludePangoMarkup;
+				return asvc;
+			}
+		}
 		
 		public int Overloads {
 			get {
@@ -68,7 +77,8 @@
 				//
 				// Mike
 				if (c is ClassProxy && c.ClassType == ClassType.Delegate) {
-					description = ambienceService.CurrentAmbience.Convert(parserService.GetClass(c.FullyQualifiedName));
+					description = ambienceService.CurrentAmbience.Convert(parserService.GetClass(c.FullyQualifiedName));
+					pango_description = PangoAmbience.Convert(parserService.GetClass(c.FullyQualifiedName));
 					c = null;
 				}
 				
@@ -90,16 +100,54 @@
 						Console.WriteLine(e.ToString());
 					}
 				}
-				return description + (overloads > 0 ? " (+" + overloads + " overloads)" : String.Empty) + "\n" + documentation;
+				return (description + (overloads > 0 ? " (+" + overloads + " overloads)" : String.Empty) + "\n" + documentation).Trim ();
 			}
 			set {
 				description = value;
 			}
 		}
+		
+		public string DescriptionPango {
+			get {
+				// get correct delegate description (when description is requested)
+				// in the classproxies aren't methods saved, therefore delegate methods
+				// must be get through the real class instead out of the proxy
+				//
+				// Mike
+				if (c is ClassProxy && c.ClassType == ClassType.Delegate) {
+					description = ambienceService.CurrentAmbience.Convert(parserService.GetClass(c.FullyQualifiedName));
+					pango_description = PangoAmbience.Convert(parserService.GetClass(c.FullyQualifiedName));
+					c = null;
+				}
+				
+				// don't give a description string, if no documentation or description is provided
+				if (description.Length + documentation.Length == 0) {
+					return null;
+				}
+				if (!convertedDocumentation) {
+					convertedDocumentation = true;
+					try {
+						documentation = GetDocumentation(documentation);
+						// new (by G.B.)
+						// XmlDocument doc = new XmlDocument();
+						// doc.LoadXml("<doc>" + documentation + "</doc>");
+						// XmlNode root      = doc.DocumentElement;
+						// XmlNode paramDocu = root.SelectSingleNode("summary");
+						// documentation = paramDocu.InnerXml;
+					} catch (Exception e) {
+						Console.WriteLine(e.ToString());
+					}
+				}
+				return (pango_description + (overloads > 0 ? " (+" + overloads + " overloads)" : String.Empty) + "\n" + documentation).Trim ();
+			}
+			set {
+				description = value;
+			}
+		}
 		
 		public CodeCompletionData(string s, int imageIndex)
 		{
-			description = documentation = String.Empty;
+			description = pango_description = documentation = String.Empty;
 			text = s;
 			completionString = s;
 			this.imageIndex = imageIndex;
@@ -112,7 +160,8 @@
 			imageIndex = classBrowserIconService.GetIcon(c);
 			text = c.Name;
 			completionString = c.Name;
-			description = ambienceService.CurrentAmbience.Convert(c);
+			description = ambienceService.CurrentAmbience.Convert(c);
+			pango_description  = PangoAmbience.Convert(c);
 			documentation = c.Documentation;
 		}
 		
@@ -120,7 +169,8 @@
 		{
 			imageIndex  = classBrowserIconService.GetIcon(method);
 			text        = method.Name;
-			description = ambienceService.CurrentAmbience.Convert(method);
+			description = ambienceService.CurrentAmbience.Convert(method);
+			pango_description  = PangoAmbience.Convert (method);
 			completionString = method.Name;
 			documentation = method.Documentation;
 		}
@@ -129,7 +179,8 @@
 		{
 			imageIndex  = classBrowserIconService.GetIcon(field);
 			text        = field.Name;
-			description = ambienceService.CurrentAmbience.Convert(field);
+			description = ambienceService.CurrentAmbience.Convert(field);
+			pango_description  = PangoAmbience.Convert (field);
 			completionString = field.Name;
 			documentation = field.Documentation;
 		}
@@ -138,7 +189,8 @@
 		{
 			imageIndex  = classBrowserIconService.GetIcon(property);
 			text        = property.Name;
-			description = ambienceService.CurrentAmbience.Convert(property);
+			description = ambienceService.CurrentAmbience.Convert(property);
+			pango_description  = PangoAmbience.Convert (property);
 			completionString = property.Name;
 			documentation = property.Documentation;
 		}
@@ -147,7 +199,8 @@
 		{
 			imageIndex  = classBrowserIconService.GetIcon(e);
 			text        = e.Name;
-			description = ambienceService.CurrentAmbience.Convert(e);
+			description = ambienceService.CurrentAmbience.Convert(e);
+			pango_description  = PangoAmbience.Convert (e);
 			completionString = e.Name;
 			documentation = e.Documentation;
 		}

Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/CompletionWindow.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/CompletionWindow.cs	2004-01-16 06:55:16 UTC (rev 496)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/CompletionWindow.cs	2004-01-16 17:30:16 UTC (rev 497)
@@ -302,7 +302,12 @@
 
 				//FIXME: This is a bad calc, its always on the right, it needs to test if thats too big, and if so, place on the left;
 				int horiz = listpos_x + listView.GdkWindow.Size.Width + 30;
-				declarationviewwindow.Description = data.Description;
+				ICompletionDataWithMarkup wMarkup = data as ICompletionDataWithMarkup;
+				if (wMarkup != null)
+					declarationviewwindow.DescriptionMarkup = wMarkup.DescriptionPango;
+				else
+					declarationviewwindow.DescriptionMarkup = data.Description;
+				
 				declarationviewwindow.ShowAll ();
 				declarationviewwindow.Move (horiz, vert);
 			}

Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/DeclarationViewWindow.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/DeclarationViewWindow.cs	2004-01-16 06:55:16 UTC (rev 496)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/DeclarationViewWindow.cs	2004-01-16 17:30:16 UTC (rev 497)
@@ -21,17 +21,16 @@
 {
 	public class DeclarationViewWindow : Gtk.Window
 	{
-		string description = "";
-		
 		Label label;
 		
-		public string Description {
+		public string DescriptionMarkup {
 			get {
 				return label.Text;
 			}
 			
-			set {
-				label.Text = value;
+			set {
+				Console.WriteLine (value);
+				label.Markup = value;
 				QueueDraw ();
 			}
 		}
@@ -39,7 +38,7 @@
 		public DeclarationViewWindow () : base (WindowType.Popup)
 		{
 			Gtk.Frame frame = new Gtk.Frame ();
-			frame.Add (label = new Label (description));
+			frame.Add (label = new Label (""));
 			Add (frame);
 		}
 	}

Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/ICompletionData.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/ICompletionData.cs	2004-01-16 06:55:16 UTC (rev 496)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Gui/CompletionWindow/ICompletionData.cs	2004-01-16 17:30:16 UTC (rev 497)
@@ -28,5 +28,12 @@
 		}
 		
 		void InsertAction(TextEditorControl control);
+	}
+	
+	public interface ICompletionDataWithMarkup : ICompletionData
+	{
+		string DescriptionPango {
+			get;
+		}
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Services/AmbienceService/AbstractAmbience.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/AmbienceService/AbstractAmbience.cs	2004-01-16 06:55:16 UTC (rev 496)
+++ trunk/MonoDevelop/src/Main/Base/Services/AmbienceService/AbstractAmbience.cs	2004-01-16 17:30:16 UTC (rev 497)
@@ -61,8 +61,14 @@
 			get {
 				return (conversionFlags & ConversionFlags.IncludeHTMLMarkup) == ConversionFlags.IncludeHTMLMarkup;
 			}
-		}
+		}
 		
+		public bool IncludePangoMarkup {
+			get {
+				return (conversionFlags & ConversionFlags.IncludePangoMarkup) == ConversionFlags.IncludePangoMarkup;
+			}
+		}
+		
 		public bool UseLinkArrayList {
 			get {
 				return (conversionFlags & ConversionFlags.UseLinkArrayList) == ConversionFlags.UseLinkArrayList;

Modified: trunk/MonoDevelop/src/Main/Base/Services/AmbienceService/IAmbience.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/AmbienceService/IAmbience.cs	2004-01-16 06:55:16 UTC (rev 496)
+++ trunk/MonoDevelop/src/Main/Base/Services/AmbienceService/IAmbience.cs	2004-01-16 17:30:16 UTC (rev 497)
@@ -25,7 +25,8 @@
 		IncludeHTMLMarkup      = 32,
 		UseLinkArrayList       = 64,
 		QualifiedNamesOnlyForReturnTypes = 128,
-		IncludeBodies          = 256,
+		IncludeBodies          = 256,
+		IncludePangoMarkup         = 512,
 		
 		StandardConversionFlags = ShowParameterNames | 
 		                          UseFullyQualifiedNames | 




More information about the Monodevelop-patches-list mailing list