Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 5478 invoked from network); 8 May 2007 02:13:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 May 2007 02:13:27 -0000 Received: (qmail 75797 invoked by uid 500); 8 May 2007 02:13:33 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 75648 invoked by uid 500); 8 May 2007 02:13:33 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 75633 invoked by uid 99); 8 May 2007 02:13:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2007 19:13:33 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2007 19:13:24 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 33AA21A9838; Mon, 7 May 2007 19:13:04 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070508021304.33AA21A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 JLine 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 JLine 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 JLine 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 @@ jline jline - 0.9.9 + 0.9.91