I'd like to create an Eclipse plugin that emulates the behaviour of the vi text editor. This would require changing the way mouse and keyboard events are handled. So, for example if the user presses "h" while in Normal Mode, the cursor should move left, rather than inserting the "h" character into the text buffer. I've found an old mailing list post that describes how to listen to changes in the document, and changes in the presentation, but nothing that describes how to intercept low-level keyboard and mouse events, such that the default behaviour can be overridden. What would be the best way to accomplish this?
One idea would be for a particular active text editor you would want to grab the low-level StyledText widget that is rendering the actual text and also accepting keyboard input and add a KeyListener there.
AbstractTextEditor textEditor = ...
ITextViewer viewer = textEditor.getSourceViewer();
StyledText textWidget = viewer.getTextWidget();
textWidget.addKeyListener(...);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With