Author: mkrueger
Date: 2008-01-25 07:59:17 -0500 (Fri, 25 Jan 2008)
New Revision: 93896

Modified:
   trunk/monodevelop/main/src/addins/Mono.Texteditor/C64Style.xml
   trunk/monodevelop/main/src/addins/Mono.Texteditor/CSharpSyntaxMode.xml
   trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/ChunkStyle.cs
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/Style.cs
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditorOptions.cs
   trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml
Log:
* OblivionStyle.xml, Mono.TextEditor/DefaultEditActions.cs,
  Mono.TextEditor/TextEditorOptions.cs,
  Mono.TextEditor/GutterMargin.cs,
  Mono.TextEditor.Highlighting/SyntaxMode.cs,
  Mono.TextEditor.Highlighting/Style.cs,
  Mono.TextEditor.Highlighting/ChunkStyle.cs, CSharpSyntaxMode.xml,
  C64Style.xml: Worked on Syntax highlighting

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/C64Style.xml
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/C64Style.xml      
2008-01-25 12:27:30 UTC (rev 93895)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/C64Style.xml      
2008-01-25 12:59:17 UTC (rev 93896)
@@ -45,10 +45,10 @@
        <Color name="FoldLineHighlighted">#FFFFFF</Color>
        <Color name="FoldToggleMarker">#97A0EF</Color>
 
-       <Color name="Comment">#BBBBBB</Color>
-       <Color name="String">#CC44CC</Color>
+       <Color name="Comment1">#BBBBBB</Color>
+       <Color name="Literal">#CC44CC</Color>
        <Color name="Punctuation">#97A0EF</Color>
-       <Color name="PreProcessor">#00CC55</Color>
+       <Color name="PreProcessorDirective1">#00CC55</Color>
        <Color name="Keyword1">#DD8855</Color>
        <Color name="Keyword2">#664400</Color>
        <Color name="Keyword3">#AAFF66</Color>

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/CSharpSyntaxMode.xml
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/CSharpSyntaxMode.xml      
2008-01-25 12:27:30 UTC (rev 93895)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/CSharpSyntaxMode.xml      
2008-01-25 12:59:17 UTC (rev 93896)
@@ -25,31 +25,31 @@
 <SyntaxMode name = "C#" mimeType="text/x-csharp">
        <Delimiters>&amp;&lt;&gt;~!%^*()-+=|\#/{}[]:;"' ,       .?</Delimiters>
 
-       <EolSpan color = "PreProcessorDirective" rule="PreProcessor">#</EolSpan>
-       <EolSpan color = "Comment" rule="XmlDocumentation">///</EolSpan>
-       <EolSpan color = "Comment" rule="Comment" constraint="!/">//</EolSpan>
+       <EolSpan color = "PreProcessorDirective1" 
rule="PreProcessor">#</EolSpan>
+       <EolSpan color = "Comment1" rule="XmlDocumentation">///</EolSpan>
+       <EolSpan color = "Comment1" rule="Comment" constraint="!/">//</EolSpan>
        
-       <Span color = "Comment" rule="Comment">
+       <Span color = "Comment1" rule="Comment">
                <Begin>/*</Begin>
                <End>*/</End>
        </Span>
        
-       <Span color = "String" stopateol = "false" escape='"'>
+       <Span color = "Literal" stopateol = "false" escape='"'>
                <Begin>@"</Begin>
                <End>"</End>
        </Span>
 
-       <Span color = "String" stopateol = "true" escape="\">
+       <Span color = "Literal" stopateol = "true" escape="\">
                <Begin>"</Begin>
                <End>"</End>
        </Span>
 
-       <Span color = "String" stopateol = "true" escape="\">
+       <Span color = "Literal" stopateol = "true" escape="\">
                <Begin>&apos;</Begin>
                <End>&apos;</End>
        </Span>
        
-       <Keywords color = "Keyword1" weight="Bold">
+       <Keywords color = "Keyword1">
                <Word>as</Word>
                <Word>is</Word>
                <Word>new</Word>
@@ -98,7 +98,7 @@
                <Word>value</Word>
        </Keywords>
        
