示例#1
0
        internal protected override void OptionsChanged()
        {
            foldBgGC              = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Background);
            foldLineGC            = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.FoldLine);
            foldLineHighlightedGC = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Foreground);

            HslColor hslColor   = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Background);
            double   brightness = HslColor.Brightness(hslColor);

            if (brightness < 0.5)
            {
                hslColor.L = hslColor.L * 0.85 + hslColor.L * 0.25;
            }
            else
            {
                hslColor.L = hslColor.L * 0.9;
            }

            foldLineHighlightedGCBg    = hslColor;
            foldToggleMarkerGC         = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.FoldCross);
            foldToggleMarkerBackground = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.FoldCrossBackground);
            lineStateChangedGC         = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.QuickDiffChanged);
            lineStateDirtyGC           = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.QuickDiffDirty);

            marginWidth = editor.LineHeight * 3 / 4;
        }
        public override void DrawForeground(MonoTextEditor editor, Context cr, MarginDrawMetrics metrics)
        {
            double size            = metrics.Margin.Width;
            double borderLineWidth = cr.LineWidth;

            double x      = Math.Floor(metrics.Margin.XOffset - borderLineWidth / 2);
            double y      = Math.Floor(metrics.Y + (metrics.Height - size) / 2);
            var    icon   = GetIcon(SmartTagSeverity);
            var    deltaX = size / 2 - icon.Width / 2 + 0.5f;
            var    deltaY = size / 2 - icon.Height / 2 + 0.5f;

            cr.DrawImage(editor, icon, Math.Round(x + deltaX), Math.Round(y + deltaY));
            Height = (int)(Math.Round(deltaY) + icon.Height);
            if (editor.TextArea.QuickFixMargin.HoveredSmartTagMarker == this)
            {
                const int triangleWidth  = 8;
                const int triangleHeight = 4;

                cr.SetSourceColor(SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.LineNumbers));
                cr.MoveTo(metrics.X + metrics.Width - triangleWidth, metrics.Y + metrics.Height - triangleHeight);
                cr.LineTo(metrics.X + metrics.Width, metrics.Y + metrics.Height - triangleHeight);
                cr.LineTo(metrics.X + metrics.Width - triangleWidth / 2, metrics.Y + metrics.Height);
                cr.LineTo(metrics.X + metrics.Width - triangleWidth, metrics.Y + metrics.Height - triangleHeight);
                cr.Fill();
            }
            PopupPosition = new Xwt.Point(metrics.X, metrics.Y);
        }
示例#3
0
        public override void Draw(MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
        {
            if (OnlyShowLinkOnHover)
            {
                if (editor.TextViewMargin.MarginCursor != textLinkCursor)
                {
                    return;
                }
                if (editor.TextViewMargin.HoveredLine == null)
                {
                    return;
                }
                var hoverOffset = editor.LocationToOffset(editor.TextViewMargin.HoveredLocation);
                if (!Segment.Contains(hoverOffset))
                {
                    return;
                }
            }

            this.Color = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Link);

            if (!OnlyShowLinkOnHover)
            {
                if (editor.TextViewMargin.MarginCursor == textLinkCursor && editor.TextViewMargin.HoveredLine != null)
                {
                    var hoverOffset = editor.LocationToOffset(editor.TextViewMargin.HoveredLocation);
                    // if (Segment.Contains (hoverOffset))
                    //	this.Color = editorEditorThemle.ActiveLinkColor.Color;
                }
            }

            base.Draw(editor, cr, metrics, startOffset, endOffset);
        }
示例#4
0
        public override void SessionStarted()
        {
            var theme = Editor.Options.GetEditorTheme();
            var color = SyntaxHighlightingService.GetColor(theme, EditorThemeColors.Selection);

            marker = TextMarkerFactory.CreateGenericTextSegmentMarker(Editor, TextSegmentMarkerEffect.Underline, color, endOffset, 1);
            Editor.AddMarker(marker);
        }
