geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r536041 - in /geronimo/sandbox/gshell/trunk: ./ gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/ gshell-server/gshell-server-ssh/src/main/java/org/apache/geronimo/gshell/server/ssh/ gshell-server/gshell-serv...
Date Tue, 08 May 2007 02:13:04 GMT
Author: jdillon
Date: Mon May  7 19:13:03 2007
New Revision: 536041

URL: http://svn.apache.org/viewvc?view=rev&rev=536041
Log:
Added workaround for problem with server-based JLine terminals in 0.9.91, re-upgrade to JLine
0.9.91

Added:
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/TerminalSupport.java
  (with props)
Modified:
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-ssh/src/main/java/org/apache/geronimo/gshell/server/ssh/SshTerminal.java
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
    geronimo/sandbox/gshell/trunk/pom.xml

Added: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/TerminalSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/TerminalSupport.java?view=auto&rev=536041
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/TerminalSupport.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/TerminalSupport.java
Mon May  7 19:13:03 2007
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.server;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import jline.Terminal;
+
+import org.apache.geronimo.gshell.console.IO;
+
+/**
+ * Provides support for server-based <a href="http://jline.sf.net">JLine</a>
terminal implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class TerminalSupport
+    extends Terminal
+{
+    protected Log log = LogFactory.getLog(TerminalSupport.class);
+    
+    public void initializeTerminal() throws Exception {
+    }
+    
+    public boolean isSupported() {
+        return true;
+    }
+    
+    public void disableEcho() {
+        // TODO
+    }
+    
+    public void enableEcho() {
+        // TODO
+    }
+    
+    public boolean isEchoEnabled() {
+        return false;
+    }
+    
+    public boolean getEcho() {
+        return false;
+    }
+
+    //
+    // NOTE: Added as workaround in bug introduced in JLine 0.9.91, should be fixed in 0.9.92+
+    //
+    
+    public InputStream getDefaultBindings() {
+        InputStream in = super.getDefaultBindings();
+        if (in == null) {
+            in = Terminal.class.getResourceAsStream("keybindings.properties");
+        }
+        
+        return in;
+    }
+
+    //
+    // NOTE: Copied (and modified) from jline.UnixTerminal
+    //
+
+    public static final short ARROW_START = 27;
+
+    public static final short ARROW_PREFIX = 91;
+
+    public static final short ARROW_LEFT = 68;
+
+    public static final short ARROW_RIGHT = 67;
+
+    public static final short ARROW_UP = 65;
+
+    public static final short ARROW_DOWN = 66;
+
+    public static final short HOME_CODE = 72;
+
+    public static final short END_CODE = 70;
+    
+    public static final short O_PREFIX = 79;
+    
+    public int readCharacter(final InputStream in) throws IOException {
+        int c = in.read();
+        
+        if (log.isDebugEnabled()) {
+            String ch;
+            if (c == 0xd) {
+                ch = "\\n";
+            }
+            else {
+                ch = new String(new char[] { (char)c });
+            }
+            
+            log.debug("Read char: " + ch + " (0x" + Integer.toHexString(c) + ")");
+        }
+        
+        return c;
+    }
+    
+    public int readVirtualKey(final InputStream in) throws IOException {
+        assert in != null;
+
+        int c = readCharacter(in);
+
+        //
+        // TODO: Need to check if this is correct... arrow handling is a tad off
+        //
+
+        // 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) {
+            c = readCharacter(in);
+
+            if (c == ARROW_PREFIX || c == O_PREFIX) {
+                c = readCharacter(in);
+
+                switch (c) {
+                    case ARROW_UP:
+                        return CTRL_P;
+
+                    case ARROW_DOWN:
+                        return CTRL_N;
+
+                    case ARROW_LEFT:
+                        return CTRL_B;
+
+                    case ARROW_RIGHT:
+                        return CTRL_F;
+
+                    case HOME_CODE:
+                        return CTRL_A;
+
+                    case END_CODE:
+                        return CTRL_E;
+                }
+            }
+        }
+        
+        if (c > 128) {
+            throw new IOException("UTF-8 not supported");
+        }
+
+        return c;
+    }
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/TerminalSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/TerminalSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/TerminalSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-ssh/src/main/java/org/apache/geronimo/gshell/server/ssh/SshTerminal.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-ssh/src/main/java/org/apache/geronimo/gshell/server/ssh/SshTerminal.java?view=diff&rev=536041&r1=536040&r2=536041
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-ssh/src/main/java/org/apache/geronimo/gshell/server/ssh/SshTerminal.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-ssh/src/main/java/org/apache/geronimo/gshell/server/ssh/SshTerminal.java
Mon May  7 19:13:03 2007
@@ -24,9 +24,7 @@
 import java.io.IOException;
 
 import org.apache.geronimo.gshell.console.IO;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gshell.server.TerminalSupport;
 
 /**
  * SSH <a href="http://jline.sf.net">JLine</a> terminal implementation
@@ -35,10 +33,8 @@
  * @version $Rev$ $Date$
  */
 public class SshTerminal
