コード例 #1
0
 internal override void Execute(EmacsCommandContext context)
 {
     try
     {
         changes = new StringBuilder();
         context.TextBuffer.Changed += OnTextBufferChanged;
         var nullable = new SnapshotSpan?();
         for (int argumentOrDefault = context.Manager.GetUniversalArgumentOrDefault(1);
              argumentOrDefault > 0;
              --argumentOrDefault)
         {
             nullable = !nullable.HasValue
                 ? context.TextStructureNavigator.GetNextWord(context.TextView)
                 : context.TextStructureNavigator.GetNextWord(nullable.Value.End);
         }
         if (nullable.HasValue)
         {
             SnapshotPoint caretPosition = context.TextView.GetCaretPosition();
             context.EditorOperations.Delete(caretPosition, nullable.Value.End - caretPosition);
         }
         KillwordClipboardSession clipboardSession =
             context.Manager.GetOrCreateKillClipboardSession(context.TextView);
         clipboardSession.KillwordSession = clipboardSession.KillwordSession + changes;
         context.Clipboard.Clear();
         context.Clipboard.Append(clipboardSession.KillwordSession);
     }
     finally
     {
         context.TextBuffer.Changed -= OnTextBufferChanged;
     }
 }
コード例 #2
0
        internal override void Execute(EmacsCommandContext context)
        {
            try
            {
                KillwordClipboardSession clipboardSession =
                    context.Manager.GetOrCreateKillClipboardSession(context.TextView);
                changes = new StringBuilder();
                context.TextBuffer.Changed += OnTextBufferChanged;
                int?universalArgument1 = context.Manager.UniversalArgument;
                if ((universalArgument1.GetValueOrDefault() != 0 ? 0 : (universalArgument1.HasValue ? 1 : 0)) != 0)
                {
                    context.EditorOperations.DeleteToBeginningOfPhysicalLine();
                    clipboardSession.KillwordSession = changes + clipboardSession.KillwordSession;
                }
                else
                {
                    if (context.UniversalArgument.HasValue)
                    {
                        int?universalArgument2 = context.UniversalArgument;
                        if ((universalArgument2.GetValueOrDefault() <= 0 ? 0 : (universalArgument2.HasValue ? 1 : 0)) ==
                            0)
                        {
                            goto label_11;
                        }
                    }
                    for (int argumentOrDefault = context.Manager.GetUniversalArgumentOrDefault(1);
                         argumentOrDefault > 0 && context.TextView.Caret.ContainingTextViewLine != null;
                         --argumentOrDefault)
                    {
                        if (context.TextView.GetCaretPosition() ==
                            context.TextView.Caret.ContainingTextViewLine.End.Position)
                        {
                            context.EditorOperations.Delete();
                        }
                        else
                        {
                            context.EditorOperations.DeleteToEndOfPhysicalLine();
                        }
                    }
                    clipboardSession.KillwordSession = clipboardSession.KillwordSession + changes;
                }
label_11:
                context.Clipboard.Clear();
                context.Clipboard.Append(clipboardSession.KillwordSession);
            }
            finally
            {
                context.TextBuffer.Changed -= OnTextBufferChanged;
            }
        }