Author: mkrueger
Date: 2008-02-15 17:10:45 -0500 (Fri, 15 Feb 2008)
New Revision: 95843

Modified:
   trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
   trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml
Log:
* OblivionStyle.xml, Mono.TextEditor/TextViewMargin.cs: Fixed caret
  drawing issues.

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-15 
22:07:29 UTC (rev 95842)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-15 
22:10:45 UTC (rev 95843)
@@ -1,3 +1,8 @@
+2008-02-16  Mike Krüger <[EMAIL PROTECTED]> 
+
+       * OblivionStyle.xml, Mono.TextEditor/TextViewMargin.cs: Fixed caret 
drawing
+         issues.
+
 2008-02-15  Mike Krüger <[EMAIL PROTECTED]> 
 
        * Mono.TextEditor/TextViewMargin.cs: Fixed ruler drawing.

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-15 22:07:29 UTC (rev 95842)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
 2008-02-15 22:10:45 UTC (rev 95843)
@@ -220,18 +220,29 @@
                        return true;
                }
                
-               void DrawCaret (Gdk.Drawable win, char ch, int x, int y)
+               char caretChar; 
+               int  caretX;
+               int  caretY;
+               
+               void SetVisibleCaretPosition (Gdk.Drawable win, char ch, int x, 
int y)
                {
+                       caretChar = ch;
+                       caretX    = x;
+                       caretY    = y;
+               }
+               
+               void DrawCaret (Gdk.Drawable win)
+               {
                        if (!Caret.IsVisible || !caretBlink || 
!textEditor.IsFocus) 
                                return;
                        gc.RgbFgColor = ColorStyle.Caret;
                        if (Caret.IsInInsertMode) {
-                               win.DrawLine (gc, x, y, x, y + LineHeight);
+                               win.DrawLine (gc, caretX, caretY, caretX, 
caretY + LineHeight);
                        } else {
-                               win.DrawRectangle (gc, true, new Gdk.Rectangle 
(x, y, this.charWidth, LineHeight));
-                               layout.SetText (ch.ToString ());
+                               win.DrawRectangle (gc, true, new Gdk.Rectangle 
(caretX, caretY, this.charWidth, LineHeight));
+                               layout.SetText (caretChar.ToString ());
                                gc.RgbFgColor = ColorStyle.CaretForeground;
-                               win.DrawLayout (gc, x, y, layout);
+                               win.DrawLayout (gc, caretX, caretY, layout);
                        }
                }
                
@@ -273,7 +284,7 @@
                        
                        int caretOffset = Caret.Offset;
                        if (caretOffset == offset + length) 
-                               DrawCaret (win, ' ', xPos, y);
+                               SetVisibleCaretPosition (win, ' ', xPos, y);
                }
                
                StringBuilder wordBuilder = new StringBuilder ();
@@ -325,7 +336,6 @@
                                                        marker.Draw 
(textEditor, win, selected, offset, offset + 1, y, xPos, xPos + charWidth);
                                                }
                                        }
-                                       
                                        xPos += this.charWidth;
                                        visibleColumn++;
                                } else if (ch == ' ') {
@@ -335,7 +345,7 @@
                                        if 
(TextEditorOptions.Options.ShowSpaces) 
                                                DrawSpaceMarker (win, selected, 
xPos, y);
                                        if (offset == caretOffset) 
-                                               DrawCaret (win, 
TextEditorOptions.Options.ShowSpaces ? spaceMarkerChar : ' ', xPos, y);
+                                               SetVisibleCaretPosition (win, 
TextEditorOptions.Options.ShowSpaces ? spaceMarkerChar : ' ', xPos, y);
                                        
                                        if (line.Markers != null) {
                                                foreach (TextMarker marker in 
line.Markers) {
@@ -355,7 +365,7 @@
                                        if (TextEditorOptions.Options.ShowTabs) 
                                                DrawTabMarker (win, selected, 
xPos, y);
                                        if (offset == caretOffset) 
-                                               DrawCaret (win, 
TextEditorOptions.Options.ShowSpaces ? tabMarkerChar : ' ', xPos, y);
+                                               SetVisibleCaretPosition (win, 
TextEditorOptions.Options.ShowSpaces ? tabMarkerChar : ' ', xPos, y);
                                        if (line.Markers != null) {
                                                foreach (TextMarker marker in 
line.Markers) {
                                                        marker.Draw 
(textEditor, win, selected, offset, offset + 1, y, xPos, xPos + delta);
@@ -376,7 +386,7 @@
                                layout.FontDescription.Style = 
Pango.Style.Normal;
                        
                        if (drawCaretAt >= 0)
-                               DrawCaret (win, Document.GetCharAt 
(caretOffset), drawCaretAt, y);
+                               SetVisibleCaretPosition (win, 
Document.GetCharAt (caretOffset), drawCaretAt, y);
                }
                
                void DrawText (Gdk.Drawable win, Gdk.Color foreColor, Gdk.Color 
backgroundColor, ref int xPos, int y)
@@ -565,8 +575,8 @@
                
                public override void Draw (Gdk.Drawable win, Gdk.Rectangle 
area, int lineNr, int x, int y)
                {
+                       this.caretX = -1;
                        layout.Alignment = Pango.Alignment.Left;
-                       
                        LineSegment line = lineNr < Document.LineCount ? 
Document.GetLine (lineNr) : null;
                        int xStart = System.Math.Max (area.X, XOffset);
                        gc.ClipRectangle = new Gdk.Rectangle (xStart, y, 
area.Right - xStart, LineHeight);
@@ -618,7 +628,7 @@
                                        gc.RgbFgColor = isFoldingSelected ? 
ColorStyle.SelectedFg : ColorStyle.FoldLine;
                                        win.DrawLayout (gc, xPos, y, layout);
                                        if (caretOffset == foldOffset)
-                                               DrawCaret (win, 
folding.Description[0], xPos, y);
+                                               SetVisibleCaretPosition (win, 
folding.Description[0], xPos, y);
                                        
                                        xPos += width;
                                        
@@ -655,7 +665,10 @@
                        }
                        
                        if (caretOffset == line.Offset + line.EditableLength)
-                               DrawCaret (win, 
TextEditorOptions.Options.ShowEolMarkers ? eolMarkerChar : ' ', xPos, y);
+                               SetVisibleCaretPosition (win, 
TextEditorOptions.Options.ShowEolMarkers ? eolMarkerChar : ' ', xPos, y);
+                       
+                       if (this.caretX >= 0)
+                               this.DrawCaret (win);
                }
                
                public override void MouseLeft ()

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml 
2008-02-15 22:07:29 UTC (rev 95842)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/OblivionStyle.xml 
2008-02-15 22:10:45 UTC (rev 95843)
@@ -62,7 +62,7 @@
        <Style name="selectedForeground" color="aluminium1"/>
        
        <Style name="lineMarker" color="aluminium5"/>
-       <Style name="ruler" color="aluminium3"/>
+       <Style name="ruler" color="aluminium5"/>
        <Style name="whitespaces" color="aluminium3"/>
        <Style name="invalidLines" color="orange1"/>
 

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

Reply via email to