protected override Gtk.Window CreateTooltipWindow(TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            //create a message string from all the results
            var  results = (IList <Result>)item.Item;
            var  sb      = new StringBuilder();
            bool first   = false;

            foreach (var r in results)
            {
                if (!first)
                {
                    first = true;
                }
                else
                {
                    sb.AppendLine();
                }
                sb.Append(r.Level.ToString());
                sb.Append(": ");
                sb.Append(AmbienceService.EscapeText(r.Message));
            }

            //FIXME: use a nicer, more specialized tooltip window, with results formatting and hints about
            // commands and stuff
            var win = new LanguageItemWindow((ExtensibleTextEditor)editor, modifierState, null, sb.ToString(), null);

            if (win.IsEmpty)
            {
                return(null);
            }
            return(win);
        }
        public override TooltipInformation CreateTooltipInformation(bool smartWrap)
        {
            var tti = new TooltipInformation();

            tti.SignatureMarkup = "<i>(Module)</i> " + Module.ModuleName;
            tti.SummaryMarkup   = AmbienceService.EscapeText(Module.Description);
            tti.FooterMarkup    = Module.FileName;

            return(tti);
        }
Exemple #3
0
        public static TooltipInformation CreateTooltipInformation(ICompilation compilation, CSharpUnresolvedFile file, TextEditorData textEditorData, MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy formattingPolicy, IType type, bool smartWrap, bool createFooter = false)
        {
            var tooltipInfo = new TooltipInformation();
            var resolver    = file != null?file.GetResolver(compilation, textEditorData.Caret.Location) : new CSharpResolver(compilation);

            var sig = new SignatureMarkupCreator(resolver, formattingPolicy.CreateOptions());

            sig.BreakLineAfterReturnType = smartWrap;
            try {
                tooltipInfo.SignatureMarkup = sig.GetMarkup(type.IsParameterized ? type.GetDefinition() : type);
            } catch (Exception e) {
                LoggingService.LogError("Got exception while creating markup for :" + type, e);
                return(new TooltipInformation());
            }
            if (type.IsParameterized)
            {
                var typeInfo = new StringBuilder();
                for (int i = 0; i < type.TypeParameterCount; i++)
                {
                    typeInfo.AppendLine(type.GetDefinition().TypeParameters [i].Name + " is " + sig.GetTypeReferenceString(type.TypeArguments [i]));
                }
                tooltipInfo.AddCategory("Type Parameters", typeInfo.ToString());
            }

            var def = type.GetDefinition();

            if (def != null)
            {
                if (createFooter && !string.IsNullOrEmpty(def.ParentAssembly.AssemblyName))
                {
                    tooltipInfo.FooterMarkup = "<small> From " + AmbienceService.EscapeText(def.ParentAssembly.AssemblyName) + "</small>";
                }
                tooltipInfo.SummaryMarkup = AmbienceService.GetSummaryMarkup(def) ?? "";
            }
            return(tooltipInfo);
        }
 public virtual string GetDescriptionMarkupText(Widget widget)
 {
     return(AmbienceService.EscapeText(Description));
 }
