Example #1
0
        public void Sync_TabStop()
        {
            _localSettings.TabStop = 42;
            Assert.Equal(42, _editorOptions.GetOptionValue(DefaultOptions.TabSizeOptionId));

            _editorOptions.SetOptionValue(DefaultOptions.TabSizeOptionId, 13);
            Assert.Equal(13, _localSettings.TabStop);
        }
 /// <summary>
 /// Propagate options from editor options to the text model (editor options are not visible at the text model level).
 /// </summary>
 /// <param name="options"></param>
 public void SetTextModelOptions(IEditorOptions options)
 {
     TextModelOptions.CompressedStorageFileSizeThreshold    = options.GetOptionValue(TextModelEditorOptions.CompressedStorageFileSizeThresholdOptionId);
     TextModelOptions.CompressedStoragePageSize             = options.GetOptionValue(TextModelEditorOptions.CompressedStoragePageSizeOptionId);
     TextModelOptions.CompressedStorageMaxLoadedPages       = options.GetOptionValue(TextModelEditorOptions.CompressedStorageMaxLoadedPagesOptionId);
     TextModelOptions.CompressedStorageRetainWeakReferences = options.GetOptionValue(TextModelEditorOptions.CompressedStorageRetainWeakReferencesOptionId);
     TextModelOptions.DiffSizeThreshold = options.GetOptionValue(TextModelEditorOptions.DiffSizeThresholdOptionId);
 }
Example #3
0
 /// <summary>
 /// Reset all options to default (in GlobalOptions)
 /// </summary>
 public void Reset()
 {
     foreach (CheckBox box in _allOptions)
     {
         LabeledOptionDefinition definition = box.Tag as LabeledOptionDefinition;
         if (definition != null)
         {
             box.IsChecked = _globalOptions.GetOptionValue <bool>(definition.Name);
         }
     }
 }
Example #4
0
        public bool SaveOption(IEditorOptions options, string optionName)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            while (true)
            {
                if (options.IsOptionDefined(optionName, true))
                {
                    break;
                }

                options = options.Parent;
                if (options == null)
                {
                    return(false);       //Unable to save option.
                }
            }

            IVsSettingsManager       manager = this.SettingsManagerService;
            IVsWritableSettingsStore store;

            Marshal.ThrowExceptionForHR(manager.GetWritableSettingsStore((uint)__VsSettingsScope.SettingsScope_UserSettings, out store));

            string result = options.GetOptionValue(optionName).ToString();

            Marshal.ThrowExceptionForHR(store.SetString("Text Editor", optionName, result));

            return(true);
        }
 /// <summary>
 /// Returns true if the user can enable or disable use-visible-whitespace option
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsCanChangeUseVisibleWhitespaceEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDsTextViewOptions.CanChangeUseVisibleWhitespaceId));
 }
 /// <summary>
 /// Gets the <see cref="BlockStructureLineKind"/> value
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static BlockStructureLineKind GetBlockStructureLineKind(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDsTextViewOptions.BlockStructureLineKindId));
 }
 /// <summary>
 /// Returns true if empty or whitespace-only lines should be compressed
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsCompressEmptyOrWhitespaceLinesEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDsTextViewOptions.CompressEmptyOrWhitespaceLinesId));
 }
 /// <summary>
 /// Returns true if references should be highlighted
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsReferenceHighlightingEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDsTextViewOptions.ReferenceHighlightingId));
 }
 /// <summary>
 /// Returns true if text should be colorized
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsColorizationEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDsTextViewOptions.EnableColorizationId));
 }
 /// <summary>
 /// Returns true if the user can change overwrite mode
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsCanChangeOverwriteModeEnabled(this IEditorOptions options)
 {
     if (options is null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDsTextViewOptions.CanChangeOverwriteModeId));
 }
 /// <summary>
 /// Returns true if related keywords should be highlighted
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsHighlightRelatedKeywordsEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.HighlightRelatedKeywordsId));
 }
 /// <summary>
 /// Returns true if box selection is enabled
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsAllowBoxSelectionEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.AllowBoxSelectionId));
 }
 /// <summary>
 /// Returns true if clear type should be forced is enabled
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsForceClearTypeIfNeededEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDsWpfViewOptions.ForceClearTypeIfNeededId));
 }
 /// <summary>
 /// Returns the number of milliseconds to wait before refreshing the screen after the document gets changed
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static int GetRefreshScreenOnChangeWaitMilliSeconds(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.RefreshScreenOnChangeWaitMilliSecondsId));
 }
 /// <summary>
 /// Returns true if extra vertical pixels should be removed from text lines
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsRemoveExtraTextLineVerticalPixelsEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.RemoveExtraTextLineVerticalPixelsId));
 }
 /// <summary>
 /// Returns true if the user can change word wrap style
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsCanChangeWordWrapStyleEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.CanChangeWordWrapStyleId));
 }
 /// <summary>
 /// Returns true if non-empty lines that don't contain letters or digits should be compressed
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsCompressNonLetterLinesEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.CompressNonLetterLinesId));
 }
 /// <summary>
 /// Returns true if the vertical lines between start and end blocks are shown
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsShowStructureLinesEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.ShowStructureLinesId));
 }
 /// <summary>
 /// Returns true if line separators should be shown
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsLineSeparatorEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.LineSeparatorId));
 }
 /// <summary>
 /// Returns true if braces should be highlighted
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsBraceMatchingEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.BraceMatchingId));
 }
