Beispiel #1
0
		public static TextEditorData Create (string input, bool reverse)
		{
			TextEditorData data = new Mono.TextEditor.TextEditorData ();
			
			int offset1 = input.IndexOf ('[');
			int offset2 = input.IndexOf (']');
			var selection = new TextSegment (offset1, offset2 - offset1 - 1);

			data.Text = input.Substring (0, offset1) + input.Substring (offset1 + 1, (offset2 - offset1) - 1) + input.Substring (offset2 + 1);
			if (reverse) {
				data.Caret.Offset = selection.Offset;
				data.SelectionAnchor = selection.EndOffset;
				data.ExtendSelectionTo (selection.Offset);
			} else {
				data.Caret.Offset = selection.EndOffset;
				data.SelectionAnchor = selection.Offset;
				data.ExtendSelectionTo (selection.EndOffset);
			}
			return data;
		}
Beispiel #2
0
        public static TextEditorData Create(string input, bool reverse)
        {
            TextEditorData data = new Mono.TextEditor.TextEditorData();

            int offset1   = input.IndexOf('[');
            int offset2   = input.IndexOf(']');
            var selection = new TextSegment(offset1, offset2 - offset1 - 1);

            data.Text = input.Substring(0, offset1) + input.Substring(offset1 + 1, (offset2 - offset1) - 1) + input.Substring(offset2 + 1);
            if (reverse)
            {
                data.Caret.Offset    = selection.Offset;
                data.SelectionAnchor = selection.EndOffset;
                data.ExtendSelectionTo(selection.Offset);
            }
            else
            {
                data.Caret.Offset    = selection.EndOffset;
                data.SelectionAnchor = selection.Offset;
                data.ExtendSelectionTo(selection.EndOffset);
            }
            return(data);
        }
		public void TestExtendSelectionTo ()
		{
			TextEditorData data = new Mono.TextEditor.TextEditorData  ();
data.Document.Text = 
@"123456789
123456789
123456789
123456789
123456789
123456789";
			
			data.SelectionAnchor = 3;
			DocumentLine line = data.Document.GetLine (3);
			
			Assert.IsFalse (data.IsSomethingSelected);
			data.ExtendSelectionTo (line.Offset + 3);
			
			Assert.IsTrue (data.IsSomethingSelected);
			
			Assert.AreEqual (3, data.SelectionRange.Offset);
			Assert.AreEqual (line.Offset + 3, data.SelectionRange.EndOffset);
		}
Beispiel #4
0
        public void TestExtendSelectionTo()
        {
            TextEditorData data = new Mono.TextEditor.TextEditorData();

            data.Document.Text =
                @"123456789
123456789
123456789
123456789
123456789
123456789";

            data.SelectionAnchor = 3;
            DocumentLine line = data.Document.GetLine(3);

            Assert.IsFalse(data.IsSomethingSelected);
            data.ExtendSelectionTo(line.Offset + 3);

            Assert.IsTrue(data.IsSomethingSelected);

            Assert.AreEqual(3, data.SelectionRange.Offset);
            Assert.AreEqual(line.Offset + 3, data.SelectionRange.EndOffset);
        }