private void BackspaceDeleteLineBreak()
 {
     if (Hookup is StringHookup || Hookup is TssHookup)
     {
         IParagraphOperations paragraphOps;
         GroupHookup          parentHookup;
         int index;
         if (!GetParagraphOps(out paragraphOps, out parentHookup, out index))
         {
             return;
         }
         if (index == 0)
         {
             // at the start of the sequence.
             // Enhance JohnT: could look for another paragraph ops higher? additional interface on paragraphOps?
             return;
         }
         var prevItem = parentHookup.Children[index - 1];
         var prevIp   = prevItem.SelectAtEnd();
         if (prevIp == null)
         {
             return;                     // for some reason we can't do it (maybe a box at end of last para?)
         }
         var    range = new RangeSelection(prevIp, this);
         Action makeSelection;
         paragraphOps.InsertString(range, "", out makeSelection);
         RootBox.Site.PerformAfterNotifications(makeSelection);
     }
 }
        public RangeSelection ExpandToWord()
        {
            var            cpe         = LgIcuCharPropEngineClass.Create();
            RangeSelection rangeSel    = new RangeSelection(this, new InsertionPoint(Hookup, StringPosition + 1, AssociatePrevious));
            var            backwardSel = new InsertionPoint(Hookup, StringPosition, AssociatePrevious);
            var            forwardSel  = new InsertionPoint(Hookup, StringPosition, AssociatePrevious);

            while (true)
            {
                if (backwardSel.StringPosition == 0)
                {
                    break;
                }
                backwardSel.StringPosition--;
                char testChar = backwardSel.ContainingRun.Text[backwardSel.StringPosition];
                int  testInt  = testChar;
                if (Surrogates.IsTrailSurrogate(testChar))
                {
                    backwardSel.StringPosition--;
                    testInt = Surrogates.Int32FromSurrogates(backwardSel.ContainingRun.Text[backwardSel.StringPosition], testChar);
                }
                else if (Surrogates.IsLeadSurrogate(testChar))
                {
                    testInt = Surrogates.Int32FromSurrogates(testChar, backwardSel.ContainingRun.Text[backwardSel.StringPosition + 1]);
                }
                if (!cpe.get_IsNumber(testInt) && !cpe.get_IsWordForming(testInt) ||
                    backwardSel.ContainingRun.WritingSystemAt(backwardSel.StringPosition) != ContainingRun.WritingSystemAt(StringPosition))
                {
                    backwardSel.StringPosition++;
                    break;
                }
                rangeSel = new RangeSelection(backwardSel, this);
            }
            backwardSel = rangeSel.Anchor;
            while (true)
            {
                if (forwardSel.StringPosition == forwardSel.ContainingRun.Length)
                {
                    if (backwardSel.StringPosition == forwardSel.StringPosition)
                    {
                        return(null);
                    }
                    break;
                }
                char testChar = forwardSel.ContainingRun.Text[forwardSel.StringPosition];
                int  testInt  = testChar;
                if (Surrogates.IsLeadSurrogate(testChar))
                {
                    forwardSel.StringPosition++;
                    testInt  = Surrogates.Int32FromSurrogates(testChar, forwardSel.ContainingRun.Text[forwardSel.StringPosition]);
                    testChar = (char)testInt;
                }
                else if (Surrogates.IsTrailSurrogate(testChar))
                {
                    testInt  = Surrogates.Int32FromSurrogates(forwardSel.ContainingRun.Text[forwardSel.StringPosition - 1], testChar);
                    testChar = (char)testInt;
                }
                if (!cpe.get_IsNumber(testInt) && !cpe.get_IsWordForming(testInt) ||
                    forwardSel.ContainingRun.WritingSystemAt(forwardSel.StringPosition) != ContainingRun.WritingSystemAt(StringPosition))
                {
                    if (testChar.Equals(" ".ToCharArray()[0]))
                    {
                        forwardSel.StringPosition++;
                        rangeSel = new RangeSelection(backwardSel, forwardSel);
                    }
                    break;
                }
                forwardSel.StringPosition++;
                rangeSel = new RangeSelection(backwardSel, forwardSel);
            }
            return(rangeSel);
        }
 public RangeRestoreData(RangeSelection rangeSelection)
 {
     StartRestoreData = new InsertionPointRestoreData(rangeSelection.Start);
     EndRestoreData   = new InsertionPointRestoreData(rangeSelection.End);
 }