Merge remote-tracking branch 'origin/master'
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 26 Oct 2016 16:31:15 +0000 (18:31 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 26 Oct 2016 16:31:15 +0000 (18:31 +0200)
plugins/terminal/lib/jediterm-pty-2.2.jar
plugins/terminal/resources/jediterm-bash.in
plugins/terminal/src/org/jetbrains/plugins/terminal/JBTabbedTerminalWidget.java
plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalStarter.java
plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalWidget.java
plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
plugins/terminal/tests/org/jetbrains/plugins/terminal/TerminalShellCommandTest.java

index ca2aa5eb4288d2dbfe934d7188e336f7c37a2b2c..61b96fd443b592402960587d067c89206fd59bb0 100644 (file)
Binary files a/plugins/terminal/lib/jediterm-pty-2.2.jar and b/plugins/terminal/lib/jediterm-pty-2.2.jar differ
index 8819720d23b5ef494ebbc4c30e88c27361451d6a..84f9a799296b744919aadf064637168b04717522 100644 (file)
@@ -26,7 +26,7 @@ function load_login_configs {
 }
 
 function load_interactive_configs {
-  if [ -f ~/.bash_profile ]; then
+  if [ -f ~/.bashrc ]; then
        source ~/.bashrc
   fi
 }
@@ -53,6 +53,11 @@ export -f generate_command_executed_sequence
 #generate escape sequence after command is executed to notify jediterm emulator
 trap "generate_command_executed_sequence" DEBUG
 
+if [ -n "$JEDITERM_USER_RCFILE" ]
+then
+  source $JEDITERM_USER_RCFILE
+fi
+
 if [ -n "$JEDITERM_SOURCE" ]
 then
   source $JEDITERM_SOURCE
index bab43d35d93c29cdddc2d15cc894b3cf47ccca3f..92aa38c26c9ef4865f213c55e445b405cad41ed4 100644 (file)
@@ -100,6 +100,9 @@ public class JBTabbedTerminalWidget extends TabbedTerminalWidget implements Disp
                                     @NotNull List<TerminalAction> actions,
                                     @Nullable final Predicate<KeyEvent> elseAction) {
     for (final TerminalAction action : actions) {
+      if (action.isHidden()) {
+        continue;
+      }
       AnAction a = new DumbAwareAction() {
         @Override
         public void actionPerformed(AnActionEvent e) {
@@ -117,7 +120,7 @@ public class JBTabbedTerminalWidget extends TabbedTerminalWidget implements Disp
 
   @Override
   protected JediTermWidget createInnerTerminalWidget(TabbedSettingsProvider settingsProvider) {
-    return new JBTerminalWidget(mySettingsProvider, myParent);
+    return new JBTerminalWidget(myProject, mySettingsProvider, myParent);
   }
 
   @Override
index f220b1b11ac032922b992f7fd0f156c2dbd1f177..ef97d1643663dc0bf77b4f016f2e1b04a2de15f3 100644 (file)
@@ -2,22 +2,24 @@ package org.jetbrains.plugins.terminal;
 
 import com.intellij.ide.GeneralSettings;
 import com.intellij.openapi.vfs.LocalFileSystem;
-import com.jediterm.terminal.*;
+import com.jediterm.terminal.Terminal;
+import com.jediterm.terminal.TerminalDataStream;
+import com.jediterm.terminal.TerminalStarter;
+import com.jediterm.terminal.TtyConnector;
 import com.jediterm.terminal.emulator.JediEmulator;
 
-import javax.swing.*;
-
 /**
  * @author traff
  */
 public class JBTerminalStarter extends TerminalStarter {
-  public JBTerminalStarter(Terminal terminal, TtyConnector ttyConnector) {
-    super(terminal, ttyConnector);
+
+  public JBTerminalStarter(Terminal terminal, TtyConnector ttyConnector, TerminalDataStream dataStream) {
+    super(terminal, ttyConnector, dataStream);
   }
 
   @Override
-  protected JediEmulator createEmulator(TtyChannel channel, TerminalOutputStream stream, Terminal terminal) {
-    return new JediEmulator(channel, stream, terminal) {
+  protected JediEmulator createEmulator(TerminalDataStream dataStream, Terminal terminal) {
+    return new JediEmulator(dataStream, terminal) {
       @Override
       protected void unsupported(char... sequenceChars) {
         if (sequenceChars[0] == 7) { //ESC BEL
index c6ab620cfac28a94eb7216482453d46ccc19f401..8a935c8c30e08ebd496294a06fab4312f4e1ef7f 100644 (file)
@@ -1,7 +1,10 @@
 package org.jetbrains.plugins.terminal;
 
+import com.google.common.base.Predicate;
 import com.intellij.openapi.Disposable;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.wm.ToolWindowManager;
 import com.intellij.ui.SearchTextField;
 import com.intellij.ui.components.JBScrollBar;
 import com.intellij.ui.components.JBScrollPane;
@@ -9,23 +12,30 @@ import com.intellij.util.ui.JBSwingUtilities;
 import com.intellij.util.ui.RegionPainter;
 import com.jediterm.terminal.SubstringFinder;
 import com.jediterm.terminal.TerminalStarter;
+import com.jediterm.terminal.TtyBasedArrayDataStream;
 import com.jediterm.terminal.TtyConnector;
 import com.jediterm.terminal.model.JediTerminal;
 import com.jediterm.terminal.model.StyleState;
 import com.jediterm.terminal.model.TerminalTextBuffer;
 import com.jediterm.terminal.ui.JediTermWidget;
+import com.jediterm.terminal.ui.TerminalAction;
 import com.jediterm.terminal.ui.settings.SettingsProvider;
 import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
 import javax.swing.event.DocumentListener;
 import java.awt.*;
+import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
+import java.util.List;
 
 public class JBTerminalWidget extends JediTermWidget implements Disposable{
 
-  public JBTerminalWidget(JBTerminalSystemSettingsProvider settingsProvider, Disposable parent) {
+  private final Project myProject;
+
+  public JBTerminalWidget(Project project, JBTerminalSystemSettingsProvider settingsProvider, Disposable parent) {
     super(settingsProvider);
+    myProject = project;
     setName("terminal");
     JBTabbedTerminalWidget.convertActions(this, getActions());
 
@@ -48,7 +58,7 @@ public class JBTerminalWidget extends JediTermWidget implements Disposable{
 
   @Override
   protected TerminalStarter createTerminalStarter(JediTerminal terminal, TtyConnector connector) {
-    return new JBTerminalStarter(terminal, connector);
+    return new JBTerminalStarter(terminal, connector, new TtyBasedArrayDataStream(connector));
   }
 
   @Override
@@ -75,7 +85,28 @@ public class JBTerminalWidget extends JediTermWidget implements Disposable{
     });
     return bar;
   }
-  
+
+  @Override
+  public List<TerminalAction> getActions() {
+     List<TerminalAction> actions = super.getActions();
+     if (!TerminalOptionsProvider.getInstance().overrideIdeShortcuts()) {
+       actions
+         .add(new TerminalAction("EditorEscape", new KeyStroke[]{KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)}, new Predicate<KeyEvent>() {
+           @Override
+           public boolean apply(KeyEvent input) {
+             if (!myTerminalPanel.getTerminalTextBuffer().isUsingAlternateBuffer()) {
+               ToolWindowManager.getInstance(myProject).activateEditorComponent();
+               return true;
+             }
+             else {
+               return false;
+             }
+           }
+         }).withHidden(true));
+     }
+     return actions;
+  };
+
   @Override
   public void dispose() {
   }
index a417ffe7ba802cc3b41a67ede513dcbdac43c5a6..e2a5119c5dedaa75dcd3b586c604f0a3ae8267e4 100644 (file)
@@ -25,6 +25,7 @@ import com.intellij.execution.process.ProcessWaitFor;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.CharsetToolkit;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.concurrency.AppExecutorUtil;
@@ -221,7 +222,7 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
     if (idx >= 0) {
       command.remove(idx);
       if (idx < command.size()) {
-        envs.put("JEDITERM_SOURCE", command.get(idx));
+        envs.put("JEDITERM_USER_RCFILE", FileUtil.expandUserHome(command.get(idx)));
         command.remove(idx);
       }
     }
index 4b3110b7fb936307e454b27b60c0baa3f7e09baf..cd80369bd2b1e7909696ac39a36ab2737978368c 100644 (file)
@@ -44,10 +44,10 @@ public class TerminalShellCommandTest extends TestCase {
 
   public void testAddRcConfig() {
     hasRcConfig("bash -i", "jediterm-bash.in", Maps.newHashMap());
-    hasRcConfig("sh --login", "jediterm-bash.in", Maps.newHashMap());
+    hasRcConfig("bash --login", "jediterm-bash.in", Maps.newHashMap());
     Map<String, String> envs = Maps.newHashMap();
-    hasRcConfig("sh --rcfile ~/.bashrc", "jediterm-bash.in", envs);
-    assertEquals("~/.bashrc", envs.get("JEDITERM_SOURCE"));
+    hasRcConfig("bash --rcfile ~/.bashrc", "jediterm-bash.in", envs);
+    assertEquals("~/.bashrc", envs.get("JEDITERM_USER_RCFILE"));
   }
 
   private static void hasRcConfig(String path, String configName, Map<String, String> envs) {