示例#5
0
        public override Components.HslColor GetBackgroundMarkerColor(EditorTheme style)
        {
            var key = (ReferenceUsageType & ReferenceUsageType.Write) != 0 ||
                      (ReferenceUsageType & ReferenceUsageType.Declaration) != 0 ?
                      EditorThemeColors.ChangingUsagesRectangle : EditorThemeColors.UsagesRectangle;

            return(SyntaxHighlightingService.GetColor(style, key));
        }
示例#6
0
 public void SetSchemeColors(EditorTheme scheme)
 {
     ;
     BackgroundColor      = SyntaxHighlightingService.GetColor(scheme, EditorThemeColors.TooltipBackground);
     PagerTextColor       = SyntaxHighlightingService.GetColor(scheme, EditorThemeColors.TooltipPagerText);
     PagerBackgroundColor = SyntaxHighlightingService.GetColor(scheme, EditorThemeColors.TooltipPager);
     PagerTriangleColor   = SyntaxHighlightingService.GetColor(scheme, EditorThemeColors.TooltipPagerTriangle);
 }
            public void Start()
            {
                allocation = mode.Allocation;
                var swapSurface = mode.swapIndicatorSurface;

                if (swapSurface != null)
                {
                    if (swapSurface.Width == allocation.Width && swapSurface.Height == allocation.Height)
                    {
                        surface = swapSurface;
                    }
                    else
                    {
                        mode.DestroyIndicatorSwapSurface();
                    }
                }

                var displayScale = Core.Platform.IsMac ? GtkWorkarounds.GetScaleFactor(mode) : 1.0;

                if (surface == null)
                {
                    using (var similiar = CairoHelper.Create(IdeApp.Workbench.RootWindow.GdkWindow))
                        surface = new SurfaceWrapper(similiar, (int)(allocation.Width * displayScale), (int)(allocation.Height * displayScale));
                }
                state        = IndicatorDrawingState.Create();
                state.Width  = allocation.Width;
                state.Height = allocation.Height;
                state.SearchResults.AddRange(mode.TextEditor.TextViewMargin.SearchResults);
                state.Usages.AddRange(mode.AllUsages);
                state.Tasks.AddRange(mode.AllTasks);
                state.ColorCache [IndicatorDrawingState.UsageColor]       = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.Foreground);
                state.ColorCache [IndicatorDrawingState.UsageColor].Alpha = 0.4;

                state.ColorCache [IndicatorDrawingState.FocusColor] = Styles.FocusColor.ToCairoColor();

                state.ColorCache [IndicatorDrawingState.ChangingUsagesColor] = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.ChangingUsagesRectangle);
                if (state.ColorCache [IndicatorDrawingState.ChangingUsagesColor].Alpha == 0.0)
                {
                    state.ColorCache [IndicatorDrawingState.ChangingUsagesColor] = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UsagesRectangle);
                }

                state.ColorCache [IndicatorDrawingState.UsagesRectangleColor] = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UsagesRectangle);
                for (int i = 0; i < 4; i++)
                {
                    state.ColorCache [i].L = 0.4;
                }

                state.ColorCache [IndicatorDrawingState.UnderlineErrorColor]      = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UnderlineError);
                state.ColorCache [IndicatorDrawingState.UnderlineWarningColor]    = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UnderlineWarning);
                state.ColorCache [IndicatorDrawingState.UnderlineSuggestionColor] = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UnderlineSuggestion);
                state.ColorCache [IndicatorDrawingState.BackgroundColor]          = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.Background);

                ResetEnumerators();

                cr = new Cairo.Context(surface.Surface);
                cr.Scale(displayScale, displayScale);
                GLib.Idle.Add(RunHandler);
            }
示例#8
0
		void DrawMarginBackground (Cairo.Context cr, int line, double x, double y, double lineHeight)
		{
			if (editor.Caret.Line == line) {
				editor.TextViewMargin.DrawCaretLineMarker (cr, x, y, Width, lineHeight);
				return;
			}
			cr.Rectangle (x, y, Width, lineHeight);

			cr.SetSourceColor (SyntaxHighlightingService.GetColor (editor.EditorTheme, EditorThemeColors.LineNumbersBackground));
			cr.Fill ();
		}
