Removed tracking of last issued command. It was not reliable.
diff --git a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/core/connector/LocalTerminalConnector.java b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/core/connector/LocalTerminalConnector.java
index 2b6f59c..3f9cffa 100644
--- a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/core/connector/LocalTerminalConnector.java
+++ b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/core/connector/LocalTerminalConnector.java
@@ -108,13 +108,6 @@
}
}
- public void addListenerToOutput(IStreamListener listener) {
- if (streamsProxy != null) {
- IStreamMonitor monitor = streamsProxy.getOutputStreamMonitor();
- addListener(monitor, listener);
- }
- }
-
private void addListener(IStreamMonitor monitor, IStreamListener listener) {
monitor.addListener(listener);
listener.streamAppended(monitor.getContents(), monitor);
diff --git a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/LastCommandTracker.java b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/LastCommandTracker.java
deleted file mode 100644
index c784365..0000000
--- a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/LastCommandTracker.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2012 Google Inc.
- *
- * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
- * Public License v1.0 which accompanies this distribution, and is available at
- *
- * http://www.eclipse.org/legal/epl-v10.html
- */
-package com.google.eclipse.terminal.local.ui.view;
-
-import java.util.*;
-import java.util.regex.Pattern;
-
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.swt.events.*;
-import org.eclipse.tm.internal.terminal.emulator.VT100TerminalControl;
-
-/**
- * @author alruiz@google.com (Alex Ruiz)
- */
-class LastCommandTracker extends KeyAdapter implements IStreamListener {
- private static final String CR_LF_CR = "\r\n\r";
- private static final String CR_LF = "\r\n";
- private static final Pattern WHITE_SPACE_PATTERN = Pattern.compile("[\\s]+");
-
- private final List<String> words = new ArrayList<String>();
-
- private final VT100TerminalControl terminalControl;
- private CommandListener commandListener;
-
- LastCommandTracker(VT100TerminalControl terminalControl) {
- this.terminalControl = terminalControl;
- }
-
- void setCommandListener(CommandListener listener) {
- commandListener = listener;
- }
-
- @Override public void streamAppended(String text, IStreamMonitor monitor) {
- int charCount = text.length();
- if (charCount == 0) {
- return;
- }
- String word = text;
- if (word.endsWith(CR_LF_CR)) {
- // this happens before a line gets wrapped
- word = word.substring(0, charCount - CR_LF_CR.length());
- }
- // this happens after a line gets wrapped
- int index = word.lastIndexOf(CR_LF);
- if (index != -1) {
- words.clear();
- word = word.substring(index + CR_LF.length(), charCount);
- }
- if (!word.isEmpty()) {
- words.add(word);
- }
- }
-
- @Override public void keyPressed(KeyEvent e) {
- if (e.character == '\r') {
- trackLastCommand();
- }
- }
-
- private void trackLastCommand() {
- int line = terminalControl.getCursorLine();
- String text = textAtLine(line);
- if (text.isEmpty() || words.isEmpty()) {
- return;
- }
- String prompt = words.get(0);
- if (text.startsWith(prompt)) {
- String command = lastCommand(prompt, text);
- notifyCommandIssued(command);
- return;
- }
- // most likely line wrapped;
- while (!text.startsWith(prompt)) {
- String previousLineText = textAtLine(--line);
- if (previousLineText.isEmpty()) {
- return;
- }
- text = previousLineText.concat(text);
- }
- String command = lastCommand(prompt, text);
- notifyCommandIssued(command);
- }
-
- private String textAtLine(int line) {
- if (line < 0) {
- return "";
- }
- char[] chars = terminalControl.getChars(line);
- if (chars == null || chars.length == 0) {
- return "";
- }
- return new String(chars).trim();
- }
-
- private String lastCommand(String prompt, String text) {
- String command = null;
- String withoutPrompt = text.substring(prompt.length());
- String[] actualInput = WHITE_SPACE_PATTERN.split(withoutPrompt);
- if (actualInput.length != 0) {
- command = actualInput[0];
- }
- return (command == null) ? "" : command;
- }
-
- private void notifyCommandIssued(String command) {
- if (!command.isEmpty() && commandListener != null) {
- commandListener.commandIssued(command);
- }
- }
-}
\ No newline at end of file
diff --git a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/TerminalView.java b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/TerminalView.java
index 14df3e5..261022f 100644
--- a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/TerminalView.java
+++ b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/TerminalView.java
@@ -47,8 +47,6 @@
private static final String VIEW_ID = "com.google.eclipse.terminal.local.localTerminalView";
- private static final String VIEW_TITLE_FORMAT = "%s : %s";
-
private IPropertyChangeListener preferencesChangeListener;
private IPropertyChangeListener textFontChangeListener;
private IMemento savedState;
@@ -93,12 +91,6 @@
@Override public void createPartControl(Composite parent) {
terminalWidget = new TerminalWidget(parent, SWT.NONE);
- terminalWidget.setCommandListener(new CommandListener() {
- @Override public void commandIssued(String command) {
- String title = String.format(VIEW_TITLE_FORMAT, workingDirectory.lastSegment(), command);
- updatePartName(title);
- }
- });
terminalWidget.setLifeCycleListener(new LifeCycleListener() {
@Override public void executionFinished() {
closeViewOnExitIfPossible();
diff --git a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/TerminalWidget.java b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/TerminalWidget.java
index ed8977f..7229294 100644
--- a/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/TerminalWidget.java
+++ b/com.google.eclipse.terminal.local/src/com/google/eclipse/terminal/local/ui/view/TerminalWidget.java
@@ -32,7 +32,6 @@
private final VT100TerminalControl terminalControl;
private final EditActions editActions;
- private final LastCommandTracker lastCommandTracker;
private LifeCycleListener lifeCycleListener;
@@ -69,8 +68,6 @@
editActions.update();
}
});
- lastCommandTracker = new LastCommandTracker(terminalControl);
- terminalTextControl.addKeyListener(lastCommandTracker);
}
private Menu createContextMenu(MenuManager menuManager) {
@@ -93,7 +90,6 @@
return;
}
terminalControl.connectTerminal();
- localTerminalConnector().addListenerToOutput(lastCommandTracker);
attachLifeCycleListener();
}
@@ -158,10 +154,6 @@
terminalControl.setScrollLock(enabled);
}
- void setCommandListener(CommandListener listener) {
- lastCommandTracker.setCommandListener(listener);
- }
-
private static class TerminalListener implements ITerminalListener {
ITerminalListener delegate;
diff --git a/com.google.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/com.google.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
index f392d5b..a69e07a 100644
--- a/com.google.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
+++ b/com.google.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
@@ -1050,12 +1050,4 @@
public void setColors(RGB background, RGB foreground) {
fCtlText.setColors(background, foreground);
}
-
- public int getCursorLine() {
- return fCtlText.getCursorLine();
- }
-
- public char[] getChars(int line) {
- return fCtlText.getChars(line);
- }
}
diff --git a/com.google.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/com.google.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java
index 560f374..181604c 100644
--- a/com.google.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java
+++ b/com.google.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java
@@ -429,13 +429,5 @@
fCellRenderer.setFont(font);
redraw();
}
-
- public int getCursorLine() {
- return fCellCanvasModel.getCursorLine();
- }
-
- public char[] getChars(int line) {
- return fCellCanvasModel.getTerminalText().getChars(line);
- }
}