Esempio n. 1
0
        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;'>&lt;</SPAN><SPAN style='color:#204987;'>foo</SPAN><BR>
<SPAN style='color:#204987;'>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style='color:#f57800;'>attr1</SPAN><SPAN style='color:#000000;'>&nbsp;=</SPAN><SPAN style='color:#204987;'>&nbsp;</SPAN><SPAN style='color:#a40000;'>&quot;</SPAN><SPAN style='color:#a40000;'>1</SPAN><SPAN style='color:#a40000;'>&quot;</SPAN><BR>
<SPAN style='color:#204987;'>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style='color:#f57800;'>attr2</SPAN><SPAN style='color:#000000;'>&nbsp;=</SPAN><SPAN style='color:#204987;'>&nbsp;</SPAN><SPAN style='color:#a40000;'>&quot;</SPAN><SPAN style='color:#a40000;'>2</SPAN><SPAN style='color:#a40000;'>&quot;</SPAN><BR>
<SPAN style='color:#000000;'>/</SPAN><SPAN style='color:#000000;'>&gt;</SPAN></FONT>
</BODY></HTML>
"
                , generatedHtml);
        }
Esempio n. 2
0
        public void TestSimpleCSharpHtml()
        {
            if (Platform.IsWindows)
            {
                Assert.Inconclusive();
            }
            var data = Create("");

            data.ColorStyle          = SyntaxModeService.GetColorStyle("Tango");
            data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode(data.Document, "text/x-csharp");
            data.Text = "class Foo {}";
            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:#3364a4;'>class</SPAN><SPAN style='color:#000000;'>&nbsp;Foo&nbsp;</SPAN><SPAN style='color:#000000;'>{}</SPAN></FONT>
</BODY></HTML>
", generatedHtml);
        }
Esempio n. 3
0
 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();
         }
     };
 }