示例#9
0
        public override bool DrawBackground(MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
        {
            var width = metrics.Width;

            cr.Rectangle(metrics.X, metrics.Y, metrics.Width, metrics.Height);
            var lineNumberGC = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.LineNumbers);

            cr.SetSourceColor(editor.Caret.Line == metrics.LineNumber ? SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.LineHighlight) : lineNumberGC);
            cr.Fill();

            return(true);
        }
示例#10
0
        public override void Draw(MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics)
        {
            var color = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.FoldLine);

            cr.SetSourceColor(color);

            cr.LineWidth = 1 * editor.Options.Zoom;
            var y = metrics.LineYRenderStartPosition;

            cr.MoveTo(metrics.TextRenderStartPosition, y + metrics.LineHeight - 1.5);
            cr.LineTo(editor.Allocation.Width, y + metrics.LineHeight - 1.5);
            cr.Stroke();
        }
示例#11
0
            protected override bool OnExposeEvent(Gdk.EventExpose e)
            {
                if (TextEditor == null)
                {
                    return(true);
                }
                using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) {
                    cr.LineWidth = 1;
                    if (backgroundPixbuf != null)
                    {
                        e.Window.DrawDrawable(Style.BlackGC, backgroundPixbuf, 0, GetBufferYOffset(), 0, 0, Allocation.Width, Allocation.Height);
                    }
                    else
                    {
                        cr.Rectangle(0, 0, Allocation.Width, Allocation.Height);
                        if (TextEditor.EditorTheme != null)
                        {
                            cr.SetSourceColor(SyntaxHighlightingService.GetColor(TextEditor.EditorTheme, EditorThemeColors.Background));
                        }
                        cr.Fill();
                    }

                    /*
                     * cr.Color = (HslColor)Style.Dark (State);
                     * cr.MoveTo (-0.5, 0.5);
                     * cr.LineTo (Allocation.Width, 0.5);
                     * cr.MoveTo (-0.5, Allocation.Height - 0.5);
                     * cr.LineTo (Allocation.Width, Allocation.Height - 0.5);
                     * cr.Stroke ();*/

                    if (backgroundPixbuf != null)
                    {
                        int y = GetBufferYOffset();

                        int    startLine = TextEditor.YToLine(vadjustment.Value);
                        double dy        = TextEditor.LogicalToVisualLocation(startLine, 1).Line *lineHeight;

                        cr.Rectangle(0,
                                     dy - y,
                                     Allocation.Width,
                                     lineHeight * vadjustment.PageSize / TextEditor.LineHeight);
                        var c = (Cairo.Color)(HslColor) Style.Dark(State);
                        c.A = 0.2;
                        cr.SetSourceColor(c);
                        cr.Fill();
                    }
                    DrawLeftBorder(cr);
                }

                return(true);
            }
