protected override void OnBeginPrint(PrintContext context) { layout = PangoUtil.CreateLayout(context); layout.FontDescription = settings.Font; layout.FontDescription.Weight = Pango.Weight.Bold; layout.SetText(" "); int w, h; layout.GetSize(out w, out h); this.lineHeight = h / Pango.Scale.PangoScale; layout.FontDescription.Weight = Pango.Weight.Normal; SetHeaderFormat(settings.HeaderFormat); SetFooterFormat(settings.FooterFormat); style = SyntaxHighlightingService.GetEditorTheme(settings.EditorTheme); pageWidth = context.PageSetup.GetPageWidth(Unit.Pixel); pageHeight = context.PageSetup.GetPageHeight(Unit.Pixel); double contentHeight = pageHeight - (headerLines > 0? settings.HeaderPadding : 0) - (footerLines > 0? settings.FooterPadding : 0); linesPerPage = (int)(contentHeight / lineHeight) - (headerLines + footerLines); totalPages = (int)Math.Ceiling((double)doc.LineCount / linesPerPage); NPages = totalPages; base.OnBeginPrint(context); }
public void TestTryScanJSonStyle() { using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream)) { writer.Write(@"{ ""information_for_contributors"": [ ""This file has been converted from https://github.com/Microsoft/TypeScript-TmLanguage/blob/master/TypeScript.tmLanguage"", ""If you want to provide a fix or improvement, please create a pull request against the original repository."", ""Once accepted there, we are happy to receive an update request."" ], ""version"": ""https://github.com/Microsoft/TypeScript-TmLanguage/commit/7bf8960f7042474b10b519f39339fc527907ce16"", ""name"": ""TypeScript"", ""scopeName"": ""source.ts"", ""fileTypes"": [ ""ts"" ]," ); writer.Flush(); stream.Position = 0; bool result = SyntaxHighlightingService.TryScanJSonStyle(stream, out var name, out var format, out var fileTypes, out var scopeName); Assert.AreEqual(true, result); Assert.AreEqual("TypeScript", name); Assert.AreEqual("source.ts", scopeName); Assert.True(fileTypes.Contains("ts")); } }
public override async Task <TooltipInformation> CreateTooltipInformation(bool smartWrap, CancellationToken cancelToken) { var description = await Task.Run(() => completionService.GetDescriptionAsync(doc, CompletionItem)).ConfigureAwait(false); var markup = new StringBuilder(); var theme = SyntaxHighlightingService.GetIdeFittingTheme(DefaultSourceEditorOptions.Instance.GetEditorTheme()); var taggedParts = description.TaggedParts; int i = 0; while (i < taggedParts.Length) { if (taggedParts [i].Tag == "LineBreak") { break; } i++; } if (i + 1 >= taggedParts.Length) { markup.AppendTaggedText(theme, taggedParts); } else { markup.AppendTaggedText(theme, taggedParts.Take(i)); markup.Append("<span font='" + FontService.SansFontName + "' size='small'>"); markup.AppendLine(); markup.AppendLine(); markup.AppendTaggedText(theme, taggedParts.Skip(i + 1)); markup.Append("</span>"); } return(new TooltipInformation { SignatureMarkup = markup.ToString() }); }
protected void DrawSearchResults(Cairo.Context cr, IEnumerator <ISegment> searchResults, ref bool nextStep) { if (!searchResults.MoveNext()) { nextStep = true; return; } var region = searchResults.Current; int line = TextEditor.OffsetToLineNumber(region.Offset); double y = GetYPosition(line); bool isMainSelection = false; if (!TextEditor.TextViewMargin.MainSearchResult.IsInvalid()) { isMainSelection = region.Offset == TextEditor.TextViewMargin.MainSearchResult.Offset; } var color = SyntaxHighlightingService.GetColor(TextEditor.EditorTheme, EditorThemeColors.FindHighlight); if (isMainSelection) { // TODO: EditorTheme does that look ok ? if (HslColor.Brightness(color) < 0.5) { color = color.AddLight(0.1); } else { color = color.AddLight(-0.1); } } cr.SetSourceColor(color); cr.Rectangle(barPadding, Math.Round(y) - 1, Allocation.Width - barPadding * 2, 2); cr.Fill(); }
protected override bool OnExposeEvent(Gdk.EventExpose ev) { if (textGC == null) { var plainText = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Foreground); textGC = plainText.CreateGC(ev.Window); plainText = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Background); textBgGC = plainText.CreateGC(ev.Window); var collapsedText = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.CollapsedText); foldGC = collapsedText.CreateGC(ev.Window); collapsedText = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Background); foldBgGC = collapsedText.CreateGC(ev.Window); } ev.Window.DrawRectangle(textBgGC, true, ev.Area); ev.Window.DrawLayout(textGC, 5, 4, layout); ev.Window.DrawRectangle(textBgGC, false, 1, 1, this.Allocation.Width - 3, this.Allocation.Height - 3); ev.Window.DrawRectangle(foldGC, false, 0, 0, this.Allocation.Width - 1, this.Allocation.Height - 1); if (!HideCodeSegmentPreviewInformString) { informLayout.SetText(CodeSegmentPreviewInformString); int w, h; informLayout.GetPixelSize(out w, out h); PreviewInformStringHeight = h; ev.Window.DrawRectangle(foldBgGC, true, Allocation.Width - w - 3, Allocation.Height - h, w + 2, h - 1); ev.Window.DrawLayout(foldGC, Allocation.Width - w - 4, Allocation.Height - h - 3, informLayout); } return(true); }
internal protected override void OptionsChanged() { backgroundColor = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.IndicatorMargin); focusedBackgroundColor = backgroundColor.AddLight(-0.02); focusedMarkerColor = backgroundColor.AddLight(-0.3); separatorColor = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.IndicatorMarginSeparator); }
protected override void OnBeginPrint(PrintContext context) { layout = PangoUtil.CreateLayout(context); layout.FontDescription = settings.Font; using (var PangoContext = context.CreatePangoContext()) using (var metrics = PangoContext.GetMetrics(settings.Font, PangoContext.Language)) { lineHeight = Math.Ceiling(0.5 + (metrics.Ascent + metrics.Descent) / Pango.Scale.PangoScale); } SetHeaderFormat(settings.HeaderFormat); SetFooterFormat(settings.FooterFormat); style = SyntaxHighlightingService.GetEditorTheme(settings.EditorTheme); pageWidth = context.PageSetup.GetPageWidth(Unit.Pixel); pageHeight = context.PageSetup.GetPageHeight(Unit.Pixel); double contentHeight = pageHeight - (headerLines > 0? settings.HeaderPadding : 0) - (footerLines > 0? settings.FooterPadding : 0); linesPerPage = (int)(contentHeight / lineHeight) - (headerLines + footerLines); totalPages = (int)Math.Ceiling((double)editor.LineCount / linesPerPage); NPages = totalPages; base.OnBeginPrint(context); }
public override void OptionsChanged() { base.OptionsChanged(); background = SyntaxHighlightingService.GetColor(Editor.EditorTheme, EditorThemeColors.Background); foreground = SyntaxHighlightingService.GetColor(Editor.EditorTheme, EditorThemeColors.Foreground); foldLine = SyntaxHighlightingService.GetColor(Editor.EditorTheme, EditorThemeColors.FoldLine); }
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); }
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 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); }
private SourceEditorPrintSettings() { var font = Xwt.Drawing.Font.FromName(DefaultSourceEditorOptions.Instance.FontName); if (font == null) { LoggingService.LogWarning("Could not load font: {0}", DefaultSourceEditorOptions.Instance.FontName); } else { Font = font.ToPangoFont(); } if (Font == null || String.IsNullOrEmpty(Font.Family)) { Font = Pango.FontDescription.FromString(TextEditorOptions.DEFAULT_FONT); } if (Font != null) { Font.Size = (int)(Font.Size * 0.5); } TabSize = DefaultSourceEditorOptions.Instance.TabSize; HeaderFormat = "%F"; FooterFormat = GettextCatalog.GetString("Page %N of %Q"); EditorTheme = SyntaxHighlightingService.GetDefaultColorStyleName(MonoDevelop.Ide.Theme.Light); HeaderSeparatorWeight = FooterSeparatorWeight = 0.5; HeaderPadding = FooterPadding = 6; UseHighlighting = true; }
Cairo.Color GetBarColor(DiagnosticSeverity severity) { var style = this.TextEditor.EditorTheme; if (style == null) { return(new Cairo.Color(0, 0, 0)); } switch (severity) { case DiagnosticSeverity.Error: return(SyntaxHighlightingService.GetColor(style, EditorThemeColors.UnderlineError)); case DiagnosticSeverity.Warning: return(SyntaxHighlightingService.GetColor(style, EditorThemeColors.UnderlineWarning)); case DiagnosticSeverity.Info: return(SyntaxHighlightingService.GetColor(style, EditorThemeColors.UnderlineSuggestion)); case DiagnosticSeverity.Hidden: return(SyntaxHighlightingService.GetColor(style, EditorThemeColors.Background)); default: throw new ArgumentOutOfRangeException(); } }
static int GetLastSourceCodePosition(IReadonlyTextDocument document, int lineOffset) { var line = document.GetLineByOffset(lineOffset); bool isInBlockComment = false; bool isInLineComment = false; int curStringQuote = -1; var lang = TextMateLanguage.Create(SyntaxHighlightingService.GetScopeForFileName(document.FileName)); var lineComments = lang.LineComments.ToArray(); var blockCommentStarts = lang.BlockComments.Select(b => b.Item1).ToList(); var blockCommentEnds = lang.BlockComments.Select(b => b.Item2).ToList(); var stringQuotes = new string [] { "\"", "'" }; for (int i = 0; i < line.Length; i++) { int offset = line.Offset + i; // check line comments if (!isInBlockComment && curStringQuote < 0) { isInLineComment = StartsWithListMember(document, lineComments, offset) >= 0; if (isInLineComment) { return(System.Math.Min(offset, lineOffset)); } } // check block comments if (!isInLineComment && curStringQuote < 0) { if (!isInBlockComment) { isInBlockComment = StartsWithListMember(document, blockCommentStarts, offset) >= 0; } else { isInBlockComment = StartsWithListMember(document, blockCommentEnds, offset) < 0; } } if (!isInBlockComment && !isInLineComment) { int j = StartsWithListMember(document, stringQuotes, offset); if (j >= 0) { if (curStringQuote >= 0) { if (curStringQuote == j) { curStringQuote = -1; } } else { curStringQuote = j; } } } } return(lineOffset); }
void HandleButtonOkClicked(object sender, EventArgs e) { Gtk.TreeIter iter; if (!store.IterNthChild(out iter, comboboxBaseStyle.Active)) { return; } string name = (string)store.GetValue(iter, 0); var style = SyntaxHighlightingService.GetEditorTheme(name); style = style.CloneWithName(entryName.Text); string path = MonoDevelop.Ide.Editor.TextEditorDisplayBinding.SyntaxModePath; string baseName = style.Name.Replace(" ", "_"); while (File.Exists(System.IO.Path.Combine(path, baseName + ".tmTheme"))) { baseName = baseName + "_"; } string fileName = System.IO.Path.Combine(path, baseName + ".tmTheme"); try { using (var writer = new StreamWriter(fileName)) TextMateFormat.Save(writer, style); } catch (Exception ex) { LoggingService.LogInternalError(ex); } }
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 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); fontDescription = Pango.FontDescription.FromString(fontName); 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); }
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); }
public static EditorTheme GetEditorTheme(this ITextEditorOptions options) { if (options == null) { throw new ArgumentNullException("options"); } return(SyntaxHighlightingService.GetEditorTheme(options.EditorTheme)); }
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)); }
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); }
public void ParseFileTypeTest() { Assert.AreEqual("xml", SyntaxHighlightingService.ParseFileType("\"xml\"")); Assert.AreEqual("xml", SyntaxHighlightingService.ParseFileType("\".xml\"")); Assert.AreEqual("xml", SyntaxHighlightingService.ParseFileType("\"xml\",")); Assert.AreEqual("xml", SyntaxHighlightingService.ParseFileType("\".xml\",")); Assert.IsTrue(string.IsNullOrEmpty(SyntaxHighlightingService.ParseFileType("\"\","))); Assert.IsTrue(string.IsNullOrEmpty(SyntaxHighlightingService.ParseFileType("\".\","))); Assert.IsTrue(string.IsNullOrEmpty(SyntaxHighlightingService.ParseFileType("}"))); }
void AddColorScheme(object sender, EventArgs args) { var dialog = new SelectFileDialog(GettextCatalog.GetString("Import Color Theme"), MonoDevelop.Components.FileChooserAction.Open) { TransientFor = this.Toplevel as Gtk.Window, }; dialog.AddFilter(GettextCatalog.GetString("Color themes (Visual Studio, Xamarin Studio, TextMate) "), "*.json", "*.vssettings", "*.tmTheme"); if (!dialog.Run()) { return; } var fileName = dialog.SelectedFile.FileName; var filePath = dialog.SelectedFile.FullPath; string newFilePath = TextEditorDisplayBinding.SyntaxModePath.Combine(fileName); if (!SyntaxHighlightingService.IsValidTheme(filePath)) { MessageService.ShowError(GettextCatalog.GetString("Could not import color theme.")); return; } bool success = true; try { if (File.Exists(newFilePath)) { var answer = MessageService.AskQuestion( GettextCatalog.GetString( "A color theme with the name '{0}' already exists in your theme folder. Would you like to replace it?", fileName ), AlertButton.Cancel, AlertButton.Replace ); if (answer != AlertButton.Replace) { return; } File.Delete(newFilePath); } File.Copy(filePath, newFilePath); } catch (Exception e) { success = false; LoggingService.LogError("Can't copy color theme file.", e); } if (success) { SyntaxHighlightingService.LoadStylesAndModesInPath(TextEditorDisplayBinding.SyntaxModePath); TextEditorDisplayBinding.LoadCustomStylesAndModes(); ShowStyles(); } }
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 (); }
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); }
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(); }
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); }
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); }
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(); } }
string[] ITextEditorFactory.GetSyntaxProperties(string mimeType, string name) { var mode = SyntaxHighlightingService.GetSyntaxHighlightingDefinition(null, mimeType); if (mode == null) { return(null); } // TODO: EditorTheme - remove the syntax properties or translate them to new language properties/services // System.Collections.Generic.List<string> value; // if (!mode.Properties.TryGetValue (name, out value)) return(null); // return value.ToArray (); }