Exemple #5
0
        public static TooltipInformation CreateTooltipInformation(ICompilation compilation, CSharpUnresolvedFile file, CSharpResolver resolver, TextEditorData textEditorData, MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy formattingPolicy, IEntity entity, bool smartWrap, bool createFooter = false)
        {
            var tooltipInfo = new TooltipInformation();

            if (resolver == null)
            {
                resolver = file != null?file.GetResolver(compilation, textEditorData.Caret.Location) : new CSharpResolver(compilation);
            }
            var sig = new SignatureMarkupCreator(resolver, formattingPolicy.CreateOptions());

            sig.BreakLineAfterReturnType = smartWrap;
            try {
                tooltipInfo.SignatureMarkup = sig.GetMarkup(entity);
            } catch (Exception e) {
                LoggingService.LogError("Got exception while creating markup for :" + entity, e);
                return(new TooltipInformation());
            }
            tooltipInfo.SummaryMarkup = AmbienceService.GetSummaryMarkup(entity) ?? "";

            if (entity is IMember)
            {
                var evt = (IMember)entity;
                if (evt.ReturnType.Kind == TypeKind.Delegate)
                {
                    tooltipInfo.AddCategory(GettextCatalog.GetString("Delegate Info"), sig.GetDelegateInfo(evt.ReturnType));
                }
            }
            if (entity is IMethod)
            {
                var method = (IMethod)entity;
                if (method.IsExtensionMethod)
                {
                    tooltipInfo.AddCategory(GettextCatalog.GetString("Extension Method from"), method.DeclaringTypeDefinition.FullName);
                }
            }
            if (createFooter)
            {
                if (entity is IType)
                {
                    var type = entity as IType;
                    var def  = type.GetDefinition();
                    if (def != null)
                    {
                        if (!string.IsNullOrEmpty(def.ParentAssembly.AssemblyName))
                        {
                            var project = def.GetSourceProject();
                            if (project != null)
                            {
                                var relPath = FileService.AbsoluteToRelativePath(project.BaseDirectory, def.Region.FileName);
                                tooltipInfo.FooterMarkup = "<small>" + GettextCatalog.GetString("Project:\t{0}", AmbienceService.EscapeText(def.ParentAssembly.AssemblyName)) + "</small>" + Environment.NewLine +
                                                           "<small>" + GettextCatalog.GetString("File:\t\t{0} (line {1})", AmbienceService.EscapeText(relPath), def.Region.Begin.Line) + "</small>";
                            }
                        }
                    }
                }
                else if (entity.DeclaringTypeDefinition != null)
                {
                    var project = entity.DeclaringTypeDefinition.GetSourceProject();
                    if (project != null)
                    {
                        var relPath = FileService.AbsoluteToRelativePath(project.BaseDirectory, entity.Region.FileName);
                        tooltipInfo.FooterMarkup =
                            "<small>" + GettextCatalog.GetString("Project:\t{0}", AmbienceService.EscapeText(project.Name)) + "</small>" + Environment.NewLine +
                            "<small>" + GettextCatalog.GetString("From:\t{0}", AmbienceService.EscapeText(entity.DeclaringType.FullName)) + "</small>" + Environment.NewLine +
                            "<small>" + GettextCatalog.GetString("File:\t\t{0} (line {1})", AmbienceService.EscapeText(relPath), entity.Region.Begin.Line) + "</small>";
                    }
                }
            }
            return(tooltipInfo);
        }
            void DrawList()
            {
                int winWidth, winHeight;

                this.GdkWindow.GetSize(out winWidth, out winHeight);

                int ypos      = margin;
                int lineWidth = winWidth - margin * 2;
                int xpos      = margin + padding;

                int n = 0;

                while (ypos < winHeight - margin && (page + n) < win.DataProvider.IconCount)
                {
                    string text = win.DataProvider.GetMarkup(page + n) ?? "&lt;null&gt;";
                    layout.SetMarkup(text);

                    Gdk.Pixbuf icon       = win.DataProvider.GetIcon(page + n);
                    int        iconHeight = icon != null ? icon.Height : 24;
                    int        iconWidth  = icon != null ? icon.Width : 0;

                    int wi, he, typos, iypos;
                    layout.GetPixelSize(out wi, out he);
                    if (wi > Allocation.Width)
                    {
                        int idx, trail;
                        if (layout.XyToIndex(
                                (int)((Allocation.Width - xpos - iconWidth - 2) * Pango.Scale.PangoScale),
                                0,
                                out idx,
                                out trail
                                ) && idx > 3)
                        {
                            text = AmbienceService.UnescapeText(text);
                            text = text.Substring(0, idx - 3) + "...";
                            text = AmbienceService.EscapeText(text);
                            layout.SetMarkup(text);
                            layout.GetPixelSize(out wi, out he);
                        }
                    }
                    typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos;
                    iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos;

                    if (page + n == selection)
                    {
                        if (!disableSelection)
                        {
                            this.GdkWindow.DrawRectangle(this.Style.BaseGC(StateType.Selected),
                                                         true, margin, ypos, lineWidth, he + padding);
                            this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Selected),
                                                      xpos + iconWidth + 2, typos, layout);
                        }
                        else
                        {
                            this.GdkWindow.DrawRectangle(this.Style.BaseGC(StateType.Selected),
                                                         false, margin, ypos, lineWidth, he + padding);
                            this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal),
                                                      xpos + iconWidth + 2, typos, layout);
                        }
                    }
                    else
                    {
                        this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal),
                                                  xpos + iconWidth + 2, typos, layout);
                    }

                    if (icon != null)
                    {
                        this.GdkWindow.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal), icon, 0, 0,
                                                  xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0);
                    }

                    ypos += rowHeight;
                    n++;

//reset the markup or it carries over to the next SetText
                    layout.SetMarkup(string.Empty);
                }
            }
Exemple #7
0
        public override TooltipInformation CreateTooltipInformation(bool smartWrap)
        {
            var tti = new TooltipInformation();

            var n  = Node;
            var dn = n as DNode;

            var sb = new StringBuilder();

            sb.Append("<i>(");

            if (dn is DClassLike)
            {
                switch ((dn as DClassLike).ClassType)
                {
                case DTokens.Class:
                    sb.Append("Class");
                    break;

                case DTokens.Template:
                    if (dn.ContainsAttribute(DTokens.Mixin))
                    {
                        sb.Append("Mixin ");
                    }
                    sb.Append("Template");
                    break;

                case DTokens.Struct:
                    sb.Append("Struct");
                    break;

                case DTokens.Union:
                    sb.Append("Union");
                    break;
                }
            }
            else if (dn is DEnum)
            {
                sb.Append("Enum");
            }
            else if (dn is DEnumValue)
            {
                sb.Append("Enum Value");
            }
            else if (dn is DVariable)
            {
                if (dn.Parent is DMethod)
                {
                    var dm = dn.Parent as DMethod;
                    if (dm.Parameters.Contains(dn))
                    {
                        sb.Append("Parameters");
                    }
                    else
                    {
                        sb.Append("Local");
                    }
                }
                else if (dn.Parent is DClassLike)
                {
                    sb.Append("Field");
                }
                else
                {
                    sb.Append("Variable");
                }
            }
            else if (dn is DMethod)
            {
                sb.Append("Method");
            }
            else if (dn is TemplateParameter.Node)
            {
                sb.Append("Template Parameter");
            }

            sb.Append(")</i> ");

            tti.SignatureMarkup = sb.Append(AmbienceService.EscapeText(PureNodeString)).ToString();


            if (!string.IsNullOrWhiteSpace(n.Description))
            {
                tti.SummaryMarkup = AmbienceService.EscapeText(n.Description);
            }

            return(tti);
        }