示例#12
0
        public override bool DrawBackground(MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics)
        {
            int caretOffset = editor.Caret.Offset - BaseOffset;

            foreach (var link in mode.Links)
            {
                if (!link.IsEditable)
                {
                    continue;
                }
                bool isPrimaryHighlighted = link.PrimaryLink.Offset <= caretOffset && caretOffset <= link.PrimaryLink.EndOffset;
                foreach (TextSegment segment in link.Links)
                {
                    if ((BaseOffset + segment.Offset <= metrics.TextStartOffset && metrics.TextStartOffset < BaseOffset + segment.EndOffset) || (metrics.TextStartOffset <= BaseOffset + segment.Offset && BaseOffset + segment.Offset < metrics.TextEndOffset))
                    {
                        int strOffset    = BaseOffset + segment.Offset - metrics.TextStartOffset;
                        int strEndOffset = BaseOffset + segment.EndOffset - metrics.TextStartOffset;

                        int x_pos  = metrics.Layout.IndexToPos(strOffset).X;
                        int x_pos2 = metrics.Layout.IndexToPos(strEndOffset).X;

                        x_pos  = (int)(x_pos / Pango.Scale.PangoScale);
                        x_pos2 = (int)(x_pos2 / Pango.Scale.PangoScale);
                        Cairo.Color fillGc, rectangleGc;
                        if (segment.Equals(link.PrimaryLink))
                        {
                            fillGc      = SyntaxHighlightingService.GetColor(editor.EditorTheme, isPrimaryHighlighted ? EditorThemeColors.PrimaryTemplateHighlighted2 : EditorThemeColors.PrimaryTemplate2);
                            rectangleGc = SyntaxHighlightingService.GetColor(editor.EditorTheme, isPrimaryHighlighted ? EditorThemeColors.PrimaryTemplateHighlighted2 : EditorThemeColors.PrimaryTemplate2);
                        }
                        else
                        {
                            fillGc      = SyntaxHighlightingService.GetColor(editor.EditorTheme, isPrimaryHighlighted ? EditorThemeColors.SecondaryTemplateHighlighted2 : EditorThemeColors.SecondaryTemplate2);
                            rectangleGc = SyntaxHighlightingService.GetColor(editor.EditorTheme, isPrimaryHighlighted ? EditorThemeColors.SecondaryTemplateHighlighted : EditorThemeColors.SecondaryTemplate);
                        }

                        // Draw segment
                        double x1 = metrics.TextRenderStartPosition + x_pos - 1;
                        double x2 = metrics.TextRenderStartPosition + x_pos2 - 1 + 0.5;

                        cr.Rectangle(x1 + 0.5, metrics.LineYRenderStartPosition + 0.5, x2 - x1, editor.LineHeight - 1);

                        cr.SetSourceColor(fillGc);
                        cr.FillPreserve();

                        cr.SetSourceColor(rectangleGc);
                        cr.Stroke();
                    }
                }
            }
            return(true);
        }
        void WriteHunks(Queue <DiffHunk> qh, IReadonlyTextDocument baseDocument, IReadonlyTextDocument changedDocument, Cairo.Context g, ref int y)
        {
            DiffHunk item;
            int      remStart;
            int      insStart;
            int      distance = 0;

            do
            {
                item     = qh.Dequeue();
                remStart = System.Math.Max(1, item.RemoveStart - (distance != 0 ? distance : item.Context));
                insStart = System.Math.Max(1, item.InsertStart - (distance != 0 ? distance : item.Context));

                for (int i = System.Math.Min(remStart, insStart); i < item.RemoveStart; i++)
                {
                    DrawLine(g, editor, i, ref y);
                }

                for (int i = item.RemoveStart; i < item.RemoveStart + item.Removed; i++)
                {
                    g.Rectangle(0, y, Allocation.Width, lineHeight);

                    g.SetSourceColor(SyntaxHighlightingService.GetColor(editor.Options.GetEditorTheme(), EditorThemeColors.PreviewDiffRemovedBackground));
                    g.Fill();
                    g.SetSourceColor(SyntaxHighlightingService.GetColor(editor.Options.GetEditorTheme(), EditorThemeColors.PreviewDiffRemoved));
                    DrawTextLine(g, editor, i, ref y);
                }

                for (int i = item.InsertStart; i < item.InsertStart + item.Inserted; i++)
                {
                    g.Rectangle(0, y, Allocation.Width, lineHeight);
                    g.SetSourceColor(SyntaxHighlightingService.GetColor(editor.Options.GetEditorTheme(), EditorThemeColors.PreviewDiffAddedBackground));
                    g.Fill();
                    g.SetSourceColor(SyntaxHighlightingService.GetColor(editor.Options.GetEditorTheme(), EditorThemeColors.PreviewDiffAdded));
                    DrawTextLine(g, changedDocument, i, ref y);
                }

                if (qh.Count != 0)
                {
                    distance = item.DistanceTo(qh.Peek());
                }
            } while (qh.Count != 0);

            int remEnd = System.Math.Min(baseDocument.LineCount, item.RemoveStart + item.Removed + item.Context);

            for (int i = item.RemoveStart + item.Removed; i < remEnd; i++)
            {
                DrawLine(g, editor, i, ref y);
            }
        }
