Author: mkrueger
Date: 2008-02-14 08:01:05 -0500 (Thu, 14 Feb 2008)
New Revision: 95624

Modified:
   trunk/monodevelop/main/src/addins/Mono.Texteditor/C64Style.xml
   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/TextEditor.cs
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
   trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml
   trunk/monodevelop/main/src/addins/Mono.Texteditor/TangoLightStyle.xml
   trunk/monodevelop/main/src/addins/Mono.Texteditor/UbuntuStyle.xml
Log:
* TangoLightStyle.xml, OblivionStyle.xml, UbuntuStyle.xml,
  Mono.TextEditor/TextViewMargin.cs, Mono.TextEditor/TextEditor.cs,
  Mono.TextEditor.Highlighting/Style.cs, C64Style.xml: Fixed some
  drawing issues & speed bug with ctrl+home.

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/C64Style.xml
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/C64Style.xml      
2008-02-14 12:50:12 UTC (rev 95623)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/C64Style.xml      
2008-02-14 13:01:05 UTC (rev 95624)
@@ -26,6 +26,7 @@
 
        <Style name="default" color="#97A0EF"/>
        <Style name="caret" color="#97A0EF"/>
+       <Style name="caretForeground" color="#3F3FDF"/>
        <Style name="background" color="#3F3FDF"/>
        <Style name="selectedBackground" color="#000000"/>
        <Style name="selectedForeground" color="#FFFFFF"/>

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-14 
12:50:12 UTC (rev 95623)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-14 
13:01:05 UTC (rev 95624)
@@ -1,5 +1,12 @@
 2008-02-14  Mike Krüger <[EMAIL PROTECTED]> 
 
+       * TangoLightStyle.xml, OblivionStyle.xml, UbuntuStyle.xml,
+         Mono.TextEditor/TextViewMargin.cs, Mono.TextEditor/TextEditor.cs,
+         Mono.TextEditor.Highlighting/Style.cs, C64Style.xml: Fixed some 
drawing
+         issues & speed bug with ctrl+home.
+
+2008-02-14  Mike Krüger <[EMAIL PROTECTED]> 
+
        * Mono.TextEditor/ISegment.cs, Mono.TextEditor/DefaultEditActions.cs,
          Mono.TextEditor/TextViewMargin.cs, Mono.TextEditor/Document.cs,
          Mono.TextEditor/TextEditorData.cs, Mono.TextEditor/TextMarker.cs,

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs 
    2008-02-14 12:50:12 UTC (rev 95623)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs 
    2008-02-14 13:01:05 UTC (rev 95624)
@@ -122,7 +122,7 @@
                                }
                                int delta = 
(int)(this.textEditorData.VAdjustment.Value - this.oldVadjustment);
                                oldVadjustment = 
