docDisplay_.addKeyDownHandler(new KeyDownHandler()
{
public void onKeyDown(KeyDownEvent event)
{
NativeEvent ne = event.getNativeEvent();
int mod = KeyboardShortcut.getModifierValue(ne);
if ((mod == KeyboardShortcut.META || (mod == KeyboardShortcut.CTRL && !BrowseCap.hasMetaKey()))
&& ne.getKeyCode() == 'F')
{
event.preventDefault();
event.stopPropagation();
commands_.findReplace().execute();
}
else if (BrowseCap.hasMetaKey() &&
(mod == KeyboardShortcut.META) &&
(ne.getKeyCode() == 'E'))
{
event.preventDefault();
event.stopPropagation();
commands_.findFromSelection().execute();
}
else if (mod == KeyboardShortcut.ALT
&& ne.getKeyCode() == 189) // hyphen
{
event.preventDefault();
event.stopPropagation();
docDisplay_.insertCode(" <- ", false);
}
else if (mod == KeyboardShortcut.CTRL
&& ne.getKeyCode() == KeyCodes.KEY_UP
&& fileType_ == FileTypeRegistry.R)
{
event.preventDefault();
event.stopPropagation();
jumpToPreviousFunction();
}
else if (mod == KeyboardShortcut.CTRL
&& ne.getKeyCode() == KeyCodes.KEY_DOWN
&& fileType_ == FileTypeRegistry.R)
{
event.preventDefault();
event.stopPropagation();
jumpToNextFunction();
}
else if ((ne.getKeyCode() == KeyCodes.KEY_ESCAPE) &&
!prefs_.useVimMode().getValue())
{
event.preventDefault();
event.stopPropagation();
if (commands_.interruptR().isEnabled())
commands_.interruptR().execute();
}
else if (ne.getKeyCode() == KeyCodes.KEY_M && (
(BrowseCap.hasMetaKey() &&
mod == (KeyboardShortcut.META + KeyboardShortcut.SHIFT)) ||
(!BrowseCap.hasMetaKey() &&
mod == (KeyboardShortcut.CTRL + KeyboardShortcut.SHIFT))))
{