示例#14
0
        public override void DrawBackground(MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
        {
            int markerStart = Offset;
            int markerEnd   = EndOffset;

            double @from;
            double to;
            var    startXPos = metrics.TextRenderStartPosition;
            var    endXPos   = metrics.TextRenderEndPosition;
            var    y         = metrics.LineYRenderStartPosition;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int start = startOffset < markerStart ? markerStart : startOffset;
                int end   = endOffset < markerEnd ? endOffset : markerEnd;

                uint curIndex = 0, byteIndex = 0;
                TextViewMargin.TranslateToUTF8Index(metrics.Layout.Text, (uint)(start - startOffset), ref curIndex, ref byteIndex);

                int x_pos = metrics.Layout.IndexToPos((int)byteIndex).X;

                @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                TextViewMargin.TranslateToUTF8Index(metrics.Layout.Text, (uint)(end - startOffset), ref curIndex, ref byteIndex);
                x_pos = metrics.Layout.IndexToPos((int)byteIndex).X;

                to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }

            @from = Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from <= to)
            {
                if (metrics.TextEndOffset < markerEnd)
                {
                    to = metrics.WholeLineWidth + metrics.TextRenderStartPosition;
                }

                var c1 = (Cairo.Color)SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Background);
                var c2 = (Cairo.Color)SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Selection);
                cr.SetSourceRGB((c1.R + c2.R) / 2, (c1.G + c2.G) / 2, (c1.B + c2.B) / 2);
                cr.Rectangle(@from, y, to - @from, metrics.LineHeight);
                cr.Fill();
            }
        }
示例#15
0
        internal protected override void OptionsChanged()
        {
            lineNumberBgGC = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.LineNumbersBackground);
            lineNumberGC   = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.LineNumbers);
            gutterFont     = editor.Options.GutterFont;
            //			gutterFont.Weight = (Pango.Weight)editor.ColorStyle.LineNumbers.FontWeight;
            //			gutterFont.Style = (Pango.Style)editor.ColorStyle.LineNumbers.FontStyle;

            /*			if (Platform.IsWindows) {
             *                              gutterFont.Size = (int)(Pango.Scale.PangoScale * 8.0 * editor.Options.Zoom);
             *                      } else {
             *                              gutterFont.Size = (int)(Pango.Scale.PangoScale * 11.0 * editor.Options.Zoom);
             *                      }*/
            CalculateWidth();
        }
示例#16
0
        public override void Draw(Mono.TextEditor.MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
        {
            this.editor = editor;
            var line = editor.GetLine(loc.Line);

            if (line == null)
            {
                return;
            }
            var x = editor.ColumnToX(line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition;

            cr.Rectangle(Math.Floor(x), Math.Floor(metrics.LineYRenderStartPosition) + editor.LineHeight - tagMarkerHeight, tagMarkerWidth, tagMarkerHeight);
            cr.SetSourceColor((HslColor.Brightness(SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Background)) < 0.5 ? Ide.Gui.Styles.Editor.SmartTagMarkerColorDark : Ide.Gui.Styles.Editor.SmartTagMarkerColorLight).ToCairoColor());
            cr.Fill();
        }
 protected void DrawLeftBorder(Cairo.Context cr)
 {
     cr.MoveTo(0.5, 0);
     cr.LineTo(0.5, Allocation.Height);
     if (TextEditor.EditorTheme != null)
     {
         var col = (Xwt.Drawing.Color)SyntaxHighlightingService.GetColor(TextEditor.EditorTheme, EditorThemeColors.Background);
         if (!MonoDevelop.Core.Platform.IsWindows)
         {
             col.Light *= 0.95;
         }
         cr.SetSourceColor(col.ToCairoColor());
     }
     cr.Stroke();
 }
        protected void DrawCaret(Cairo.Context cr)
        {
            if (TextEditor.EditorTheme == null || caretLine < 0)
            {
                return;
            }
            double y = GetYPosition(caretLine);

            cr.MoveTo(0, y - 4);
            cr.LineTo(7, y);
            cr.LineTo(0, y + 4);
            cr.ClosePath();
            cr.SetSourceColor(SyntaxHighlightingService.GetColor(TextEditor.EditorTheme, EditorThemeColors.Foreground));
            cr.Fill();
        }
            protected override bool OnExposeEvent(Gdk.EventExpose evnt)
            {
                using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window)) {
                    const int triangleWidth  = 8;
                    const int triangleHeight = 4;

                    cr.SetSourceColor(SyntaxHighlightingService.GetColor(DefaultSourceEditorOptions.Instance.GetEditorTheme(), EditorThemeColors.LineNumbers));
                    var topPosition = Allocation.Height / 2 - triangleHeight / 2;

                    cr.MoveTo(Allocation.Width / 2 + triangleWidth / 2, topPosition);
                    cr.LineTo(Allocation.Width / 2 - triangleWidth / 2, topPosition);
                    cr.LineTo(Allocation.Width / 2, topPosition + triangleHeight);
                    cr.LineTo(Allocation.Width / 2 + triangleWidth / 2, topPosition);
                    cr.Fill();
                }
                return(true);
            }
