protected void DeleteSelectedText()
        {
            if (!Caret.HasSelection())
            {
                return;
            }
            var start = Math.Min(Caret.SelectionStartOffset, Caret.SelectionEndOffset);
            var end   = Math.Max(Caret.SelectionStartOffset, Caret.SelectionEndOffset);

            Document.DeleteAt(start, end - start);
        }
 void OnDeleteKey(KeyEventArgs args)
 {
     if (!ReadOnly)
     {
         if (Caret.HasSelection())
         {
             DeleteSelectedText();
         }
         else if (Caret.SelectionEndOffset < Document.TextLength)
         {
             Document.DeleteAt(Caret.SelectionEndOffset, 1);
         }
     }
 }
 void OnBackKey(KeyEventArgs args)
 {
     if (!ReadOnly)
     {
         if (Caret.HasSelection())
         {
             DeleteSelectedText();
         }
         else if (Caret.SelectionEndOffset > 0)
         {
             Document.DeleteAt(Caret.SelectionEndOffset - 1, 1);
         }
     }
 }
        public void CopySelectedText()
        {
            if (!Caret.HasSelection())
            {
                return;
            }

            var selectedText     = Caret.TextForSelection(Document);
            var clipboardService = Screen?.WindowService.Clipboard;

            if (clipboardService != null)
            {
                clipboardService.ClipboardText = selectedText;
            }
        }