public void TestCoordinatesAfterFolding () { var editor = new TextEditorData (); for (int i = 0; i < 100; i++) editor.Insert (0, "line\n"); HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); heightTree.Fold (1, 2); heightTree.Fold (6, 4); heightTree.Fold (5, 10); var f = heightTree.Fold (20, 8); heightTree.Unfold (f, 20, 8); heightTree.Fold (20, 4); heightTree.Fold (25, 4); for (int i = 50; i <= editor.LineCount; i++) { var y = System.Math.Max (0, (i - 3 - 10 - 8) * editor.LineHeight); Assert.AreEqual (y, heightTree.LineNumberToY (i), "line:" + i + " --> y:" + y); Assert.AreEqual (i, heightTree.YToLineNumber (y), "y:" + y + " --> line:" + i); } for (int i = 50; i <= editor.LineCount; i++) { var y = System.Math.Max (0, (i - 3 - 10 - 8) * editor.LineHeight); Assert.AreEqual (y, heightTree.LineNumberToY (i), "line:" + i + " --> y:" + y); Assert.AreEqual (i, heightTree.YToLineNumber (y), "y:" + y + " --> line:" + i); } }
public void TestLineNumberToYWithFolds() { var editor = new TextEditorData(); editor.Text = "1\n2\n3\n4\n5\n6\n7\n8\n9\n0"; //123 //4 //5[678]90 HeightTree heightTree = new HeightTree(editor); heightTree.Rebuild(); heightTree.Fold(1, 2); heightTree.Fold(6, 3); heightTree.Fold(5, 5); Assert.AreEqual(0 * editor.LineHeight, heightTree.LineNumberToY(1)); Assert.AreEqual(0 * editor.LineHeight, heightTree.LineNumberToY(2)); Assert.AreEqual(0 * editor.LineHeight, heightTree.LineNumberToY(3)); Assert.AreEqual(1 * editor.LineHeight, heightTree.LineNumberToY(4)); for (int i = 5; i <= 10; i++) { Assert.AreEqual(2 * editor.LineHeight, heightTree.LineNumberToY(i)); } }
public void Setup() { MyMultiLineDoc <string> myMultiLineDoc = new MyMultiLineDoc <string>(); string[] simpleDoc = new string[] { "A", "B", "CDE", "F" };// myMultiLineDoc.LoadLines(simpleDoc); heightTree = new HeightTree(myMultiLineDoc); heightTree.Rebuild(); int line_index = 1; foreach (string mytext in simpleDoc) { heightTree.SetLineHeight(line_index, 16); line_index++; } double ypos0 = heightTree.LineNumberToY(1); double ypos1 = heightTree.LineNumberToY(2); //document = new TextDocument(); //document.Text = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10"; //heightTree = new HeightTree(document, 10); //foreach (DocumentLine line in document.Lines) //{ // heightTree.SetHeight(line, line.LineNumber); //} }
public void TestFoldLineNumberToY () { var editor = Create ("1\n2\n3\n4\n5\n6\n7\n8"); HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); heightTree.Fold (1, 3); Assert.AreEqual (0, heightTree.LineNumberToY (2)); Assert.AreEqual (0, heightTree.LineNumberToY (4)); Assert.AreEqual (1 * editor.LineHeight, heightTree.LineNumberToY (5)); Assert.AreEqual (2 * editor.LineHeight, heightTree.LineNumberToY (6)); Assert.AreEqual (3 * editor.LineHeight, heightTree.LineNumberToY (7)); }
public void TestFoldLineNumberToYCase1() { var editor = new TextEditorData(); editor.Text = "1\n2\n3\n4\n5\n6\n7"; HeightTree heightTree = new HeightTree(editor); heightTree.Rebuild(); heightTree.Fold(2, 2); for (int i = 1; i <= editor.LineCount; i++) { int j = i; if (j >= 2) { if (j <= 4) { j = 2; } else { j -= 2; } } Assert.AreEqual((j - 1) * editor.LineHeight, heightTree.LineNumberToY(i)); } }
public void TestSetLineHeight() { var editor = new TextEditorData(); editor.Text = "1\n2\n3\n4\n5\n6\n7"; HeightTree heightTree = new HeightTree(editor); heightTree.Rebuild(); for (int i = 1; i <= editor.LineCount; i += 2) { heightTree.SetLineHeight(i, editor.LineHeight * 2); } double y = 0; for (int i = 1; i <= editor.LineCount; i++) { Assert.AreEqual(y, heightTree.LineNumberToY(i)); y += i % 2 == 0 ? editor.LineHeight : editor.LineHeight * 2; } y = 0; for (int i = 1; i <= editor.LineCount; i++) { Assert.AreEqual(i, heightTree.YToLineNumber(y)); y += i % 2 == 0 ? editor.LineHeight : editor.LineHeight * 2; } }
public void TestSimpleLineNumberToY () { var editor = Create ("1\n2\n3\n4\n5\n6\n7"); HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); for (int i = 1; i <= editor.LineCount; i++) { Assert.AreEqual ((i - 1) * editor.LineHeight, heightTree.LineNumberToY (i)); } }
public void TestBug4839 () { var editor = Create ("1\n2\n3\n4\n5\n6\n7"); editor.Caret.Offset = editor.Text.Length; var heightTree = new HeightTree (editor); heightTree.Rebuild (); MiscActions.InsertNewLine (editor); Assert.AreEqual ((editor.LineCount - 1) * editor.LineHeight, heightTree.LineNumberToY (editor.LineCount)); }
public void TestUnfold () { var editor = Create ("1\n2\n3\n4\n5\n6\n7"); HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); var f = heightTree.Fold (2, 2); heightTree.Unfold (f, 2, 2); for (int i = 1; i <= editor.LineCount; i++) { Assert.AreEqual ((i - 1) * editor.LineHeight, heightTree.LineNumberToY (i)); Assert.AreEqual (i, heightTree.YToLineNumber ((i - 1) * editor.LineHeight)); } }
public void TestSetLineHeight () { var editor = new TextEditorData (); editor.Text = "1\n2\n3\n4\n5\n6\n7"; HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); for (int i = 1; i <= editor.LineCount; i += 2) { heightTree.SetLineHeight (i, editor.LineHeight * 2); } double y = 0; for (int i = 1; i <= editor.LineCount; i++) { Assert.AreEqual (y, heightTree.LineNumberToY (i)); y += i % 2 == 0 ? editor.LineHeight : editor.LineHeight * 2; } y = 0; for (int i = 1; i <= editor.LineCount; i++) { Assert.AreEqual (i, heightTree.YToLineNumber (y)); y += i % 2 == 0 ? editor.LineHeight : editor.LineHeight * 2; } }
public void TestFoldLineNumberToY() { var editor = new TextEditorData(); editor.Text = "1\n2\n3\n4\n5\n6\n7\n8"; HeightTree heightTree = new HeightTree(editor); heightTree.Rebuild(); heightTree.Fold(1, 3); for (int i = 1; i <= editor.LineCount; i++) { Console.WriteLine(i + ":" + heightTree.LineNumberToY(i)); } Assert.AreEqual(0, heightTree.LineNumberToY(2)); Assert.AreEqual(0, heightTree.LineNumberToY(4)); Assert.AreEqual(1 * editor.LineHeight, heightTree.LineNumberToY(5)); Assert.AreEqual(2 * editor.LineHeight, heightTree.LineNumberToY(6)); Assert.AreEqual(3 * editor.LineHeight, heightTree.LineNumberToY(7)); }
public void TestFoldLineNumberToYCase1 () { var editor = Create ("1\n2\n3\n4\n5\n6\n7"); HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); heightTree.Fold (2, 2); for (int i = 1; i <= editor.LineCount; i++) { int j = i; if (j >= 2) { if (j <= 4) { j = 2; } else { j -= 2; } } Assert.AreEqual ((j - 1) * editor.LineHeight, heightTree.LineNumberToY (i)); } }
public void TestFoldLineNumberToYCase1 () { var editor = new TextEditorData (); editor.Text = "1\n2\n3\n4\n5\n6\n7"; HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); heightTree.Fold (2, 2); for (int i = 1; i <= editor.LineCount; i++) { int j = i; if (j >= 2) { if (j <= 4) { j = 2; } else { j -= 2; } } Console.WriteLine ("i:" + i + "/" + j); Assert.AreEqual ((j - 1) * editor.LineHeight, heightTree.LineNumberToY (i)); } }
public void TestUnfold () { var editor = new TextEditorData (); editor.Text = "1\n2\n3\n4\n5\n6\n7"; HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); heightTree.Fold (2, 2); heightTree.Unfold (2, 2); for (int i = 1; i <= editor.LineCount; i++) { Assert.AreEqual ((i - 1) * editor.LineHeight, heightTree.LineNumberToY (i)); Assert.AreEqual (i, heightTree.YToLineNumber ((i - 1) * editor.LineHeight)); } }
public void TestFoldLineNumberToY () { var editor = new TextEditorData (); editor.Text = "1\n2\n3\n4\n5\n6\n7\n8"; HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); heightTree.Fold (1, 3); for (int i = 1; i <= editor.LineCount; i++) { Console.WriteLine (i + ":"+ heightTree.LineNumberToY (i)); } Assert.AreEqual (0, heightTree.LineNumberToY (2)); Assert.AreEqual (0, heightTree.LineNumberToY (4)); Assert.AreEqual (1 * editor.LineHeight, heightTree.LineNumberToY (5)); Assert.AreEqual (2 * editor.LineHeight, heightTree.LineNumberToY (6)); Assert.AreEqual (3 * editor.LineHeight, heightTree.LineNumberToY (7)); }
public void TestLineNumberToYWithFolds () { var editor = new TextEditorData (); editor.Text = "1\n2\n3\n4\n5\n6\n7\n8\n9\n0"; //123 //4 //5[678]90 HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); heightTree.Fold (1, 2); heightTree.Fold (6, 3); heightTree.Fold (5, 5); Assert.AreEqual (0 * editor.LineHeight, heightTree.LineNumberToY (1)); Assert.AreEqual (0 * editor.LineHeight, heightTree.LineNumberToY (2)); Assert.AreEqual (0 * editor.LineHeight, heightTree.LineNumberToY (3)); Assert.AreEqual (1 * editor.LineHeight, heightTree.LineNumberToY (4)); for (int i = 5; i <= 10; i++) Assert.AreEqual (2 * editor.LineHeight, heightTree.LineNumberToY (i)); }
public void TestBug4839MultipleNewLines () { var editor = new TextEditorData (); editor.Text = "1\n2\n3\n4\n5\n6\n7"; editor.Caret.Offset = editor.Text.Length; var heightTree = new HeightTree (editor); heightTree.Rebuild (); MiscActions.InsertNewLine (editor); MiscActions.InsertNewLine (editor); Assert.AreEqual ((editor.LineCount - 1) * editor.LineHeight, heightTree.LineNumberToY (editor.LineCount)); }
public void TestCoordinatesAfterFolding () { var editor = new TextEditorData (); for (int i = 0; i < 100; i++) editor.Insert (0, "line\n"); HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); heightTree.Fold (1, 2); heightTree.Fold (6, 4); heightTree.Fold (5, 10); var f = heightTree.Fold (20, 8); heightTree.Unfold (f, 20, 8); heightTree.Fold (20, 4); heightTree.Fold (25, 4); for (int i = 50; i <= editor.LineCount; i++) { var y = System.Math.Max (0, (i - 3 - 10 - 8) * editor.LineHeight); Assert.AreEqual (y, heightTree.LineNumberToY (i), "line:" + i + " --> y:" + y); Assert.AreEqual (i, heightTree.YToLineNumber (y), "y:" + y + " --> line:" + i); } for (int i = 50; i <= editor.LineCount; i++) { var y = System.Math.Max (0, (i - 3 - 10 - 8) * editor.LineHeight); Assert.AreEqual (y, heightTree.LineNumberToY (i), "line:" + i + " --> y:" + y); Assert.AreEqual (i, heightTree.YToLineNumber (y), "y:" + y + " --> line:" + i); } }
public void TestFoldLineNumberToY () { var editor = new TextEditorData (); editor.Text = "1\n2\n3\n4\n5\n6\n7\n8"; HeightTree heightTree = new HeightTree (editor); heightTree.Rebuild (); heightTree.Fold (1, 3); Assert.AreEqual (0, heightTree.LineNumberToY (2)); Assert.AreEqual (0, heightTree.LineNumberToY (4)); Assert.AreEqual (1 * editor.LineHeight, heightTree.LineNumberToY (5)); Assert.AreEqual (2 * editor.LineHeight, heightTree.LineNumberToY (6)); Assert.AreEqual (3 * editor.LineHeight, heightTree.LineNumberToY (7)); }