Freigeben über


LanguagePreferences Class

Definition

Important

This API is not CLS-compliant.

LanguagePreferences encapsulates the standard General and Tab settings for a language service and provides a way of getting and setting the values. It is expected that you will have one global LanguagePreferences created by your package. The General and Tabs settings are automatically persisted in .vssettings files by the core editor package. All you need to do is register your language under AutomationProperties/TextEditor and specify:

YourLanguage = s '%YourLocalizedName%'
{
   val Name = s 'YourLanguage'
   val Package = s '{F5E7E720-1401-11D1-883B-0000F87579D2}'
   val ProfileSave = d 1
   val ResourcePackage = s '%YourPackage%'
}

Therefore this class hides all it's properties from user setting persistence using DesignerSerializationVisibility.Hidden. This is so that if you give this object to the Package.ExportSettings method as the AutomationObject then it will only write out your new settings which is what you want, otherwise the General and Tab settings will appear in two places in the .vsssettings file.

public ref class LanguagePreferences : IDisposable, Microsoft::VisualStudio::TextManager::Interop::IVsTextManagerEvents2
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.Guid("934a92fd-b63a-49c7-9284-11aec8c1e03f")]
public class LanguagePreferences : IDisposable, Microsoft.VisualStudio.TextManager.Interop.IVsTextManagerEvents2
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.Guid("934a92fd-b63a-49c7-9284-11aec8c1e03f")]
public class LanguagePreferences : IDisposable, Microsoft.VisualStudio.TextManager.Interop.IVsTextManagerEvents2
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Runtime.InteropServices.Guid("934a92fd-b63a-49c7-9284-11aec8c1e03f")>]
type LanguagePreferences = class
    interface IVsTextManagerEvents2
    interface IDisposable
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Runtime.InteropServices.Guid("934a92fd-b63a-49c7-9284-11aec8c1e03f")>]
type LanguagePreferences = class
    interface IVsTextManagerEvents2
    interface IDisposable
Public Class LanguagePreferences
Implements IDisposable, IVsTextManagerEvents2
Inheritance
LanguagePreferences
Attributes
Implements

Remarks

The base class manages preferences specific to your language service as well as general preferences the user can affect from the Tools -> Options -> Text Editor category.

The following registry entries are specific to language services and are already reflected in properties in the base class. These registry entries are stored in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\<X.Y>\Languages\Language Services\<Language Name>.

<X.Y> is the version of Visual Studio (for example, 8.0 or 8.0Exp).

<Language Name> is the name of your language.

Registry entry Type Value Description
CodeSense DWORD <0 or 1> 1 indicates support for IntelliSense.
MatchBraces DWORD <0 or 1> 1 indicates support for matching braces.
QuickInfo DWORD <0 or 1> 1 indicates support for the Quick Info IntelliSense operation.
ShowMatchingBraces DWORD <0 or 1> 1 indicates that the text included in the span for a matching pair of language elements is shown in the status bar.
MatchBracesAtCaret DWORD <0 or 1> 1 indicates that matching braces can be shown while typing a matching brace.
MaxErrorMessages DWORD <number> The maximum number of error messages that can be put into the Error List Options window from the parser.
CodeSenseDelay DWORD <number> The amount of time in milliseconds the user must hold the cursor over an identifier before triggering an IntelliSense operation.
EnableAsyncCompletion DWORD <0 or 1> 1 indicates support for asynchronous or background parsing.
EnableCommenting DWORD <0 or 1> 1 indicates support for commenting and uncommenting code in a single operation.
EnableFormatSelection DWORD <0 or 1> 1 indicates support for formatting the source text.
AutoOutlining DWORD <0 or 1> 1 indicates support for automatic outlining (this requires parser support for hidden regions).
MaxRegions DWORD <number> The maximum number of hidden regions that can be handled in a single file.

Notes to Inheritors

If you have any language-specific properties in addition to those already supported by the base class, you have to derive a class from LanguagePreferences and return an instance of your class from the GetLanguagePreferences() method. Be sure to call the Initialize() method before returning your language preferences instance. In addition, you must override InitUserPreferences(RegistryKey, String), OnUserPreferencesChanged2(VIEWPREFERENCES2[], FRAMEPREFERENCES2[], LANGPREFERENCES2[], FONTCOLORPREFERENCES2[]), and Apply() methods to support accessing your specified properties.

It is assumed that a single instance of the LanguagePreferences object is maintained for your language service. In this way, any changes the user makes to the properties are dynamically updated in your preferences and from there, throughout the language service.

Notes to Callers

An instance of this class is returned from the LanguageService method GetLanguagePreferences(). A number of properties are referenced throughout the managed package framework version of the language service classes.

Constructors

LanguagePreferences()

Initializes a new instance of the LanguagePreferences class (default initialization only).

LanguagePreferences(IServiceProvider, Guid, String)

Gets the language preferences.

Properties

AutoListMembers

Gets or sets whether members are automatically listed as part of IntelliSense support.

AutoOutlining

Gets or sets whether or not auto-outlining is supported outlining (this requires parser support for hidden regions).

CodeSenseDelay

Gets or sets the number of milliseconds the user must hold the cursor over an identifier before initiating any IntelliSense operation.

CutCopyBlankLines

Gets or sets whether to include spaces on blank lines when cutting and copying.

EnableAsyncCompletion

Gets or sets if background parsing is supported.

EnableCodeSense

Gets or sets whether or not IntelliSense is supported.

EnableCommenting

Gets or sets whether or not blocks of code can be commented and uncommented.

EnableFormatSelection

Gets or sets whether or not code can be formatted.

EnableLeftClickForURLs

Gets or sets whether or not URLs in the code can be navigated to by a simple click.

EnableMatchBraces

Gets or sets whether or not matching braces are supported.

EnableMatchBracesAtCaret

Gets or sets whether or not matching braces can be shown while typing a matching brace.

EnableQuickInfo

Gets or sets whether or not the IntelliSense Quick Info operation is supported.

EnableShowMatchingBrace

Gets or sets whether or not the text included in the span of the matching pair is shown in the status bar.

HideAdvancedMembers

Gets or sets whether or not advanced members are hidden in the IntelliSense members list.

HighlightMatchingBraceFlags

Gets or sets the flags for highlighting matching braces.

IndentSize

Gets or sets the number of spaces to indent when formatting source.

IndentStyle

Gets or sets the style used for formatting sections of text.

InsertTabs

Gets or sets whether or not to insert tabs instead of spaces when formatting sections of text.

LanguageName

Gets or sets the name the language service is registered under.

LineNumbers

Gets or sets whether or not line numbers are to be shown.

MaxErrorMessages

Gets or sets the maximum number of error messages that can be shown at any one time.

MaxRegionTime

Gets or sets the maximum region time.

ParameterInformation

Gets or sets whether or not the IntelliSense method tip operation is supported.

ShowNavigationBar

Gets or sets whether or not drop-down bars are to be shown.

Site

This property is not public for a reason. If it were public it would get called during LoadSettingsFromStorage which will break it.
Instead use GetSite().

TabSize

Gets or sets the number of spaces a single tab covers.

VirtualSpace

Gets or sets whether or not the editor should assume spaces at the end of all lines.

WordWrap

Gets or sets whether or not word wrapping is enabled.

WordWrapGlyphs

Gets or sets whether or not a glyph should be shown for a line that is word-wrapped.

Methods

Apply()

Applies all changes made to the preferences.

Dispose()

Cleans up any allocated resources before the object is destroyed.

GetBooleanValue(RegistryKey, String, Boolean)

Obtains a boolean value from the specified registry entry.

GetIntegerValue(RegistryKey, String, Int32)

Gets an integer value from the specified registry entry.

GetLanguagePreferences()

Gets the modifiable user language settings from Visual Studio.

GetSite()

Gets the service provider.

Init()

Initializes LanguagePreferences.

InitMachinePreferences(RegistryKey, String)

Gets language service-specific settings from the registry.

InitUserPreferences(RegistryKey, String)

Gets user-modifiable settings.

OnRegisterMarkerType(Int32)

Called when a new marker type is registered with Visual Studio.

OnRegisterView(IVsTextView)

Called when a view is registered.

OnReplaceAllInFilesBegin()

Called when the Replace All in Files operation has begun.

OnReplaceAllInFilesEnd()

Called when the Replace All In Files operation has ended.

OnUnregisterView(IVsTextView)

Called when a view is closed.

OnUserPreferencesChanged2(VIEWPREFERENCES2[], FRAMEPREFERENCES2[], LANGPREFERENCES2[], FONTCOLORPREFERENCES2[])

Called when a user preference has been changed.

Applies to