public void TestXml() { var data = Create( @"<foo attr1 = ""1"" attr2 = ""2"" />"); data.ColorStyle = SyntaxModeService.GetColorStyle("TangoLight"); data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode(data.Document, "application/xml"); string generatedRtf = RtfWriter.GenerateRtf(data); Assert.AreEqual( @"{\rtf1\ansi\deff0\adeflang1025 {\fonttbl {\f0\fnil\fprq1\fcharset128 Mono;} } {\colortbl ;\red68\green68\blue68;\red51\green100\blue164;\red245\green125\blue0;}\viewkind4\uc1\pard \f0 \fs20\cf1 \cf1 <\cf2 foo\line \tab\cf1 attr1 =\cf2 \cf3 ""1""\line \cf2\tab\cf1 attr2 =\cf2 \cf3 ""2""\line \cf1 />\line }" , generatedRtf); }
void CopyData(TextEditorData data, Selection selection) { copiedDocument = null; monoDocument = null; if (selection != null && data != null && data.Document != null) { copiedDocument = new Document(); monoDocument = new Document(); this.docStyle = data.ColorStyle; this.options = data.Options; this.mode = data.Document.SyntaxMode != null && data.Options.EnableSyntaxHighlighting ? data.Document.SyntaxMode : Mono.TextEditor.Highlighting.SyntaxMode.Default; switch (selection.SelectionMode) { case SelectionMode.Normal: isBlockMode = false; ISegment segment = selection.GetSelectionRange(data); copiedDocument.Text = this.mode.GetTextWithoutMarkup(data.Document, data.ColorStyle, segment.Offset, segment.Length); monoDocument.Text = this.mode.GetTextWithoutMarkup(data.Document, data.ColorStyle, segment.Offset, segment.Length); LineSegment line = data.Document.GetLineByOffset(segment.Offset); var spanStack = line.StartSpan.Clone(); SyntaxModeService.ScanSpans(data.Document, this.mode, this.mode, spanStack, line.Offset, segment.Offset); this.copiedDocument.GetLine(DocumentLocation.MinLine).StartSpan = spanStack; break; case SelectionMode.Block: isBlockMode = true; DocumentLocation visStart = data.LogicalToVisualLocation(selection.Anchor); DocumentLocation visEnd = data.LogicalToVisualLocation(selection.Lead); int startCol = System.Math.Min(visStart.Column, visEnd.Column); int endCol = System.Math.Max(visStart.Column, visEnd.Column); for (int lineNr = selection.MinLine; lineNr <= selection.MaxLine; lineNr++) { LineSegment curLine = data.Document.GetLine(lineNr); int col1 = curLine.GetLogicalColumn(data, startCol) - 1; int col2 = System.Math.Min(curLine.GetLogicalColumn(data, endCol) - 1, curLine.EditableLength); if (col1 < col2) { ((IBuffer)copiedDocument).Insert(copiedDocument.Length, data.Document.GetTextAt(curLine.Offset + col1, col2 - col1)); ((IBuffer)monoDocument).Insert(monoDocument.Length, data.Document.GetTextAt(curLine.Offset + col1, col2 - col1)); } if (lineNr < selection.MaxLine) { // Clipboard line end needs to be system dependend and not the document one. ((IBuffer)copiedDocument).Insert(copiedDocument.Length, Environment.NewLine); // \r in mono document stands for block selection line end. ((IBuffer)monoDocument).Insert(monoDocument.Length, "\r"); } } line = data.Document.GetLine(selection.MinLine); spanStack = line.StartSpan.Clone(); SyntaxModeService.ScanSpans(data.Document, this.mode, this.mode, spanStack, line.Offset, line.Offset + startCol); this.copiedDocument.GetLine(DocumentLocation.MinLine).StartSpan = spanStack; break; } } else { copiedDocument = null; } }
public void TestSimpleCSharpHtml() { if (Platform.IsWindows) { Assert.Inconclusive(); } var data = Create("class Foo {}"); data.ColorStyle = SyntaxModeService.GetColorStyle("TangoLight"); data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode(data.Document, "text/x-csharp"); string generatedHtml = HtmlWriter.GenerateHtml(data); Assert.AreEqual( @"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN""> <HTML> <HEAD> <META HTTP-EQUIV=""CONTENT-TYPE"" CONTENT=""text/html; charset=utf-8""> <META NAME=""GENERATOR"" CONTENT=""Mono Text Editor""> </HEAD> <BODY> <FONT face = 'Mono'> <SPAN style='color:#009695;'>class</SPAN><SPAN style='color:#444444;'> Foo </SPAN><SPAN style='color:#444444;'>{}</SPAN></FONT> </BODY></HTML> ", generatedHtml); }
public void TestXml() { if (Platform.IsWindows) { Assert.Inconclusive(); } var data = Create(""); data.ColorStyle = SyntaxModeService.GetColorStyle("Tango"); data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode(data.Document, "application/xml"); data.Text = @"<foo attr1 = ""1"" attr2 = ""2"" />"; SyntaxModeService.WaitUpdate(data.Document); string generatedHtml = HtmlWriter.GenerateHtml(data); Assert.AreEqual( @"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN""> <HTML> <HEAD> <META HTTP-EQUIV=""CONTENT-TYPE"" CONTENT=""text/html; charset=utf-8""> <META NAME=""GENERATOR"" CONTENT=""Mono Text Editor""> </HEAD> <BODY> <FONT face = 'Mono'> <SPAN style='color:#000000;'><</SPAN><SPAN style='color:#204987;'>foo</SPAN><BR> <SPAN style='color:#204987;'> </SPAN><SPAN style='color:#f57800;'>attr1</SPAN><SPAN style='color:#000000;'> =</SPAN><SPAN style='color:#204987;'> </SPAN><SPAN style='color:#a40000;'>"</SPAN><SPAN style='color:#a40000;'>1</SPAN><SPAN style='color:#a40000;'>"</SPAN><BR> <SPAN style='color:#204987;'> </SPAN><SPAN style='color:#f57800;'>attr2</SPAN><SPAN style='color:#000000;'> =</SPAN><SPAN style='color:#204987;'> </SPAN><SPAN style='color:#a40000;'>"</SPAN><SPAN style='color:#a40000;'>2</SPAN><SPAN style='color:#a40000;'>"</SPAN><BR> <SPAN style='color:#000000;'>/</SPAN><SPAN style='color:#000000;'>></SPAN></FONT> </BODY></HTML> " , generatedHtml); }
public void TestXml() { var data = Create( @"<foo attr1 = ""1"" attr2 = ""2"" />"); data.ColorStyle = SyntaxModeService.GetColorStyle("TangoLight"); data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode(data.Document, "application/xml"); string generatedHtml = HtmlWriter.GenerateHtml(data); Console.WriteLine(generatedHtml); Assert.AreEqual( @"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN""> <HTML> <HEAD> <META HTTP-EQUIV=""CONTENT-TYPE"" CONTENT=""text/html; charset=utf-8""> <META NAME=""GENERATOR"" CONTENT=""Mono Text Editor""> </HEAD> <BODY> <FONT face = 'Mono'> <SPAN style='color:#444444;'><</SPAN><SPAN style='color:#3364a4;'>foo</SPAN><BR> <SPAN style='color:#3364a4;'> </SPAN><SPAN style='color:#444444;'>attr1</SPAN><SPAN style='color:#444444;'> =</SPAN><SPAN style='color:#3364a4;'> </SPAN><SPAN style='color:#f57d00;'>"</SPAN><SPAN style='color:#f57d00;'>1</SPAN><SPAN style='color:#f57d00;'>"</SPAN><BR> <SPAN style='color:#3364a4;'> </SPAN><SPAN style='color:#444444;'>attr2</SPAN><SPAN style='color:#444444;'> =</SPAN><SPAN style='color:#3364a4;'> </SPAN><SPAN style='color:#f57d00;'>"</SPAN><SPAN style='color:#f57d00;'>2</SPAN><SPAN style='color:#f57d00;'>"</SPAN><BR> <SPAN style='color:#444444;'>/</SPAN><SPAN style='color:#444444;'>></SPAN></FONT> </BODY></HTML> " , generatedHtml); }
protected override void OnShown() { var style = SyntaxModeService.GetColorStyle (IdeApp.Preferences.ColorScheme); Theme.SetFlatColor (style.CompletionWindow.Color); if (style.CompletionWindow.HasBorderColor) Theme.BorderColor = style.CompletionWindow.BorderColor; base.OnShown (); }
internal void SetDefaultScheme() { var scheme = SyntaxModeService.GetColorStyle(IdeApp.Preferences.ColorScheme); Theme.SetSchemeColors(scheme); foreColor = scheme.PlainText.Foreground; headLabel.ModifyFg(StateType.Normal, foreColor.ToGdkColor()); }
public static string GetMarkup(string input, string syntaxMode) { Document doc = new Document(); doc.SyntaxMode = SyntaxModeService.GetSyntaxMode(syntaxMode); doc.Text = input; return(doc.SyntaxMode.GetMarkup(doc, TextEditorOptions.DefaultOptions, SyntaxModeService.GetColorStyle(null, "TangoLight"), 0, doc.Length, false)); }
public static string GetMarkup(string input, string syntaxMode) { var data = new TextEditorData(new TextDocument(input)); data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode(data.Document, syntaxMode); data.ColorStyle = SyntaxModeService.GetColorStyle("TangoLight"); return(data.GetMarkup(0, data.Length, false)); }
public static ColorScheme GetColorStyle(this ITextEditorOptions options) { if (options == null) { throw new ArgumentNullException("options"); } return(SyntaxModeService.GetColorStyle(options.ColorScheme)); }
public void TestSimpleCSharpRtf() { var data = Create("class Foo {}"); var style = SyntaxModeService.GetColorStyle(null, "TangoLight"); ISyntaxMode mode = SyntaxModeService.GetSyntaxMode(data.Document, "text/x-csharp"); string generatedRtf = RtfWriter.GenerateRtf(data.Document, mode, style, data.Options); Assert.AreEqual( @"{\rtf1\ansi\deff0\adeflang1025{\fonttbl{\f0\fnil\fprq1\fcharset128 Mono;}}{\colortbl ;\red92\green53\blue102;\red0\green0\blue0;}\viewkind4\uc1\pard\f0\fs20\cf1\b\cf1 class\b0\cf2 Foo \{\}\par" + Environment.NewLine + "}", generatedRtf); }
public void TestSimpleCSharpHtml() { var data = Create("class Foo {}"); var style = SyntaxModeService.GetColorStyle("TangoLight"); ISyntaxMode mode = SyntaxModeService.GetSyntaxMode(data.Document, "text/x-csharp"); string generatedHtml = HtmlWriter.GenerateHtml(data.Document, mode, style, data.Options); Assert.AreEqual( @"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN""><HTML><BODY><FONT face = 'Mono'><SPAN style = 'color:#009695;' >class</SPAN><SPAN style = 'color:#444444;' > Foo </SPAN><SPAN style = 'color:#444444;' >{}</SPAN></FONT></BODY></HTML>", generatedHtml); }
protected override void OnShown() { var scheme = SyntaxModeService.GetColorStyle(IdeApp.Preferences.ColorScheme); Theme.SetSchemeColors(scheme); foreColor = scheme.PlainText.Foreground; headlabel.ModifyFg(StateType.Normal, foreColor.ToGdkColor()); base.OnShown(); }
/// <summary> /// Performs a one-time registration of the report syntax highlighting rules. /// This will only run once, the first time the user clicks on a report node. /// </summary> private void LoadReportSyntaxMode() { string resource = "ApsimNG.Resources.SyntaxHighlighting.Report.xml"; using (System.IO.Stream s = GetType().Assembly.GetManifestResourceStream(resource)) { ProtoTypeSyntaxModeProvider p = new ProtoTypeSyntaxModeProvider(SyntaxMode.Read(s)); SyntaxModeService.InstallSyntaxMode("text/x-apsimreport", p); } }
public void TestBug5628() { var data = Create("class Foo {}"); var style = SyntaxModeService.GetColorStyle(null, "TangoLight"); ISyntaxMode mode = null; string generatedRtf = RtfWriter.GenerateRtf(data.Document, mode, style, data.Options); Assert.AreEqual( @"{\rtf1\ansi\deff0\adeflang1025{\fonttbl{\f0\fnil\fprq1\fcharset128 Mono;}}{\colortbl ;}\viewkind4\uc1\pard\f0\fs20\cf1class Foo \{\}}", generatedRtf); }
protected override string OnGetValue() { var style = base.OnGetValue(); if (SyntaxModeService.Styles.Contains(style)) { return(style); } var defaultStyle = SyntaxModeService.GetDefaultColorStyleName(); LoggingService.LogWarning("Highlighting Theme \"{0}\" not found, using default \"{1}\" instead", style, defaultStyle); Value = defaultStyle; return(SyntaxModeService.GetDefaultColorStyleName()); }
public static string[] GetCommentTags(string fileName) { //Document doc = IdeApp.Workbench.ActiveDocument; string loadedMimeType = DesktopService.GetMimeTypeForUri(fileName); SyntaxMode mode = null; foreach (string mt in DesktopService.GetMimeTypeInheritanceChain(loadedMimeType)) { mode = SyntaxModeService.GetSyntaxMode(mt); if (mode != null) { break; } } if (mode == null) { return(null); } List <string> ctags; if (mode.Properties.TryGetValue("LineComment", out ctags) && ctags.Count > 0) { return(new string [] { ctags [0] }); } List <string> tags = new List <string> (); if (mode.Properties.TryGetValue("BlockCommentStart", out ctags)) { tags.Add(ctags [0]); } if (mode.Properties.TryGetValue("BlockCommentEnd", out ctags)) { tags.Add(ctags [0]); } if (tags.Count == 2) { return(tags.ToArray()); } else { return(null); } }
public void TestBug7386() { var data = Create("✔"); data.ColorStyle = SyntaxModeService.GetColorStyle("TangoLight"); string generatedRtf = RtfWriter.GenerateRtf(data); Assert.AreEqual( @"{\rtf1\ansi\deff0\adeflang1025 {\fonttbl {\f0\fnil\fprq1\fcharset128 Mono;} } {\colortbl ;}\viewkind4\uc1\pard \f0 \fs20\cf1 \uc1\u10004*}", generatedRtf); }
public void TestBug5628() { var data = Create("class Foo {}"); data.ColorStyle = SyntaxModeService.GetColorStyle("TangoLight"); string generatedRtf = RtfWriter.GenerateRtf(data); Assert.AreEqual( @"{\rtf1\ansi\deff0\adeflang1025 {\fonttbl {\f0\fnil\fprq1\fcharset128 Mono;} } {\colortbl ;\red68\green68\blue68;}\viewkind4\uc1\pard \f0 \fs20\cf1 \cf1 class Foo \{\}\line }", generatedRtf); }
public static void LoadCustomStylesAndModes() { bool success = true; if (!Directory.Exists(SyntaxModePath)) { try { Directory.CreateDirectory(SyntaxModePath); } catch (Exception e) { success = false; LoggingService.LogError("Can't create syntax mode directory", e); } } if (success) { SyntaxModeService.LoadStylesAndModes(SyntaxModePath); } }
private void LoadSetting() { TextEditorOptions options = new TextEditorOptions(); options.ColorScheme = "Moscrif"; options.ShowInvalidLines = true; options.ShowLineNumberMargin = true; options.AutoIndent = true; options.TabSize = MainClass.Settings.SourceEditorSettings.TabSpace; //8; options.TabsToSpaces = MainClass.Settings.SourceEditorSettings.TabsToSpaces; options.ShowEolMarkers = MainClass.Settings.SourceEditorSettings.ShowEolMarker; options.ShowRuler = MainClass.Settings.SourceEditorSettings.ShowRuler; options.RulerColumn = MainClass.Settings.SourceEditorSettings.RulerColumn; options.ShowTabs = MainClass.Settings.SourceEditorSettings.ShowTab; options.ShowSpaces = MainClass.Settings.SourceEditorSettings.ShowSpaces; options.EnableAnimations = MainClass.Settings.SourceEditorSettings.EnableAnimations; options.ShowLineNumberMargin = MainClass.Settings.SourceEditorSettings.ShowLineNumber; options.HighlightCaretLine = true; options.DefaultEolMarker = "\n"; options.OverrideDocumentEolMarker = true; if (!String.IsNullOrEmpty(MainClass.Settings.SourceEditorSettings.EditorFont)) { options.FontName = MainClass.Settings.SourceEditorSettings.EditorFont; } try{ //check parse style Mono.TextEditor.Highlighting.Style style = SyntaxModeService.GetColorStyle(null, "Moscrif"); }catch (Exception ex) { options.ColorScheme = ""; //MessageDialogs msd = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_load_styles"),ex.Message, Gtk.MessageType.Error,null); //msd.ShowDialog(); Tool.Logger.Error(MainClass.Languages.Translate("error_load_styles")); Tool.Logger.Error(ex.Message); } editor.Options = options; // editor.Options.ShowFoldMargin = true; }
void UpdateStyles(object sender = null, EventArgs e = null) { highlightStyle = SyntaxModeService.GetColorStyle(IdeApp.Preferences.ColorScheme); if (!highlightStyle.FitsIdeTheme(IdeApp.Preferences.UserInterfaceTheme)) { highlightStyle = SyntaxModeService.GetDefaultColorStyle(Ide.IdeApp.Preferences.UserInterfaceTheme); } if (markupCache != null) { markupCache = new List <Tuple <SearchResult, string> > (); } if (IsRealized) { store.Foreach((model, path, iter) => { model.EmitRowChanged(path, iter); return(false); }); } }
internal void SetDefaultScheme() { var scheme = SyntaxModeService.GetColorStyle(IdeApp.Preferences.ColorScheme); if (!scheme.FitsIdeSkin(IdeApp.Preferences.UserInterfaceSkin)) { scheme = SyntaxModeService.GetDefaultColorStyle(IdeApp.Preferences.UserInterfaceSkin); } Theme.SetSchemeColors(scheme); foreColor = Styles.PopoverWindow.DefaultTextColor.ToCairoColor(); headLabel.ModifyFg(StateType.Normal, foreColor.ToGdkColor()); headLabel.FontDescription = FontService.GetFontDescription("Editor").CopyModified(Styles.FontScale11); Theme.Font = FontService.SansFont.CopyModified(Styles.FontScale11); Theme.ShadowColor = Styles.PopoverWindow.ShadowColor.ToCairoColor(); if (this.Visible) { ShowOverload(); } }
public ListWidget(ListWindow win) { this.win = win; this.Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask; DefaultCompletionString = ""; categoryLayout = new Pango.Layout(this.PangoContext); noMatchLayout = new Pango.Layout(this.PangoContext); layout = new Pango.Layout(this.PangoContext); layout.Wrap = Pango.WrapMode.Char; var style = SyntaxModeService.GetColorStyle(IdeApp.Preferences.ColorScheme); SetFont(); textColor = style.CompletionText.Foreground; highlightColor = style.CompletionHighlight.GetColor("color"); backgroundColor = style.CompletionText.Background; selectedItemColor = style.CompletionSelectedText; selectedItemInactiveColor = style.CompletionSelectedInactiveText; selectionBorderColor = style.CompletionBorder.GetColor("color"); selectionBorderInactiveColor = style.CompletionInactiveBorder.GetColor("color"); }
static CSharpSyntaxMode() { MonoDevelop.Debugger.DebuggingService.DisableConditionalCompilation += DispatchService.GuiDispatch(new EventHandler <DocumentEventArgs> (OnDisableConditionalCompilation)); if (IdeApp.Workspace != null) { IdeApp.Workspace.ActiveConfigurationChanged += delegate { foreach (var doc in IdeApp.Workbench.Documents) { TextEditorData data = doc.Editor; if (data == null) { continue; } // Force syntax mode reparse (required for #if directives) var editor = doc.Editor; if (editor != null) { if (data.Document.SyntaxMode is SyntaxMode) { ((SyntaxMode)data.Document.SyntaxMode).UpdateDocumentHighlighting(); SyntaxModeService.WaitUpdate(data.Document); } editor.Parent.TextViewMargin.PurgeLayoutCache(); doc.ReparseDocument(); editor.Parent.QueueDraw(); } } }; } CommentTag.SpecialCommentTagsChanged += (sender, e) => { UpdateCommentRule(); var actDoc = IdeApp.Workbench.ActiveDocument; if (actDoc != null && actDoc.Editor != null) { actDoc.UpdateParseDocument(); actDoc.Editor.Parent.TextViewMargin.PurgeLayoutCache(); actDoc.Editor.Parent.QueueDraw(); } }; }
public void TestBug7386() { if (Platform.IsWindows) { Assert.Inconclusive(); } var data = Create("✔"); data.ColorStyle = SyntaxModeService.GetColorStyle("Tango"); string generatedRtf = RtfWriter.GenerateRtf(data); Assert.AreEqual( @"{\rtf1\ansi\deff0\adeflang1025 {\fonttbl {\f0\fnil\fprq1\fcharset128 Mono;} } {\colortbl ;\red0\green0\blue0;}\viewkind4\uc1\pard \f0 \fs20\cf1 \cf1 \uc1\u10004*\line }", generatedRtf); }
public void TestChunkValidity() { const string text = @"System.Console.WriteLine();"; var data = new TextEditorData(new TextDocument(@"namespace FooBar { class Test { " + text + @" } }")); data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode(data.Document, "text/x-csharp"); data.ColorStyle = SyntaxModeService.GetColorStyle("Light"); var line = data.GetLine(5); var chunks = data.GetChunks(line, line.Offset + 3, line.Length - 3); StringBuilder sb = new StringBuilder(); foreach (var chunk in chunks) { sb.Append(data.GetTextAt(chunk)); } Assert.AreEqual(text, sb.ToString()); }
public void TestSimpleCSharpRtf() { if (Platform.IsWindows) { Assert.Inconclusive(); } var data = Create("class Foo {}"); data.ColorStyle = SyntaxModeService.GetColorStyle("Tango"); data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode(data.Document, "text/x-csharp"); string generatedRtf = RtfWriter.GenerateRtf(data); Assert.AreEqual( @"{\rtf1\ansi\deff0\adeflang1025 {\fonttbl {\f0\fnil\fprq1\fcharset128 Mono;} } {\colortbl ;\red51\green100\blue164;\red0\green0\blue0;}\viewkind4\uc1\pard \f0 \fs20\cf1 \cf1 class\cf2 Foo \{\}\line }", generatedRtf); }
public ListWindow(Gtk.WindowType type) : base(type) { vbox = new VBox(); list = new ListWidget(this); list.SelectionChanged += new EventHandler(OnSelectionChanged); list.ScrollEvent += new ScrollEventHandler(OnScrolled); scrollbar = new MonoDevelop.Components.CompactScrolledWindow(); scrollbar.Child = list; list.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { if (args.Event.Button == 1 && args.Event.Type == Gdk.EventType.TwoButtonPress) { DoubleClick(); } }; vbox.PackEnd(scrollbar, true, true, 0); ContentBox.Add(vbox); this.AutoSelect = true; this.TypeHint = WindowTypeHint.Menu; Theme.CornerRadius = 4; var style = SyntaxModeService.GetColorStyle(IdeApp.Preferences.ColorScheme); Theme.SetFlatColor(style.CompletionText.Background); }
protected override void OnRealized() { base.OnRealized(); highlightStyle = SyntaxModeService.GetColorStyle(IdeApp.Preferences.ColorScheme); }