Skip to content

Commit

Permalink
merge master into ace-console
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed May 19, 2011
2 parents 9e5d291 + f1dac4e commit 6f570b5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 25 deletions.
Expand Up @@ -75,7 +75,7 @@ public FileTypeRegistry(EventBus eventBus)
register("README", TEXT, icons.iconText());
register("*.r", R, icons.iconRdoc());
register(".rprofile", R, icons.iconRprofile());
register("*.rhistory", R, icons.iconRhistory());
register("*.rhistory", TEXT, icons.iconRhistory());
register("*.rnw", SWEAVE, icons.iconRsweave());
register("*.snw", SWEAVE, icons.iconRsweave());
register("*.nw", SWEAVE, icons.iconRsweave());
Expand Down
Expand Up @@ -217,8 +217,6 @@ well as menu structures (for main menu and popup menus).
<shortcut refid="firstTab" value="Ctrl+Alt+Shift+Left"/>
<shortcut refid="lastTab" value="Ctrl+Alt+Shift+Right"/>
<shortcut refid="quickOpen" value="Cmd+Alt+O"/>
<shortcut refid="historySendToConsole" value="Cmd+Shift+C"/>
<shortcut refid="historySendToSource" value="Cmd+Shift+U"/>
<shortcut refid="previousPlot" value="Cmd+PageUp" />
<shortcut refid="nextPlot" value="Cmd+PageDown" />
<shortcut refid="removePlot" value="Cmd+Shift+R" />
Expand Down Expand Up @@ -412,11 +410,11 @@ well as menu structures (for main menu and popup menus).
<cmd id="historySendToSource"
menuLabel="Insert into _Source"
buttonLabel="To Source"
desc="Insert the selected command(s) into the current document"/>
desc="Insert the selected commands into the current document (Shift+Enter)"/>
<cmd id="historySendToConsole"
menuLabel="Send to _Console"
buttonLabel="To Console"
desc="Send the selected command(s) to the R console"/>
desc="Send the selected commands to the R console (Enter)"/>
<cmd id="searchHistory"
menuLabel="Search History"
buttonLabel=""
Expand Down
Expand Up @@ -168,7 +168,7 @@ public void consoleWriteInput(String input)
{
pendingInput_.setText("");
pendingInput_.setVisible(false);
output(input, styles_.input() + KEYWORD_CLASS_NAME, false);
output(input, styles_.command() + KEYWORD_CLASS_NAME, false);
scrollToBottomAsync();
}

Expand Down
Expand Up @@ -272,13 +272,18 @@ public void onHistoryEntriesAdded(HistoryEntriesAddedEvent event)
view_.getSearchBox().addValueChangeHandler(searchCommand_);

view_.getRecentCommandsWidget().getKeyTarget().addKeyDownHandler(
new KeyHandler(commands.historySendToConsole(), null, null));
new KeyHandler(commands.historySendToConsole(),
commands.historySendToSource(),
null,
null));
view_.getSearchResultsWidget().getKeyTarget().addKeyDownHandler(
new KeyHandler(commands.historySendToConsole(),
commands.historySendToSource(),
commands.historyDismissResults(),
commands.historyShowContext()));
view_.getCommandContextWidget().getKeyTarget().addKeyDownHandler(
new KeyHandler(commands.historySendToConsole(),
commands.historySendToSource(),
commands.historyDismissContext(),
null));

Expand Down Expand Up @@ -338,38 +343,57 @@ private void setRecentCommands(ArrayList<HistoryEntry> commands,

private class KeyHandler implements KeyDownHandler
{
private KeyHandler(Command accept, Command left, Command right)
private KeyHandler(Command accept,
Command shiftAccept,
Command left,
Command right)
{
this.accept_ = accept;
this.shiftAccept_ = shiftAccept;
this.left_ = left;
this.right_ = right;
}

public void onKeyDown(KeyDownEvent event)
{
if (event.isAnyModifierKeyDown() || !view_.isCommandTableFocused())
if (!view_.isCommandTableFocused())
return;

boolean handled = false;
switch (event.getNativeKeyCode())

if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
{
case KeyCodes.KEY_ENTER:
if (event.isShiftKeyDown())
{
if (shiftAccept_ != null)
shiftAccept_.execute();
handled = true;
}
else if (!event.isAnyModifierKeyDown())
{
if (accept_ != null)
accept_.execute();
handled = true;
break;
case KeyCodes.KEY_ESCAPE:
case KeyCodes.KEY_LEFT:
if (left_ != null)
left_.execute();
handled = true;
break;
case KeyCodes.KEY_RIGHT:
if (right_ != null)
right_.execute();
handled = true;
break;
}
}
else if (!event.isAnyModifierKeyDown())
{
switch (event.getNativeKeyCode())
{
case KeyCodes.KEY_ESCAPE:
case KeyCodes.KEY_LEFT:
if (left_ != null)
left_.execute();
handled = true;
break;
case KeyCodes.KEY_RIGHT:
if (right_ != null)
right_.execute();
handled = true;
break;
}
}

if (handled)
{
event.preventDefault();
Expand All @@ -378,6 +402,7 @@ public void onKeyDown(KeyDownEvent event)
}

private final Command accept_;
private final Command shiftAccept_;
private final Command left_;
private final Command right_;
}
Expand Down
Expand Up @@ -320,7 +320,7 @@ public void onClick(ClickEvent event)
{
if (doubleClick_.checkForDoubleClick(event.getNativeEvent()))
{
if (event.getNativeEvent().getAltKey())
if (event.getNativeEvent().getShiftKey())
commands_.historySendToSource().execute();
else
commands_.historySendToConsole().execute();
Expand Down

0 comments on commit 6f570b5

Please sign in to comment.