示例#1
0
        protected override void HandleCharactersEntered(string characters)
        {
            string previous = text;

            text = SelectionRangeUtil.InsertText(text, ref selectionRange, characters);
            HandleTextChanged(previous);
        }
示例#2
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");
    }
示例#3
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");
    }
示例#4
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);
    }
示例#5
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");
    }
示例#6
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|");
    }
示例#7
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 |");
    }