Author: mkrueger
Date: 2008-01-25 16:27:30 -0500 (Fri, 25 Jan 2008)
New Revision: 93962

Modified:
   trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
   
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/TextEditor.cs
Log:
* Mono.TextEditor/TextEditor.cs,
  Mono.TextEditor.Highlighting/SyntaxMode.cs,
  Mono.TextEditor.Highlighting/Style.cs: Worked on styles.

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-01-25 
21:08:52 UTC (rev 93961)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-01-25 
21:27:30 UTC (rev 93962)
@@ -1,5 +1,15 @@
 2008-01-25  Mike Krüger <[EMAIL PROTECTED]> 
 
+       * Mono.TextEditor/TextEditor.cs, 
Mono.TextEditor.Highlighting/SyntaxMode.cs,
+         Mono.TextEditor.Highlighting/Style.cs: Worked on styles.
+
+2008-01-25  Mike Krüger <[EMAIL PROTECTED]> 
+
+       * Mono.TextEditor/TextEditor.cs, 
Mono.TextEditor.Highlighting/SyntaxMode.cs,
+         Mono.TextEditor.Highlighting/Style.cs: Worked on styles.
+
+2008-01-25  Mike Krüger <[EMAIL PROTECTED]> 
+
        * Mono.TextEditor/DefaultEditActions.cs: Fixed little issue in rtf 
output.
 
 2008-01-25  Mike Krüger <[EMAIL PROTECTED]> 

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs 
    2008-01-25 21:08:52 UTC (rev 93961)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs 
    2008-01-25 21:27:30 UTC (rev 93962)
@@ -115,6 +115,7 @@
                                           EventMask.ScrollMask | 
                                               EventMask.PointerMotionMask
                        ;