示例#20
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            using (var cr = CairoHelper.Create(evnt.Window)) {
                cr.LineWidth = 1;
                cr.Rectangle(0, 0, Allocation.Width, Allocation.Height);

                cr.SetSourceColor(SyntaxHighlightingService.GetColor(textEditor.EditorTheme, EditorThemeColors.NotificationTextBackground));
                cr.Fill();
                cr.RoundedRectangle(0, 0, Allocation.Width, Allocation.Height, 3);
                cr.SetSourceColor(SyntaxHighlightingService.GetColor(textEditor.EditorTheme, EditorThemeColors.NotificationTextBackground));
                cr.FillPreserve();

                cr.SetSourceColor(SyntaxHighlightingService.GetColor(textEditor.EditorTheme, EditorThemeColors.NotificationBorder));
                cr.Stroke();
            }

            return(base.OnExposeEvent(evnt));
        }
示例#21
0
        public CodePreviewWindow(
            Gdk.Window parentWindow,
            string fontName   = null,
            EditorTheme theme = null)
            : base(Gtk.WindowType.Popup)
        {
            ParentWindow = parentWindow ?? MonoDevelop.Ide.IdeApp.Workbench.RootWindow.GdkWindow;

            AppPaintable  = true;
            SkipPagerHint = SkipTaskbarHint = true;
            TypeHint      = WindowTypeHint.Menu;

            this.fontName = fontName = fontName ?? DefaultSourceEditorOptions.Instance.FontName;

            layout = PangoUtil.CreateLayout(this);
            var font = Xwt.Drawing.Font.FromName(fontName);

            if (font == null)
            {
                LoggingService.LogError("Can't parse font " + fontName);
            }
            else
            {
                fontDescription        = font.ToPangoFont();
                fontDescription.Size   = (int)(fontDescription.Size * 0.8f);
                layout.FontDescription = fontDescription;
            }
            layout.Ellipsize = Pango.EllipsizeMode.End;

            var geometry = Screen.GetUsableMonitorGeometry(Screen.GetMonitorAtWindow(ParentWindow));

            maxWidth  = geometry.Width * 2 / 5;
            maxHeight = geometry.Height * 2 / 5;

            layout.SetText("n");
            layout.GetPixelSize(out int _, out int lineHeight);
            MaximumLineCount = maxHeight / lineHeight;

            theme     = theme ?? DefaultSourceEditorOptions.Instance.GetEditorTheme();
            colorText = SyntaxHighlightingService.GetColor(theme, EditorThemeColors.Foreground);
            colorBg   = SyntaxHighlightingService.GetColor(theme, EditorThemeColors.Background);
            colorFold = SyntaxHighlightingService.GetColor(theme, EditorThemeColors.CollapsedText);
        }