-    extends jline.Terminal
+    extends TerminalSupport
 {
-    private static final Log log = LogFactory.getLog(SshTerminal.class);
-    
     private final IO io;
 
     public SshTerminal(final InputStream input, final OutputStream output) throws IOException
{
@@ -49,12 +45,6 @@
         this.io =  new IO(createInputStream(), createOutputStream());
     }
 
-    public void initializeTerminal() throws Exception {
-        //
-        // TODO:
-        //
-    }
-
     public int getTerminalWidth() {
         throw new Error("TODO");
     }
@@ -63,26 +53,6 @@
         throw new Error("TODO");
     }
     
-    public boolean isSupported() {
-        return true;
-    }
-
-    public boolean getEcho() {
-        return false;
-    }
-    
-    public void disableEcho() {
-        // TODO
-    }
-    
-    public void enableEcho() {
-        // TODO
-    }
-    
-    public boolean isEchoEnabled() {
-        return false;
-    }
-    
     private InputStream createInputStream() {
         return new InputStream() {
             public int read() throws IOException {
@@ -101,69 +71,5 @@
     
     public IO getIO() {
         return io;
-    }
-
-    //
-    // NOTE: Copied (and modified) from jline.UnixTerminal
-    //
-
-    public static final short ARROW_START = 27;
-
-    public static final short ARROW_PREFIX = 91;
-
-    public static final short ARROW_LEFT = 68;
-
-    public static final short ARROW_RIGHT = 67;
-
-    public static final short ARROW_UP = 65;
-
-    public static final short ARROW_DOWN = 66;
-
-    public static final short HOME_CODE = 72;
-
-    public static final short END_CODE = 70;
-
-    public int readVirtualKey(final InputStream in) throws IOException {
-        assert in != null;
-
-        int c = readCharacter(in);
-
-        //
-        // TODO: Need to check if this is correct... arrow handling is a tad off
-        //
-
-        // 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) {
-            c = readCharacter(in);
-
-            if (c == ARROW_PREFIX) {
-                c = readCharacter(in);
-
-                switch (c) {
-                    case ARROW_UP:
-                        return CTRL_P;
-
-                    case ARROW_DOWN:
-                        return CTRL_N;
-
-                    case ARROW_LEFT:
-                        return CTRL_B;
-
-                    case ARROW_RIGHT:
-                        return CTRL_F;
-
-                    case HOME_CODE:
-                        return CTRL_A;
-
-                    case END_CODE:
-                        return CTRL_E;
-                }
-            }
-        }
-
-        return c;
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java?view=diff&rev=536041&r1=536040&r2=536041
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
Mon May  7 19:13:03 2007
@@ -26,8 +26,7 @@
 import java.io.IOException;
 
 import org.apache.geronimo.gshell.console.IO;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gshell.server.TerminalSupport;
 
 /**
  * Telnet <a href="http://jline.sf.net">JLine</a> terminal implementation
@@ -37,10 +36,8 @@
  * @version $Rev$ $Date$
  */
 public class TelnetTerminal
-    extends jline.Terminal
+    extends TerminalSupport
 {
-    private static final Log log = LogFactory.getLog(TelnetTerminal.class);
-
     private final Terminal term;
 
     private final IO io;
@@ -50,12 +47,6 @@
         this.io =  new IO(createInputStream(), createOutputStream());
     }
 
-    public void initializeTerminal() throws Exception {
-        //
-        // NVT4j does all init in Terminal.init() which is called from constructor
-        //
-    }
-
     public int getTerminalWidth() {
         return term.getColumns();
     }
@@ -64,26 +55,6 @@
         return term.getRows();
     }
 
-    public boolean isSupported() {
-        return true;
-    }
-    
-    public void disableEcho() {
-        // TODO
-    }
-    
-    public void enableEcho() {
-        // TODO
-    }
-    
-    public boolean isEchoEnabled() {
-        return false;
-    }
-    
-    public boolean getEcho() {
-        return false;
-    }
-
     private InputStream createInputStream() {
         return new InputStream() {
             public int read() throws IOException {
@@ -102,93 +73,5 @@
 
     public IO getIO() {
         return io;
-    }
-
-    //
-    // NOTE: Copied (and modified) from jline.UnixTerminal
-    //
-
-    public static final short ARROW_START = 27;
-
-    public static final short ARROW_PREFIX = 91;
-
-    public static final short ARROW_LEFT = 68;
-
-    public static final short ARROW_RIGHT = 67;
-
-    public static final short ARROW_UP = 65;
-
-    public static final short ARROW_DOWN = 66;
-
-    public static final short HOME_CODE = 72;
-
-    public static final short END_CODE = 70;
-    
-    public static final short O_PREFIX = 79;
-    
-    public int readCharacter(final InputStream in) throws IOException {
-        int c = in.read();
-        
-        if (log.isDebugEnabled()) {
-            String ch;
-            if (c == 0xd) {
-                ch = "\\n";
-            }
-            else {
-                ch = new String(new char[] { (char)c });
-            }
-            
-            log.debug("Read char: " + ch + " (0x" + Integer.toHexString(c) + ")");
-        }
-        
-        return c;
-    }
-    
-    public int readVirtualKey(final InputStream in) throws IOException {
-        assert in != null;
-
-        int c = readCharacter(in);
-
-        //
-        // TODO: Need to check if this is correct... arrow handling is a tad off
-        //
-
-        // 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) {
-            c = readCharacter(in);
-
-            if (c == ARROW_PREFIX || c == O_PREFIX) {
-                c = readCharacter(in);
-
-                switch (c) {
-                    case ARROW_UP:
-                        return CTRL_P;
-
-                    case ARROW_DOWN:
-                        return CTRL_N;
-
-                    case ARROW_LEFT:
-                        return CTRL_B;
-
-                    case ARROW_RIGHT:
-                        return CTRL_F;
-
-                    case HOME_CODE:
-                        return CTRL_A;
-
-                    case END_CODE:
-                        return CTRL_E;
-                }
-            }
-        }
-        
-        if (c > 128) {
-            throw new IOException("UTF-8 not supported");
-        }
-
-        return c;
     }
 }

Modified: geronimo/sandbox/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/pom.xml?view=diff&rev=536041&r1=536040&r2=536041
==============================================================================
--- geronimo/sandbox/gshell/trunk/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/pom.xml Mon May  7 19:13:03 2007
@@ -128,7 +128,7 @@
             <dependency>
                 <groupId>jline</groupId>
                 <artifactId>jline</artifactId>
-                <version>0.9.9</version>
+                <version>0.9.91</version>
             </dependency>
 
             <dependency>



Mime
View raw message