Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 2210 invoked from network); 9 Feb 2009 16:42:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Feb 2009 16:42:15 -0000 Received: (qmail 28875 invoked by uid 500); 9 Feb 2009 16:42:14 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 28831 invoked by uid 500); 9 Feb 2009 16:42:14 -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 28808 invoked by uid 99); 9 Feb 2009 16:42:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Feb 2009 08:42:14 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Feb 2009 16:42:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 131BE23889FA; Mon, 9 Feb 2009 16:41:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r742606 - /geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java Date: Mon, 09 Feb 2009 16:41:50 -0000 To: scm@geronimo.apache.org From: kevan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090209164151.131BE23889FA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kevan Date: Mon Feb 9 16:41:50 2009 New Revision: 742606 URL: http://svn.apache.org/viewvc?rev=742606&view=rev Log: GERONIMO-4533 Default the terminal width, if the terminal width is zero. This will avoid 'This is ridiculous' error messages Modified: geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java Modified: geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java?rev=742606&r1=742605&r2=742606&view=diff ============================================================================== --- geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java (original) +++ geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java Mon Feb 9 16:41:50 2009 @@ -95,13 +95,21 @@ return buf.toString(); } + private final static int DEFAULT_TERM_WIDTH = 256; + public static void println(String line, int indent, ConsoleReader consoleReader) throws IOException { int endCol = consoleReader.getTermwidth(); int start = consoleReader.getCursorBuffer().cursor; + + // some terminals will give a terminal width of zero (e.g. emacs shell). + // in that case, default to a reasonable term width value. + if (endCol == 0) { + endCol = DEFAULT_TERM_WIDTH; + } + if (endCol - indent < 10) { throw new IllegalArgumentException("This is ridiculous!"); } -// StringBuffer buf = new StringBuffer((int)(source.length()*1.1)); String prefix = indent == 0 ? "" : buildIndent(indent); int pos; while (line.length() > 0) {