Date: Wed, 26 Sep 2007 15:34:05 +0200 From: Martin Kammerhofer <dada@pluto.tugraz.at> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/116661: New port: devel/jline Java library for handling console input Message-ID: <200709261334.l8QDY5kT021339@pluto.tugraz.at> Resent-Message-ID: <200709261340.l8QDe20a053781@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 116661 >Category: ports >Synopsis: New port: devel/jline Java library for handling console input >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Sep 26 13:40:01 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Martin Kammerhofer >Release: FreeBSD 6.2-STABLE i386 >Organization: >Environment: System: FreeBSD Martin.liebt.Susi 6.2-STABLE FreeBSD 6.2-STABLE #0: Sun Aug 19 14:22:22 CEST 2007 toor@Martin.liebt.Susi:/usr/obj/usr/src/sys/P2B-S i386 >Description: JLine is a Java library for handling console input. It is similar in functionality to BSD editline and GNU readline. People familiar with the readline/editline capabilities for modern shells (such as bash and tcsh) will find most of the command editing features of JLine to be familiar. JLine is distributed under the BSD license, meaning that you are completely free to redistribute, modify, or sell it with almost no restrictions. API documentation can be found in the apidocs directory. You can use the jline.ConsoleRunner application to set up the system input stream and continue on the launch another program. For example, to use JLine as the input handler for the popular BeanShell console application, you can run: java jline.ConsoleRunner bsh.Interpreter WWW: http://jline.sourceforge.net/ >How-To-Repeat: >Fix: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # devel/jline # devel/jline/Makefile # devel/jline/distinfo # devel/jline/pkg-descr # devel/jline/pkg-message # devel/jline/pkg-plist # devel/jline/files # devel/jline/files/JLineCompleter.py # devel/jline/files/patch-src-src-main-java-jline-ConsoleRunner.java # echo c - devel/jline mkdir -p devel/jline > /dev/null 2>&1 echo x - devel/jline/Makefile sed 's/^X//' >devel/jline/Makefile << 'END-of-devel/jline/Makefile' X# New ports collection makefile for: libreadline-java X# Date created: 21 September 2007 X# Whom: Martin Kammerhofer <mkamm@gmx.net> X# X# $FreeBSD$ X# X XPORTNAME= jline XPORTVERSION= 0.9.91 XCATEGORIES= devel java XMASTER_SITES= ${MASTER_SITE_SOURCEFORGE} XMASTER_SITE_SUBDIR= ${PORTNAME} X XMAINTAINER= mkamm@gmx.net XCOMMENT= JLine is a Java library for handling console input X XPKGMESSAGE= ${WRKDIR}/pkg-message XUSE_JAVA= yes XUSE_ZIP= yes XOPTIONS= JLINEPATCH "Allow ConsoleRunner customized completion" OFF XJLINEJAR= ${WRKSRC}/jline-${PORTVERSION}.jar X X.include <bsd.port.pre.mk> X X# Update jar archive with patched jline.ConsoleRunner class. Xdo-build: X.ifdef(WITH_JLINEPATCH) X ${JAVAC} -classpath ${JLINEJAR} \ X ${WRKSRC}/src/src/main/java/jline/ConsoleRunner.java X ${JAR} uvf ${JLINEJAR} -C ${WRKSRC}/src/src/main/java \ X jline/ConsoleRunner.class X.endif X Xdo-install: X ${INSTALL_DATA} ${JLINEJAR} ${JAVAJARDIR} X ${LN} -nfs ${JAVAJARDIR}/jline-${PORTVERSION}.jar \ X ${JAVAJARDIR}/jline.jar X.if !defined(NOPORTDOCS) X ${MKDIR} ${DOCSDIR} X ${CP} -R ${WRKSRC}/apidocs ${WRKSRC}/examples ${DOCSDIR} X ${INSTALL_DATA} ${FILESDIR}/JLineCompleter.py ${DOCSDIR}/examples X.endif X Xpost-install: X @${SED} -e 's|%%JAVAJARDIR%%|${JAVAJARDIR}|g' -- \ X ${.CURDIR}/pkg-message >${PKGMESSAGE} X @${CAT} ${PKGMESSAGE} X X# Next rule is for maintainer use only: Automatically (re)create the pkg-plist. Xplist: X @test -e ${CONFIGURE_COOKIE} || { \ X ${ECHO_MSG} >&2 "do 'make configure' first!"; exit 64; } X ${ECHO_CMD} "%%JAVAJARDIR%%/jline-${PORTVERSION}.jar" >${PLIST} X ${ECHO_CMD} "%%JAVAJARDIR%%/jline.jar" >>${PLIST} X ( \ X cd ${WRKSRC} || exit; \ X ${FIND} ./apidocs ./examples -type f | ${SORT}; \ X ${ECHO_CMD} "./examples/JLineCompleter.py"; \ X ${FIND} ./apidocs ./examples -type d | ${SORT} -r \ X | ${SED} -e 's/^/@dirrm /'; \ X ${ECHO_CMD} "@dirrm %%DOCSDIR%%" ; \ X ) | ${SED} -e 's/\.\//%%DOCSDIR%%\//' -e 's/^/%%PORTDOCS%%/' >>${PLIST} X X.include <bsd.port.post.mk> END-of-devel/jline/Makefile echo x - devel/jline/distinfo sed 's/^X//' >devel/jline/distinfo << 'END-of-devel/jline/distinfo' XMD5 (jline-0.9.91.zip) = 787330d1975c0d58a94ab84b5378d521 XSHA256 (jline-0.9.91.zip) = c9086800211ba4a55a62055967cb467078c626cad31916270204691f31e4c74b XSIZE (jline-0.9.91.zip) = 750026 END-of-devel/jline/distinfo echo x - devel/jline/pkg-descr sed 's/^X//' >devel/jline/pkg-descr << 'END-of-devel/jline/pkg-descr' XJLine is a Java library for handling console input. It is similar in Xfunctionality to BSD editline and GNU readline. People familiar with Xthe readline/editline capabilities for modern shells (such as bash and Xtcsh) will find most of the command editing features of JLine to be Xfamiliar. X XJLine is distributed under the BSD license, meaning that you are Xcompletely free to redistribute, modify, or sell it with almost no Xrestrictions. X XAPI documentation can be found in the apidocs directory. X XYou can use the jline.ConsoleRunner application to set up the system Xinput stream and continue on the launch another program. For example, Xto use JLine as the input handler for the popular BeanShell console Xapplication, you can run: java jline.ConsoleRunner bsh.Interpreter X XWWW: http://jline.sourceforge.net/ END-of-devel/jline/pkg-descr echo x - devel/jline/pkg-message sed 's/^X//' >devel/jline/pkg-message << 'END-of-devel/jline/pkg-message' X--------------------------------------- XTo use JLine add the file X%%JAVAJARDIR%%/jline.jar Xto your classpath! X--------------------------------------- END-of-devel/jline/pkg-message echo x - devel/jline/pkg-plist sed 's/^X//' >devel/jline/pkg-plist << 'END-of-devel/jline/pkg-plist' X%%JAVAJARDIR%%/jline-0.9.91.jar X%%JAVAJARDIR%%/jline.jar X%%PORTDOCS%%%%DOCSDIR%%/apidocs/allclasses-frame.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/allclasses-noframe.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/constant-values.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/deprecated-list.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/files X%%PORTDOCS%%%%DOCSDIR%%/apidocs/help-doc.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/index-all.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/index.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ANSIBuffer.ANSICodes.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ANSIBuffer.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ArgumentCompletor.AbstractArgumentDelimiter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ArgumentCompletor.ArgumentDelimiter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ArgumentCompletor.ArgumentList.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ArgumentCompletor.WhitespaceArgumentDelimiter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ArgumentCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/CandidateCycleCompletionHandler.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/CandidateListCompletionHandler.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ClassNameCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/CompletionHandler.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/Completor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ConsoleOperations.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ConsoleReader.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ConsoleReaderInputStream.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/ConsoleRunner.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/CursorBuffer.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/FileNameCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/History.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/MultiCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/NullCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/SimpleCompletor.NoOpFilter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/SimpleCompletor.SimpleCompletorFilter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/SimpleCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/Terminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/UnixTerminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/UnsupportedTerminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/WindowsTerminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ANSIBuffer.ANSICodes.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ANSIBuffer.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ArgumentCompletor.AbstractArgumentDelimiter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ArgumentCompletor.ArgumentDelimiter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ArgumentCompletor.ArgumentList.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ArgumentCompletor.WhitespaceArgumentDelimiter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ArgumentCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/CandidateCycleCompletionHandler.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/CandidateListCompletionHandler.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ClassNameCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/CompletionHandler.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/Completor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ConsoleOperations.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ConsoleReader.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ConsoleReaderInputStream.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/ConsoleRunner.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/CursorBuffer.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/FileNameCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/History.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/MultiCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/NullCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/SimpleCompletor.NoOpFilter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/SimpleCompletor.SimpleCompletorFilter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/SimpleCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/Terminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/UnixTerminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/UnsupportedTerminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/class-use/WindowsTerminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/package-frame.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/package-summary.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/package-tree.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/jline/package-use.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/options X%%PORTDOCS%%%%DOCSDIR%%/apidocs/overview-tree.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/package-list X%%PORTDOCS%%%%DOCSDIR%%/apidocs/resources/inherit.gif X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ANSIBuffer.ANSICodes.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ANSIBuffer.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ArgumentCompletor.AbstractArgumentDelimiter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ArgumentCompletor.ArgumentDelimiter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ArgumentCompletor.ArgumentList.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ArgumentCompletor.WhitespaceArgumentDelimiter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ArgumentCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/CandidateCycleCompletionHandler.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/CandidateListCompletionHandler.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ClassNameCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/CompletionHandler.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/Completor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ConsoleOperations.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ConsoleReader.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ConsoleReaderInputStream.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/ConsoleRunner.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/CursorBuffer.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/FileNameCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/History.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/MultiCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/NullCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/SimpleCompletor.NoOpFilter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/SimpleCompletor.SimpleCompletorFilter.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/SimpleCompletor.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/Terminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/UnixTerminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/UnsupportedTerminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/src-html/jline/WindowsTerminal.html X%%PORTDOCS%%%%DOCSDIR%%/apidocs/stylesheet.css X%%PORTDOCS%%%%DOCSDIR%%/examples/jline/example/Example.java X%%PORTDOCS%%%%DOCSDIR%%/examples/jline/example/Example.java.rej X%%PORTDOCS%%%%DOCSDIR%%/examples/jline/example/PasswordReader.java X%%PORTDOCS%%%%DOCSDIR%%/examples/jline/example/english.gz X%%PORTDOCS%%%%DOCSDIR%%/examples/JLineCompleter.py X%%PORTDOCS%%@dirrm %%DOCSDIR%%/examples/jline/example X%%PORTDOCS%%@dirrm %%DOCSDIR%%/examples/jline X%%PORTDOCS%%@dirrm %%DOCSDIR%%/examples X%%PORTDOCS%%@dirrm %%DOCSDIR%%/apidocs/src-html/jline X%%PORTDOCS%%@dirrm %%DOCSDIR%%/apidocs/src-html X%%PORTDOCS%%@dirrm %%DOCSDIR%%/apidocs/resources X%%PORTDOCS%%@dirrm %%DOCSDIR%%/apidocs/jline/class-use X%%PORTDOCS%%@dirrm %%DOCSDIR%%/apidocs/jline X%%PORTDOCS%%@dirrm %%DOCSDIR%%/apidocs X%%PORTDOCS%%@dirrm %%DOCSDIR%% END-of-devel/jline/pkg-plist echo c - devel/jline/files mkdir -p devel/jline/files > /dev/null 2>&1 echo x - devel/jline/files/JLineCompleter.py sed 's/^X//' >devel/jline/files/JLineCompleter.py << 'END-of-devel/jline/files/JLineCompleter.py' X# (X)Emacs: -*- mode: python; coding: latin-1; -*- X# TAB-Completion for Jython with JLine console. X# JLineCompleter.py,v 1.4 2007/09/26 11:57:31 martin Exp X X# Jython + JLine + Tab-Completion Micro-Howto: X# X# JLine is a 99% pure Java console library similar to GNU Readline but X# with an incompatible API. Jython 2.2 already contains some support X# for JLine. For basic line editing and a command history it suffices X# to set python.console=org.python.util.JLineConsole either in the X# Jython registry or in the ~/.jython file. Obviously the JLine X# jarfile must be in your classpath. X# X# Unfortunately Jython does not support tab-completion for JLine yet. X# It can be enabled by importing this file - however this needs X# patches. To summarize prerequisites: X# X# 1. You need a patch to JLine that adds the X# ConsoleRunner.getReader() method. On FreeBSD build jline with X# option WITH_JLINEPATCH enabled. X# X# 2. You must wrap the entry point to Jython with a X# jline.ConsoleRunner instance. You do this by editing X# /usr/local/bin/jython and inserting an extra argument X# "jline.ConsoleRunner" right before the "org.python.util.jython" X# argument. X# X# 3. While there don't forget to add X# /usr/local/share/java/classes/jline.jar to the classpath. X# X# 4. You must set python.console="" in the ~/.jython file. You X# don't want Jython to create another console instance running X# behind the wrapper console. X# X# 5. Finally you have to import this module. You may want to do a X# "import user" instead and code the "import JLineCompleter" X# inside ~/.pythonrc.py instead. X# X# If that is too much hassle - just wait for my upcoming X# devel/libreadline-java port! X X X"""Word completion for JLine X XThe completer completes keywords, built-ins and globals in a Xselectable namespace (which defaults to __main__); when completing XNAME.NAME..., it evaluates (!) the expression up to the last dot and Xcompletes its attributes. X XIt's very cool to do "import sys" type "sys.", hit the Xcompletion key (twice), and see the list of names defined by the Xsys module! X XTip: to use the tab key as the completion key, call X X readline.parse_and_bind("tab: complete") X XNotes: X X- Exceptions raised by the completer function are *ignored* (and Xgenerally cause the completion to fail). This is a feature -- since Xreadline sets the tty device in raw (or cbreak) mode, printing a Xtraceback wouldn't work well without some complicated hoopla to save, Xreset and restore the tty state. X X- The evaluation of the NAME.NAME... form may cause arbitrary Xapplication defined code to be executed if an object with a X__getattr__ hook is found. Since it is the responsibility of the Xapplication (or the user) to enable this feature, I consider this an Xacceptable risk. More complicated expressions (e.g. function calls or Xindexing operations) are *not* evaluated. X XThis module is a slightly hacked version of the CPython 2.5 module Xrlcompleter. It is therefore under the PSF (Python Software XFoundation) license. X""" X X__all__ = ["JLineCompleter"] X__license__ = "PSF" X Ximport jline Xif not jline.__file__: X jline.__file__ = "jline.jar" # Keep the site module from throwing. Ximport __main__ Ximport __builtin__ Ximport keyword Ximport re X X X# @sig public class JythonCompleter extends java.lang.Object implements X# jline.Completor, org.python.core.PyProxy, org.python.core.ClassDictInit Xclass JLineCompleter(jline.Completor): X def __init__(self, namespace = None): X """Create a new completer for the command line. X X Completer([namespace]) -> completer instance. X X If unspecified, the default namespace where completions are performed X is __main__ (technically, __main__.__dict__). Namespaces should be X given as dictionaries. X X Completer instances should be used as the completion mechanism of X JLine via the jline.ConsoleRunner.completors system property. X """ X X if namespace and not isinstance(namespace, dict): X raise TypeError,'namespace must be a dictionary' X X # Don't bind to namespace quite yet, but flag whether the user wants a X # specific namespace or to use __main__.__dict__. This will allow us X # to bind to __main__.__dict__ at completion time, not now. X if namespace is None: X self.use_main_ns = 1 X else: X self.use_main_ns = 0 X self.namespace = namespace X X # @sig int complete(String buffer, int cursor, List candidates) X def complete(self, buffer, cursor, candidates): X """Return the list of possible completions for 'buffer'.""" X if self.use_main_ns: X self.namespace = __main__.__dict__ X X # Determine the text to be expanded: X text = buffer[:cursor] X start = 0 X for i in xrange(cursor - 1, -1, -1): X ch = text[i] X if not (ch.isalnum() or ch == '.' or ch == '_'): X start = i + 1 X break X text = text[start:] X if "." in text: X self.matches = self.attr_matches(text) X else: X self.matches = self.global_matches(text) X for m in self.matches: X candidates.add(m) X if self.matches: X return start X else: X return -1 X X def global_matches(self, text): X """Compute matches when text is a simple name. X X Return a list of all keywords, built-in functions and names currently X defined in self.namespace that match. X X """ X matches = [] X n = len(text) X for list in [keyword.kwlist, X __builtin__.__dict__, X self.namespace]: X for word in list: X if word[:n] == text and word != "__builtins__": X matches.append(word) X return matches X X def attr_matches(self, text): X """Compute matches when text contains a dot. X X Assuming the text is of the form NAME.NAME....[NAME], and is X evaluatable in self.namespace, it will be evaluated and its attributes X (as revealed by dir()) are used as possible completions. (For class X instances, class members are also considered.) X X WARNING: this can still invoke arbitrary C code, if an object X with a __getattr__ hook is evaluated. X X """ X m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text) X if not m: X return X expr, attr = m.group(1, 3) X object = eval(expr, self.namespace) X words = dir(object) X if hasattr(object,'__class__'): X words.append('__class__') X words = words + get_class_members(object.__class__) X matches = [] X n = len(attr) X for word in words: X if word[:n] == attr and word != "__builtins__": X matches.append("%s.%s" % (expr, word)) X return matches X Xdef get_class_members(klass): X ret = dir(klass) X if hasattr(klass,'__bases__'): X for base in klass.__bases__: X ret = ret + get_class_members(base) X return ret X Xtry: X reader = jline.ConsoleRunner.getReader() X if reader: X reader.addCompletor(JLineCompleter()) X else: X raise RuntimeError("jline.ConsoleRunner not active") Xexcept AttributeError: X # XXX This message is FreeBSD specific! X raise NotImplementedError("Incompatible JLine version! Set WITH_JLINEPATCH=1 and rebuild the devel/jline port!") X Xif __name__ == '__main__': X print "Sorry, no unittests yet!" X X#EOF# END-of-devel/jline/files/JLineCompleter.py echo x - devel/jline/files/patch-src-src-main-java-jline-ConsoleRunner.java sed 's/^X//' >devel/jline/files/patch-src-src-main-java-jline-ConsoleRunner.java << 'END-of-devel/jline/files/patch-src-src-main-java-jline-ConsoleRunner.java' X--- src/src/main/java/jline/ConsoleRunner.java.orig 2007-03-09 16:32:28.000000000 +0100 X+++ src/src/main/java/jline/ConsoleRunner.java 2007-09-24 19:22:42.000000000 +0200 X@@ -17,6 +17,10 @@ X * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a> X */ X public class ConsoleRunner { X+ private static ConsoleReader reader; X+ X+ public static ConsoleReader getReader() { return reader; } X+ X public static final String property = "jline.history"; X X public static void main(final String[] args) throws Exception { X@@ -36,7 +40,7 @@ X String mainClass = (String) argList.remove(0); X X // setup the inpout stream X- ConsoleReader reader = new ConsoleReader(); X+ reader = new ConsoleReader(); X X if (historyFileName != null) { X reader.setHistory(new History (new File END-of-devel/jline/files/patch-src-src-main-java-jline-ConsoleRunner.java exit >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709261334.l8QDY5kT021339>