SHL-82 Improve detection of apple terminal

Remove AbstractShellTest as it didn't test anything other than calling for system properties
Fix failing tests
This commit is contained in:
mpollack
2013-07-25 18:24:47 -04:00
parent 42328fb890
commit 612da3bda1
4 changed files with 9 additions and 60 deletions

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.shell.core;
import static org.springframework.shell.support.util.OsUtils.LINE_SEPARATOR;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
@@ -26,13 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.text.DateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -47,7 +39,6 @@ import org.springframework.shell.support.util.IOUtils;
import org.springframework.shell.support.util.MathUtils;
import org.springframework.shell.support.util.VersionUtils;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Provides a base {@link Shell} implementation.

View File

@@ -74,7 +74,6 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker,
private static final String ANSI_CONSOLE_CLASSNAME = "org.fusesource.jansi.AnsiConsole";
private static final boolean JANSI_AVAILABLE = ClassUtils.isPresent(ANSI_CONSOLE_CLASSNAME,
JLineShell.class.getClassLoader());
private static final boolean APPLE_TERMINAL = Boolean.getBoolean("is.apple.terminal");
private static final char ESCAPE = 27;
private static final String BEL = "\007";
// Fields
@@ -410,7 +409,7 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker,
// Externally synchronized via the two calling methods having a mutex on flashInfoMap
private void doAnsiFlash(final int row, final Level level, final String message) {
ANSIBuffer buff = JLineLogHandler.getANSIBuffer();
if (APPLE_TERMINAL) {
if (isAppleTerminal()) {
buff.append(ESCAPE + "7");
}
else {
@@ -452,7 +451,7 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker,
// Record we want to erase from this positioning next time (so we clean up after ourselves)
rowErasureMap.put(row, startFrom);
}
if (APPLE_TERMINAL) {
if (isAppleTerminal()) {
buff.append(ESCAPE + "8");
}
else {
@@ -621,5 +620,11 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker,
public void setHistorySize(int historySize) {
this.historySize = historySize;
}
private static boolean isAppleTerminal()
{
final String terminalName = System.getenv( "TERM_PROGRAM" );
return ("Apple_Terminal".equalsIgnoreCase( terminalName ) || Boolean.getBoolean("is.apple.terminal"));
}
}