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:
Obtain a IVsTextBuffer to hold the document data object being edited.
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:
Use the SetLanguageServiceID method to associate a language service and the document data object that the editor uses.
Either create your own shortcut keys, or use the system default by setting the IVsWindowFrame objects display properties. To do this, call the SetGuidProperty method with the VSFPROPID_InheritKeyBindings property.
To obtain and use non-standard shortcut keys, generate them using the .vsct file. For more information, see Visual Studio Command Table (.Vsct) Files.
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 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.