Author: mkrueger
Date: 2008-02-18 06:37:51 -0500 (Mon, 18 Feb 2008)
New Revision: 96046

Added:
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.DefaultEditActions/DocumentTests.cs
Modified:
   trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.DefaultEditActions/CaretMoveTests.cs
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.mdp
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.pidb
   
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
Log:
* Mono.TextEditor/TextEditor.cs: Changed scroll to caret a bit.

Modified: trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-18 
11:12:34 UTC (rev 96045)
+++ trunk/monodevelop/main/src/addins/Mono.Texteditor/ChangeLog 2008-02-18 
11:37:51 UTC (rev 96046)
@@ -1,5 +1,9 @@
 2008-02-18  Mike Krüger <[EMAIL PROTECTED]> 
 
+       * Mono.TextEditor/TextEditor.cs: Changed scroll to caret a bit.
+
+2008-02-18  Mike Krüger <[EMAIL PROTECTED]> 
+
        * Mono.TextEditor/DefaultEditActions.cs: Fixed tabs2spaces option.
 
 2008-02-18  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-02-18 11:12:34 UTC (rev 96045)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor/TextEditor.cs 
    2008-02-18 11:37:51 UTC (rev 96046)
@@ -640,11 +640,11 @@
                {
                        if (Caret.Line < 0 || Caret.Line >= Document.LineCount)
                                return;
-                       int yMargin = 2 * this.LineHeight;
+                       int yMargin = 1 * this.LineHeight;
                        int xMargin = 10 * this.textViewMargin.CharWidth;
                        int caretPosition = Document.LogicalToVisualLine 
(Caret.Line) * this.LineHeight;
-                       if (this.textEditorData.VAdjustment.Value > 
caretPosition - yMargin) {
-                               this.textEditorData.VAdjustment.Value = 
caretPosition - yMargin;
+                       if (this.textEditorData.VAdjustment.Value > 
caretPosition) {
+                               this.textEditorData.VAdjustment.Value = 
caretPosition;
                        } else if (this.textEditorData.VAdjustment.Value + 
this.textEditorData.VAdjustment.PageSize - this.LineHeight < caretPosition + 
yMargin) {
                                this.textEditorData.VAdjustment.Value = 
caretPosition - this.textEditorData.VAdjustment.PageSize + this.LineHeight + 
yMargin;
                        }

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.DefaultEditActions/CaretMoveTests.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.DefaultEditActions/CaretMoveTests.cs
  2008-02-18 11:12:34 UTC (rev 96045)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.DefaultEditActions/CaretMoveTests.cs
  2008-02-18 11:37:51 UTC (rev 96046)
@@ -25,7 +25,6 @@
 //
 //
 
-
 using System;
 using NUnit.Framework;
 
@@ -34,20 +33,6 @@
        [TestFixture()]
        public class CaretMoveTests
        {
-               [Test()]
-               public void TestCaretMoveUp ()
-               {
-                       Mono.TextEditor.TextEditorData data = new 
Mono.TextEditor.TextEditorData ();
-//                     data.Document.Buffer.Text = "1\n2\n3\n";
-                       Assert.AreEqual (0, 0);
-                       /*
-                       new CaretMoveUp ().Run (data);
-                       Assert.AreEqual (0, data.Caret.Line);
-                       Assert.AreEqual (0, data.Caret.Column);
-                       new CaretMoveUp ().Run (data);
-                       Assert.AreEqual (0, data.Caret.Line);
-                       Assert.AreEqual (0, data.Caret.Column);*/
-               }
 //             
 //             [Test()]
 //             public void TestCaretMoveDown ()
@@ -89,5 +74,17 @@
 //                     new CaretMoveRight ().Run (document, caret);
 //                     Assert.AreEqual (4, caret.Column);
 //             }
+               
+               [TestFixtureSetUp] 
+               public void SetUp()
+               {
+                       Gtk.Application.Init ();
+               }
+               
+               [TestFixtureTearDown] 
+               public void Dispose()
+               {
+               }
+               
        }
 }

Added: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.DefaultEditActions/DocumentTests.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.DefaultEditActions/DocumentTests.cs
   2008-02-18 11:12:34 UTC (rev 96045)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.DefaultEditActions/DocumentTests.cs
   2008-02-18 11:37:51 UTC (rev 96046)
@@ -0,0 +1,159 @@
+//
+// DocumentTests.cs
+//
+// Author:
+//   Mike Krüger <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using NUnit.Framework;
+
+namespace Mono.TextEditor.Tests
+{
+       [TestFixture()]
+       public class DocumentTests
+       {
+               [Test()]
+               public void TestDocumentCreation ()
+               {
+                       Document document = new Mono.TextEditor.Document ();
+                       
+                       string text = 
+                       "1234567890\n" +
+                       "12345678\n" +
+                       "1234567\n" +
+                       "123456\n" +
+                       "12345\n" +
+                       "1234\n" +
+                       "123\n" +
+                       "12\n" +
+                       "1\n" +
+                       "\n";
+                       document.Text = text;
+                       
+                       Assert.AreEqual (text, document.Text);
+                       Assert.AreEqual (11, document.LineCount);
+               }
+               
+               [Test]
+               public void TestDocumentInsert ()
+               {
+                       Document document = new Mono.TextEditor.Document ();
+                       
+                       string top  = "1234567890\n";
+                       string text =
+                       "12345678\n" +
+                       "1234567\n" +
+                       "123456\n" +
+                       "12345\n" +
+                       "1234\n" +
+                       "123\n" +
+                       "12\n" +
+                       "1\n" +
+                       "\n";
+                       
+                       document.Text = top;
+                       document.Insert (top.Length, text);
+                       Assert.AreEqual (top + text, document.Text);
+               }
+               
+               [Test]
+               public void TestDocumentRemove ()
+               {
+                       Document document = new Mono.TextEditor.Document ();
+                       
+                       string top      = "1234567890\n";
+                       string testText =
+                       "12345678\n" +
+                       "1234567\n" +
+                       "123456\n" +
+                       "12345\n" +
+                       "1234\n" +
+                       "123\n" +
+                       "12\n" +
+                       "1\n" +
+                       "\n";
+                       document.Text = top + testText;
+                       document.Remove (0, top.Length);
+                       Assert.AreEqual (document.Text, testText);
+                       
+                       document.Remove (0, document.Length);
+                       LineSegment line = document.GetLine (0);
+                       Assert.AreEqual (0, line.Offset);
+                       Assert.AreEqual (0, line.Length);
+                       Assert.AreEqual (0, document.Length);
+                       Assert.AreEqual (1, document.LineCount);
+               }
+               
+               [Test]
+               public void TestDocumentBug1Test()
+               {
+                       Document document = new Mono.TextEditor.Document ();
+                                               
+                       string top    = "1234567890";
+                       document.Text = top;
+                       
+                       Assert.AreEqual (document.GetLine (0).Length, 
document.Length);
+                       
+                       document.Remove(0, document.Length);
+                       
+                       LineSegment line = document.GetLine (0);
+                       Assert.AreEqual(0, line.Offset);
+                       Assert.AreEqual(0, line.Length);
+                       Assert.AreEqual(0, document.Length);
+                       Assert.AreEqual(1, document.LineCount);
+               }
+               
+               [Test]
+               public void TestDocumentBug2Test()
+               {
+                       Document document = new Mono.TextEditor.Document ();
+                       
+                       string top      = "123\n456\n789\n0";
+                       string testText = "Hello World!";
+                       
+                       document.Text = top;
+                       
+                       document.Insert (top.Length, testText);
+                       
+                       LineSegment line = document.GetLine (document.LineCount 
- 1);
+                       
+                       Assert.AreEqual (top.Length - 1, line.Offset);
+                       Assert.AreEqual (testText.Length + 1, line.Length);
+               }
+                               
+               [TestFixtureSetUp] 
+               public void SetUp()
+               {
+                       Gtk.Application.Init ();
+               }
+               
+               [TestFixtureTearDown] 
+               public void Dispose()
+               {
+               }
+               
+               
+       }
+}

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.mdp
===================================================================
--- 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.mdp
   2008-02-18 11:12:34 UTC (rev 96045)
+++ 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.mdp
   2008-02-18 11:37:51 UTC (rev 96046)
@@ -17,6 +17,7 @@
     <File name="Mono.TextEditor.Tests.DefaultEditActions" subtype="Directory" 
buildaction="Compile" />
     <File 
name="Mono.TextEditor.Tests.DefaultEditActions/InsertNewLineTests.cs" 
subtype="Code" buildaction="Compile" />
     <File name="Mono.TextEditor.Tests.DefaultEditActions/CaretMoveTests.cs" 
subtype="Code" buildaction="Compile" />
+    <File name="Mono.TextEditor.Tests.DefaultEditActions/DocumentTests.cs" 
subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="Mono.TextEditor" 
/>

Modified: 
trunk/monodevelop/main/src/addins/Mono.Texteditor/Mono.TextEditor.Tests/Mono.TextEditor.Tests.pidb
===================================================================
(Binary files differ)

_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to