-       <Keywords color = "Keyword2" weight="Bold">
+       <Keywords color = "Keyword2">
                <Word>bool</Word>
                <Word>byte</Word>
                <Word>char</Word>
@@ -118,7 +118,7 @@
                <Word>string</Word>
        </Keywords>
        
-       <Keywords color = "Keyword3" weight="Bold">
+       <Keywords color = "Keyword3">
                <Word>class</Word>
                <Word>interface</Word>
                <Word>delegate</Word>
@@ -150,7 +150,7 @@
        </Keywords>
 
        <Rule name = "PreProcessor" color = "PreProcessorDirective">
-               <Keywords weight="Bold">
+               <Keywords color="PreProcessorDirective2">
                        <Word>if</Word>
                        <Word>else</Word>
                        <Word>elif</Word>
@@ -167,7 +167,7 @@
        </Rule>
        
        <Rule name = "Comment">
-               <Keywords weight="Italic" ignorecase="True">
+               <Keywords color="Comment4" ignorecase="True">
                        <Word>TODO</Word>
                        <Word>FIXME</Word>
                        <Word>HACK</Word>
@@ -176,7 +176,7 @@
        </Rule>
        
        <Rule name = "XmlDocumentation">
-               <Keywords weight="Bold">
+               <Keywords color="Comment2">
                        <Word>c</Word>
                        <Word>code</Word>
                        <Word>example</Word>

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-01-25 
12:27:30 UTC (rev 93895)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-01-25 
12:59:17 UTC (rev 93896)
@@ -1,5 +1,23 @@
 2008-01-25  Mike Krüger <[EMAIL PROTECTED]> 
 
+       * OblivionStyle.xml, Mono.TextEditor/DefaultEditActions.cs,
+         Mono.TextEditor/TextEditorOptions.cs, Mono.TextEditor/GutterMargin.cs,
+         Mono.TextEditor.Highlighting/SyntaxMode.cs,
+         Mono.TextEditor.Highlighting/Style.cs,
+         Mono.TextEditor.Highlighting/ChunkStyle.cs, CSharpSyntaxMode.xml,
+         C64Style.xml: Worked on Syntax highlighting
+
+2008-01-25  Mike Krüger <[EMAIL PROTECTED]> 
+
+       * OblivionStyle.xml, Mono.TextEditor/DefaultEditActions.cs,
+         Mono.TextEditor/TextEditorOptions.cs, Mono.TextEditor/GutterMargin.cs,
+         Mono.TextEditor.Highlighting/SyntaxMode.cs,
+         Mono.TextEditor.Highlighting/Style.cs,
+         Mono.TextEditor.Highlighting/ChunkStyle.cs, CSharpSyntaxMode.xml,
+         C64Style.xml: Worked on Syntax highlighting
+
+2008-01-25  Mike Krüger <[EMAIL PROTECTED]> 
+
        * Mono.TextEditor/DefaultEditActions.cs, Mono.TextEditor/TextEditor.cs,
          Mono.TextEditor/TextEditorOptions.cs: Optimized drawing a bit, added
          syntax mode enabled option.

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
     2008-01-25 12:27:30 UTC (rev 93895)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
     2008-01-25 12:59:17 UTC (rev 93896)
@@ -707,7 +707,7 @@
                        rtf.Append (@"{\colortbl ;");
                        Dictionary<Gdk.Color, int> colorTable = new 
Dictionary<Gdk.Color,int> ();
                        for (int i = 0; i < 
Mono.TextEditor.Highlighting.Style.ColorTableCount; i++) {
-                               Gdk.Color color = data.ColorStyle.GetColor 
(Mono.TextEditor.Highlighting.Style.GetColorName (i));
+                               Gdk.Color color = data.ColorStyle.GetColor 
(Mono.TextEditor.Highlighting.Style.GetColorName (i)).Color;
                                rtf.Append (@"\red");
                                rtf.Append (color.Red);
                                rtf.Append (@"\green");

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
   2008-01-25 12:27:30 UTC (rev 93895)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
   2008-01-25 12:59:17 UTC (rev 93896)
@@ -31,21 +31,30 @@
 
 namespace Mono.TextEditor
 {
-       public class GutterMargin : AbstractMargin
+       public class GutterMargin : AbstractMargin, System.IDisposable
        {
                TextEditor editor;
                Pango.Layout layout;
-               
+               int width;
                public GutterMargin (TextEditor editor)
                {
                        this.editor = editor;
                        layout = new Pango.Layout (editor.PangoContext);
+                       TextEditorOptions.Changed += OptionsChanged;
+                       OptionsChanged (this, EventArgs.Empty);
+               }
+               
+               protected virtual void OptionsChanged (object sender, EventArgs 
args)
+               {
                        layout.FontDescription = TextEditorOptions.Options.Font;
                }
                
                public override int Width {
                        get {
-                               return 5 + (int)(System.Math.Max (2, 
System.Math.Log10 (editor.Splitter.LineCount)) * 10);
+                               layout.SetText 
(editor.Splitter.LineCount.ToString ());
+                               int height;
+                               layout.GetPixelSize (out width, out height);
+                               return 5 + width;
                        }
                }
                
@@ -80,5 +89,10 @@
                                win.DrawLayout (gc, x + 1, y, layout);
                        }
                }
+
+               public void Dispose ()
+               {
+                       TextEditorOptions.Changed -= OptionsChanged;
+               }
        }
 }
\ No newline at end of file

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditorOptions.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditorOptions.cs
      2008-01-25 12:27:30 UTC (rev 93895)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditorOptions.cs
      2008-01-25 12:59:17 UTC (rev 93896)
@@ -226,7 +226,6 @@
                        }
                }
                