示例#22
0
        HslColor GetColor(int i, double brightness, int colorCount)
        {
            HslColor hslColor      = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Background);
            int      colorPosition = i + 1;

            if (i == foldSegments.Count - 1)
            {
                return(hslColor);
            }
            if (brightness < 0.5)
            {
                hslColor.L = hslColor.L * 0.81 + hslColor.L * 0.25 * (colorCount - colorPosition) / colorCount;
            }
            else
            {
                hslColor.L = hslColor.L * 0.86 + hslColor.L * 0.1 * colorPosition / colorCount;
            }
            return(hslColor);
        }
            static Cairo.Color GetColor(TextEditor editor, Result result)
            {
                switch (result.Level)
                {
                case DiagnosticSeverity.Hidden:
                    return(SyntaxHighlightingService.GetColor(DefaultSourceEditorOptions.Instance.GetEditorTheme(), EditorThemeColors.Background));

                case DiagnosticSeverity.Error:
                    return(SyntaxHighlightingService.GetColor(DefaultSourceEditorOptions.Instance.GetEditorTheme(), EditorThemeColors.UnderlineError));

                case DiagnosticSeverity.Warning:
                    return(SyntaxHighlightingService.GetColor(DefaultSourceEditorOptions.Instance.GetEditorTheme(), EditorThemeColors.UnderlineWarning));

                case DiagnosticSeverity.Info:
                    return(SyntaxHighlightingService.GetColor(DefaultSourceEditorOptions.Instance.GetEditorTheme(), EditorThemeColors.UnderlineSuggestion));

                default:
                    throw new System.ArgumentOutOfRangeException();
                }
            }
        protected override void OnDrawContent(Gdk.EventExpose evnt, Cairo.Context g)
        {
            var style = editor.Options.GetEditorTheme();

            g.Rectangle(0, 0, Allocation.Width, Allocation.Height);

            g.SetSourceColor(SyntaxHighlightingService.GetColor(style, EditorThemeColors.Background));
            g.Fill();

            int y = verticalTextSpace / 2;

            var qh = new Queue <DiffHunk> ();
            var he = diff.GetEnumerator();

            he.MoveNext();
            var      current = he.Current;
            DiffHunk next;

            qh.Enqueue(current);
            while (he.MoveNext())
            {
                next = he.Current;

                if (current.Overlaps(next))
                {
                    // Change upper bounds.
                }
                else
                {
                    WriteHunks(qh, editor, changedTextDocument, g, ref y);
                }
                qh.Enqueue(next);

                current = next;
            }
            if (qh.Count != 0)
            {
                WriteHunks(qh, editor, changedTextDocument, g, ref y);
            }
        }
