Exemplo n.º 1
0
        internal void OnTextCopied(TextEventArgs e)
        {
            // [DIGITALRUNE] Add text to clipboard ring.
            ClipboardRing.Add(e.Text);

            if (TextCopied != null)
            {
                TextCopied(this, e);
            }
        }
Exemplo n.º 2
0
 public void Execute(ITextView view, IEmacsCommandMetadata metadata, bool evaluateUniversalArgument = true)
 {
     try
     {
         changes = new StringBuilder();
         view.TextBuffer.Changed += OnTextBufferChanged;
         EmacsCommand          command      = CreateCommand(metadata);
         EmacsCommand          emacsCommand = null;
         IEmacsCommandMetadata metadata1    = null;
         var context = new EmacsCommandContext(this, TextStructureNavigatorSelectorService,
                                               EditorOperationsFactoryService.GetEditorOperations(view), view,
                                               CommandRouterProvider.GetCommandRouter(view));
         if (ClipboardRing.Count == 0 || ClipboardRing.Last() != Clipboard.GetText())
         {
             ClipboardRing.Add(Clipboard.GetText());
         }
         if (command == null)
         {
             return;
         }
         ITextUndoHistory history = TextUndoHistoryRegistry.GetHistory(context.TextBuffer);
         using (ITextUndoTransaction transaction = CreateTransaction(metadata, history))
         {
             int  num  = 1;
             bool flag = false;
             if (evaluateUniversalArgument)
             {
                 flag = GetUniversalArgumentOrDefault(0) < 0;
                 if (flag)
                 {
                     metadata1    = GetCommandMetadata(metadata.InverseCommand);
                     emacsCommand = CreateCommand(metadata1);
                 }
                 if (metadata.CanBeRepeated)
                 {
                     num = Math.Abs(GetUniversalArgumentOrDefault(1));
                 }
             }
             for (; num > 0; --num)
             {
                 if (flag)
                 {
                     if (emacsCommand != null)
                     {
                         emacsCommand.Execute(context);
                     }
                     else
                     {
                         command.ExecuteInverse(context);
                     }
                 }
                 else
                 {
                     command.Execute(context);
                 }
             }
             if (transaction != null)
             {
                 transaction.Complete();
             }
             if (context.Clipboard.Length > 0)
             {
                 ClipboardRing.Add(context.Clipboard.ToString());
                 Clipboard.SetText(context.Clipboard.ToString());
             }
             else if (changes.Length > 0 && metadata.CopyDeletedTextToTheClipboard)
             {
                 ClipboardRing.Add(changes.ToString());
                 Clipboard.SetText(changes.ToString());
             }
             LastExecutedCommand = flag ? metadata1 : metadata;
         }
     }
     catch (NoOperationException ex)
     {
     }
     finally
     {
         view.TextBuffer.Changed -= OnTextBufferChanged;
     }
 }