Skip to content

Commit

Permalink
Alt+- inserts <-
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Mar 15, 2011
1 parent 2136f7e commit 24b5116
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.gwt.user.client.DeferredCommand;
import com.google.inject.Inject;
import org.rstudio.core.client.BrowseCap;
import org.rstudio.core.client.Debug;
import org.rstudio.core.client.command.CommandBinder;
import org.rstudio.core.client.command.Handler;
import org.rstudio.core.client.command.KeyboardShortcut;
Expand Down Expand Up @@ -456,6 +457,17 @@ else if (mod == KeyboardShortcut.META)
break;
}
}
else if (mod == KeyboardShortcut.ALT)
{
switch (keyCode)
{
case 189: // hyphen
event.preventDefault();
event.stopPropagation();
input_.replaceSelection(" <- ", true);
break;
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.rstudio.core.client.command.AppCommand;
import org.rstudio.core.client.command.CommandBinder;
import org.rstudio.core.client.command.Handler;
import org.rstudio.core.client.command.KeyboardShortcut;
import org.rstudio.core.client.dom.DomUtils;
import org.rstudio.core.client.events.EnsureVisibleHandler;
import org.rstudio.core.client.events.HasEnsureVisibleHandlers;
Expand Down Expand Up @@ -217,15 +218,21 @@ public TextEditingTarget(Commands commands,
public void onKeyDown(KeyDownEvent event)
{
NativeEvent ne = event.getNativeEvent();
if ((ne.getMetaKey() ^ ne.getCtrlKey())
&& !ne.getAltKey()
&& !ne.getShiftKey()
int mod = KeyboardShortcut.getModifierValue(ne);
if ((mod == KeyboardShortcut.META || mod == KeyboardShortcut.CTRL)
&& ne.getKeyCode() == 'F')
{
event.preventDefault();
event.stopPropagation();
commands_.findReplace().execute();
}
else if (mod == KeyboardShortcut.ALT
&& ne.getKeyCode() == 189) // hyphen
{
event.preventDefault();
event.stopPropagation();
docDisplay_.insertCode(" <- ", false);
}
}
});
}
Expand Down

0 comments on commit 24b5116

Please sign in to comment.