+                       
                        base.CanFocus =true;
                        this.ParentSet += delegate {
 //                             if (Parent is Viewport) {

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 21:08:52 UTC (rev 93961)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/Style.cs
     2008-01-25 21:27:30 UTC (rev 93962)
@@ -43,9 +43,9 @@
                Color lineNumberFg, lineNumberBg, lineNumberFgHighlighted;
                Color iconBarBg, iconBarSeperator;
                Color foldLine, foldLineHighlighted, foldBg, foldToggleMarker;
+               List<ChunkStyle>        styles           = new 
List<Mono.TextEditor.ChunkStyle> ();
+               Dictionary<string, int> styleLookupTable = new 
Dictionary<string, int> (); 
                
-               Dictionary<string, ChunkStyle> highlightingStyles = new 
Dictionary<string, ChunkStyle> (); 
-
                public virtual Color Default {
                        get {
                                return def;
@@ -180,81 +180,78 @@
                        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);
+                       SetStyle ("Comment1", new Mono.TextEditor.ChunkStyle 
(new Gdk.Color (0, 0, 255), false, false));
+                       SetStyle ("Comment2", new Mono.TextEditor.ChunkStyle 
(new Gdk.Color (0, 0, 255), true, false));
+                       SetStyle ("Comment3", new Mono.TextEditor.ChunkStyle 
(new Gdk.Color (0, 0, 255), false, false));
+                       SetStyle ("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[] { 
-                       "Comment1", 
-                       "Comment2",
-                       "Comment3", 
-                       "Comment4",
+                       SetStyle ("Digit", new Mono.TextEditor.ChunkStyle (new 
Gdk.Color (0, 0, 0), true, false));
+                       SetStyle ("Literal", new Mono.TextEditor.ChunkStyle 
(new Gdk.Color (0, 0, 0), true, false));
+                       SetStyle ("Punctuation", new Mono.TextEditor.ChunkStyle 
(new Gdk.Color (0, 0, 0), true, false));
                        
-                       "Digit",
-                       "Literal",
-                       "Punctuation",
+                       SetStyle ("Keyword1", new Mono.TextEditor.ChunkStyle 
(new Gdk.Color (165, 42, 42), true, false));
+                       SetStyle ("Keyword2", new Mono.TextEditor.ChunkStyle 
(new Gdk.Color (46, 139, 87), true, false));
+                       SetStyle ("Keyword3", new Mono.TextEditor.ChunkStyle 
(new Gdk.Color (165, 42, 42), true, false));
+                       SetStyle ("Keyword4", new Mono.TextEditor.ChunkStyle 
(new Gdk.Color (0, 200, 0), true, false));
                        
-            "Keyword1",
-            "Keyword2",
-            "Keyword3",
-            "Keyword4",
-                       
-                       "PreProcessorDirective1", 
-                       "PreProcessorDirective2", 
-               };
-               
-               public static int ColorTableCount {
-                       get {
-                               return colorTable.Length;
-                       }
+                       SetStyle ("PreProcessorDirective1", new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (0, 200, 0), false, false));
+                       SetStyle ("PreProcessorDirective2", new 
Mono.TextEditor.ChunkStyle (new Gdk.Color (0, 200, 0), true, false));
                }
                
-               public static string GetColorName (int number)
+               void SetStyle (string name, ChunkStyle style)
                {
-                       return colorTable[number];
+                       if (!styleLookupTable.ContainsKey (name)) {
+                               styleLookupTable.Add (name, styles.Count);
+                               styles.Add (style);
+                       } else {
+                               styles[styleLookupTable[name]] = style;
+                       }
                }
                
-               public static bool IsTableColor (string name)
+
+               public ChunkStyle GetChunkStyle (string name)
                {
-                       return GetColorNumber (name) >= 0;
+                       if (!styleLookupTable.ContainsKey (name)) 
+                               return ChunkStyle.Default;
+                       return this.styles [styleLookupTable[name]];
                }
                
-               public static int GetColorNumber (string name)
+               public void SetChunkStyle (string name, string weight, string 
value)
                {
-                       for (int i = 0; i < colorTable.Length; i++) {
-                               if (colorTable[i] == name)
-                                       return i;
+                       Gdk.Color color = new Color ();
+                       if (!Gdk.Color.Parse (value, ref color)) {
+                               throw new Exception ("Can't parse color: " + 
value);
                        }
-                       return -1;
+                       SetStyle (name, new Mono.TextEditor.ChunkStyle (color, 
+                                                                       weight 
== null ? false : weight.ToUpper ().IndexOf ("BOLD") > 0,
+                                                                       weight 
== null ? false : weight.ToUpper ().IndexOf ("ITALIC") > 0));
                }
                
-               public ChunkStyle GetColor (string name)
+               public static bool IsChunkStyle (string name)
                {
-                       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);
+                       switch (name) {
+                       case "Default":
+                       case "Background":
+                       case "SelectedBackground":
+                       case "SelectedForeground":
+                       case "LineMarker":
+                       case "Ruler":
+                       case "Whitespaces":
+                       case "InvalidLines":
+                       case "LineNumber":
+                       case "LineNumberHighlighted":
+                       case "LineNumberBg":
+                       case "IconBar":
+                       case "IconBarSeperator":
+                       case "FoldLine":
+                       case "FoldBg":
+                       case "FoldLineHighlighted":
+                       case "FoldToggleMarker":
+                               return false;
                        }
-                       highlightingStyles [name] = new 
Mono.TextEditor.ChunkStyle (color, 
-                                                                               
    weight == null ? false : weight.ToUpper ().IndexOf ("BOLD") > 0,
-                                                                               
    weight == null ? false : weight.ToUpper ().IndexOf ("ITALIC") > 0);
+                       return true;
                }
+               
                public void SetColor (string name, string value)
                {
                        Gdk.Color color = new Color ();
@@ -327,10 +324,11 @@
                                        result.name        = 
reader.GetAttribute ("_name");
                                        result.description = 
reader.GetAttribute ("_description");
                                        return true;
+                                       
                                case "Color":
                                        string name = reader.GetAttribute 
("name"); 
-                                       if (IsTableColor (name)) {
-                                               result.SetTableColor (name,
+                                       if (IsChunkStyle (name)) {
+                                               result.SetChunkStyle (name,
                                                                 
reader.GetAttribute ("weight"),
                                                                 
reader.ReadElementContentAsString ());
                                        } else {

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 21:08:52 UTC (rev 93961)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs
        2008-01-25 21:27:30 UTC (rev 93962)
@@ -100,9 +100,9 @@
                        {
                                ChunkStyle result ;
                                if (!String.IsNullOrEmpty (word.Color)) {
-                                       result = style.GetColor (word.Color);
+                                       result = style.GetChunkStyle 
(word.Color);
                                } else {
-                                       result = spanStack.Count > 0 ? 
style.GetColor (spanStack.Peek ().Color) : ChunkStyle.Default;
+                                       result = spanStack.Count > 0 ? 
style.GetChunkStyle (spanStack.Peek ().Color) : ChunkStyle.Default;
                                }
                                return result;
                        }
@@ -111,7 +111,7 @@
                        {
                                if (spanStack.Count == 0)
                                        return ChunkStyle.Default;
-                               return style.GetColor (spanStack.Peek ().Color);
+                               return style.GetChunkStyle (spanStack.Peek 
().Color);
                        }
                        
                        void SetTree ()

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

Reply via email to