示例#25
0
        void IChunkMarker.ChangeForeColor(MonoTextEditor editor, MonoDevelop.Ide.Editor.Highlighting.ColoredSegment chunk, ref Cairo.Color color)
        {
            if (Debugger.DebuggingService.IsDebugging)
            {
                return;
            }
            int markerStart = Segment.Offset;
            int markerEnd   = Segment.EndOffset;

            if (chunk.EndOffset <= markerStart || markerEnd <= chunk.Offset)
            {
                return;
            }
            var    bgc   = (Cairo.Color)SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Background);
            double alpha = 0.6;

            color = new Cairo.Color(
                color.R * alpha + bgc.R * (1.0 - alpha),
                color.G * alpha + bgc.G * (1.0 - alpha),
                color.B * alpha + bgc.B * (1.0 - alpha)
                );
        }
            public override void OptionsChanged()
            {
                base.OptionsChanged();
                foldBgGC              = SyntaxHighlightingService.GetColor(Editor.EditorTheme, EditorThemeColors.Background);
                foldLineGC            = SyntaxHighlightingService.GetColor(Editor.EditorTheme, EditorThemeColors.FoldLine);
                foldLineHighlightedGC = SyntaxHighlightingService.GetColor(Editor.EditorTheme, EditorThemeColors.Foreground);

                HslColor hslColor   = SyntaxHighlightingService.GetColor(Editor.EditorTheme, EditorThemeColors.Background);
                double   brightness = HslColor.Brightness(hslColor);

                if (brightness < 0.5)
                {
                    hslColor.L = hslColor.L * 0.85 + hslColor.L * 0.25;
                }
                else
                {
                    hslColor.L = hslColor.L * 0.9;
                }

                foldLineHighlightedGCBg    = hslColor;
                foldToggleMarkerGC         = SyntaxHighlightingService.GetColor(Editor.EditorTheme, EditorThemeColors.FoldCross);
                foldToggleMarkerBackground = SyntaxHighlightingService.GetColor(Editor.EditorTheme, EditorThemeColors.FoldCrossBackground);
            }
        void DrawBackground(Cairo.Context cr, Gdk.Rectangle allocation)
        {
            cr.LineWidth = 1;
            cr.Rectangle(0, 0, allocation.Width, allocation.Height);

            if (TextEditor.EditorTheme != null)
            {
                var bgColor = SyntaxHighlightingService.GetColor(TextEditor.EditorTheme, EditorThemeColors.Background);
                if (MonoDevelop.Core.Platform.IsWindows)
                {
                    using (var pattern = new Cairo.SolidPattern(bgColor)) {
                        cr.SetSource(pattern);
                        cr.Fill();
                    }
                }
                else
                {
                    cr.SetSourceColor(bgColor);
                    cr.Fill();
                }
            }
            DrawLeftBorder(cr);
        }
        protected virtual void DrawBar(Cairo.Context cr)
        {
            if (vadjustment == null || vadjustment.Upper <= vadjustment.PageSize)
            {
                return;
            }

            double x, y, w, h;

            GetBarDimensions(out x, out y, out w, out h);

            if (MonoDevelop.Core.Platform.IsWindows)
            {
                cr.Rectangle(x, y, w, h);
            }
            else
            {
                MonoDevelop.Components.CairoExtensions.RoundedRectangle(cr, x, y, w, h, 4);
            }

            bool prelight = State == StateType.Prelight;

            Cairo.Color c;
            if (MonoDevelop.Core.Platform.IsWindows)
            {
                c = prelight ? win81SliderPrelight : win81Slider;
                //compute new color such that it will produce same color when blended with bg
                c = AddAlpha(SyntaxHighlightingService.GetColor(TextEditor.EditorTheme, EditorThemeColors.Background), c, 0.5d);
            }
            else
            {
                var brightness = HslColor.Brightness(SyntaxHighlightingService.GetColor(TextEditor.EditorTheme, EditorThemeColors.Background));
                c = new Cairo.Color(1 - brightness, 1 - brightness, 1 - brightness, barColorValue * (barAlphaMax - barAlphaMin) + barAlphaMin);
            }
            cr.SetSourceColor(c);
            cr.Fill();
        }
示例#29
0
        public override void DrawForeground(MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
        {
            var width          = metrics.Width;
            var lineNumberBgGC = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.LineNumbersBackground);



            if (metrics.LineNumber <= editor.Document.LineCount)
            {
                // Due to a mac? gtk bug I need to re-create the layout here
                // otherwise I get pango exceptions.
                using (var layout = PangoUtil.CreateLayout(editor)) {
                    layout.FontDescription = editor.Options.Font;
                    layout.Width           = (int)width;
                    layout.Alignment       = Pango.Alignment.Right;
                    layout.SetText(metrics.LineNumber.ToString());
                    cr.Save();
                    cr.Translate(metrics.X + (int)width + (editor.Options.ShowFoldMargin ? 0 : -2), metrics.Y);
                    cr.SetSourceColor(lineNumberBgGC);
                    cr.ShowLayout(layout);
                    cr.Restore();
                }
            }
        }
示例#30
0
                public BgBufferUpdate(Minimpap mode)
                {
                    this.mode = mode;

                    cr = Gdk.CairoHelper.Create(mode.backgroundBuffer);

                    cr.LineWidth = 1;
                    int w = mode.backgroundBuffer.ClipRegion.Clipbox.Width;
                    int h = mode.backgroundBuffer.ClipRegion.Clipbox.Height;

                    cr.Rectangle(0, 0, w, h);
                    if (mode.TextEditor.EditorTheme != null)
                    {
                        cr.SetSourceColor(SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.Background));
                    }
                    cr.Fill();

                    maxLine = mode.TextEditor.GetTextEditorData().VisibleLineCount;
                    sx      = w / (double)mode.TextEditor.Allocation.Width;
                    sy      = Math.Min(1, lineHeight * maxLine / (double)mode.TextEditor.GetTextEditorData().TotalHeight);
                    cr.Scale(sx, sy);

                    handler = GLib.Idle.Add(BgBufferUpdater);
                }