Exemplo n.º 1
0
        protected override void HandleCharactersEntered(string characters)
        {
            string previous = text;

            text = SelectionRangeUtil.InsertText(text, ref selectionRange, characters);
            HandleTextChanged(previous);
        }
Exemplo n.º 2
0
        protected override void HandleCharactersDeletedBackwards()
        {
            string previous = text;

            text = SelectionRangeUtil.DeleteTextBackwards(text, ref selectionRange);
            HandleTextChanged(previous);
        }
Exemplo n.º 3
0
    public void DeleteTextRangeBackwardFromMiddle()
    {
        string text = "Keep|Delete|Keep";

        SelectionRange range = GetSelectionFromCharacters(ref text);

        string expected = "KeepKeep";
        string result   = SelectionRangeUtil.DeleteTextBackwards(text, ref range);

        Assert.AreEqual(expected, result);
        AssertSelection(result, range, "Keep|Keep");
    }
Exemplo n.º 4
0
    public void DeleteTextSelectionOnInsert()
    {
        string text = "Keep|Delete|Keep";

        SelectionRange range = GetSelectionFromCharacters(ref text);

        string expected = "KeepInsertedKeep";
        string result   = SelectionRangeUtil.InsertText(text, ref range, "Inserted");

        Assert.AreEqual(expected, result);
        AssertSelection(result, range, "KeepInserted|Keep");
    }
Exemplo n.º 5
0
    public void DeleteTextBackwardFromEnd()
    {
        string text = "KeepA|";

        SelectionRange range = GetCursorFromCharacter(ref text);

        string expected = "Keep";
        string result   = SelectionRangeUtil.DeleteTextBackwards(text, ref range);

        Assert.AreEqual(expected, result);
        AssertSelection(result, range, "Keep|");
    }
Exemplo n.º 6
0
    public void DeleteTextForwardFromStart()
    {
        string text = "|AKeep";

        SelectionRange range = GetCursorFromCharacter(ref text);

        string expected = "Keep";
        string result   = SelectionRangeUtil.DeleteTextForwards(text, ref range);

        Assert.AreEqual(expected, result);
        AssertSelection(result, range, "|Keep");
    }
Exemplo n.º 7
0
    public void PrependTextToNonEmptyString()
    {
        string text = "|CONTENT";

        SelectionRange range = GetCursorFromCharacter(ref text);

        string toAdd = "this is added";

        string result = SelectionRangeUtil.InsertText(text, ref range, toAdd);

        Assert.AreEqual(toAdd + text, result);
        AssertSelection(result, range, "this is added|CONTENT");
    }
Exemplo n.º 8
0
    public void AppendTextToNonEmptyString()
    {
        string text = "CONTENT |";

        SelectionRange range = GetCursorFromCharacter(ref text);

        string toAdd = "this is added";

        string result = SelectionRangeUtil.InsertText(text, ref range, toAdd);

        Assert.AreEqual(text + toAdd, result);
        AssertRangesEqual(new SelectionRange((text + toAdd).Length), range);
    }
Exemplo n.º 9
0
    public void InsertTextToNonEmptyString()
    {
        string text = "INSERT|HERE";

        SelectionRange range = GetCursorFromCharacter(ref text);

        string toAdd = "this is added";

        string expected = "INSERTthis is addedHERE";
        string result   = SelectionRangeUtil.InsertText(text, ref range, toAdd);

        Assert.AreEqual(expected, result);
        AssertSelection(result, range, "INSERTthis is added|HERE");
    }
Exemplo n.º 10
0
    public void InsertWhitespaceToNonEmptyString()
    {
        string text = "Randomword|";

        SelectionRange range = GetCursorFromCharacter(ref text);

        string toAdd = " ";

        string expected = "Randomword another";
        string result   = SelectionRangeUtil.InsertText(text, ref range, toAdd);

        result = SelectionRangeUtil.InsertText(result, ref range, "another");

        Assert.AreEqual(expected, result);
        AssertSelection(result, range, "Randomword another|");
    }
Exemplo n.º 11
0
    public void DeleteTextRangeForwardFromEnd()
    {
        string text = "Keep|Delete|";

        SelectionRange range = GetSelectionFromCharacters(ref text);

        string expected = "Keep";
        string result   = SelectionRangeUtil.DeleteTextForwards(text, ref range);

        Assert.AreEqual(expected, result);
        AssertSelection(result, range, "Keep|");

        string toAdd = " ";

        result = SelectionRangeUtil.InsertText(result, ref range, toAdd);

        Assert.AreEqual("Keep ", result);
        AssertSelection(result, range, "Keep |");
    }