FormatRangeExact() public static méthode

public static FormatRangeExact ( ITextView textView, ITextBuffer textBuffer, ITextRange formatRange, Microsoft.R.Core.Formatting.RFormatOptions options, IEditorShell editorShell ) : bool
textView ITextView
textBuffer ITextBuffer
formatRange ITextRange
options Microsoft.R.Core.Formatting.RFormatOptions
editorShell IEditorShell
Résultat bool
Exemple #1
0
        public static void UndoableFormatRange(ITextView textView, ITextBuffer textBuffer, ITextRange formatRange, IEditorShell editorShell, bool exactRange = false)
        {
            using (var undoAction = editorShell.CreateCompoundAction(textView, textView.TextBuffer)) {
                undoAction.Open(Resources.AutoFormat);
                var result = exactRange
                    ? RangeFormatter.FormatRangeExact(textView, textBuffer, formatRange, REditorSettings.FormatOptions, editorShell)
                    : RangeFormatter.FormatRange(textView, textBuffer, formatRange, REditorSettings.FormatOptions, editorShell);

                if (result)
                {
                    undoAction.Commit();
                }
            }
        }
Exemple #2
0
 public static void UndoableFormatRange(ITextView textView, ITextBuffer textBuffer, ITextRange formatRange, bool exactRange = false)
 {
     using (var undoAction = EditorShell.Current.CreateCompoundAction(textView, textView.TextBuffer)) {
         undoAction.Open(Resources.AutoFormat);
         bool result;
         if (exactRange)
         {
             result = RangeFormatter.FormatRangeExact(textView, textBuffer, formatRange, REditorSettings.FormatOptions);
         }
         else
         {
             result = RangeFormatter.FormatRange(textView, textBuffer, formatRange, REditorSettings.FormatOptions);
         }
         if (result)
         {
             undoAction.Commit();
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Formats specific scope
        /// </summary>
        private static void FormatScope(ITextView textView, ITextBuffer textBuffer,
                                        AstRoot ast, IScope scope, int baseIndentPosition, bool indentCaret)
        {
            ICompoundUndoAction undoAction = EditorShell.Current.CreateCompoundAction(textView, textView.TextBuffer);

            undoAction.Open(Resources.AutoFormat);
            bool changed = false;

            try {
                // Now format the scope
                changed = RangeFormatter.FormatRangeExact(textView, textBuffer, scope, ast,
                                                          REditorSettings.FormatOptions, baseIndentPosition, indentCaret);
                if (indentCaret)
                {
                    IndentCaretInNewScope(textView, textBuffer, scope, REditorSettings.FormatOptions);
                    changed = true;
                }
            } finally {
                undoAction.Close(!changed);
            }
        }