karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1124287 - /karaf/branches/karaf-2.2.x/shell/console/src/main/java/jline/console/ConsoleReader.java
Date Wed, 18 May 2011 14:42:24 GMT
Author: gawor
Date: Wed May 18 14:42:24 2011
New Revision: 1124287

URL: http://svn.apache.org/viewvc?rev=1124287&view=rev
Log:
KARAF-496: Karaf prompt displayed twice on Windows with unsupported terminal

Modified:
    karaf/branches/karaf-2.2.x/shell/console/src/main/java/jline/console/ConsoleReader.java

Modified: karaf/branches/karaf-2.2.x/shell/console/src/main/java/jline/console/ConsoleReader.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/console/src/main/java/jline/console/ConsoleReader.java?rev=1124287&r1=1124286&r2=1124287&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/console/src/main/java/jline/console/ConsoleReader.java
(original)
+++ karaf/branches/karaf-2.2.x/shell/console/src/main/java/jline/console/ConsoleReader.java
Wed May 18 14:42:24 2011
@@ -99,6 +99,8 @@ public class ConsoleReader
     private String previousSearchTerm = "";
 
     private int searchIndex = -1;
+    
+    private boolean skipLF = false;
 
     public ConsoleReader(final InputStream in, final Writer out, final InputStream bindings,
final Terminal term) throws
         IOException
@@ -1371,17 +1373,32 @@ public class ConsoleReader
     private String readLine(final InputStream in) throws IOException {
         StringBuilder buff = new StringBuilder();
 
+        if (skipLF) {
+            skipLF = false;
+            
+            int i = streamBuffer.isEmpty() ? in.read() : streamBuffer.remove(0);
+            
+            if (i == -1 || i == '\r') {
+                return buff.toString();
+            } else if (i == '\n') {
+                // ignore
+            } else {
+                buff.append((char) i);
+            }
+        }        
+        
         while (true) {
             int i = streamBuffer.isEmpty() ? in.read() : streamBuffer.remove(0);
 
-            if (i == -1 || i == '\n' || i == '\r') {
+            if (i == -1 || i == '\n') {
                 return buff.toString();
+            } else if (i == '\r') {
+                skipLF = true;
+                return buff.toString();
+            } else {
+                buff.append((char) i);
             }
-
-            buff.append((char) i);
         }
-
-        // return new BufferedReader (new InputStreamReader (in)).readLine ();
     }
 
     //



Mime
View raw message