-               
                public virtual Pango.FontDescription Font {
                        get {
                                return Pango.FontDescription.FromString 
(FontName);

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/ChunkStyle.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/ChunkStyle.cs
        2008-01-25 12:27:30 UTC (rev 93895)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/ChunkStyle.cs
        2008-01-25 12:59:17 UTC (rev 93896)
@@ -76,6 +76,13 @@
                        this.color = color;
                        this.bold  = bold;
                }
+               
+               public ChunkStyle (Gdk.Color color, bool bold, bool italic)
+               {
+                       this.color = color;
+                       this.bold  = bold;
+                       this.italic  = italic;
+               }
 
                public override string ToString ()
                {

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/Style.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/Style.cs
     2008-01-25 12:27:30 UTC (rev 93895)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/Style.cs
     2008-01-25 12:59:17 UTC (rev 93896)
@@ -26,6 +26,7 @@
 //
 
 using System;
+using System.Collections.Generic;
 using System.Xml;
 using Gdk;
 
@@ -42,7 +43,8 @@
                Color lineNumberFg, lineNumberBg, lineNumberFgHighlighted;
                Color iconBarBg, iconBarSeperator;
                Color foldLine, foldLineHighlighted, foldBg, foldToggleMarker;
-               Color comment, str, punctuation, keyword1, keyword2, keyword3, 
keyword4, preprocessor; 
+               
+               Dictionary<string, ChunkStyle> highlightingStyles = new 
Dictionary<string, ChunkStyle> (); 
 
                public virtual Color Default {
                        get {
@@ -159,14 +161,6 @@
 
                public Style ()
                {
-                       comment      = new Gdk.Color (0, 0, 255);
-                       str          = new Gdk.Color (255, 0, 255);
-                       punctuation  = new Gdk.Color (0, 0, 0);
-                       keyword1     = new Gdk.Color (165, 42, 42);
-                       keyword2     = new Gdk.Color (46, 139, 87);
-                       keyword3     = new Gdk.Color (165, 42, 42);
-                       keyword4     = new Gdk.Color (0, 200, 0);
-                       preprocessor = new Gdk.Color (0, 200, 0);
                        def          = new Gdk.Color (0, 0, 0); 
                        
                        lineNumberBg = new Gdk.Color (255, 255, 255);
@@ -179,23 +173,49 @@
                        foldToggleMarker    = new Gdk.Color (0, 0, 0);
                        
                        background = new Gdk.Color (255, 255, 255);
-                       selectedBg   = new Gdk.Color (96, 87, 210);
-                       selectedFg   = new Gdk.Color (255, 255, 255);
-                       lineMarker  = new Gdk.Color (200, 255, 255);
-                       ruler       = new Gdk.Color (187, 187, 187);
-                       whitespaceMarker = new Gdk.Color (187, 187, 187);
+                       selectedBg = new Gdk.Color (96, 87, 210);
+                       selectedFg = new Gdk.Color (255, 255, 255);
+                       lineMarker = new Gdk.Color (200, 255, 255);
+                       ruler      = new Gdk.Color (187, 187, 187);
+                       whitespaceMarker  = new Gdk.Color (187, 187, 187);
                        invalidLineMarker = new Gdk.Color (210, 0, 0);
                        
+                       foreach (string color in colorTable) {
+                               highlightingStyles [color] = new 
Mono.TextEditor.ChunkStyle (def, false, false);
+                       }
+                       highlightingStyles ["Comment1"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (0, 0, 255), false, false);
+                       highlightingStyles ["Comment2"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (0, 0, 255), true, false);
+                       highlightingStyles ["Comment3"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (0, 0, 255), false, false);
+                       highlightingStyles ["Comment4"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (0, 0, 255), false, true);
+                       
+                       highlightingStyles ["Keyword1"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (165, 42, 42), true, false);
+                       highlightingStyles ["Keyword2"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (46, 139, 87), true, false);
+                       highlightingStyles ["Keyword3"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (165, 42, 42), true, false);
+                       highlightingStyles ["Keyword4"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (0, 200, 0), true, false);
+
+                       highlightingStyles ["PreProcessorDirective1"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (0, 200, 0), false, false);
+                       highlightingStyles ["PreProcessorDirective2"] = new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (0, 200, 0), true, false);
                }
-               static readonly string[] colorTable = new string[] { "Comment", 
-                                           "String",
-                                           "Punctuation",
-                                           "Keyword1",
-                                           "Keyword2",
-                                           "Keyword3",
-                                           "Keyword4",
-                                           "PreProcessorDirective" };
                
+               static readonly string[] colorTable = new string[] { 
+                       "Comment1", 
+                       "Comment2",
+                       "Comment3", 
+                       "Comment4",
+                       
+                       "Digit",
+                       "Literal",
+                       "Punctuation",
+                       
+            "Keyword1",
+            "Keyword2",
+            "Keyword3",
+            "Keyword4",
+                       
+                       "PreProcessorDirective1", 
+                       "PreProcessorDirective2", 
+               };
+               
                public static int ColorTableCount {
                        get {
                                return colorTable.Length;
@@ -207,6 +227,11 @@
                        return colorTable[number];
                }
                
+               public static bool IsTableColor (string name)
+               {
+                       return GetColorNumber (name) >= 0;
+               }
+               
                public static int GetColorNumber (string name)
                {
                        for (int i = 0; i < colorTable.Length; i++) {
@@ -216,29 +241,20 @@
                        return -1;
                }
                
-               public Gdk.Color GetColor (string name)
+               public ChunkStyle GetColor (string name)
                {
-                       switch (name) {
-                       case "Comment":
-                               return comment;
-                       case "String":
-                               return str;
-                       case "Punctuation":
-                               return punctuation;
-                       case "Keyword1":
-                               return keyword1;
-                       case "Keyword2":
-                               return keyword2;
-                       case "Keyword3":
-                               return keyword3;
-                       case "Keyword4":
-                               return keyword4;
-                       case "PreProcessorDirective":
-                               return preprocessor;
+                       return this.highlightingStyles [name];
+               }
+               public void SetTableColor (string name, string weight, string 
value)
+               {
+                       Gdk.Color color = new Color ();
+                       if (!Gdk.Color.Parse (value, ref color)) {
+                               throw new Exception ("Can't parse color: " + 
value);
                        }
-                       return def;
+                       highlightingStyles [name] = new 
Mono.TextEditor.ChunkStyle (color, 
+                                                                               
    weight == null ? false : weight.ToUpper ().IndexOf ("BOLD") > 0,
+                                                                               
    weight == null ? false : weight.ToUpper ().IndexOf ("ITALIC") > 0);
                }
-               
                public void SetColor (string name, string value)
                {
                        Gdk.Color color = new Color ();
@@ -297,31 +313,6 @@
                        case "FoldToggleMarker":
                                this.foldToggleMarker = color;
                                break;
-                               
-                       case "Comment":
-                               this.comment = color;
-                               break;
-                       case "String":
-                               this.str = color;
-                               break;
-                       case "Punctuation":
-                               this.punctuation = color;
-                               break;
-                       case "PreProcessor":
-                               this.preprocessor = color;
-                               break;
-                       case "Keyword1":
-                               this.keyword1 = color;
-                               break;
-                       case "Keyword2":
-                               this.keyword2 = color;
-                               break;
-                       case "Keyword3":
-                               this.keyword3 = color;
-                               break;
-                       case "Keyword4":
-                               this.keyword4 = color;
-                               break;
                        default:
                                throw new Exception ("color  " + name + " 
invalid.");
                        }
@@ -337,8 +328,15 @@
                                        result.description = 
reader.GetAttribute ("_description");
                                        return true;
                                case "Color":
-                                       result.SetColor (reader.GetAttribute 
("name"),
-                                                        
reader.ReadElementContentAsString ());
+                                       string name = reader.GetAttribute 
("name"); 
+                                       if (IsTableColor (name)) {
+                                               result.SetTableColor (name,
+                                                                
reader.GetAttribute ("weight"),
+                                                                
reader.ReadElementContentAsString ());
+                                       } else {
+                                               result.SetColor (name,
+                                                                
reader.ReadElementContentAsString ());
+                                       }
                                        return true;
                                }
                                return false;

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs
        2008-01-25 12:27:30 UTC (rev 93895)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs
        2008-01-25 12:59:17 UTC (rev 93896)
@@ -98,14 +98,12 @@
                        
                        ChunkStyle GetChunkStyleColor (Stack<Span> spanStack, 
Keywords word)
                        {
-                               ChunkStyle result = new ChunkStyle ();
+                               ChunkStyle result ;
                                if (!String.IsNullOrEmpty (word.Color)) {
-                                       result.Color = style.GetColor 
(word.Color);
+                                       result = style.GetColor (word.Color);
                                } else {
-                                       result.Color = spanStack.Count > 0 ? 
style.GetColor (spanStack.Peek ().Color) : new Gdk.Color (0, 0, 0);
+                                       result = spanStack.Count > 0 ? 
style.GetColor (spanStack.Peek ().Color) : ChunkStyle.Default;
                                }
-                               result.Bold   = (word.Weight & 
KeywordWeight.Bold)   == KeywordWeight.Bold; 
-                               result.Italic = (word.Weight & 
KeywordWeight.Italic) == KeywordWeight.Italic; 
                                return result;
                        }
                        
@@ -113,7 +111,7 @@
                        {
                                if (spanStack.Count == 0)
                                        return ChunkStyle.Default;
-                               return new ChunkStyle (style.GetColor 
(spanStack.Peek ().Color));
+                               return style.GetColor (spanStack.Peek ().Color);
                        }
                        
                        void SetTree ()

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml 
2008-01-25 12:27:30 UTC (rev 93895)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml 
2008-01-25 12:59:17 UTC (rev 93896)
@@ -45,10 +45,10 @@
        <Color name="FoldLineHighlighted">#d3d7cf</Color>
        <Color name="FoldToggleMarker">#eeeeec</Color>
 
-       <Color name="Comment">#888a85</Color>
-       <Color name="String">#edd400</Color>
+       <Color name="Comment1">#888a85</Color>
+       <Color name="Literal">#edd400</Color>
        <Color name="Punctuation">#97A0EF</Color>
-       <Color name="PreProcessor">#ad7fa8</Color>
+       <Color name="PreProcessorDirective1">#ad7fa8</Color>
        <Color name="Keyword1">white</Color>
        <Color name="Keyword2">white</Color>
        <Color name="Keyword3">white</Color>

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to