You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2015/11/17 01:10:34 UTC
incubator-geode git commit: Revert "GEODE-543: upgrade the Jline and
Spring Shell libraries and fix the compilation erros"
Repository: incubator-geode
Updated Branches:
refs/heads/develop 058aad366 -> e8ddd3398
Revert "GEODE-543: upgrade the Jline and Spring Shell libraries and fix the compilation erros"
This reverts commit 058aad3663cb00de3ac83f76b9c9b72a32952ca3.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/e8ddd339
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/e8ddd339
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/e8ddd339
Branch: refs/heads/develop
Commit: e8ddd3398d90818f552dcec00eff29d01bc93795
Parents: 058aad3
Author: Jens Deppe <jd...@pivotal.io>
Authored: Mon Nov 16 16:07:39 2015 -0800
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Mon Nov 16 16:07:39 2015 -0800
----------------------------------------------------------------------
gemfire-core/build.gradle | 2 +-
.../management/internal/cli/CliUtil.java | 2 +-
.../management/internal/cli/Launcher.java | 4 +-
.../internal/cli/commands/ShellCommands.java | 4 +-
.../management/internal/cli/shell/Gfsh.java | 15 +-
.../internal/cli/shell/jline/ANSIBuffer.java | 433 -------------------
.../internal/cli/shell/jline/ANSIHandler.java | 5 +-
.../cli/shell/jline/CygwinMinttyTerminal.java | 137 +++++-
.../internal/cli/shell/jline/GfshHistory.java | 13 +-
.../shell/jline/GfshUnsupportedTerminal.java | 2 +-
.../internal/cli/util/CLIConsoleBufferUtil.java | 8 +-
.../PersistentPartitionedRegionTestBase.java | 2 +-
gradle/dependency-versions.properties | 4 +-
13 files changed, 163 insertions(+), 468 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-core/build.gradle b/gemfire-core/build.gradle
index aa83bb9..f03066f 100755
--- a/gemfire-core/build.gradle
+++ b/gemfire-core/build.gradle
@@ -35,7 +35,7 @@ dependencies {
compile 'mx4j:mx4j-remote:' + project.'mx4j.version'
compile 'mx4j:mx4j-tools:' + project.'mx4j.version'
compile 'net.java.dev.jna:jna:' + project.'jna.version'
- compile 'jline:jline:' + project.'jline.version'
+ compile 'net.sourceforge.jline:jline:' + project.'jline.version'
provided 'org.apache.hadoop:hadoop-common:' + project.'hadoop.version'
provided 'org.apache.hadoop:hadoop-annotations:' + project.'hadoop.version'
provided 'org.apache.hadoop:hadoop-hdfs:' + project.'hadoop.version'
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/CliUtil.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/CliUtil.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/CliUtil.java
index 09f8bd8..bc1f7b7 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/CliUtil.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/CliUtil.java
@@ -105,7 +105,7 @@ public class CliUtil {
if (includeGfshDependencies) {
// ConsoleReader from jline
- jarProductName = checkLibraryByLoadingClass("jline.console.ConsoleReader", "JLine");
+ jarProductName = checkLibraryByLoadingClass("jline.ConsoleReader", "JLine");
if (jarProductName != null) {
return jarProductName;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/Launcher.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/Launcher.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/Launcher.java
index 12e2c50..8bf1ce1 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/Launcher.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/Launcher.java
@@ -166,7 +166,7 @@ public final class Launcher {
System.err.println(CliStrings.format(MSG_INVALID_COMMAND_OR_OPTION, CliUtil.arrayToString(args)));
exitRequest = ExitShellRequest.FATAL_EXIT;
} else {
- if (!gfsh.executeScriptLine(commandLineCommand)) {
+ if (!gfsh.executeCommand(commandLineCommand)) {
if (gfsh.getLastExecutionStatus() != 0)
exitRequest = ExitShellRequest.FATAL_EXIT;
} else if (gfsh.getLastExecutionStatus() != 0) {
@@ -224,7 +224,7 @@ public final class Launcher {
String command = commandsToExecute.get(i);
System.out.println(GfshParser.LINE_SEPARATOR + "(" + (i + 1) + ") Executing - " + command
+ GfshParser.LINE_SEPARATOR);
- if (!gfsh.executeScriptLine(command) || gfsh.getLastExecutionStatus() != 0) {
+ if (!gfsh.executeCommand(command) || gfsh.getLastExecutionStatus() != 0) {
exitRequest = ExitShellRequest.FATAL_EXIT;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
index 1bd7692..edab207 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
@@ -853,8 +853,8 @@ private void configureHttpsURLConnection(Map<String, String> sslConfigProps) thr
int historySizeWordLength = historySizeString.length();
GfshHistory gfshHistory = gfsh.getGfshHistory();
- //List<?> gfshHistoryList = gfshHistory.getHistoryList();
- Iterator<?> it = gfshHistory.entries();
+ List<?> gfshHistoryList = gfshHistory.getHistoryList();
+ Iterator<?> it = gfshHistoryList.iterator();
boolean flagForLineNumbers = (saveHistoryTo != null && saveHistoryTo
.length() > 0) ? false : true;
long lineNumber = 0;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/Gfsh.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/Gfsh.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/Gfsh.java
index 67a8ccb..1d14c5b 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/Gfsh.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/Gfsh.java
@@ -36,9 +36,9 @@ import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
+import jline.ConsoleReader;
import jline.Terminal;
-import jline.console.ConsoleReader;
import org.springframework.shell.core.AbstractShell;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.Converter;
@@ -380,6 +380,7 @@ public class Gfsh extends JLineShell {
/**
* See findResources in {@link AbstractShell}
*/
+ @Override
protected Collection<URL> findResources(String resourceName) {
// return Collections.singleton(ClassPathLoader.getLatest().getResource(resourceName));
return null;
@@ -419,7 +420,7 @@ public class Gfsh extends JLineShell {
* @return true if execution is successful; false otherwise
*/
@Override
- public boolean executeScriptLine(final String line) {
+ public boolean executeCommand(final String line) {
boolean success = false;
String withPropsExpanded = line;
@@ -439,7 +440,7 @@ public class Gfsh extends JLineShell {
if (gfshFileLogger.fineEnabled()) {
gfshFileLogger.fine(logMessage + withPropsExpanded);
}
- success = super.executeScriptLine(withPropsExpanded);
+ success = super.executeCommand(withPropsExpanded);
} catch (Exception e) {
//TODO: should there be a way to differentiate error in shell & error on
//server. May be by exception type.
@@ -632,12 +633,12 @@ public class Gfsh extends JLineShell {
///////////////////// JLineShell Class Methods End //////////////////////////
public int getTerminalHeight() {
- return terminal != null ? terminal.getHeight() : DEFAULT_HEIGHT;
+ return terminal != null ? terminal.getTerminalHeight() : DEFAULT_HEIGHT;
}
public int getTerminalWidth() {
if (terminal != null) {
- return terminal.getWidth();
+ return terminal.getTerminalWidth();
}
Map<String, String> env = System.getenv();
@@ -804,7 +805,7 @@ public class Gfsh extends JLineShell {
++commandSrNum;
Gfsh.println(commandSrNum+". Executing - " + cmdLet);
Gfsh.println();
- boolean executeSuccess = executeScriptLine(cmdLet);
+ boolean executeSuccess = executeCommand(cmdLet);
if (!executeSuccess) {
setLastExecutionStatus(-1);
}
@@ -921,7 +922,7 @@ public class Gfsh extends JLineShell {
readLine = reader.readLine(prompt);
} catch (IndexOutOfBoundsException e) {
if (earlierLine.length() == 0) {
- reader.println();
+ reader.printNewline();
readLine = LINE_SEPARATOR;
reader.getCursorBuffer().cursor = 0;
} else {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/ANSIBuffer.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/ANSIBuffer.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/ANSIBuffer.java
deleted file mode 100644
index 572f899..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/ANSIBuffer.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Marc Prud'hommeaux. All rights reserved.
- *
- * This software is distributable under the BSD license. See the terms of the
- * BSD license in the documentation provided with this software.
- */
-package com.gemstone.gemfire.management.internal.cli.shell.jline;
-
-import org.springframework.shell.support.util.OsUtils;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-/**
- * A buffer that can contain ANSI text.
- *
- * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
- */
-public class ANSIBuffer {
- private boolean ansiEnabled = true;
- private final StringBuffer ansiBuffer = new StringBuffer();
- private final StringBuffer plainBuffer = new StringBuffer();
-
- public ANSIBuffer() {
- }
-
- public ANSIBuffer(final String str) {
- append(str);
- }
-
- public void setAnsiEnabled(final boolean ansi) {
- this.ansiEnabled = ansi;
- }
-
- public boolean getAnsiEnabled() {
- return this.ansiEnabled;
- }
-
- public String getAnsiBuffer() {
- return ansiBuffer.toString();
- }
-
- public String getPlainBuffer() {
- return plainBuffer.toString();
- }
-
- public String toString(final boolean ansi) {
- return ansi ? getAnsiBuffer() : getPlainBuffer();
- }
-
- public String toString() {
- return toString(ansiEnabled);
- }
-
- public ANSIBuffer append(final String str) {
- ansiBuffer.append(str);
- plainBuffer.append(str);
-
- return this;
- }
-
- public ANSIBuffer attrib(final String str, final int code) {
- ansiBuffer.append(ANSICodes.attrib(code)).append(str)
- .append(ANSICodes.attrib(ANSICodes.OFF));
- plainBuffer.append(str);
-
- return this;
- }
-
- public ANSIBuffer red(final String str) {
- return attrib(str, ANSICodes.FG_RED);
- }
-
- public ANSIBuffer blue(final String str) {
- return attrib(str, ANSICodes.FG_BLUE);
- }
-
- public ANSIBuffer green(final String str) {
- return attrib(str, ANSICodes.FG_GREEN);
- }
-
- public ANSIBuffer black(final String str) {
- return attrib(str, ANSICodes.FG_BLACK);
- }
-
- public ANSIBuffer yellow(final String str) {
- return attrib(str, ANSICodes.FG_YELLOW);
- }
-
- public ANSIBuffer magenta(final String str) {
- return attrib(str, ANSICodes.FG_MAGENTA);
- }
-
- public ANSIBuffer cyan(final String str) {
- return attrib(str, ANSICodes.FG_CYAN);
- }
-
- public ANSIBuffer bold(final String str) {
- return attrib(str, ANSICodes.BOLD);
- }
-
- public ANSIBuffer underscore(final String str) {
- return attrib(str, ANSICodes.UNDERSCORE);
- }
-
- public ANSIBuffer blink(final String str) {
- return attrib(str, ANSICodes.BLINK);
- }
-
- public ANSIBuffer reverse(final String str) {
- return attrib(str, ANSICodes.REVERSE);
- }
-
- public static class ANSICodes {
- static final int OFF = 0;
- static final int BOLD = 1;
- static final int UNDERSCORE = 4;
- static final int BLINK = 5;
- static final int REVERSE = 7;
- static final int CONCEALED = 8;
- static final int FG_BLACK = 30;
- static final int FG_RED = 31;
- static final int FG_GREEN = 32;
- static final int FG_YELLOW = 33;
- static final int FG_BLUE = 34;
- static final int FG_MAGENTA = 35;
- static final int FG_CYAN = 36;
- static final int FG_WHITE = 37;
- static final char ESC = 27;
-
- /**
- * Constructor is private since this is a utility class.
- */
- private ANSICodes() {
- }
-
- /**
- * Sets the screen mode. The mode will be one of the following values:
- * <pre>
- * mode description
- * ----------------------------------------
- * 0 40 x 148 x 25 monochrome (text)
- * 1 40 x 148 x 25 color (text)
- * 2 80 x 148 x 25 monochrome (text)
- * 3 80 x 148 x 25 color (text)
- * 4 320 x 148 x 200 4-color (graphics)
- * 5 320 x 148 x 200 monochrome (graphics)
- * 6 640 x 148 x 200 monochrome (graphics)
- * 7 Enables line wrapping
- * 13 320 x 148 x 200 color (graphics)
- * 14 640 x 148 x 200 color (16-color graphics)
- * 15 640 x 148 x 350 monochrome (2-color graphics)
- * 16 640 x 148 x 350 color (16-color graphics)
- * 17 640 x 148 x 480 monochrome (2-color graphics)
- * 18 640 x 148 x 480 color (16-color graphics)
- * 19 320 x 148 x 200 color (256-color graphics)
- * </pre>
- */
- public static String setmode(final int mode) {
- return ESC + "[=" + mode + "h";
- }
-
- /**
- * Same as setmode () except for mode = 7, which disables line
- * wrapping (useful for writing the right-most column without
- * scrolling to the next line).
- */
- public static String resetmode(final int mode) {
- return ESC + "[=" + mode + "l";
- }
-
- /**
- * Clears the screen and moves the cursor to the home postition.
- */
- public static String clrscr() {
- return ESC + "[2J";
- }
-
- /**
- * Removes all characters from the current cursor position until
- * the end of the line.
- */
- public static String clreol() {
- return ESC + "[K";
- }
-
- /**
- * Moves the cursor n positions to the left. If n is greater or
- * equal to the current cursor column, the cursor is moved to the
- * first column.
- */
- public static String left(final int n) {
- return ESC + "[" + n + "D";
- }
-
- /**
- * Moves the cursor n positions to the right. If n plus the current
- * cursor column is greater than the rightmost column, the cursor
- * is moved to the rightmost column.
- */
- public static String right(final int n) {
- return ESC + "[" + n + "C";
- }
-
- /**
- * Moves the cursor n rows up without changing the current column.
- * If n is greater than or equal to the current row, the cursor is
- * placed in the first row.
- */
- public static String up(final int n) {
- return ESC + "[" + n + "A";
- }
-
- /**
- * Moves the cursor n rows down. If n plus the current row is greater
- * than the bottom row, the cursor is moved to the bottom row.
- */
- public static String down(final int n) {
- return ESC + "[" + n + "B";
- }
-
- /*
- * Moves the cursor to the given row and column. (1,1) represents
- * the upper left corner. The lower right corner of a usual DOS
- * screen is (25, 80).
- */
- public static String gotoxy(final int row, final int column) {
- return ESC + "[" + row + ";" + column + "H";
- }
-
- /**
- * Saves the current cursor position.
- */
- public static String save() {
- return ESC + "[s";
- }
-
- /**
- * Restores the saved cursor position.
- */
- public static String restore() {
- return ESC + "[u";
- }
-
- /**
- * Sets the character attribute. It will be
- * one of the following character attributes:
- *
- * <pre>
- * Text attributes
- * 0 All attributes off
- * 1 Bold on
- * 4 Underscore (on monochrome display adapter only)
- * 5 Blink on
- * 7 Reverse video on
- * 8 Concealed on
- *
- * Foreground colors
- * 30 Black
- * 31 Red
- * 32 Green
- * 33 Yellow
- * 34 Blue
- * 35 Magenta
- * 36 Cyan
- * 37 White
- *
- * Background colors
- * 40 Black
- * 41 Red
- * 42 Green
- * 43 Yellow
- * 44 Blue
- * 45 Magenta
- * 46 Cyan
- * 47 White
- * </pre>
- *
- * The attributes remain in effect until the next attribute command
- * is sent.
- */
- public static String attrib(final int attr) {
- return ESC + "[" + attr + "m";
- }
-
- /**
- * Sets the key with the given code to the given value. code must be
- * derived from the following table, value must
- * be any semicolon-separated
- * combination of String (enclosed in double quotes) and numeric values.
- * For example, to set F1 to the String "Hello F1", followed by a CRLF
- * sequence, one can use: ANSI.setkey ("0;59", "\"Hello F1\";13;10").
- * Heres's the table of key values:
- * <pre>
- * Key Code SHIFT+code CTRL+code ALT+code
- * ---------------------------------------------------------------
- * F1 0;59 0;84 0;94 0;104
- * F2 0;60 0;85 0;95 0;105
- * F3 0;61 0;86 0;96 0;106
- * F4 0;62 0;87 0;97 0;107
- * F5 0;63 0;88 0;98 0;108
- * F6 0;64 0;89 0;99 0;109
- * F7 0;65 0;90 0;100 0;110
- * F8 0;66 0;91 0;101 0;111
- * F9 0;67 0;92 0;102 0;112
- * F10 0;68 0;93 0;103 0;113
- * F11 0;133 0;135 0;137 0;139
- * F12 0;134 0;136 0;138 0;140
- * HOME (num keypad) 0;71 55 0;119 --
- * UP ARROW (num keypad) 0;72 56 (0;141) --
- * PAGE UP (num keypad) 0;73 57 0;132 --
- * LEFT ARROW (num keypad) 0;75 52 0;115 --
- * RIGHT ARROW (num keypad) 0;77 54 0;116 --
- * END (num keypad) 0;79 49 0;117 --
- * DOWN ARROW (num keypad) 0;80 50 (0;145) --
- * PAGE DOWN (num keypad) 0;81 51 0;118 --
- * INSERT (num keypad) 0;82 48 (0;146) --
- * DELETE (num keypad) 0;83 46 (0;147) --
- * HOME (224;71) (224;71) (224;119) (224;151)
- * UP ARROW (224;72) (224;72) (224;141) (224;152)
- * PAGE UP (224;73) (224;73) (224;132) (224;153)
- * LEFT ARROW (224;75) (224;75) (224;115) (224;155)
- * RIGHT ARROW (224;77) (224;77) (224;116) (224;157)
- * END (224;79) (224;79) (224;117) (224;159)
- * DOWN ARROW (224;80) (224;80) (224;145) (224;154)
- * PAGE DOWN (224;81) (224;81) (224;118) (224;161)
- * INSERT (224;82) (224;82) (224;146) (224;162)
- * DELETE (224;83) (224;83) (224;147) (224;163)
- * PRINT SCREEN -- -- 0;114 --
- * PAUSE/BREAK -- -- 0;0 --
- * BACKSPACE 8 8 127 (0)
- * ENTER 13 -- 10 (0
- * TAB 9 0;15 (0;148) (0;165)
- * NULL 0;3 -- -- --
- * A 97 65 1 0;30
- * B 98 66 2 0;48
- * C 99 66 3 0;46
- * D 100 68 4 0;32
- * E 101 69 5 0;18
- * F 102 70 6 0;33
- * G 103 71 7 0;34
- * H 104 72 8 0;35
- * I 105 73 9 0;23
- * J 106 74 10 0;36
- * K 107 75 11 0;37
- * L 108 76 12 0;38
- * M 109 77 13 0;50
- * N 110 78 14 0;49
- * O 111 79 15 0;24
- * P 112 80 16 0;25
- * Q 113 81 17 0;16
- * R 114 82 18 0;19
- * S 115 83 19 0;31
- * T 116 84 20 0;20
- * U 117 85 21 0;22
- * V 118 86 22 0;47
- * W 119 87 23 0;17
- * X 120 88 24 0;45
- * Y 121 89 25 0;21
- * Z 122 90 26 0;44
- * 1 49 33 -- 0;120
- * 2 50 64 0 0;121
- * 3 51 35 -- 0;122
- * 4 52 36 -- 0;123
- * 5 53 37 -- 0;124
- * 6 54 94 30 0;125
- * 7 55 38 -- 0;126
- * 8 56 42 -- 0;126
- * 9 57 40 -- 0;127
- * 0 48 41 -- 0;129
- * - 45 95 31 0;130
- * = 61 43 --- 0;131
- * [ 91 123 27 0;26
- * ] 93 125 29 0;27
- * 92 124 28 0;43
- * ; 59 58 -- 0;39
- * ' 39 34 -- 0;40
- * , 44 60 -- 0;51
- * . 46 62 -- 0;52
- * / 47 63 -- 0;53
- * ` 96 126 -- (0;41)
- * ENTER (keypad) 13 -- 10 (0;166)
- * / (keypad) 47 47 (0;142) (0;74)
- * * (keypad) 42 (0;144) (0;78) --
- * - (keypad) 45 45 (0;149) (0;164)
- * + (keypad) 43 43 (0;150) (0;55)
- * 5 (keypad) (0;76) 53 (0;143) --
- */
- public static String setkey(final String code, final String value) {
- return ESC + "[" + code + ";" + value + "p";
- }
- }
-
- public static void main(final String[] args) throws Exception {
- // sequence, one can use: ANSI.setkey ("0;59", "\"Hello F1\";13;10").
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(System.in));
- System.out.print(ANSICodes.setkey("97", "97;98;99;13")
- + ANSICodes.attrib(ANSICodes.OFF));
- System.out.flush();
-
- String line;
-
- while ((line = reader.readLine()) != null) {
- System.out.println("GOT: " + line);
- }
- }
-
- private static final boolean ROO_BRIGHT_COLORS = Boolean.getBoolean("roo.bright");
- private static final boolean SHELL_BRIGHT_COLORS = Boolean.getBoolean("spring.shell.bright");
- private static final boolean BRIGHT_COLORS = ROO_BRIGHT_COLORS || SHELL_BRIGHT_COLORS;
-
- public static ANSIBuffer getANSIBuffer() {
- final char esc = (char) 27;
- return new ANSIBuffer() {
- @Override
- public ANSIBuffer reverse(final String str) {
- if (OsUtils.isWindows()) {
- return super.reverse(str).append(ANSICodes.attrib(esc));
- }
- return super.reverse(str);
- };
- @Override
- public ANSIBuffer attrib(final String str, final int code) {
- if (BRIGHT_COLORS && 30 <= code && code <= 37) {
- // This is a color code: add a 'bright' code
- return append(esc + "[" + code + ";1m").append(str).append(ANSICodes.attrib(0));
- }
- return super.attrib(str, code);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/ANSIHandler.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/ANSIHandler.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/ANSIHandler.java
index c8102ae..ccd9864 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/ANSIHandler.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/ANSIHandler.java
@@ -18,6 +18,8 @@ package com.gemstone.gemfire.management.internal.cli.shell.jline;
import org.springframework.shell.core.JLineLogHandler;
+import jline.ANSIBuffer;
+
/**
* Overrides jline.History to add History without newline characters.
*
@@ -48,8 +50,7 @@ public class ANSIHandler {
String decoratedInput = input;
if (isAnsiEnabled()) {
- ANSIBuffer ansiBuffer = ANSIBuffer.getANSIBuffer();
-
+ ANSIBuffer ansiBuffer = JLineLogHandler.getANSIBuffer();
for (ANSIStyle ansiStyle : styles) {
switch (ansiStyle) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/CygwinMinttyTerminal.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/CygwinMinttyTerminal.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/CygwinMinttyTerminal.java
index f486774..d84bbe7 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/CygwinMinttyTerminal.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/CygwinMinttyTerminal.java
@@ -39,18 +39,147 @@ public class CygwinMinttyTerminal extends UnixTerminal {
String encoding = System.getProperty("input.encoding", "UTF-8");
+ ReplayPrefixOneCharInputStream replayStream = new ReplayPrefixOneCharInputStream(encoding);
InputStreamReader replayReader;
- public CygwinMinttyTerminal() throws Exception{
+ public CygwinMinttyTerminal() {
+ try {
+ replayReader = new InputStreamReader(replayStream, encoding);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
@Override
- public void init() throws Exception{
+ public void initializeTerminal() throws IOException, InterruptedException {
}
@Override
- public void restore() throws Exception {
- reset();
+ public void restoreTerminal() throws Exception {
+ resetTerminal();
}
+
+ @Override
+ public int readVirtualKey(InputStream in) throws IOException {
+ int c = readCharacter(in);
+
+ //if (backspaceDeleteSwitched)
+ if (c == DELETE)
+ c = BACKSPACE;
+ else if (c == BACKSPACE)
+ c = DELETE;
+
+ // in Unix terminals, arrow keys are represented by
+ // a sequence of 3 characters. E.g., the up arrow
+ // key yields 27, 91, 68
+ if (c == ARROW_START && in.available() > 0) {
+ // Escape key is also 27, so we use InputStream.available()
+ // to distinguish those. If 27 represents an arrow, there
+ // should be two more chars immediately available.
+ while (c == ARROW_START) {
+ c = readCharacter(in);
+ }
+ if (c == ARROW_PREFIX || c == O_PREFIX) {
+ c = readCharacter(in);
+ if (c == ARROW_UP) {
+ return CTRL_P;
+ } else if (c == ARROW_DOWN) {
+ return CTRL_N;
+ } else if (c == ARROW_LEFT) {
+ return CTRL_B;
+ } else if (c == ARROW_RIGHT) {
+ return CTRL_F;
+ } else if (c == HOME_CODE) {
+ return CTRL_A;
+ } else if (c == END_CODE) {
+ return CTRL_E;
+ } else if (c == DEL_THIRD) {
+ c = readCharacter(in); // read 4th
+ return DELETE;
+ }
+ }
+ }
+ // handle unicode characters, thanks for a patch from amyi@inf.ed.ac.uk
+ if (c > 128) {
+ // handle unicode characters longer than 2 bytes,
+ // thanks to Marc.Herbert@continuent.com
+ replayStream.setInput(c, in);
+// replayReader = new InputStreamReader(replayStream, encoding);
+ c = replayReader.read();
+
+ }
+ return c;
+ }
+
+ /**
+ * This is awkward and inefficient, but probably the minimal way to add
+ * UTF-8 support to JLine
+ *
+ * @author <a href="mailto:Marc.Herbert@continuent.com">Marc Herbert</a>
+ */
+ static class ReplayPrefixOneCharInputStream extends InputStream {
+ byte firstByte;
+ int byteLength;
+ InputStream wrappedStream;
+ int byteRead;
+
+ final String encoding;
+
+ public ReplayPrefixOneCharInputStream(String encoding) {
+ this.encoding = encoding;
+ }
+
+ public void setInput(int recorded, InputStream wrapped) throws IOException {
+ this.byteRead = 0;
+ this.firstByte = (byte) recorded;
+ this.wrappedStream = wrapped;
+
+ byteLength = 1;
+ if (encoding.equalsIgnoreCase("UTF-8"))
+ setInputUTF8(recorded, wrapped);
+ else if (encoding.equalsIgnoreCase("UTF-16"))
+ byteLength = 2;
+ else if (encoding.equalsIgnoreCase("UTF-32"))
+ byteLength = 4;
+ }
+
+
+ public void setInputUTF8(int recorded, InputStream wrapped) throws IOException {
+ // 110yyyyy 10zzzzzz
+ if ((firstByte & (byte) 0xE0) == (byte) 0xC0)
+ this.byteLength = 2;
+ // 1110xxxx 10yyyyyy 10zzzzzz
+ else if ((firstByte & (byte) 0xF0) == (byte) 0xE0)
+ this.byteLength = 3;
+ // 11110www 10xxxxxx 10yyyyyy 10zzzzzz
+ else if ((firstByte & (byte) 0xF8) == (byte) 0xF0)
+ this.byteLength = 4;
+ else
+ throw new IOException("invalid UTF-8 first byte: " + firstByte);
+ }
+
+ public int read() throws IOException {
+ if (available() == 0)
+ return -1;
+
+ byteRead++;
+
+ if (byteRead == 1)
+ return firstByte;
+
+ return wrappedStream.read();
+ }
+
+ /**
+ * InputStreamReader is greedy and will try to read bytes in advance. We
+ * do NOT want this to happen since we use a temporary/"losing bytes"
+ * InputStreamReader above, that's why we hide the real
+ * wrappedStream.available() here.
+ */
+ public int available() {
+ return byteLength - byteRead;
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshHistory.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshHistory.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshHistory.java
index dc3fbe1..9f18cae 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshHistory.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshHistory.java
@@ -18,10 +18,7 @@ package com.gemstone.gemfire.management.internal.cli.shell.jline;
import com.gemstone.gemfire.management.internal.cli.parser.preprocessor.PreprocessorUtils;
-import jline.console.history.MemoryHistory;
-
-import java.io.File;
-import java.io.IOException;
+import jline.History;
/**
* Overrides jline.History to add History without newline characters.
@@ -29,14 +26,14 @@ import java.io.IOException;
* @author Abhishek Chaudhari
* @since 7.0
*/
-public class GfshHistory extends MemoryHistory {
-
+public class GfshHistory extends History {
// let the history from history file get added initially
private boolean autoFlush = true;
-
+
+ @Override
public void addToHistory(String buffer) {
if (isAutoFlush()) {
- super.add(toHistoryLoggable(buffer));
+ super.addToHistory(toHistoryLoggable(buffer));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshUnsupportedTerminal.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshUnsupportedTerminal.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshUnsupportedTerminal.java
index 3bc839e..59609ba 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshUnsupportedTerminal.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/jline/GfshUnsupportedTerminal.java
@@ -27,7 +27,7 @@ import jline.UnsupportedTerminal;
*/
public class GfshUnsupportedTerminal extends UnsupportedTerminal {
@Override
- public synchronized boolean isAnsiSupported() {
+ public boolean isANSISupported() {
return false;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/CLIConsoleBufferUtil.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/CLIConsoleBufferUtil.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/CLIConsoleBufferUtil.java
index 9d1bdbe..70a00a1 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/CLIConsoleBufferUtil.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/CLIConsoleBufferUtil.java
@@ -16,7 +16,7 @@
*/
package com.gemstone.gemfire.management.internal.cli.util;
-import jline.console.ConsoleReader;
+import jline.ConsoleReader;
import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
public class CLIConsoleBufferUtil {
@@ -24,9 +24,9 @@ public class CLIConsoleBufferUtil {
ConsoleReader reader = Gfsh.getConsoleReader();
if (reader != null) {
- int bufferLength = reader.getCursorBuffer().length();
- if(bufferLength > messege.length()){
- int appendSpaces = bufferLength - messege.length();
+ StringBuffer buffer = reader.getCursorBuffer().getBuffer();
+ if(buffer.length() > messege.length()){
+ int appendSpaces = buffer.length() - messege.length();
for(int i = 0; i < appendSpaces; i++){
messege = messege + " ";
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentPartitionedRegionTestBase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentPartitionedRegionTestBase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentPartitionedRegionTestBase.java
index 057be81..6ce1a13 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentPartitionedRegionTestBase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/PersistentPartitionedRegionTestBase.java
@@ -172,7 +172,7 @@ public abstract class PersistentPartitionedRegionTestBase extends CacheTestCase
public void run() {
Cache cache = getCache();
Region region = cache.getRegion(regionName);
-
+
for(int i =startKey; i < endKey; i++) {
assertEquals("For key " + i, value, region.get(i));
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e8ddd339/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 9c47763..c86d45d 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -33,7 +33,7 @@ javax.servlet-api.version = 3.1.0
javax.transaction-api.version = 1.2
jedis.version = 2.7.2
jetty.version = 9.2.3.v20140905
-jline.version = 2.12
+jline.version = 1.0.S2-B
jmock.version = 2.8.1
jna.version = 4.0.0
json4s.version = 3.2.4
@@ -56,7 +56,7 @@ snappy-java.version = 1.1.1.6
spring-data-commons.version = 1.9.1.RELEASE
spring-data-gemfire.version = 1.5.1.RELEASE
spring-hateos.version = 0.16.0.RELEASE
-spring-shell.version = 1.1.0.RELEASE
+spring-shell.version = 1.0.0.RELEASE
springframework.version = 3.2.12.RELEASE
spymemcached.version = 2.9.0
swagger.version = 1.3.2