Пример #1
0
        static void MessageFunc(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            string filter = GetCurrentFilter(model);

            CellRendererText renderer = (CellRendererText)cell;
            var rev = (Revision)model.GetValue(iter, 0);

            if (string.IsNullOrEmpty(rev.Message))
            {
                renderer.Text = GettextCatalog.GetString("(No message)");
            }
            else
            {
                string message = RevisionHelpers.FormatMessage(rev.Message);
                int    idx     = message.IndexOf('\n');
                if (idx > 0)
                {
                    message = message.Substring(0, idx);
                }
                if (string.IsNullOrEmpty(filter))
                {
                    renderer.Text = message;
                }
                else
                {
                    renderer.Markup = EscapeWithFilterMarker(message, filter);
                }
            }
        }
Пример #2
0
        public void RevisionFormatMessageChangelogStyle()
        {
            var res = RevisionHelpers.FormatMessage(
                @"2009-11-23 Test Author

	* MonoDevelop.CSharp/CSharpBindingCompilerManager.cs: Emit the
	  target platform option. Fixes bug #557146."    );

            var expected =
                @"Emit the target platform option. Fixes bug #557146.";

            Assert.AreEqual(expected, res);
        }
Пример #3
0
        public void RevisionFormatMessageChangelogStyleMultipleLines()
        {
            var res = RevisionHelpers.FormatMessage(
                @"2005-09-22 Test Author
	* Services/NUnitService.cs:
	* Services/CombineTestGroup.cs:
	* Services/NUnitProjectTestSuite.cs:
	* Services/SystemTestProvider.cs: Only generate a test suite for
	projects that reference the nunit.framework assembly."    );

            var expected =
                @"* Services/CombineTestGroup.cs:
 * Services/NUnitProjectTestSuite.cs:
 * Services/SystemTestProvider.cs: Only generate a test suite for
 projects that reference the nunit.framework assembly.";

//			var expected =
//@"Only generate a test suite for projects that reference the nunit.framework assembly.";

            Assert.AreEqual(expected, res);
        }
Пример #4
0
        public void RevisionFormatMessageChangelogStyleMultipleMessages()
        {
            var res = RevisionHelpers.FormatMessage(
                @"2005-08-22 Test Author
	* Commands/ViewCommands.cs: Implemented delete layout command.
	* Gui/Workbench/Layouts/SdiWorkspaceLayout.cs: Properly load saved
	layouts. Added DeleteLayout method.
	* Gui/IWorkbenchLayout.cs: Added DeleteLayout method.
	* MonoDevelopCore.addin.xml: Added Delete Layout command."    );

//			var expected =
//@"Implemented delete layout command.
// Properly load saved layouts. Added DeleteLayout method.
// Added DeleteLayout method.
// Added Delete Layout command.

            var expected =
                @"Implemented delete layout command. * Gui/Workbench/Layouts/SdiWorkspaceLayout.cs: Properly load saved
 layouts. Added DeleteLayout method.
 * Gui/IWorkbenchLayout.cs: Added DeleteLayout method.
 * MonoDevelopCore.addin.xml: Added Delete Layout command.";

            Assert.AreEqual(expected, res);
        }
Пример #5
0
            protected override bool OnExposeEvent(Gdk.EventExpose e)
            {
                using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) {
                    cr.LineWidth = Math.Max(1.0, widget.Editor.Options.Zoom);

                    cr.Rectangle(leftSpacer, 0, Allocation.Width, Allocation.Height);
                    cr.SetSourceColor(Styles.BlameView.AnnotationBackgroundColor.ToCairoColor());
                    cr.Fill();

                    int    startLine = widget.Editor.YToLine((int)widget.Editor.VAdjustment.Value);
                    double startY    = widget.Editor.LineToY(startLine);
                    while (startLine > 1 && startLine < annotations.Count && annotations[startLine - 1] != null && annotations[startLine] != null && annotations[startLine - 1].Revision == annotations[startLine].Revision)
                    {
                        startLine--;
                        startY -= widget.Editor.GetLineHeight(widget.Editor.Document.GetLine(startLine));
                    }
                    double curY = startY - widget.Editor.VAdjustment.Value;
                    int    line = startLine;
                    while (curY < Allocation.Bottom && line <= widget.Editor.LineCount)
                    {
                        double curStart = curY;
//						widget.JumpOverFoldings (ref line);
                        int        lineStart = line;
                        int        authorWidth = 0, revisionWidth = 0, dateWidth = 0, h = 16;
                        Annotation ann = line <= annotations.Count ? annotations[line - 1] : null;
                        if (ann != null)
                        {
                            do
                            {
                                widget.JumpOverFoldings(ref line);
                                line++;
                            } while (line <= annotations.Count && annotations[line - 1] != null && annotations[line - 1].Revision == ann.Revision);

                            double nextY = widget.editor.LineToY(line) - widget.editor.VAdjustment.Value;
                            if (highlightAnnotation != null && highlightAnnotation.Revision == ann.Revision && curStart <= highlightPositon && highlightPositon < nextY)
                            {
                                cr.Rectangle(leftSpacer, curStart + cr.LineWidth, Allocation.Width - leftSpacer, nextY - curStart - cr.LineWidth);
                                cr.SetSourceColor(Styles.BlameView.AnnotationHighlightColor.ToCairoColor());
                                cr.Fill();
                            }

                            // use a fixed size revision to get a approx. revision width
                            layout.SetText("88888888");
                            layout.GetPixelSize(out revisionWidth, out h);
                            layout.SetText(TruncRevision(ann.Text));

                            const int dateRevisionSpacing = 16;

                            using (var gc = new Gdk.GC(e.Window)) {
                                gc.RgbFgColor = Styles.BlameView.AnnotationTextColor.ToGdkColor();
                                e.Window.DrawLayout(gc, Allocation.Width - revisionWidth - margin, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout);

                                if (ann.HasDate)
                                {
                                    string dateTime = ann.Date.ToShortDateString();
                                    // use a fixed size date to get a approx. date width
                                    layout.SetText(new DateTime(1999, 10, 10).ToShortDateString());
                                    layout.GetPixelSize(out dateWidth, out h);
                                    layout.SetText(dateTime);

                                    e.Window.DrawLayout(gc, Allocation.Width - revisionWidth - margin - revisionWidth - dateRevisionSpacing, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout);
                                }
                            }

                            using (var authorLayout = MonoDevelop.Components.PangoUtil.CreateLayout(this)) {
                                authorLayout.FontDescription = FontService.SansFont.CopyModified(Ide.Gui.Styles.FontScale11);
                                authorLayout.SetText(ann.Author);
                                authorLayout.GetPixelSize(out authorWidth, out h);

                                var maxWidth = Allocation.Width - revisionWidth - margin - revisionWidth - dateRevisionSpacing;

                                /*				if (authorWidth > maxWidth) {
                                 *                                      int idx = ann.Author.IndexOf ('<');
                                 *                                      if (idx > 0)
                                 *                                              authorLayout.SetText (ann.Author.Substring (0, idx) + Environment.NewLine + ann.Author.Substring (idx));
                                 *                                      authorLayout.GetPixelSize (out authorWidth, out h);
                                 *                              }*/

                                cr.Save();
                                cr.Rectangle(0, 0, maxWidth, Allocation.Height);
                                cr.Clip();
                                cr.Translate(leftSpacer + margin, (int)(curY + (widget.Editor.LineHeight - h) / 2));
                                cr.SetSourceColor(Styles.BlameView.AnnotationTextColor.ToCairoColor());
                                cr.ShowLayout(authorLayout);
                                cr.ResetClip();
                                cr.Restore();
                            }

                            curY = nextY;
                        }
                        else
                        {
                            curY += widget.Editor.GetLineHeight(line);
                            line++;
                            widget.JumpOverFoldings(ref line);
                        }

                        if (ann != null && line - lineStart > 1)
                        {
                            string msg = GetCommitMessage(lineStart, false);
                            if (!string.IsNullOrEmpty(msg))
                            {
                                msg = RevisionHelpers.FormatMessage(msg);

                                layout.SetText(msg);
                                layout.Width = (int)(Allocation.Width * Pango.Scale.PangoScale);
                                using (var gc = new Gdk.GC(e.Window)) {
                                    gc.RgbFgColor    = Styles.BlameView.AnnotationSummaryTextColor.ToGdkColor();
                                    gc.ClipRectangle = new Rectangle(0, (int)curStart, Allocation.Width, (int)(curY - curStart));
                                    e.Window.DrawLayout(gc, (int)(leftSpacer + margin), (int)(curStart + h), layout);
                                }
                            }
                        }

                        cr.Rectangle(0, curStart, leftSpacer, curY - curStart);

                        if (ann != null && !string.IsNullOrEmpty(ann.Author))
                        {
                            double a;

                            if (ann != null && (maxDate - minDate).TotalHours > 0)
                            {
                                a = 1 - (ann.Date - minDate).TotalHours / (maxDate - minDate).TotalHours;
                            }
                            else
                            {
                                a = 1;
                            }
                            var color = Styles.BlameView.AnnotationMarkColor;
                            color.Light      = 0.4 + a / 2;
                            color.Saturation = 1 - a / 2;
                            cr.SetSourceColor(color.ToCairoColor());
                        }
                        else
                        {
                            cr.SetSourceColor((ann != null ? Styles.BlameView.AnnotationMarkModifiedColor : Styles.BlameView.AnnotationBackgroundColor).ToCairoColor());
                        }
                        cr.Fill();

                        if (ann != null)
                        {
                            cr.MoveTo(0, curY + 0.5);
                            cr.LineTo(Allocation.Width, curY + 0.5);
                            cr.SetSourceColor(Styles.BlameView.AnnotationSplitterColor.ToCairoColor());
                            cr.Stroke();
                        }
                    }
                }
                return(true);
            }