Example #21
0
 /// <summary>
 /// Gets the indent style option
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static IndentStyle GetIndentStyle(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDsOptions.IndentStyleOptionId));
 }
 /// <summary>
 /// Returns true if refresh-screen-on-change is enabled
 /// </summary>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public static bool IsRefreshScreenOnChangeEnabled(this IEditorOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(options.GetOptionValue(DefaultDnSpyTextViewOptions.RefreshScreenOnChangeId));
 }
Example #23
0
        /// <summary>
        ///Gets the size of the tab for the specified <see cref="IEditorOptions"/>.
        /// </summary>
        /// <param name="options">The <see cref="IEditorOptions"/>.</param>
        /// <returns>The number of spaces of the tab size.</returns>
        public static int GetTabSize(this IEditorOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(options.GetOptionValue(DefaultOptions.TabSizeOptionId));
        }
Example #24
0
        /// <summary>
        /// Gets the new line character for the specified editor options.
        /// </summary>
        /// <param name="options">The <see cref="IEditorOptions"/>.</param>
        /// <returns>A string containing the new line character or characters.</returns>
        public static string GetNewLineCharacter(this IEditorOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(options.GetOptionValue(DefaultOptions.NewLineCharacterOptionId));
        }
        /// <summary>
        /// Specifies the minimum allowed zoomlevel
        /// </summary>
        /// <param name="options">The <see cref="IEditorOptions"/>.</param>
        public static double MinZoom(this IEditorOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(options.GetOptionValue(DefaultTextViewOptions.MinZoomLevelId));
        }
