Author: mkrueger
Date: 2008-02-12 22:57:50 -0500 (Tue, 12 Feb 2008)
New Revision: 95558
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/BookmarkMargin.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/FoldMarkerMargin.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/IMargin.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextMarker.cs
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
Log:
* Mono.TextEditor/TextViewMargin.cs,
Mono.TextEditor/FoldMarkerMargin.cs, Mono.TextEditor/IMargin.cs,
Mono.TextEditor/TextMarker.cs, Mono.TextEditor/TextEditor.cs,
Mono.TextEditor/BookmarkMargin.cs, Mono.TextEditor/GutterMargin.cs:
Implemented smooth scrolling.
Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-13
02:40:51 UTC (rev 95557)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-13
03:57:50 UTC (rev 95558)
@@ -1,3 +1,10 @@
+2008-02-13 Mike Krüger <[EMAIL PROTECTED]>
+
+ * Mono.TextEditor/TextViewMargin.cs,
Mono.TextEditor/FoldMarkerMargin.cs,
+ Mono.TextEditor/IMargin.cs, Mono.TextEditor/TextMarker.cs,
+ Mono.TextEditor/TextEditor.cs, Mono.TextEditor/BookmarkMargin.cs,
+ Mono.TextEditor/GutterMargin.cs: Implemented smooth scrolling.
+
2008-02-12 Mike Krüger <[EMAIL PROTECTED]>
* Mono.TextEditor/TextEditor.cs: Fixed an error.
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/BookmarkMargin.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/BookmarkMargin.cs
2008-02-13 02:40:51 UTC (rev 95557)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/BookmarkMargin.cs
2008-02-13 03:57:50 UTC (rev 95558)
@@ -111,7 +111,7 @@
}
}
- public override void Draw (Gdk.Window win, Gdk.Rectangle area,
int line, int x, int y)
+ public override void Draw (Gdk.Drawable win, Gdk.Rectangle
area, int line, int x, int y)
{
Gdk.Rectangle drawArea = new Gdk.Rectangle (x, y,
Width, editor.LineHeight);
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/FoldMarkerMargin.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/FoldMarkerMargin.cs
2008-02-13 02:40:51 UTC (rev 95557)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/FoldMarkerMargin.cs
2008-02-13 03:57:50 UTC (rev 95558)
@@ -125,7 +125,7 @@
}
}
- void DrawFoldSegment (Gdk.Window win, int x, int y, bool
isOpen, bool isSelected)
+ void DrawFoldSegment (Gdk.Drawable win, int x, int y, bool
isOpen, bool isSelected)
{
Gdk.Rectangle drawArea = new Gdk.Rectangle (x + 3, y +
3, foldSegmentSize, foldSegmentSize);
win.DrawRectangle (foldBgGC, true, drawArea);
@@ -145,7 +145,7 @@
drawArea.Bottom - 2);
}
- void DrawDashedVLine (Gdk.Window win, int x, int top, int
bottom)
+ void DrawDashedVLine (Gdk.Drawable win, int x, int top, int
bottom)
{
for (int i = top; i <= bottom; i++) {
if (i % 2 == 0)
@@ -162,7 +162,7 @@
return false;
}
- public override void Draw (Gdk.Window win, Gdk.Rectangle area,
int line, int x, int y)
+ public override void Draw (Gdk.Drawable win, Gdk.Rectangle
area, int line, int x, int y)
{
Gdk.Rectangle drawArea = new Gdk.Rectangle (x, y,
Width, editor.LineHeight);
win.DrawRectangle (foldBgGC, true, drawArea);
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
2008-02-13 02:40:51 UTC (rev 95557)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
2008-02-13 03:57:50 UTC (rev 95558)
@@ -124,7 +124,7 @@
lineNumberHighlightGC.RgbFgColor =
editor.ColorStyle.LineNumberFgHighlighted;
}
- public override void Draw (Gdk.Window win, Gdk.Rectangle area,
int line, int x, int y)
+ public override void Draw (Gdk.Drawable win, Gdk.Rectangle
area, int line, int x, int y)
{
Gdk.Rectangle drawArea = new Rectangle (x, y, Width,
editor.LineHeight);
win.DrawRectangle (lineNumberBgGC, true, drawArea);
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/IMargin.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/IMargin.cs
2008-02-13 02:40:51 UTC (rev 95557)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/IMargin.cs
2008-02-13 03:57:50 UTC (rev 95558)
@@ -46,7 +46,7 @@
void OptionsChanged ();
- void Draw (Gdk.Window win, Gdk.Rectangle area, int line, int x,
int y);
+ void Draw (Gdk.Drawable drawable, Gdk.Rectangle area, int line,
int x, int y);
void MousePressed (int button, int x, int y, bool doubleClick);
void MouseHover (int x, int y, bool buttonPressed);
@@ -78,8 +78,9 @@
xOffset = value;
}
}
- public abstract void Draw (Gdk.Window win, Gdk.Rectangle area,
int line, int x, int y);
+ public abstract void Draw (Gdk.Drawable drawable, Gdk.Rectangle
area, int line, int x, int y);
+
public virtual void OptionsChanged ()
{
}
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-13 02:40:51 UTC (rev 95557)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
2008-02-13 03:57:50 UTC (rev 95558)
@@ -85,39 +85,85 @@
{
}
+ Gdk.Pixmap buffer = null, flipBuffer = null;
+ void DoFlipBuffer ()
+ {
+ Gdk.Pixmap tmp = buffer;
+ buffer = flipBuffer;
+ flipBuffer = tmp;
+ }
+ void AllocateWindowBuffer (Rectangle allocation)
+ {
+ if (buffer != null) {
+ buffer.Dispose ();
+ flipBuffer.Dispose ();
+ }
+ buffer = new Gdk.Pixmap (this.GdkWindow,
allocation.Width, allocation.Height);
+ flipBuffer = new Gdk.Pixmap (this.GdkWindow,
allocation.Width, allocation.Height);
+ }
+
protected override void OnSetScrollAdjustments (Adjustment
hAdjustement, Adjustment vAdjustement)
{
this.textEditorData.HAdjustment = hAdjustement;
this.textEditorData.VAdjustment = vAdjustement;
+
if (hAdjustement == null || vAdjustement == null)
return;
+ SetAdjustments ();
this.textEditorData.HAdjustment.ValueChanged +=
delegate {
this.QueueDraw ();
};
this.textEditorData.VAdjustment.ValueChanged +=
delegate {
- this.QueueDraw ();
+ if (this.textEditorData.VAdjustment.Value !=
System.Math.Ceiling (this.textEditorData.VAdjustment.Value)) {
+ this.textEditorData.VAdjustment.Value =
System.Math.Ceiling (this.textEditorData.VAdjustment.Value);
+ return;
+ }
+// int reminder =
(int)this.textEditorData.VAdjustment.Value % LineHeight;
+// if (reminder != 0) {
+// this.textEditorData.VAdjustment.Value
-= reminder;
+// return;
+// }
+ int delta =
(int)(this.textEditorData.VAdjustment.Value - this.oldVadjustment);
+ oldVadjustment =
this.textEditorData.VAdjustment.Value;
+ if (delta >= Allocation.Height -
this.LineHeight || this.textViewMargin.inSelectionDrag) {
+ this.QueueDraw ();
+ return;
+ }
+
+ int from, to;
+ if (delta > 0) {
+ from = delta;
+ to = 0;
+ } else {
+ from = 0;
+ to = -delta;
+ }
+ DoFlipBuffer ();
+ this.buffer.DrawDrawable (Style.BackgroundGC
(StateType.Normal),
+ flipBuffer,
+ 0, from,
+ 0, to,
+ Allocation.Width,
Allocation.Height - from - to);
+ if (delta > 0) {
+ this.QueueDrawArea (0,
Allocation.Height - delta, Allocation.Width, delta + this.LineHeight);
+ } else {
+ this.QueueDrawArea (0, 0,
Allocation.Width, -delta + this.LineHeight);
+ }
+ GdkWindow.DrawDrawable (Style.BackgroundGC
(StateType.Normal),
+ buffer,
+ 0, 0,
+ 0, 0,
+ Allocation.Width,
Allocation.Height);
};
}
-// protected override bool OnScrollEvent (Gdk.EventScroll evnt)
-// {
-// if (evnt.Direction == ScrollDirection.Down ||
evnt.Direction == ScrollDirection.Up) {
-// //this.GdkWindow.MoveRegion
(this.GdkWindow.VisibleRegion, 0, (int)evnt.Y);
-// }
-// return true;
-// }
-
public TextEditor (Document doc)
{
this.textEditorData.Document = doc;
this.Events = EventMask.AllEventsMask;
+ this.DoubleBuffered = false;
base.CanFocus = true;
- this.SizeAllocated += delegate {
- SetAdjustments ();
- };
-
-
keyBindings.Add (GetKeyCode (Gdk.Key.Left), new
CaretMoveLeft ());
keyBindings.Add (GetKeyCode (Gdk.Key.Left,
Gdk.ModifierType.ShiftMask), new SelectionMoveLeft ());
keyBindings.Add (GetKeyCode (Gdk.Key.Left,
Gdk.ModifierType.ControlMask), new CaretMovePrevWord ());
@@ -302,6 +348,15 @@
if (margin is IDisposable)
((IDisposable)margin).Dispose ();
}
+ if (buffer != null) {
+ buffer.Dispose ();
+ buffer = null;
+ }
+ if (flipBuffer != null) {
+ flipBuffer.Dispose ();
+ flipBuffer = null;
+ }
+
base.Dispose ();
}
@@ -310,7 +365,7 @@
{
if (isDisposed)
return;
- this.QueueDrawArea (0,
(int)-this.textEditorData.VAdjustment.Value + Document.LogicalToVisualLine
(logicalLine) * LineHeight, this.Allocation.Width, LineHeight);
+ this.QueueDrawArea (0, Document.LogicalToVisualLine
(logicalLine) * LineHeight - (int)this.textEditorData.VAdjustment.Value,
this.Allocation.Width, LineHeight);
}
internal void RedrawPosition (int logicalLine, int
logicalColumn)
@@ -421,6 +476,7 @@
Caret.Location = textViewMargin.clickLocation;
mousePressed = false;
textViewMargin.inDrag = false;
+ textViewMargin.inSelectionDrag = false;
return base.OnButtonReleaseEvent (e);
}
@@ -585,6 +641,14 @@
}
+ protected override void OnSizeAllocated (Gdk.Rectangle
allocation)
+ {
+ if (IsRealized)
+ AllocateWindowBuffer (allocation);
+ SetAdjustments ();
+ base.OnSizeAllocated (allocation);
+ }
+
internal void SetAdjustments ()
{
this.textEditorData.VAdjustment.SetBounds (0,
@@ -599,17 +663,18 @@
this.Allocation.Width,
this.Allocation.Width);
}
+
public int GetWidth (string text)
{
return this.textViewMargin.GetWidth (text);
}
+ double oldVadjustment = 0;
protected override bool OnExposeEvent (Gdk.EventExpose e)
{
- Gdk.Window win = e.Window;
+ Gdk.Drawable win = buffer;
Gdk.Rectangle area = e.Area;
-
- if (oldRequest !=Splitter.LineCount * this.LineHeight) {
+ if (oldRequest != Splitter.LineCount * this.LineHeight)
{
SetAdjustments ();
oldRequest = Splitter.LineCount *
this.LineHeight;
}
@@ -623,19 +688,27 @@
} else {
endLine++;
}
-// System.Console.WriteLine("draw" + startLine + " -- to:
" + endLine);
+ int startY = startLine * this.LineHeight - reminder;
+ int curY = startY;
+ //System.Console.WriteLine("Redraw #" + (endLine -
startLine));
+ //System.Console.WriteLine("Redraw line:" + startLine +
" to " + endLine);
for (int visualLineNumber = startLine; visualLineNumber
<= endLine; visualLineNumber++) {
int curX = 0;
int logicalLineNumber =
Document.VisualToLogicalLine (visualLineNumber + firstLine);
-// System.Console.WriteLine(logicalLineNumber + "
== " + (visualLineNumber + firstLine));
foreach (IMargin margin in this.margins) {
if (margin.IsVisible) {
margin.XOffset = curX;
- margin.Draw (win, area,
logicalLineNumber, curX, visualLineNumber * LineHeight - reminder);
+ margin.Draw (win, area,
logicalLineNumber, curX, curY);
curX += margin.Width;
}
}
+ curY += LineHeight;
}
+
+ e.Window.DrawDrawable (Style.BackgroundGC
(StateType.Normal),
+ buffer,
+ e.Area.X, e.Area.Y, e.Area.X,
e.Area.Y,
+ e.Area.Width, e.Area.Height);
return true;
}
}
Modified:
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextMarker.cs
===================================================================
---
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextMarker.cs
2008-02-13 02:40:51 UTC (rev 95557)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextMarker.cs
2008-02-13 03:57:50 UTC (rev 95558)
@@ -45,7 +45,7 @@
this.endColumn = endColumn;
}
- public override void Draw (TextEditor editor, Gdk.Window win,
int startOffset, int endOffset, int y, int startXPos, int endXPos)
+ public override void Draw (TextEditor editor, Gdk.Drawable win,
int startOffset, int endOffset, int y, int startXPos, int endXPos)
{
using (Gdk.GC gc = new Gdk.GC (win)) {
int width1 = editor.GetWidth
(editor.Buffer.GetTextAt (line.Offset, startColumn));
@@ -73,7 +73,7 @@
}
}
- public virtual void Draw (TextEditor editor, Gdk.Window win,
int startOffset, int endOffset, int y, int startXPos, int endXPos)
+ public virtual void Draw (TextEditor editor, Gdk.Drawable win,
int startOffset, int endOffset, int y, int startXPos, int endXPos)
{
using (Gdk.GC gc = new Gdk.GC (win)) {
gc.RgbFgColor = new Color (255, 0, 0);
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-13 02:40:51 UTC (rev 95557)
+++
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
2008-02-13 03:57:50 UTC (rev 95558)
@@ -217,7 +217,7 @@
return true;
}
- void DrawCaret (Gdk.Window win, int x, int y)
+ void DrawCaret (Gdk.Drawable win, int x, int y)
{
if (!caretBlink || !textEditor.IsFocus)
return;
@@ -231,7 +231,7 @@
int bracketIndex = -1;
- void DrawLineText (Gdk.Window win, LineSegment line, int
offset, int length, ref int xPos, int y)
+ 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;
Chunk[] chunks = mode.GetChunks (Document,
TextEditorData.ColorStyle, line, offset, length);
@@ -290,7 +290,7 @@
}
}
- void DrawTextWithHighlightedWs (Gdk.Window win, bool selected,
ChunkStyle style, ref int xPos, int y, string text)
+ void DrawTextWithHighlightedWs (Gdk.Drawable win, bool
selected, ChunkStyle style, ref int xPos, int y, string text)
{
string[] spaces = text.Split (' ');
for (int i = 0; i < spaces.Length; i++) {
@@ -326,7 +326,7 @@
}
}
- void DrawText (Gdk.Window win, ref int xPos, int y, string text)
+ void DrawText (Gdk.Drawable win, ref int xPos, int y, string
text)
{
layout.SetText (text);
win.DrawLayout (gc, xPos, y, layout);
@@ -335,33 +335,33 @@
xPos += width;
}
- void DrawEolMarker (Gdk.Window win, bool selected, ref int
xPos, int y)
+ void DrawEolMarker (Gdk.Drawable win, bool selected, ref int
xPos, int y)
{
gc.RgbFgColor = selected ? ColorStyle.SelectedFg :
ColorStyle.WhitespaceMarker;
win.DrawLayout (gc, xPos, y, eolMarker);
}
- void DrawSpaceMarker (Gdk.Window win, bool selected, ref int
xPos, int y)
+ void DrawSpaceMarker (Gdk.Drawable win, bool selected, ref int
xPos, int y)
{
gc.RgbFgColor = selected ? ColorStyle.SelectedFg :
ColorStyle.WhitespaceMarker;
win.DrawLayout (gc, xPos, y, spaceMarker);
xPos += charWidth;
}
- void DrawTabMarker (Gdk.Window win, bool selected, ref int
xPos, int y)
+ void DrawTabMarker (Gdk.Drawable win, bool selected, ref int
xPos, int y)
{
gc.RgbFgColor = selected ? ColorStyle.SelectedFg :
ColorStyle.WhitespaceMarker;
win.DrawLayout (gc, xPos, y, tabMarker);
xPos += charWidth * TextEditorOptions.Options.TabSize;
}
- void DrawInvalidLineMarker (Gdk.Window win, int x, int y)
+ void DrawInvalidLineMarker (Gdk.Drawable win, int x, int y)
{
gc.RgbFgColor = ColorStyle.InvalidLineMarker;
win.DrawLayout (gc, x, y, invalidLineMarker);
}
- bool inSelectionDrag = false;
+ public bool inSelectionDrag = false;
public bool inDrag = false;
public DocumentLocation clickLocation;
@@ -430,7 +430,7 @@
Caret.PreserveSelection = false;
SelectionMoveLeft.EndSelection (TextEditorData);
this.caretBlink = false;
-// this.RedrawLines (System.Math.Min (oldLine,
Caret.Line), System.Math.Max (oldLine, Caret.Line));
+// textEditor.RedrawLines (System.Math.Min
(oldLine, Caret.Line), System.Math.Max (oldLine, Caret.Line));
}
}
@@ -463,7 +463,7 @@
(byte)(((byte)color.Blue * 19) / 20));
}
Gdk.GC gc;
- void DrawRectangleWithRuler (Gdk.Window win, int x,
Gdk.Rectangle area, Gdk.Color color)
+ void DrawRectangleWithRuler (Gdk.Drawable win, int x,
Gdk.Rectangle area, Gdk.Color color)
{
gc.RgbFgColor = color;
if (TextEditorOptions.Options.ShowRuler) {
@@ -476,7 +476,7 @@
}
}
- public override void Draw (Gdk.Window win, Gdk.Rectangle area,
int lineNr, int x, int y)
+ public override void Draw (Gdk.Drawable win, Gdk.Rectangle
area, int lineNr, int x, int y)
{
layout.Alignment = Pango.Alignment.Left;
LineSegment line = lineNr < Document.Splitter.LineCount
? Document.Splitter.Get (lineNr) : null;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches