Export (0) Print
Expand All

Instantiating the Core Editor By Using the Legacy API

The editor is responsible for text editing functions such as insertion, deletion, copy, and paste. It combines these functions with those provided by language services, such as text coloring, indentation, and IntelliSense statement completion.

You can instantiate an instance of the core editor in one of three ways:

  • Explicitly create an instance of the core editor in a window.

  • Provide an editor factory which returns an instance of the core editor

  • Open a file from the project hierarchy.

The following sections discuss how to use the legacy API to instantiate the editor.

When explicitly obtaining an instance of the core editor:

At this point, displaying the IVsWindowFrame interface provides a window that contains an instance of the core editor.

However, this is not a very useful instance, because it does not have shortcut keys, or access to advanced features. To obtain access to shortcut keys and advanced features:

When implementing a core editor with an editor factory using the CreateEditorInstance method, follow all the steps outlined in the previous section to explicitly host an IVsCodeWindow using an IVsTextBuffer document data object, in an IVsWindowFrame object.

To display the text, obtain a IVsTextView interface from the IVsCodeWindow object and call the CreateEditorInstance method.

To provide a language service to the editor, call the SetLanguageServiceID method within the CreateEditorInstance method.

To obtain default shortcut keys, unlike the previous section, you use the command context returned by the CreateEditorInstance method when obtaining the core editor from the CreateEditorInstance method.

If the CreateEditorInstance method returns the same command GUID as the text editor, the instance of the core editor automatically obtains the default shortcut keys.

For general information, see Walkthrough: Creating a Core Editor and Registering an Editor File Type.

© 2014 Microsoft