this.textEditorData.VAdjustment.Value;
-                               if (delta >= Allocation.Height - 
this.LineHeight * 2 || this.TextViewMargin.inSelectionDrag) {
+                               if (System.Math.Abs (delta) >= 
Allocation.Height - this.LineHeight * 2 || this.TextViewMargin.inSelectionDrag) 
{
                                        this.QueueDraw ();
                                        return;
                                }
@@ -375,8 +375,6 @@
        
                public void SimulateKeyPress (Gdk.Key key, Gdk.ModifierType 
modifier)
                {
-                       if (isDisposed)
-                               return;
                        int keyCode = GetKeyCode (key, modifier);
                        if (keyBindings.ContainsKey (keyCode)) {
                                try {
@@ -685,7 +683,6 @@
                                                margin.XOffset = curX;
                                                curX += margin.Width;
                                                if (curX > area.X || 
margin.Width < 0) {
-                                                       DateTime now = 
DateTime.Now;
                                                        margin.Draw (win, area, 
logicalLineNumber, margin.XOffset, curY);
                                                }
                                        }

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
 2008-02-14 12:50:12 UTC (rev 95623)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
 2008-02-14 13:01:05 UTC (rev 95624)
@@ -53,6 +53,8 @@
                Gdk.Cursor textCursor;
                
                int lineHeight = 16;
+               int highlightBracketOffset = -1;
+               
                public int LineHeight {
                        get {
                                return lineHeight;
@@ -88,6 +90,9 @@
                                return textEditor.TextEditorData;
                        }
                }
+               const char spaceMarkerChar = '\u00B7'; 
+               const char tabMarkerChar = '\u00BB'; 
+               const char eolMarkerChar = '\u00B6'; 
                
                public TextViewMargin (TextEditor textEditor)
                {
@@ -100,7 +105,7 @@
                        tabMarker.SetText ("\u00BB");
                        
                        spaceMarker = new Pango.Layout 
(textEditor.PangoContext);
-                       spaceMarker.SetText ("\u00B7");
+                       spaceMarker.SetText (spaceMarkerChar.ToString ());
                        
                        eolMarker = new Pango.Layout (textEditor.PangoContext);
                        eolMarker.SetText ("\u00B6");
@@ -112,9 +117,11 @@
                        Caret.PositionChanged += delegate (object sender, 
DocumentLocationEventArgs args) {
                                if (Caret.AutoScrollToCaret) {
                                        textEditor.ScrollToCaret ();
+                                       if (args.Location.Line != Caret.Line) {
+                                               caretBlink = false;
+                                               textEditor.RedrawLine 
(args.Location.Line);
+                                       }
                                        caretBlink = true;
-                                       if (args.Location.Line != Caret.Line) 
-                                               textEditor.RedrawLine 
(args.Location.Line);
                                        textEditor.RedrawLine (Caret.Line);
                                }
                        };
@@ -130,20 +137,20 @@
                                        offset = 0;
                                char ch = Document.Buffer.GetCharAt (offset);
                                int bracket = TextUtil.openBrackets.IndexOf 
(ch);
-                               int oldIndex = bracketIndex;
+                               int oldIndex = highlightBracketOffset;
                                if (bracket >= 0) {
-                                       bracketIndex = 
TextUtil.SearchMatchingBracketForward (Document, offset + 1, bracket);
+                                       highlightBracketOffset = 
TextUtil.SearchMatchingBracketForward (Document, offset + 1, bracket);
                                } else {
                                        bracket = 
TextUtil.closingBrackets.IndexOf (ch);
                                        if (bracket >= 0) {
-                                               bracketIndex = 
TextUtil.SearchMatchingBracketBackward (Document, offset - 1, bracket);
+                                               highlightBracketOffset = 
TextUtil.SearchMatchingBracketBackward (Document, offset - 1, bracket);
                                        } else {
-                                               bracketIndex = -1;
+                                               highlightBracketOffset = -1;
                                        }
                                }
-                               if (bracketIndex != oldIndex) {
+                               if (highlightBracketOffset != oldIndex) {
                                        int line1 = oldIndex >= 0 ? 
Document.Splitter.OffsetToLineNumber (oldIndex) : -1;
-                                       int line2 = bracketIndex >= 0 ? 
Document.Splitter.OffsetToLineNumber (bracketIndex) : -1;
+                                       int line2 = highlightBracketOffset >= 0 
? Document.Splitter.OffsetToLineNumber (highlightBracketOffset) : -1;
                                        if (line1 >= 0)
                                                textEditor.RedrawLine (line1);
                                        if (line1 != line2 && line2 >= 0)
@@ -218,7 +225,7 @@
                        return true;
                }
                
-               void DrawCaret (Gdk.Drawable win, int x, int y)
+               void DrawCaret (Gdk.Drawable win, char ch, int x, int y)
                {
                        if (!caretBlink || !textEditor.IsFocus) 
                                return;
@@ -226,12 +233,13 @@
                        if (Caret.IsInInsertMode) {
                                win.DrawLine (gc, x, y, x, y + LineHeight);
                        } else {
-                               win.DrawRectangle (gc, false, new Gdk.Rectangle 
(x, y, this.charWidth, LineHeight - 1));
+                               win.DrawRectangle (gc, true, new Gdk.Rectangle 
(x, y, this.charWidth, LineHeight));
+                               layout.SetText (ch.ToString ());
+                               gc.RgbFgColor = ColorStyle.CaretForeground;
+                               win.DrawLayout (gc, x, y, layout);
                        }
                }
-               int bracketIndex = -1;
                
-               
                void DrawLineText (Gdk.Drawable win, LineSegment line, int 
offset, int length, ref int xPos, int y)
                {
                        SyntaxMode mode = Document.SyntaxMode != null && 
TextEditorOptions.Options.EnableSyntaxHighlighting ? Document.SyntaxMode : 
SyntaxMode.Default;
@@ -248,19 +256,6 @@
                                selectionStart = tmp;
                        }
                        
-                       if (TextEditorOptions.Options.HighlightMatchingBracket 
&& offset <= this.bracketIndex && this.bracketIndex < offset + length) {
-                               int bracketMarkerColumn = this.bracketIndex - 
line.Offset; 
-                               int width, height;
-                               layout.SetText (Document.Buffer.GetTextAt 
(offset, bracketMarkerColumn).Replace ("\t", new string (' ', 
TextEditorOptions.Options.TabSize)));
-                               layout.GetPixelSize (out width, out height);
-                               Gdk.Rectangle bracketMatch = new Gdk.Rectangle 
(xStart + width, y, charWidth, LineHeight - 1);
-                               if (this.bracketIndex < selectionStart || 
this.bracketIndex > selectionEnd) {
-                                       gc.RgbFgColor = 
this.ColorStyle.BracketHighlightBg;
-                                       win.DrawRectangle (gc, true, 
bracketMatch);
-                               }
-                               gc.RgbFgColor = 
this.ColorStyle.BracketHighlightRectangle;
-                               win.DrawRectangle (gc, false, bracketMatch);
-                       }
                        
 //                             Console.WriteLine ("#" + chunks.Length);
                        foreach (Chunk chunk in chunks) {
@@ -287,7 +282,7 @@
                        
                        int caretOffset = Caret.Offset;
                        if (caretOffset == offset + length) 
-                               DrawCaret (win, xPos, y);
+                               DrawCaret (win, ' ', xPos, y);
                }
                
                StringBuilder wordBuilder = new StringBuilder ();
@@ -313,14 +308,29 @@
                                layout.FontDescription.Style = 
Pango.Style.Italic;
                        for (int offset = startOffset; offset < endOffset; 
offset++) {
                                char ch = Document.Buffer.GetCharAt (offset);
-                               if (ch == ' ') {
+                               if 
(TextEditorOptions.Options.HighlightMatchingBracket && offset == 
this.highlightBracketOffset) {
                                        OutputWordBuilder (win, selected, 
style, ref visibleColumn, ref xPos, y);
+                                       
+                                       Gdk.Rectangle bracketMatch = new 
Gdk.Rectangle (xPos, y, charWidth - 1, LineHeight - 1);
+                                       gc.RgbFgColor = selected ? 
this.ColorStyle.SelectedBg : this.ColorStyle.BracketHighlightBg;
+                                       win.DrawRectangle (gc, true, 
bracketMatch);
+                                       gc.RgbFgColor = 
this.ColorStyle.BracketHighlightRectangle;
+                                       win.DrawRectangle (gc, false, 
bracketMatch);
+                                       
+                                       layout.SetText (ch.ToString ());
+                                       gc.RgbFgColor = selected ? 
ColorStyle.SelectedFg : style.Color;
+                                       win.DrawLayout (gc, xPos, y, layout);
+                                       
+                                       xPos += this.charWidth;
+                                       visibleColumn++;
+                               } else if (ch == ' ') {
+                                       OutputWordBuilder (win, selected, 
style, ref visibleColumn, ref xPos, y);
                                        DrawRectangleWithRuler (win, 
this.XOffset, new Gdk.Rectangle (xPos, y, charWidth, LineHeight), selected ? 
ColorStyle.SelectedBg : ColorStyle.Background);
                                        
                                        if 
(TextEditorOptions.Options.ShowSpaces) 
                                                DrawSpaceMarker (win, selected, 
xPos, y);
                                        if (offset == caretOffset) 
-                                               DrawCaret (win, xPos, y);
+                                               DrawCaret (win, 
TextEditorOptions.Options.ShowSpaces ? spaceMarkerChar : ' ', xPos, y);
                                        xPos += this.charWidth;
                                        visibleColumn++;
                                } else if (ch == '\t') {
@@ -335,7 +345,7 @@
                                        if (TextEditorOptions.Options.ShowTabs) 
                                                DrawTabMarker (win, selected, 
xPos, y);
                                        if (offset == caretOffset) 
-                                               DrawCaret (win, xPos, y);
+                                               DrawCaret (win, 
TextEditorOptions.Options.ShowSpaces ? tabMarkerChar : ' ', xPos, y);
                                        xPos += delta;
                                } else {
                                        if (offset == caretOffset) 
@@ -351,7 +361,7 @@
                                layout.FontDescription.Style = 
Pango.Style.Normal;
                        
                        if (drawCaretAt >= 0)
-                               DrawCaret (win, drawCaretAt , y);
+                               DrawCaret (win, Document.Buffer.GetCharAt 
(caretOffset), drawCaretAt, y);
                }
                
                void DrawText (Gdk.Drawable win, Gdk.Color foreColor, Gdk.Color 
backgroundColor, ref int xPos, int y)
@@ -367,7 +377,7 @@
                        xPos += width;
                }
                
-               void DrawEolMarker (Gdk.Drawable win, bool selected, ref int 
xPos, int y)
+               void DrawEolMarker (Gdk.Drawable win, bool selected, int xPos, 
int y)
                {
                        gc.RgbFgColor = selected ? ColorStyle.SelectedFg : 
ColorStyle.WhitespaceMarker;
                        win.DrawLayout (gc, xPos, y, eolMarker);
@@ -483,7 +493,7 @@
                        int lineXPos  = 0;
                        
                        int visibleColumn = 0;
-                       for (int c = 0; c < column; c++) {
+                       for (int c = 0; c < column && c < line.EditableLength; 
c++) {
                                int delta;
                                if (this.Document.Buffer.GetCharAt (line.Offset 
+ column) == '\t') {
                                        int newColumn = visibleColumn + 
TextEditorOptions.Options.TabSize;
@@ -496,6 +506,8 @@
                                }
                                lineXPos += delta;
                        }
+                       if (column >= line.EditableLength)
+                               lineXPos += (line.EditableLength - column + 1) 
* this.charWidth;
                        return lineXPos;
                }
                int rulerX = 0;
@@ -579,7 +591,7 @@
                                        gc.RgbFgColor = ColorStyle.FoldLine;
                                        win.DrawLayout (gc, xPos, y, layout);
                                        if (caretOffset == foldOffset)
-                                               DrawCaret (win, xPos, y);
+                                               DrawCaret (win, 
folding.Description[0], xPos, y);
                                        
                                        xPos += width;
                                        
@@ -602,20 +614,21 @@
                                DrawLineText (win, line, offset, line.Offset + 
line.EditableLength - offset, ref xPos, y);
                        
                        bool isEolSelected = TextEditorData.IsSomethingSelected 
&& TextEditorData.SelectionRange.Contains (line.Offset + line.EditableLength);
-                       if (TextEditorOptions.Options.ShowEolMarkers) // TODO: 
EOL selected
-                               DrawEolMarker (win, isEolSelected, ref xPos, y);
                        
                        lineArea.X     = xPos;
                        lineArea.Width = textEditor.Allocation.Width - xPos;
                        DrawRectangleWithRuler (win, x, lineArea, isEolSelected 
? this.ColorStyle.SelectedBg : this.ColorStyle.Background);
                        
+                       if (TextEditorOptions.Options.ShowEolMarkers)
+                               DrawEolMarker (win, isEolSelected, xPos, y);
+                       
                        if (TextEditorOptions.Options.ShowRuler) {
                                gc.RgbFgColor = ColorStyle.Ruler;
                                win.DrawLine (gc, x + rulerX, y, x + rulerX, y 
+ LineHeight); 
                        }
                        
                        if (caretOffset == line.Offset + line.EditableLength)
-                               DrawCaret (win, xPos, y);
+                               DrawCaret (win, 
TextEditorOptions.Options.ShowEolMarkers ? eolMarkerChar : ' ', xPos, y);
                }
                
                public override void MouseLeft ()

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-02-14 12:50:12 UTC (rev 95623)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Highlighting/Style.cs
     2008-02-14 13:01:05 UTC (rev 95624)
@@ -40,6 +40,7 @@
                Color def, background, selectedBg, selectedFg;
                Color caret;
                Color lineMarker, ruler, whitespaceMarker, invalidLineMarker;
+               Color caretForeground;
                
                Color bookmarkColor1, bookmarkColor2;
                
@@ -194,6 +195,12 @@
                                return description;
                        }
                }
+
+               public virtual Color CaretForeground {
+                       get {
+                               return caretForeground;
+                       }
+               }
                
                public Style ()
                {
@@ -201,6 +208,7 @@
                        def          = new Gdk.Color (0, 0, 0); 
                        
                        caret        = new Gdk.Color (0, 0, 0); 
+                       caretForeground  = new Gdk.Color (255, 255, 255);
                        
                        lineNumberBg = new Gdk.Color (255, 255, 255);
                        lineNumberFg = new Gdk.Color (172, 168, 153);
@@ -291,6 +299,7 @@
                        case "default":
                        case "background":
                        case "caret":
+                       case "caretForeground":
                        case "selectedBackground":
                        case "selectedForeground":
                        case "lineMarker":
@@ -337,6 +346,9 @@
                        case "caret":
                                this.caret = color;
                                break;
+                       case "caretForeground":
+                               this.caretForeground = color;
+                               break;
                        case "background":
                                this.background = color;
                                break;

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml 
2008-02-14 12:50:12 UTC (rev 95623)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml 
2008-02-14 13:01:05 UTC (rev 95624)
@@ -56,6 +56,7 @@
        <!-- environment -->
        <Style name="default" color="aluminium2"/>
        <Style name="caret" color="aluminium2"/>
+       <Style name="caretForeground" color="aluminium6"/>
        <Style name="background" color="aluminium6"/>
        <Style name="selectedBackground" color="aluminium4"/>
        <Style name="selectedForeground" color="aluminium1"/>

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/TangoLightStyle.xml
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/TangoLightStyle.xml       
2008-02-14 12:50:12 UTC (rev 95623)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/TangoLightStyle.xml       
2008-02-14 13:01:05 UTC (rev 95624)
@@ -56,6 +56,7 @@
        <!-- environment -->
        <Style name="default" color="black"/>
        <Style name="caret" color="black"/>
+       <Style name="caretForeground" color="white"/>
        <Style name="background" color="white"/>
        <Style name="selectedBackground" color="skyblue1"/>
        <Style name="selectedForeground" color="aluminium1"/>

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/UbuntuStyle.xml
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/UbuntuStyle.xml   
2008-02-14 12:50:12 UTC (rev 95623)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/UbuntuStyle.xml   
2008-02-14 13:01:05 UTC (rev 95624)
@@ -68,6 +68,7 @@
        <!-- environment -->
        <Style name="default" color="black"/>
        <Style name="caret" color="black"/>
+       <Style name="caretForeground" color="white"/>
        <Style name="background" color="white"/>
        <Style name="selectedBackground" color="human_highlight"/>
        <Style name="selectedForeground" color="black"/>

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

Reply via email to