Example #26
0
        /// <summary>
        /// Determines whether to trim trailing whitespace.
        /// </summary>
        /// <param name="options">The <see cref="IEditorOptions"/>.</param>
        /// <returns><c>true</c> if trailing whitespace should be trimmed, otherwise <c>false</c>.</returns>
        public static bool GetTrimTrailingWhieSpace(this IEditorOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(options.GetOptionValue(DefaultOptions.TrimTrailingWhiteSpaceOptionId));
        }
        /// <summary>
        /// Specifies the appearance category.
        /// </summary>
        /// <param name="options">The <see cref="IEditorOptions"/>.</param>
        /// <returns>The appearance category, which determines where to look up font properties and colors.</returns>
        public static string AppearanceCategory(this IEditorOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(options.GetOptionValue <string> (DefaultTextViewOptions.AppearanceCategory));
        }
        /// <summary>
        ///  Determines whether to allow mouse wheel zooming
        /// </summary>
        /// <param name="options">The set of editor options.</param>
        /// <returns><c>true</c> if the mouse wheel zooming is enabled, otherwise <c>false</c>.</returns>
        /// <remarks>Disabling the mouse wheel zooming does NOT turn off Zooming (it disables zooming using mouse wheel)</remarks>
        public static bool IsMouseWheelZoomEnabled(this IEditorOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(options.GetOptionValue <bool> (DefaultTextViewOptions.EnableMouseWheelZoomId));
        }
        /// <summary>
        /// Determines whether the option to draw a gradient selection is enabled.
        /// </summary>
        /// <param name="options">The <see cref="IEditorOptions"/>.</param>
        /// <returns><c>true</c> if the draw selection gradient option was enabled, otherwise <c>false</c>.</returns>
        public static bool IsSimpleGraphicsEnabled(this IEditorOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(options.GetOptionValue <bool> (DefaultTextViewOptions.EnableSimpleGraphicsId));
        }
        /// <summary>
        /// Determines whether the option to highlight the current line is enabled.
        /// </summary>
        /// <param name="options">The <see cref="IEditorOptions"/>.</param>
        /// <returns><c>true</c> if the highlight option was enabled, otherwise <c>false</c>.</returns>
        public static bool IsHighlightCurrentLineEnabled(this IEditorOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(options.GetOptionValue <bool> (DefaultTextViewOptions.EnableHighlightCurrentLineId));
        }
Example #31
0
        public OptionsControl(IEditorOptions globalOptions, IEnumerable<LabeledOptionDefinitionGroup> optionGroups)
        {
            InitializeComponent();

            _globalOptions = globalOptions;

            foreach (var optionGroup in optionGroups)
            {
                GroupBox groupBox = null;
                StackPanel itemList = null;

                // Create a group if the group heading is not null or empty.
                if (!string.IsNullOrEmpty(optionGroup.GroupHeading))
                {
                    groupBox = new GroupBox();
                    groupBox.Header = optionGroup.GroupHeading;

                    itemList = new StackPanel();
                    itemList.Orientation = Orientation.Vertical;

                    groupBox.Content = itemList;

                    groupBox.Padding = new Thickness(4.0, 6.0, 4.0, 2.0);
                    groupBox.Margin = new Thickness(0.0, 4.0, 0.0, 0.0);
                    groupBox.Foreground = SystemColors.WindowTextBrush;
                }

                bool atLeastOneOptionIsDefined = false;
                foreach (var labeledOption in optionGroup.LabeledOptionDefinitions)
                {
                    if (_globalOptions.IsOptionDefined(labeledOption.Name, localScopeOnly: true))
                    {
                        // Add a checkbox to the group if it exists; if the group doesn't exist, then
                        // add the checkbox to the list of options.
                        CheckBox box = new CheckBox();
                        _allOptions.Add(box);

                        box.IsEnabled = true;
                        box.IsChecked = _globalOptions.GetOptionValue<bool>(labeledOption.Name);

                        box.Tag = labeledOption;
                        box.Content = labeledOption.Label;

                        box.Margin = new Thickness(0.0, 1.0, 0.0, 1.0);

                        // We found at least one option that can is defined in global options.
                        // Now we can add the group to the options page (if there is a group).
                        if (!atLeastOneOptionIsDefined)
                        {
                            if (groupBox != null)
                            {
                                this.Options.Items.Add(groupBox);
                            }

                            atLeastOneOptionIsDefined = true;
                        }

                        if (itemList != null)
                        {
                            itemList.Children.Add(box);
                        }
                        else
                        {
                            this.Options.Items.Add(box);
                        }
                    }
                }
            }
        }