Dear all,
I'm quite new to VSIP and am in the process of writing a syntax highlighter
for an old proprietary language that we are using internally.
I have therefore developped and successfully run a very simple VsPackage
with a VsEditorFactory that instantiates the core editor.
However, it appears that most keypresses are not handled by the editor. I
can only type characters, digits and probably the Del key but the Enter,
Backspace and Arrow keys are not handled. Others are probably not handled
either.
Is there something to pay attention to when instantiating the core editor?
My VsEditorFactory instantiates both a VsTextBuffer and a VsCodeWindow
object, sites the text buffer, hooks up the code window to the text buffer
and returns the appropriate interfaces.
However, it does *not* create a VsCodeWindowManager (yet) nor does it set
the resulting caption string and command guid.
I noticed that the last parameter of the
IVsEditorFactory::CreateEditorInstance() in the samples is a pointer to a
VSEDITORCREATEDOCWIN whereas it is documented in the VSIP EnvSDK as a pointer
to a BOOL...
Thanks for your help.
Cheers.
"Ed Dore [MSFT]" - 22 Mar 2005 22:09 GMT
Hi Maxime,
It sounds like accelerator keyboard messages aren't being processed
properly. Are you by chance parenting this code window in another window
(that implements IVsWindowPane)?
I did this some time ago with a C# package, where I created a VsCodeWindow
and parented it to a .net user control, and ran into a similar behavior.
The problem was that my user control (which derived from IVsWindowPane),
didn't call the code window's IVsWindowPane::TranslateAccelerator(). Once I
defered the TranslateAccelerator call to the core editor's IVsWindowPane,
the various keyboard messages worked fine.
Just a guess.
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.
Fred Heida - 23 Mar 2005 21:26 GMT
Hi Ed,
Are there any samples available for doing this ? em.go hosting a
VsCodeWindow inside a
.net control ?
Cheers,
Fred
> Hi Maxime,
>
[quoted text clipped - 16 lines]
>
> This post is 'AS IS' with no warranties, and confers no rights.
"Ed Dore [MSFT]" - 24 Mar 2005 23:50 GMT
Hi Fred,
I have a sample that compiles against Whidbey Beta1 that does this. It's
basically a "proof of concept" package for some other stuff I was working
on for another customer. But I'd be more than happy to send you a copy.
Just email me (minus the ".online" portion in my email address), and I'll
send you a copy. I'm working on a new Beta2 variant that will implement
multiple views, one of which will host the codewindow as a child control on
a .net user control.
Basically, you have to revert to the Win32 API's to parent the codewindow's
HWND onto a usercontrol. It's kludgy, but it's the same technique we use
with our managed packages too.
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.
Maxime LABELLE - 23 Mar 2005 09:21 GMT
Well,
I have made some tests with the Figures sample collection and have found
that the FigEdt sample alone suffers from the exact same problem. It starts
to work correctly when the FigLgSvc sample is registered.
As it turns out, it seems I can have a language service without an editor
but I cannot have an editor without a language service. Is that correct?
Also, can both the language service and the editor be implemented in the
same VsPackage?
Cheers.
Maxime.
Gaston Milano - 23 Mar 2005 22:18 GMT
You have to inherit the keybindings from the TextEditor, you should write something like this:
Guid guid = NativeMethods.GUID_TextEditorFactory;
windowFrame.SetGuidProperty((int) __VSFPROPID.VSFPROPID_InheritKeyBindings, ref guid);
Regards,
Gaston
> Dear all,
>
[quoted text clipped - 24 lines]
> Thanks for your help.
> Cheers.
Maxime LABELLE - 24 Mar 2005 10:13 GMT
OK,
That puts me on the right track. However, it seems I have to do that from
the code window manager in a language service VsPackage. It seems to confirm
that you can have a language service VsPackage without an editor VsPackage
but not the other way around.
It sorts of make sense : in order to create a custom syntax highlighter, it
does not seem necessary to create a custom editor.
Thanks a lot.
> You have to inherit the keybindings from the TextEditor, you should write something like this:
>
[quoted text clipped - 3 lines]
> Regards,
> Gaston
"Ed Dore [MSFT]" - 24 Mar 2005 23:43 GMT
I've actually written both an editor without a language service, and a
language service without an editor.
You can set the VSFPROPID_InheritKeyBindings property from your editor
factory's CreateEditorInstance implementation as Gaston mentioned, or
alternatively return that same guid, for that out pguidCmdUI argument.
Gaston's suggestion is the proper way to go though, as you may have
specific key bindings tied to your own package commands.
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.
Maxime LABELLE - 25 Mar 2005 17:37 GMT
OK. I'm starting to understand.
Thanks for the clarifications.
Maxime.