public void SetSheme(ColorSheme style) { if (style == null) { throw new ArgumentNullException("style"); } this.fileName = Mono.TextEditor.Highlighting.SyntaxModeService.GetFileNameForStyle(style); this.colorSheme = style; this.entryName.Text = style.Name; this.entryDescription.Text = style.Description; this.textEditor.Document.MimeType = "text/x-csharp"; this.textEditor.GetTextEditorData().ColorStyle = style; this.textEditor.Text = @"using System; // This is an example class Example { public static void Main (string[] args) { Console.WriteLine (""Hello World""); } }"; foreach (var data in metaData) { colorStore.AppendValues(data.Description, style.GetChunkStyle(data.Name), data); } Stylechanged(null, null); }
public virtual ChunkStyle GetChunkStyle(ColorSheme style) { if (style == null) { return(null); } return(style.GetChunkStyle(Style)); }
static Cairo.Color[,,,,] CreateColorMatrix(TextEditor editor, bool isError) { string typeString = isError ? "error" : "warning"; Cairo.Color[,,,,] colorMatrix = new Cairo.Color[2, 2, 3, 2, 2]; ColorSheme style = editor.ColorStyle; if (style == null) { style = new DefaultStyle(editor.Style); } var baseColor = style.GetChunkStyle("bubble." + typeString + "").CairoBackgroundColor; AdjustColorMatrix(colorMatrix, 0, baseColor); var hsl = (HslColor)baseColor; hsl.S *= 0.6; baseColor = hsl; AdjustColorMatrix(colorMatrix, 1, hsl); double factor = 1.03; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 3; k++) { HslColor color = colorMatrix [i, j, k, 0, 0]; color.L *= factor; colorMatrix [i, j, k, 1, 0] = color; } } } var selectionColor = ColorSheme.ToCairoColor(style.Selection.BackgroundColor); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 3; k++) { for (int l = 0; l < 2; l++) { var color = colorMatrix [i, j, k, l, 0]; colorMatrix [i, j, k, l, 1] = new Cairo.Color((color.R + selectionColor.R * 1.5) / 2.5, (color.G + selectionColor.G * 1.5) / 2.5, (color.B + selectionColor.B * 1.5) / 2.5); } } } } return(colorMatrix); }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); palletes = htmlShemes.Select(c => ToPallete(c)).ToList(); Generate(); } }
public virtual void ApplyChanges() { DefaultSourceEditorOptions.Instance.EnableSyntaxHighlighting = this.enableHighlightingCheckbutton.Active; // DefaultSourceEditorOptions.Instance.EnableSemanticHighlighting = this.enableSemanticHighlightingCheckbutton.Active; TreeIter selectedIter; if (styleTreeview.Selection.GetSelected(out selectedIter)) { ColorSheme sheme = ((Mono.TextEditor.Highlighting.ColorSheme) this.styleStore.GetValue(selectedIter, 1)); DefaultSourceEditorOptions.Instance.ColorScheme = sheme != null ? sheme.Name : null; } }
void ApplyStyle(ColorSheme sheme) { sheme.Name = entryName.Text; sheme.Description = entryDescription.Text; Gtk.TreeIter iter; if (colorStore.GetIterFirst(out iter)) { do { var data = (ColorMetaData)colorStore.GetValue(iter, 2); var style = (ChunkStyle)colorStore.GetValue(iter, 1); sheme.SetChunkStyle(data.Name, style); } while (colorStore.IterNext(ref iter)); } }
void SetColors() { ColorSheme style = editor.ColorStyle; if (style == null) { style = new DefaultStyle(editor.Style); } errorGc = (HslColor)(style.GetChunkStyle("bubble.error").Color); warningGc = (HslColor)(style.GetChunkStyle("bubble.warning").Color); errorMatrix = CreateColorMatrix(editor, true); warningMatrix = CreateColorMatrix(editor, false); gcSelected = (HslColor)style.Selection.Color; gcLight = new Cairo.Color(1, 1, 1); }
public CSharpChunkParser(SpanParser spanParser, Mono.TextEditor.Document doc, ColorSheme style, SyntaxMode mode, LineSegment line) : base(spanParser, doc, style, mode, line) { document = IdeApp.Workbench.GetDocument(doc.FileName); foreach (var tag in ProjectDomService.SpecialCommentTags) { tags.Add(tag.Tag); } // ICSharpCode.OldNRefactory.Ast.CompilationUnit unit = null; // if (document != null && document.ParsedDocument != null && MonoDevelop.Core.PropertyService.Get ("EnableSemanticHighlighting", false)) { // resolver = document.GetResolver (); // if (!document.ParsedDocument.TryGetTag (out unit)) { // try { // using (ICSharpCode.OldNRefactory.IParser parser = ICSharpCode.OldNRefactory.ParserFactory.CreateParser (ICSharpCode.OldNRefactory.SupportedLanguage.CSharp, document.Editor.Document.OpenTextReader ())) { // parser.Parse (); // unit = parser.CompilationUnit; // document.ParsedDocument.SetTag (unit); // } // } catch (Exception) { // resolver = null; // return; // } // } // resolver.SetupParsedCompilationUnit (unit); // } }
public override ChunkParser CreateChunkParser(SpanParser spanParser, Mono.TextEditor.Document doc, ColorSheme style, SyntaxMode mode, LineSegment line) { return(new CSharpChunkParser(spanParser, doc, style, mode, line)); }
public void Draw(Cairo.Context cr, Cairo.Rectangle area, LineSegment lineSegment, double x, double y, double lineHeight) { int foundSegment = -1; if (lineSegment != null) { for (int i = 0; i < foldSegments.Count; i++) { FoldSegment segment = foldSegments[i]; if (segment.StartLine.Offset <= lineSegment.Offset && lineSegment.EndOffset <= segment.EndLine.EndOffset) { foundSegment = i; roles[i] = Roles.Between; if (segment.StartLine.Offset == lineSegment.Offset) { roles[i] |= Roles.Start; if (segment.IsFolded) { roles[i] |= Roles.End; } } if (segment.EndLine.Offset == lineSegment.Offset) { roles[i] |= Roles.End; } } } } TextViewMargin textViewMargin = editor.TextViewMargin; SyntaxMode mode = Document.SyntaxMode != null && editor.Options.EnableSyntaxHighlighting ? Document.SyntaxMode : SyntaxMode.Default; // Gdk.Rectangle lineArea = new Gdk.Rectangle (textViewMargin.XOffset, y, editor.Allocation.Width - textViewMargin.XOffset, editor.LineHeight); // Gdk.GC gc = new Gdk.GC (drawable); TextViewMargin.LayoutWrapper lineLayout = null; double brightness = HslColor.Brightness(editor.ColorStyle.Default.BackgroundColor); int colorCount = foldSegments.Count + 2; for (int segment = -1; segment <= foundSegment; segment++) { HslColor hslColor = new HslColor(editor.ColorStyle.Default.BackgroundColor); int colorPosition = segment + 1; if (segment == foldSegments.Count - 1) { colorPosition += 2; } 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; } Roles role = Roles.Between; double xPos = textViewMargin.XOffset; double rectangleWidth = editor.Allocation.Width - xPos; if (segment >= 0) { LineSegment segmentStartLine = foldSegments[segment].StartLine; lineLayout = textViewMargin.CreateLinePartLayout(mode, segmentStartLine, segmentStartLine.Offset, segmentStartLine.EditableLength, -1, -1); Pango.Rectangle rectangle = lineLayout.Layout.IndexToPos(GetFirstNonWsIdx(lineLayout.Layout.Text)); xPos = System.Math.Max(textViewMargin.XOffset, (textViewMargin.XOffset + rectangle.X / Pango.Scale.PangoScale - editor.HAdjustment.Value)); LineSegment segmentEndLine = foldSegments[segment].EndLine; lineLayout = textViewMargin.CreateLinePartLayout(mode, segmentEndLine, segmentEndLine.Offset, segmentEndLine.EditableLength, -1, -1); rectangle = lineLayout.Layout.IndexToPos(GetFirstNonWsIdx(lineLayout.Layout.Text)); xPos = System.Math.Min(xPos, System.Math.Max(textViewMargin.XOffset, (textViewMargin.XOffset + rectangle.X / Pango.Scale.PangoScale - editor.HAdjustment.Value))); int width = editor.Allocation.Width; if (editor.HAdjustment.Upper > width) { width = (int)(textViewMargin.XOffset + editor.HAdjustment.Upper - editor.HAdjustment.Value); } rectangleWidth = (int)(width - xPos - 6 * (segment + 1)); role = roles[segment]; } DrawRoundRectangle(cr, (role & Roles.Start) == Roles.Start, (role & Roles.End) == Roles.End, xPos, y, editor.LineHeight / 2, rectangleWidth, lineHeight); cr.Color = ColorSheme.ToCairoColor(hslColor); cr.Fill(); /* if (segment == foldSegments.Count - 1) { * cr.Color = new Cairo.Color (0.5, 0.5, 0.5, 1); * cr.Stroke (); * }*/ if (lineLayout != null && lineLayout.IsUncached) { lineLayout.Dispose(); lineLayout = null; } } // gc.Dispose (); }
void SetStyle() { colorStyle = SyntaxModeService.GetColorStyle(hexEditor.Style, PropertyService.Get("ColorScheme", "Default")); }