libreadline-java-0.8.0.1+dfsg/ 0000755 0001750 0001750 00000000000 07606524213 014475 5 ustar moon moon libreadline-java-0.8.0.1+dfsg/README 0000644 0001750 0001750 00000007212 07606524213 015357 0 ustar moon moon This is my "port" of GNU-Readline to Java. Actually, it is a crude wrapper
using the Java Native Interface (JNI).
Starting from version 0.6, alternative libraries are supported. Currently
only Editline is implemented, but adding support for other implementations
should be easy.
From 0.6 on, JavaReadline also has a fallback solution (System.in) for
platforms without Readline or Editline support, making your programs portable
again.
This version implements basic readline functionality like line editing and
filename completion, which should be just enough for normal use. Not all
functionality is available with all implementations.
Various people contributed code (see the file NEWS for details).
Since I changed some of the code, all bugs are my fault and bugreports
should be adressed to me.
The binary distribution contains the API documentation, a JAR with the
Readline class and the shared library libJavaReadline.so.
The source distribution contains all the source (I hope this doesn't surprise
you ;-) and a system of makefiles. You need the JDK to compile it.
LICENSING ISSUES
================
Although JavaReadline is distributed under the LGPL, the underlying
Readline library is GPL code. The consequence is, that any program
linking with JavaReadline+Readline, will fall under the GPL.
There is a Readline replacement called Editline with a more liberal
license. Use that library if you want to distribute your program
under the LGPL instead of the GPL.
You can fetch the Editline stuff at http://packages.debian.org. You
need libedit2 and libedit-dev. Source code is also available, although
I must admit I did not succeed in compiling it on my non-BSD and
non-Debian system :-(
A second Readline replacement is called Getline. This is a very minimal
Readline-clone with a liberal license, and the source-code is provided
in the java-readline distribution. It has the advantage that it
compiles natively on Windows.
COMPILATION
===========
Compilation should be no problem. Try "make". You should set the
variable JAVA_HOME (or edit the makefile). Also, if you don't use jikes,
you should change the variables JAVAC and JAVAC_OPT in the makefile. A better
alternative is to install jikes, it will speed up your development by
a factor of 2-3.
JAVAC and JAVAC_OPT can also be set in the environment or from the
make commandline.
If you want Editline support, use "make T_LIBS=JavaEditline". Getline support
is selected with "make T_LIBS=JavaGetline".
Getline support is also available for (native) WIN32. To build it from
source, you need the cygwin-environment (only necessary because we still
use GNU-make) and a native C-compiler. All necessary variables are configured
in the toplevel Makefile. Before running make, set the WIN32-variable to MSC:
> WIN32=MSC make
A ready-to-use DLL is in the contrib/win32 directory. Since this feature
is experimental, your feedback is appreciated. If you figure out how to
link JavaReadline with cygwin, please let me know as well (some stubs
are already built into the makefiles).
INSTALLATION
============
Copy the files libJava*.so to one of your library directories or add
the directory where you put libJava*.so to LD_LIBARY_PATH. Also, add
java_readline.jar to your CLASSPATH. After building the jar and the shared
library, you can run a program with something like:
LD_LIBRARY_PATH=/usr/lib java -cp java_readline.jar org.foo.bar.MyClass
assuming that you put libJava*.so into /usr/lib.
DEBIAN
======
Thanks to Ben Burton, Debian-packages for JavaReadline are available!
SUPPORT
=======
If you think you found a bug or want to contribute some code please drop
me a note.
Bernhard Bablok
mail@bablokb.de
http://www.bablokb.de
libreadline-java-0.8.0.1+dfsg/README.1st 0000644 0001750 0001750 00000002115 07606524213 016062 0 ustar moon moon IMPORTANT NOTE
==============
From 0.5.2 to 0.6 there have been two incompatible interface changes:
1. You must call Readline.load(ReadlineLibrary lib); before using any
other methods.
=====================================================================
If you omit the call to the load()-method, the pure Java fallback
solution is used. Possible values for lib are:
ReadlineLibrary.PureJava
ReadlineLibrary.GnuReadline
ReadlineLibrary.Editline
Note that all programs using Gnu-Readline will fall under the GPL,
since Gnu-Readline is GPL software.
If you want to write portable programs and you are not sure if
GnuReadline/Editline is available on all target machines, use code like
try {
Readline.load(ReadlineLibrary.GnuReadline);
} catch (Exception e) {
}
2. Readline.readline() now additionally throws an IOException
=============================================================
This is due to the fact that starting from 0.6 the pure Java fallback
solution is supported. Using the native libraries, you should never
see this exception, nevertheless you will have to deal with it.
libreadline-java-0.8.0.1+dfsg/NEWS 0000644 0001750 0001750 00000006303 07606524213 015176 0 ustar moon moon For release 0.8.0:
- added JScheme completer. Provided by Samer Abdallah
- added support for Getline (Bernhard)
- added support for WIN32
For release 0.7.3:
- don't add history automatically for each line. Provided by Brian Clapper
- removed 1024-byte limitation (useful for long multiline input)
For release 0.7.2:
- no functionality changes; only modified build process a bit
for first libreadline-java release on sourceforge (Henner)
For release 0.7.1:
(provided by Henner Zeller )
- provide method hasTerminal() to check, if we are run from a terminal
(calls isatty())
- make build process work on Solaris
- provide RPM-spec file
For release 0.7.0:
- bugfix: setCompleter(null) crashed the virtual machine. Now, it sets
the completer back to default behaviour (filename completion)
- native functions added:
o cleanupReadlineImpl() does a reset of the readline lib and the
terminal. Exported as 'void cleanup()' to the java user.
o getLineBufferImpl() returns the current line buffer. This is
usually needed within completers to access the _full_ line (the
completer only gets the last word). Exported as
'String getLineBuffer()' to the java user.
- documentation: complete example for ReadlineCompleter interface;
better indented example for Readline. Added cleanup() in the example.
- declare the 'UnsatisfiedLinkError' in the load() method for
documentation purposes.
(all changes provided by Henner Zeller )
- added note about Debian-packages in README
- new description on how to make Jython work with JavaReadline
(copied from a posting of Steve Cohen to
jython-users@lists.sourceforge.net)
For release 0.6.1:
- bugfix: fallback-solution did not throw EOFException
- bugfix: missing P ("ureJava") in method Readline.byName()
For release 0.6:
- added ReadlineLibrary
- implemented Editline-support
- improved documentation
For release 0.5.2:
- added ReadlineReader (provided by Shane Celis )
- added contrib-directory with
* bsh (provided by Shane Celis )
* jpython (moved from my own website into this package)
- added section about LICENSING ISSUES in README
- updated TODO
For release 0.5.1:
- added word break patch (sets rl_completer_word_break_characters,
provided by David Dribin )
For release 0.5:
- added code for reading/writing history files
(provided by erik@skiinfo.fr)
- added code for setting a custom completer
(provided by erik@skiinfo.fr)
- added a sample custom completer
- changed ReadlineTest to include new methods
For release 0.43:
- rewrote makefile(s)
- changed directory structure
- moved ReadlineTest to package test
- removed file INSTALL
For release 0.42:
- Moved native code to native subdirectory
- Reorganized makefiles
For release 0.41:
- Changed package name to org.gnu.readline (to be SUN compliant)
For release 0.4:
- Added the following methods: readInitFile() and parseAndBind()
For release 0.3:
- Added UTF-8 to UCS-1 conversion: characters with 8'th bit set are now
supported
For release 0.2:
- Initial public release
libreadline-java-0.8.0.1+dfsg/TODO 0000644 0001750 0001750 00000000147 07606524213 015167 0 ustar moon moon - Add support for the following readline functions/variables:
* rl_initialize
* rl_library_version
libreadline-java-0.8.0.1+dfsg/ChangeLog 0000644 0001750 0001750 00000047313 07606524213 016257 0 ustar moon moon 2003-01-07 Bernhard Bablok
* /cvsroot/java-readline/java-readline/misc/release-checklist.txt:
added item '0. Change version numbers'
* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec,
/cvsroot/java-readline/java-readline/web/index.html:
updated version number to 0.8.0
2002-12-17 Bernhard Bablok
* /cvsroot/java-readline/java-readline/src/native/Makefile:
bugfix: only add -lcygwin if MSC=cygwin
2002-11-24 Bernhard Bablok
* /cvsroot/java-readline/java-readline/contrib/jscheme/SilkCompleter.java,
/cvsroot/java-readline/java-readline/contrib/win32/JavaGetline.dll:
initial entry
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
minor code cleanups
* /cvsroot/java-readline/java-readline/src/native/getline.h:
bugfix: moved #defines outside #if __STDC__ > 0
* /cvsroot/java-readline/java-readline/src/native/Makefile,
/cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
added support for WIN32
* /cvsroot/java-readline/java-readline/NEWS: news for version 0.8.0
* /cvsroot/java-readline/java-readline/VERSION:
upgraded version number to 0.8.0
* /cvsroot/java-readline/java-readline/README: describe WIN32 support
* /cvsroot/java-readline/java-readline/Makefile:
added support for WIN32
2002-11-02 Bernhard Bablok
* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec,
/cvsroot/java-readline/java-readline/Makefile:
updated HOMEPAGE-Url
* /cvsroot/java-readline/java-readline/README: added note about Getline
2002-10-28 Bernhard Bablok
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
fixed implementation of getHistoryImpl for Editline (patch from Ben Burton)
2002-10-15 Bernhard Bablok
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
- enable history-methods for editline
- added javadoc-comments stating which method is supported by
which backing implementation
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
fix typecast for java_completer (patch provided by Ben Burton)
* /cvsroot/java-readline/java-readline/Makefile:
group documentation into packages (patch provided by Ben Burton)
2002-08-12 Bernhard Bablok
* /cvsroot/java-readline/java-readline/web/index.html:
added XNap as project using Java-Readline
* /cvsroot/java-readline/java-readline/web/index.html:
- changed address of henplus
- fixed relative URLs to absolute URLs for JYTHON and BeanShell
2002-06-25 Bernhard Bablok
* /cvsroot/java-readline/java-readline/Makefile,
/cvsroot/java-readline/java-readline/src/native/Makefile,
/cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c,
/cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java,
/cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineLibrary.java:
integrated getline
* /cvsroot/java-readline/java-readline/src/native/getline.c,
/cvsroot/java-readline/java-readline/src/native/getline.h:
initial entry
* /cvsroot/java-readline/java-readline/VERSION:
changed version to 0.7.4
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
bugfix: too many braces
2002-06-07 Bernhard Bablok
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
integrated encoding-patch
2002-05-27 Bernhard Bablok
* /cvsroot/java-readline/java-readline/misc/release-checklist.txt:
initial entry
* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec:
added NEWS to %doc
* /cvsroot/java-readline/java-readline/NEWS,
/cvsroot/java-readline/java-readline/web/index.html:
prepared release 0.7.3
2002-05-11 Bernhard Bablok
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
changed implementation of utf2ucs and ucs2utf
* /cvsroot/java-readline/java-readline/Makefile: added variable NEWS
* /cvsroot/java-readline/java-readline/README:
changed reference to ChangeLog to NEWS
* /cvsroot/java-readline/java-readline/ChangeLog: moved to NEWS
* /cvsroot/java-readline/java-readline/NEWS: initial entry
2002-05-09 hzeller
* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec, /cvsroot/java-readline/java-readline/Makefile:
o build RPM in own build directory. Don't need to be root to do so.
2002-05-02 Bernhard Bablok
* /cvsroot/java-readline/java-readline/web/index.html:
added Sourceforge logo
* /cvsroot/java-readline/java-readline/web/index.html: initial entry
2002-04-30 Bernhard Bablok
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
fixed bugs in Readline.readline(...) functions
2002-04-24 hzeller
* /cvsroot/java-readline/java-readline/VERSION, /cvsroot/java-readline/java-readline/etc/libreadline-java.spec:
o bump version to 0.7.3 .. the future release.
2002-04-15 hzeller
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java, /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
o don't add history automatically for each line. Provided by Brian Clapper.
2002-03-11 hzeller
* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec, /cvsroot/java-readline/java-readline/ChangeLog, /cvsroot/java-readline/java-readline/VERSION:
o 0.7.2 - first release for sourceforge.
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java, /cvsroot/java-readline/java-readline/etc/libreadline-java.spec, /cvsroot/java-readline/java-readline/Makefile:
o small modifications for first JavaReadline release on sourceforge.
* /cvsroot/java-readline/java-readline/etc/libreadline-java.spec:
o add spec file.
2002-03-03 Bablokb
* /cvsroot/java-readline/java-readline/Makefile, /cvsroot/java-readline/java-readline/etc/Makefile, /cvsroot/java-readline/java-readline/src/Makefile, /cvsroot/java-readline/java-readline/src/mkrules.inc, /cvsroot/java-readline/java-readline/src/native/Makefile, /cvsroot/java-readline/java-readline/src/org/Makefile, /cvsroot/java-readline/java-readline/src/org/gnu/Makefile, /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile:
switched to new build-system
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
- make cleanupReadlineImpl only for JavaReadline available
- added hasTerminalImpl
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
- added method hasTerminal()
- added method hasTerminalImpl()
* /cvsroot/java-readline/java-readline/ChangeLog:
release notes for 0.7.1
* /cvsroot/java-readline/java-readline/VERSION:
changed version to 0.7.1
2002-01-19 Bablokb
* /cvsroot/java-readline/java-readline/VERSION:
changed version to 0.7.0
* /cvsroot/java-readline/java-readline/ChangeLog:
release notes for 0.7.0
2002-01-01 Bablokb
* /cvsroot/java-readline/java-readline/TODO:
removed todo-item about JPython/Jython
* /cvsroot/java-readline/java-readline/contrib/jpython/jython-install.txt:
Initial entry
* /cvsroot/java-readline/java-readline/contrib/jpython/README:
updated the file to point to jython-install.txt
2001-12-27 Bablokb
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
- bugfix: setCompleter(null) crashed the virtual machine
- added methods cleanup(), getLineBuffer() and the respective *Impl methods
- improved documentation
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
- added cleanupReadlineImpl and getLineBufferImpl (provided by Henner Zeller)
- minor code cleanup (provided by Henner Zeller)
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
- added Readline.cleanup() code
- minor changes to main input loop
* /cvsroot/java-readline/java-readline/README:
added note about Debian-packages
* /cvsroot/java-readline/java-readline/Makefile:
removed option -private from call to javadoc
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineCompleter.java:
Initial entry
2001-12-15 Bablokb
* /cvsroot/java-readline/java-readline/ChangeLog:
correct version is 0.6.1, not 0.61
* /cvsroot/java-readline/java-readline/VERSION:
changed version to 0.6.1
* /cvsroot/java-readline/java-readline/VERSION: changed version to 0.61
* /cvsroot/java-readline/java-readline/ChangeLog:
release notes for 0.61
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
bugfix: fallback-solution did not throw EOFException
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineLibrary.java:
bugfix: missing P ("ureJava") in method byName
2001-10-12 Bablokb
* /cvsroot/java-readline/java-readline/VERSION: changed version to 0.6
* /cvsroot/java-readline/java-readline/TODO:
removed all TODO-items finished for 0.6
* /cvsroot/java-readline/java-readline/contrib/bsh/Interpreter.java.diff:
added ReadlineLibrary argument to constructor of ReadlineReader
* /cvsroot/java-readline/java-readline/src/native/Makefile:
reorganized dependencies and rules
* /cvsroot/java-readline/java-readline/contrib/bsh/README:
added note about changes due to the new post 0.6-features
* /cvsroot/java-readline/java-readline/contrib/bsh/Interpreter.java:
added ReadlineLibrary argument to constructor of ReadlineReader
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineReader.java:
added ReadlineLibrary argument to all constructors
2001-09-08 Bablokb
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
implemented switching of backing libraries
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineLibrary.java:
implemented byName() method
* /cvsroot/java-readline/java-readline/TODO: TODO-status as of 0.6pre1
* /cvsroot/java-readline/java-readline/VERSION:
changed version to 0.6pre1
* /cvsroot/java-readline/java-readline/ChangeLog: release notes for 0.6
* /cvsroot/java-readline/java-readline/Makefile: - added README.1st
- bugfix: use $(shell ls *.so) instead of $(wildcard *.so)
- reorganized BIN_ADD and SRC_ADD
* /cvsroot/java-readline/java-readline/README.1st: Initial entry
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
added EOFException explicitly to readline()
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
added more comments
* /cvsroot/java-readline/java-readline/README: updated to 0.6
* /cvsroot/java-readline/java-readline/contrib/jpython/ReadlineConsole.java:
updated to reflect new methods since 0.6
* /cvsroot/java-readline/java-readline/src/native/Makefile:
changed -D in compilation of org_gnu_readline_Readline.c
(just define library-name, don't define a value)
* /cvsroot/java-readline/java-readline/Makefile:
added support for Editline
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
readInitFile() and parseAndBind() are only support by GnuReadline
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
added #defines for JavaReadline/JavaEditline
* /cvsroot/java-readline/java-readline/src/native/Makefile:
generalized makefile to support various readline implementations
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
replaced UnsupportedMethodError with standard UnsupportedOperationException
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
method setThrowErrorOnUnsupportedMethod() changed to
setThrowExceptionOnUnsupportedMethod()
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile:
removed dependency of Readline to UnsupportedMethodError
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/UnsupportedMethodError.java:
replaced with UnsupportedOperationException
2001-09-07 Bablokb
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
added rl_initialize() to initReadlineImpl
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile:
added dependency of Readline to UnsupportedMethodError
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
- bugfix: make [gs]etThrowErrorOnUnsupportedMethod() static
- throw error from all unsupported methods if throw-flag is true
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
added call to Readline.setThrowErrorOnUnsupportedMethod(true);
* /cvsroot/java-readline/java-readline/VERSION: upgraded version to 0.6
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
added call to Readline.load(ReadlineLibrary.GnuReadline)
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
added some comments to load()
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
- added field iThrowError
- added methods getThrowErrorOnUnsupportedMethod() and
setThrowErrorOnUnsupportedMethod()
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/UnsupportedMethodError.java, /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineLibrary.java:
Initial entry
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
- made all native methods private and renamed to *Impl
- implemented simple fallback solution
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
catch IOException instead of EOFException
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile:
added dependency of Readline to ReadlineLibrary
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
renamed installCompleterImpl to setCompleterImpl
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
added Impl to all native methods
2001-09-02 Bablokb
* /cvsroot/java-readline/java-readline/Makefile:
added contrib to SRC_ADD
* /cvsroot/java-readline/java-readline/Makefile:
changed to tar.bz2 archives
2001-08-27 Bablokb
* /cvsroot/java-readline/java-readline/ChangeLog:
added author of word break patch
2001-08-26 Bablokb
* /cvsroot/java-readline/java-readline/VERSION: added ReadlineReader
* /cvsroot/java-readline/java-readline/ChangeLog:
release notes for 0.5.2
* /cvsroot/java-readline/java-readline/TODO: added a few todo-items
* /cvsroot/java-readline/java-readline/README:
added section about LICENSING ISSUES
* /cvsroot/java-readline/java-readline/contrib/jpython/README:
added a note about JPython <-> Jython
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/ReadlineReader.java:
Initial entry
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
added javadoc comments to getWordBreakCharacters() and setWordBreakCharacters()
* /cvsroot/java-readline/java-readline/contrib/bsh/BshCompleter.java, /cvsroot/java-readline/java-readline/contrib/bsh/Interpreter.java, /cvsroot/java-readline/java-readline/contrib/bsh/Interpreter.java.diff, /cvsroot/java-readline/java-readline/contrib/bsh/README:
Initial entry
* /cvsroot/java-readline/java-readline/ChangeLog: log entry for 0.5.1
* /cvsroot/java-readline/java-readline/VERSION, /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c, /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java, /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
added word break patch
2001-03-18 Bablokb
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile, /cvsroot/java-readline/java-readline/src/org/gnu/Makefile, /cvsroot/java-readline/java-readline/src/org/Makefile, /cvsroot/java-readline/java-readline/src/test/Makefile:
added copyright header
* /cvsroot/java-readline/java-readline/etc/Makefile:
removed reference to RRSystem
* /cvsroot/java-readline/java-readline/ChangeLog: release notes for 0.5
* /cvsroot/java-readline/java-readline/README: upgraded text to 0.5
* /cvsroot/java-readline/java-readline/TODO:
removed custom completers from TODO list
* /cvsroot/java-readline/java-readline/Makefile:
- added $(APIDIR) to BIN_ADD
- added $(BIN_ADD) to target bin-dist
- updated target clean
* /cvsroot/java-readline/java-readline/VERSION:
upgraded version number to 0.5
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
added additional methods: readHistoryFile(), writeHistoryFile(),
setCompleter(), getCompleter(), installCompleter()
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
added code for new functions
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c:
added code for readHistoryFile, writeHistoryFile and installCompleter
* /cvsroot/java-readline/java-readline/src/test/TestCompleter.java:
Initial entry
* /cvsroot/java-readline/java-readline/src/test/Makefile:
added dependency TestCompleter of ReadlineTest
2001-03-17 Bablokb
* /cvsroot/java-readline/java-readline/VERSION: Initial entry
* /cvsroot/java-readline/java-readline/src/native/org_gnu_readline_Readline.c, /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
changed copyright
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java, /cvsroot/java-readline/java-readline/src/org/gnu/readline/Readline.java:
changed mail adress
* /cvsroot/java-readline/java-readline/README: - merged INSTALL
- minor changes in wording
* /cvsroot/java-readline/java-readline/ChangeLog:
added release notes for release 0.4.3
* /cvsroot/java-readline/java-readline/Makefile:
rewrote makefile for new structure
* /cvsroot/java-readline/java-readline/INSTALL: merged with README
* /cvsroot/java-readline/java-readline/src/native/Makefile:
added $(SO) to rm statement in target clean
* /cvsroot/java-readline/java-readline/etc/Makefile, /cvsroot/java-readline/java-readline/etc/manifest.stub:
Initial entry
* /cvsroot/java-readline/java-readline/src/native/Makefile:
changed target directory for shared library
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
- moved import-statements before class definition
- added javadoc comments about main-method
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
made init-file an argument
* /cvsroot/java-readline/java-readline/src/native/Makefile:
ignore error from rm in target clean
* /cvsroot/java-readline/java-readline/src/native/Makefile:
new structure
* /cvsroot/java-readline/java-readline/src/Makefile, /cvsroot/java-readline/java-readline/src/mkrules.inc:
added target clean
* /cvsroot/java-readline/java-readline/src/test/ReadlineTest.java:
added package statement
* /cvsroot/java-readline/java-readline/src/org/gnu/readline/Makefile, /cvsroot/java-readline/java-readline/src/org/gnu/Makefile, /cvsroot/java-readline/java-readline/src/org/Makefile, /cvsroot/java-readline/java-readline/src/test/Makefile, /cvsroot/java-readline/java-readline/src/Makefile, /cvsroot/java-readline/java-readline/src/mkrules.inc, /cvsroot/java-readline/java-readline/COPYING.LIB:
Initial entry
2001-03-04 Bablokb
* /cvsroot/java-readline/java-readline/contrib/jpython/ReadlineConsole.java:
bugfix: deal with prompt==null in raw_input()
2000-09-18 Bablokb
* /cvsroot/java-readline/java-readline/contrib/jpython/README, /cvsroot/java-readline/java-readline/contrib/jpython/ReadlineConsole.java, /cvsroot/java-readline/java-readline/contrib/jpython/jpython.java, /cvsroot/java-readline/java-readline/contrib/jpython/jpython.diff:
Initial entry
2000-05-01 Bablokb
* /cvsroot/java-readline/java-readline/src/native/Makefile:
changed JAVANATINC to jdk 1.2 standard libreadline-java-0.8.0.1+dfsg/COPYING.LIB 0000644 0001750 0001750 00000057505 07606524213 016151 0 ustar moon moon GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
libreadline-java-0.8.0.1+dfsg/Makefile 0000644 0001750 0001750 00000011425 07606524213 016140 0 ustar moon moon #**************************************************************************
#* Makefile for libJavaReadline.so -- load library for JNI wrapper
#* of GNU readline
#*
#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
#*
#* This program is free software; you can redistribute it and/or modify
#* it under the terms of the GNU Library General Public License as published
#* by the Free Software Foundation; either version 2 of the License or
#* (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful, but
#* WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU Library General Public License for more details.
#*
#* You should have received a copy of the GNU Library General Public License
#* along with this program; see the file COPYING.LIB. If not, write to
#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
#* Boston, MA 02111-1307 USA
#***************************************************************************
#
# Toplevel Makefile for Java-Readline
#
# $Author: bablokb $
# $Revision: 1.18 $
#
TARGET = libreadline-java
README = README README.1st
NEWS = NEWS
CHANGELOG = ChangeLog
LICENSE = COPYING.LIB
TODO = TODO
NAME = The Java-Readline Library
HOMEPAGE = http://java-readline.sourceforge.net/
COPYRIGHT = Released under the LGPL, (c) Bernhard Bablok, Henner Zeller 1998-2002
WTITLE = "$(NAME)"
DTITLE = "$(NAME), Version $(VERSION)"
DBOTTOM = "$(COPYRIGHT)
Homepage: $(HOMEPAGE)"
DHEADER = "$(NAME), Version $(VERSION)"
DFOOTER = "$(NAME), Version $(VERSION)"
BIN_ADD = $(README) $(NEWS) $(TODO) $(CHANGELOG) $(LICENSE) \
$(JAR) *.so $(APIDIR)
SRC_ADD = $(README) $(NEWS) $(TODO) $(CHANGELOG) $(LICENSE) \
Makefile VERSION $(SUBDIRS) contrib src etc
MF_STUB = etc/manifest.stub
# installation procedure
PREFIX = /usr
BINLIBDIR = $(PREFIX)/lib
DOCDIR = $(PREFIX)/doc
JAVALIBDIR= $(PREFIX)/share/java
# libraries to build
T_LIBS = JavaReadline
# Operating system dependent
JAVAINCLUDE = $(JAVA_HOME)/include
JAVANATINC = $(JAVA_HOME)/include/linux
ifeq (MSC,$(WIN32))
JAVA_HOME := c:/j2sdk1.4.0
JAVANATINC = $(JAVA_HOME)/include/win32
export PATH:=/cygdrive/$(subst :,,$(JAVA_HOME))/bin:/cygdrive/c/Programme/DevStudio/VC/bin:/cygdrive/c/Programme/DevStudio/SharedIDE/bin/:$(PATH)
T_LIBS = JavaGetline
ARGS = Getline
endif
## normal javac
JAVAC = javac
JC_FLAGS =
## with jikes
#JAVAC = jikes
#JC_FLAGS = -O +E
VERSION = `cat VERSION`
JAR = $(TARGET).jar
APIDIR = ./api
BUILDDIR = ./build
# we build the rpm relative to our build..
RPM_BASE = `pwd`/$(BUILDDIR)/
world : jar build-native
jar: build-java
cd $(BUILDDIR) ; jar -cvmf ../$(MF_STUB) ../$(JAR) *
$(JAR):
cd $(BUILDDIR) ; jar -cvmf ../$(MF_STUB) ../$(JAR) *
build-java: $(BUILDDIR)
cd src ; $(MAKE) JAVAC="$(JAVAC)" JC_FLAGS="$(JC_FLAGS)" java
build-native:
cd src; $(MAKE) T_LIBS="$(T_LIBS)" JAVAINCLUDE="$(JAVAINCLUDE)" \
JAVANATINC="$(JAVANATINC)" native
apidoc: $(APIDIR)
javadoc -sourcepath src -d $(APIDIR) -windowtitle $(WTITLE) \
-doctitle $(DTITLE) -footer $(DFOOTER) -header $(DHEADER) \
-bottom $(DBOTTOM) \
-version -author org.gnu.readline test
install: jar build-native apidoc
install -D $(JAR) $(DESTDIR)$(JAVALIBDIR)/$(JAR)
install -d $(DESTDIR)$(BINLIBDIR)
install *.so $(DESTDIR)$(BINLIBDIR)
install -d $(DESTDIR)$(DOCDIR)/$(TARGET)-$(VERSION)
cp -r api $(DESTDIR)$(DOCDIR)/$(TARGET)-$(VERSION)
bin-dist: jar build-native apidoc
mkdir -p "$(TARGET)-$(VERSION)"
-cp -r $(BIN_ADD) "$(TARGET)-$(VERSION)"
tar -czf $(TARGET)-$(VERSION)-bin.tar.gz --exclude "CVS" "$(TARGET)-$(VERSION)"
rm -rf "$(TARGET)-$(VERSION)"
src-dist: clean
mkdir -p "$(TARGET)-$(VERSION)"
-cp -r $(SRC_ADD) "$(TARGET)-$(VERSION)"
tar -czf $(TARGET)-$(VERSION)-src.tar.gz --exclude "CVS" "$(TARGET)-$(VERSION)"
rm -rf "$(TARGET)-$(VERSION)"
$(APIDIR):
mkdir $(APIDIR)
$(BUILDDIR):
mkdir $(BUILDDIR)
$(METADIR):
mkdir $(METADIR)
rpm: src-dist
mkdir -p $(RPM_BASE)/SPECS $(RPM_BASE)/SOURCES $(RPM_BASE)/BUILD \
$(RPM_BASE)/SRPMS $(RPM_BASE)/RPMS
cp etc/libreadline-java.spec $(RPM_BASE)/SPECS
cp $(TARGET)-$(VERSION)-src.tar.gz $(RPM_BASE)/SOURCES
rpm --define _topdir$(RPM_BASE) -ba $(RPM_BASE)/SPECS/libreadline-java.spec
test: $(JAR) build-native
LD_LIBRARY_PATH=. java -jar $(JAR) src/test/tinputrc $(ARGS)
clean:
$(MAKE) -C src/native clean
-rm -fr `find . -name "*.o" -o -name "*~"` \
$(JAR) $(TARGET)-*.tar.*z* $(APIDIR) \
$(BUILDDIR) *.so .rltest_history
libreadline-java-0.8.0.1+dfsg/VERSION 0000644 0001750 0001750 00000000006 07606524213 015541 0 ustar moon moon 0.8.0
libreadline-java-0.8.0.1+dfsg/src/ 0000755 0001750 0001750 00000000000 07606524213 015264 5 ustar moon moon libreadline-java-0.8.0.1+dfsg/src/native/ 0000755 0001750 0001750 00000000000 07606524213 016552 5 ustar moon moon libreadline-java-0.8.0.1+dfsg/src/native/getline.c 0000644 0001750 0001750 00000071474 07606524213 020362 0 ustar moon moon #ifndef lint
static char rcsid[] =
"$Id: getline.c,v 1.1 2002/06/25 15:24:26 bablokb Exp $";
static char *copyright = "Copyright (C) 1991-1994, Chris Thewalt";
#endif
/*
* Copyright (C) 1991-1994 by Chris Thewalt (thewalt@ce.berkeley.edu)
*
* Permission to use, copy, modify, and distribute this software
* for any purpose and without fee is hereby granted, provided
* that the above copyright notices appear in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. This software is provided "as is" without express or
* implied warranty.
*
* Thanks to the following people who have provided enhancements and fixes:
* Ron Ueberschaer, Christoph Keller, Scott Schwartz, Steven List,
* DaviD W. Sanderson, Goran Bostrom, Michael Gleason, Glenn Kasten,
* Edin Hodzic, Eric J Bivona, Kai Uwe Rommel, Danny Quah, Ulrich Betzler,
* V. Phaniraj.
*/
#include "getline.h"
static int gl_tab(); /* forward reference needed for gl_tab_hook */
/******************** imported interface *********************************/
#include
#include
#include
#include
extern int isatty();
extern void *malloc();
extern void free();
/********************* readline compatibility ****************************/
char* rl_readline_name;
/********************* exported interface ********************************/
char *getline(); /* read a line of input */
void gl_setwidth(); /* specify width of screen */
void gl_histadd(); /* adds entries to hist */
void gl_strwidth(); /* to bind gl_strlen */
int (*gl_in_hook)() = 0;
int (*gl_out_hook)() = 0;
int (*gl_tab_hook)() = gl_tab;
/******************** internal interface *********************************/
#define BUF_SIZE 1024
static int gl_init_done = -1; /* terminal mode flag */
static int gl_termw = 80; /* actual terminal width */
static int gl_scroll = 27; /* width of EOL scrolling region */
static int gl_width = 0; /* net size available for input */
static int gl_extent = 0; /* how far to redraw, 0 means all */
static int gl_overwrite = 0; /* overwrite mode */
static int gl_pos, gl_cnt = 0; /* position and size of input */
static char gl_buf[BUF_SIZE]; /* input buffer */
static char gl_killbuf[BUF_SIZE]=""; /* killed text */
static char *gl_prompt; /* to save the prompt string */
static char gl_intrc = 0; /* keyboard SIGINT char */
static char gl_quitc = 0; /* keyboard SIGQUIT char */
static char gl_suspc = 0; /* keyboard SIGTSTP char */
static char gl_dsuspc = 0; /* delayed SIGTSTP char */
static int gl_search_mode = 0; /* search mode flag */
static void gl_init(); /* prepare to edit a line */
static void gl_cleanup(); /* to undo gl_init */
static void gl_char_init(); /* get ready for no echo input */
static void gl_char_cleanup(); /* undo gl_char_init */
static size_t (*gl_strlen)() = (size_t(*)())strlen;
/* returns printable prompt width */
static void gl_addchar(); /* install specified char */
static void gl_del(); /* del, either left (-1) or cur (0) */
static void gl_error(); /* write error msg and die */
static void gl_fixup(); /* fixup state variables and screen */
static int gl_getc(); /* read one char from terminal */
static void gl_kill(); /* delete to EOL */
static void gl_newline(); /* handle \n or \r */
static void gl_putc(); /* write one char to terminal */
static void gl_puts(); /* write a line to terminal */
static void gl_redraw(); /* issue \n and redraw all */
static void gl_transpose(); /* transpose two chars */
static void gl_yank(); /* yank killed text */
static void gl_word(); /* move a word */
void hist_init(); /* initializes hist pointers */
static char *hist_next(); /* return ptr to next item */
static char *hist_prev(); /* return ptr to prev item */
static char *hist_save(); /* makes copy of a string, without NL */
static void search_addchar(); /* increment search string */
static void search_term(); /* reset with current contents */
static void search_back(); /* look back for current string */
static void search_forw(); /* look forw for current string */
/************************ nonportable part *********************************/
extern int write();
extern void exit();
#ifdef unix
#ifndef __unix__
#define __unix__
#endif /* not __unix__ */
#endif /* unix */
#ifdef _IBMR2
#ifndef __unix__
#define __unix__
#endif
#endif
#ifdef __IBMC__
#include
#endif
#ifdef __GO32__
#include
#undef MSDOS
#undef __unix__
#endif
#ifdef MSDOS
#include
#endif
#ifdef __unix__
#ifndef __convexc__
extern int read();
extern int kill();
extern int ioctl();
#endif /* not __convexc__ */
#ifdef POSIX /* use POSIX interface */
#include
struct termios new_termios, old_termios;
#else /* not POSIX */
#include
#ifdef M_XENIX /* does not really use bsd terminal interface */
#undef TIOCSETN
#endif /* M_XENIX */
#ifdef TIOCSETN /* use BSD interface */
#include
struct sgttyb new_tty, old_tty;
struct tchars tch;
struct ltchars ltch;
#else /* use SYSV interface */
#include
struct termio new_termio, old_termio;
#endif /* TIOCSETN */
#endif /* POSIX */
#endif /* __unix__ */
#ifdef vms
#include
#include
#include
#include unixio
static int setbuff[2]; /* buffer to set terminal attributes */
static short chan = -1; /* channel to terminal */
struct dsc$descriptor_s descrip; /* VMS descriptor */
#endif
static void
gl_char_init() /* turn off input echo */
{
#ifdef __unix__
#ifdef POSIX
tcgetattr(0, &old_termios);
gl_intrc = old_termios.c_cc[VINTR];
gl_quitc = old_termios.c_cc[VQUIT];
#ifdef VSUSP
gl_suspc = old_termios.c_cc[VSUSP];
#endif
#ifdef VDSUSP
gl_dsuspc = old_termios.c_cc[VDSUSP];
#endif
new_termios = old_termios;
new_termios.c_iflag &= ~(BRKINT|ISTRIP|IXON|IXOFF);
new_termios.c_iflag |= (IGNBRK|IGNPAR);
new_termios.c_lflag &= ~(ICANON|ISIG|IEXTEN|ECHO);
new_termios.c_cc[VMIN] = 1;
new_termios.c_cc[VTIME] = 0;
tcsetattr(0, TCSANOW, &new_termios);
#else /* not POSIX */
#ifdef TIOCSETN /* BSD */
ioctl(0, TIOCGETC, &tch);
ioctl(0, TIOCGLTC, <ch);
gl_intrc = tch.t_intrc;
gl_quitc = tch.t_quitc;
gl_suspc = ltch.t_suspc;
gl_dsuspc = ltch.t_dsuspc;
ioctl(0, TIOCGETP, &old_tty);
new_tty = old_tty;
new_tty.sg_flags |= RAW;
new_tty.sg_flags &= ~ECHO;
ioctl(0, TIOCSETN, &new_tty);
#else /* SYSV */
ioctl(0, TCGETA, &old_termio);
gl_intrc = old_termio.c_cc[VINTR];
gl_quitc = old_termio.c_cc[VQUIT];
new_termio = old_termio;
new_termio.c_iflag &= ~(BRKINT|ISTRIP|IXON|IXOFF);
new_termio.c_iflag |= (IGNBRK|IGNPAR);
new_termio.c_lflag &= ~(ICANON|ISIG|ECHO);
new_termio.c_cc[VMIN] = 1;
new_termio.c_cc[VTIME] = 0;
ioctl(0, TCSETA, &new_termio);
#endif /* TIOCSETN */
#endif /* POSIX */
#endif /* __unix__ */
#ifdef vms
descrip.dsc$w_length = strlen("tt:");
descrip.dsc$b_dtype = DSC$K_DTYPE_T;
descrip.dsc$b_class = DSC$K_CLASS_S;
descrip.dsc$a_pointer = "tt:";
(void)sys$assign(&descrip,&chan,0,0);
(void)sys$qiow(0,chan,IO$_SENSEMODE,0,0,0,setbuff,8,0,0,0,0);
setbuff[1] |= TT$M_NOECHO;
(void)sys$qiow(0,chan,IO$_SETMODE,0,0,0,setbuff,8,0,0,0,0);
#endif /* vms */
}
static void
gl_char_cleanup() /* undo effects of gl_char_init */
{
#ifdef __unix__
#ifdef POSIX
tcsetattr(0, TCSANOW, &old_termios);
#else /* not POSIX */
#ifdef TIOCSETN /* BSD */
ioctl(0, TIOCSETN, &old_tty);
#else /* SYSV */
ioctl(0, TCSETA, &old_termio);
#endif /* TIOCSETN */
#endif /* POSIX */
#endif /* __unix__ */
#ifdef vms
setbuff[1] &= ~TT$M_NOECHO;
(void)sys$qiow(0,chan,IO$_SETMODE,0,0,0,setbuff,8,0,0,0,0);
sys$dassgn(chan);
chan = -1;
#endif
}
#if MSDOS || __EMX__ || __GO32__ || __IBMC__
int pc_keymap(c)
int c;
{
switch (c) {
case 72: c = 16; /* up -> ^P */
break;
case 80: c = 14; /* down -> ^N */
break;
case 75: c = 2; /* left -> ^B */
break;
case 77: c = 6; /* right -> ^F */
break;
case 83: c = 4; /* delete -> ^D */
break;
case 71: c = 1; /* home -> ^A */
break;
case 79: c = 5; /* end -> ^E */
break;
case 82: c =15; /* insert -> ^O */
break;
default: c = 0; /* make it garbage */
}
return c;
}
#endif /* MSDOS || __EMX__ || __GO32__ || __IBMC__ */
static int
gl_getc()
/* get a character without echoing it to screen */
{
int c;
#ifdef __unix__
char ch;
#endif
#ifdef __unix__
while ((c = read(0, &ch, 1)) == -1) {
if (errno != EINTR)
break;
}
c = (c <= 0)? -1 : ch;
#endif /* __unix__ */
#ifdef MSDOS
c = _bios_keybrd(_NKEYBRD_READ);
#endif /* MSDOS */
#ifdef __GO32__
c = getkey () ;
if (c > 255) c = pc_keymap(c & 0377);
#endif /* __GO32__ */
#ifdef __TURBOC__
while(!bioskey(1))
;
c = bioskey(0);
#endif
#if MSDOS || __TURBOC__
if ((c & 0377) == 224) {
c = pc_keymap((c >> 8) & 0377);
} else {
c &= 0377;
}
#endif /* MSDOS || __TURBOC__ */
#ifdef __EMX__
c = _read_kbd(0, 1, 0);
if (c == 224 || c == 0) {
c = pc_keymap(_read_kbd(0, 1, 0));
} else {
c &= 0377;
}
#endif
#ifdef __IBMC__
c=_getch();
if (c == 224 || c == 0) {
c = pc_keymap(_getch());
} else {
c &= 0377;
}
#endif
#ifdef vms
if(chan < 0) {
c='\0';
}
(void)sys$qiow(0,chan,IO$_TTYREADALL,0,0,0,&c,1,0,0,0,0);
c &= 0177; /* get a char */
#endif
return c;
}
static void
gl_putc(c)
int c;
{
char ch = c;
write(1, &ch, 1);
if (ch == '\n') {
ch = '\r';
write(1, &ch, 1); /* RAW mode needs '\r', does not hurt */
}
}
/******************** fairly portable part *********************************/
static void
gl_puts(buf)
char *buf;
{
int len;
if (buf) {
len = strlen(buf);
write(1, buf, len);
}
}
static void
gl_error(buf)
char *buf;
{
int len = strlen(buf);
gl_cleanup();
write(2, buf, len);
exit(1);
}
static void
gl_init()
/* set up variables and terminal */
{
if (gl_init_done < 0) { /* -1 only on startup */
hist_init();
}
if (isatty(0) == 0 || isatty(1) == 0)
gl_error("\n*** Error: getline(): not interactive, use stdio.\n");
gl_char_init();
gl_init_done = 1;
}
static void
gl_cleanup()
/* undo effects of gl_init, as necessary */
{
if (gl_init_done > 0)
gl_char_cleanup();
gl_init_done = 0;
}
void
gl_setwidth(w)
int w;
{
if (w > 20) {
gl_termw = w;
gl_scroll = w / 3;
} else {
gl_error("\n*** Error: minimum screen width is 21\n");
}
}
char *
getline(prompt)
char *prompt;
{
int c, loc, tmp;
#ifdef __unix__
int sig;
#endif
gl_init();
gl_prompt = (prompt)? prompt : "";
gl_buf[0] = 0;
if (gl_in_hook)
gl_in_hook(gl_buf);
gl_fixup(gl_prompt, -2, BUF_SIZE);
while ((c = gl_getc()) >= 0) {
gl_extent = 0; /* reset to full extent */
if (isprint(c)) {
if (gl_search_mode)
search_addchar(c);
else
gl_addchar(c);
} else {
if (gl_search_mode) {
if (c == '\033' || c == '\016' || c == '\020') {
search_term();
c = 0; /* ignore the character */
} else if (c == '\010' || c == '\177') {
search_addchar(-1); /* unwind search string */
c = 0;
} else if (c != '\022' && c != '\023') {
search_term(); /* terminate and handle char */
}
}
switch (c) {
case '\n': case '\r': /* newline */
gl_newline();
gl_cleanup();
return gl_buf;
/*NOTREACHED*/
break;
case '\001': gl_fixup(gl_prompt, -1, 0); /* ^A */
break;
case '\002': gl_fixup(gl_prompt, -1, gl_pos-1); /* ^B */
break;
case '\004': /* ^D */
if (gl_cnt == 0) {
gl_buf[0] = 0;
gl_cleanup();
gl_putc('\n');
return NULL;
} else {
gl_del(0);
}
break;
case '\005': gl_fixup(gl_prompt, -1, gl_cnt); /* ^E */
break;
case '\006': gl_fixup(gl_prompt, -1, gl_pos+1); /* ^F */
break;
case '\010': case '\177': gl_del(-1); /* ^H and DEL */
break;
case '\t': /* TAB */
if (gl_tab_hook) {
tmp = gl_pos;
loc = gl_tab_hook(gl_buf, gl_strlen(gl_prompt), &tmp);
if (loc >= 0 || tmp != gl_pos)
gl_fixup(gl_prompt, loc, tmp);
}
break;
case '\013': gl_kill(gl_pos); /* ^K */
break;
case '\014': gl_redraw(); /* ^L */
break;
case '\016': /* ^N */
strcpy(gl_buf, hist_next());
if (gl_in_hook)
gl_in_hook(gl_buf);
gl_fixup(gl_prompt, 0, BUF_SIZE);
break;
case '\017': gl_overwrite = !gl_overwrite; /* ^O */
break;
case '\020': /* ^P */
strcpy(gl_buf, hist_prev());
if (gl_in_hook)
gl_in_hook(gl_buf);
gl_fixup(gl_prompt, 0, BUF_SIZE);
break;
case '\022': search_back(1); /* ^R */
break;
case '\023': search_forw(1); /* ^S */
break;
case '\024': gl_transpose(); /* ^T */
break;
case '\025': gl_kill(0); /* ^U */
break;
case '\031': gl_yank(); /* ^Y */
break;
case '\033': /* ansi arrow keys */
c = gl_getc();
if (c == '[') {
switch(c = gl_getc()) {
case 'A': /* up */
strcpy(gl_buf, hist_prev());
if (gl_in_hook)
gl_in_hook(gl_buf);
gl_fixup(gl_prompt, 0, BUF_SIZE);
break;
case 'B': /* down */
strcpy(gl_buf, hist_next());
if (gl_in_hook)
gl_in_hook(gl_buf);
gl_fixup(gl_prompt, 0, BUF_SIZE);
break;
case 'C': gl_fixup(gl_prompt, -1, gl_pos+1); /* right */
break;
case 'D': gl_fixup(gl_prompt, -1, gl_pos-1); /* left */
break;
default: gl_putc('\007'); /* who knows */
break;
}
} else if (c == 'f' || c == 'F') {
gl_word(1);
} else if (c == 'b' || c == 'B') {
gl_word(-1);
} else
gl_putc('\007');
break;
default: /* check for a terminal signal */
#ifdef __unix__
if (c > 0) { /* ignore 0 (reset above) */
sig = 0;
#ifdef SIGINT
if (c == gl_intrc)
sig = SIGINT;
#endif
#ifdef SIGQUIT
if (c == gl_quitc)
sig = SIGQUIT;
#endif
#ifdef SIGTSTP
if (c == gl_suspc || c == gl_dsuspc)
sig = SIGTSTP;
#endif
if (sig != 0) {
gl_cleanup();
kill(0, sig);
gl_init();
gl_redraw();
c = 0;
}
}
#endif /* __unix__ */
if (c > 0)
gl_putc('\007');
break;
}
}
}
gl_cleanup();
gl_buf[0] = 0;
return gl_buf;
}
static void
gl_addchar(c)
int c;
/* adds the character c to the input buffer at current location */
{
int i;
if (gl_cnt >= BUF_SIZE - 1)
gl_error("\n*** Error: getline(): input buffer overflow\n");
if (gl_overwrite == 0 || gl_pos == gl_cnt) {
for (i=gl_cnt; i >= gl_pos; i--)
gl_buf[i+1] = gl_buf[i];
gl_buf[gl_pos] = c;
gl_fixup(gl_prompt, gl_pos, gl_pos+1);
} else {
gl_buf[gl_pos] = c;
gl_extent = 1;
gl_fixup(gl_prompt, gl_pos, gl_pos+1);
}
}
static void
gl_yank()
/* adds the kill buffer to the input buffer at current location */
{
int i, len;
len = strlen(gl_killbuf);
if (len > 0) {
if (gl_overwrite == 0) {
if (gl_cnt + len >= BUF_SIZE - 1)
gl_error("\n*** Error: getline(): input buffer overflow\n");
for (i=gl_cnt; i >= gl_pos; i--)
gl_buf[i+len] = gl_buf[i];
for (i=0; i < len; i++)
gl_buf[gl_pos+i] = gl_killbuf[i];
gl_fixup(gl_prompt, gl_pos, gl_pos+len);
} else {
if (gl_pos + len > gl_cnt) {
if (gl_pos + len >= BUF_SIZE - 1)
gl_error("\n*** Error: getline(): input buffer overflow\n");
gl_buf[gl_pos + len] = 0;
}
for (i=0; i < len; i++)
gl_buf[gl_pos+i] = gl_killbuf[i];
gl_extent = len;
gl_fixup(gl_prompt, gl_pos, gl_pos+len);
}
} else
gl_putc('\007');
}
static void
gl_transpose()
/* switch character under cursor and to left of cursor */
{
int c;
if (gl_pos > 0 && gl_cnt > gl_pos) {
c = gl_buf[gl_pos-1];
gl_buf[gl_pos-1] = gl_buf[gl_pos];
gl_buf[gl_pos] = c;
gl_extent = 2;
gl_fixup(gl_prompt, gl_pos-1, gl_pos);
} else
gl_putc('\007');
}
static void
gl_newline()
/*
* Cleans up entire line before returning to caller. A \n is appended.
* If line longer than screen, we redraw starting at beginning
*/
{
int change = gl_cnt;
int len = gl_cnt;
int loc = gl_width - 5; /* shifts line back to start position */
if (gl_cnt >= BUF_SIZE - 1)
gl_error("\n*** Error: getline(): input buffer overflow\n");
if (gl_out_hook) {
change = gl_out_hook(gl_buf);
len = strlen(gl_buf);
}
if (loc > len)
loc = len;
gl_fixup(gl_prompt, change, loc); /* must do this before appending \n */
gl_buf[len] = '\0';
/* gl_buf[len] = '\n'; */
/* gl_buf[len+1] = '\0'; */
gl_putc('\n');
}
static void
gl_del(loc)
int loc;
/*
* Delete a character. The loc variable can be:
* -1 : delete character to left of cursor
* 0 : delete character under cursor
*/
{
int i;
if ((loc == -1 && gl_pos > 0) || (loc == 0 && gl_pos < gl_cnt)) {
for (i=gl_pos+loc; i < gl_cnt; i++)
gl_buf[i] = gl_buf[i+1];
gl_fixup(gl_prompt, gl_pos+loc, gl_pos+loc);
} else
gl_putc('\007');
}
static void
gl_kill(pos)
int pos;
/* delete from pos to the end of line */
{
if (pos < gl_cnt) {
strcpy(gl_killbuf, gl_buf + pos);
gl_buf[pos] = '\0';
gl_fixup(gl_prompt, pos, pos);
} else
gl_putc('\007');
}
static void
gl_word(direction)
int direction;
/* move forward or backword one word */
{
int pos = gl_pos;
if (direction > 0) { /* forward */
while (!isspace(gl_buf[pos]) && pos < gl_cnt)
pos++;
while (isspace(gl_buf[pos]) && pos < gl_cnt)
pos++;
} else { /* backword */
if (pos > 0)
pos--;
while (isspace(gl_buf[pos]) && pos > 0)
pos--;
while (!isspace(gl_buf[pos]) && pos > 0)
pos--;
if (pos < gl_cnt && isspace(gl_buf[pos])) /* move onto word */
pos++;
}
gl_fixup(gl_prompt, -1, pos);
}
static void
gl_redraw()
/* emit a newline, reset and redraw prompt and current input line */
{
if (gl_init_done > 0) {
gl_putc('\n');
gl_fixup(gl_prompt, -2, gl_pos);
}
}
static void
gl_fixup(prompt, change, cursor)
char *prompt;
int change, cursor;
/*
* This function is used both for redrawing when input changes or for
* moving within the input line. The parameters are:
* prompt: compared to last_prompt[] for changes;
* change : the index of the start of changes in the input buffer,
* with -1 indicating no changes, -2 indicating we're on
* a new line, redraw everything.
* cursor : the desired location of the cursor after the call.
* A value of BUF_SIZE can be used to indicate the cursor should
* move just past the end of the input line.
*/
{
static int gl_shift; /* index of first on screen character */
static int off_right; /* true if more text right of screen */
static int off_left; /* true if more text left of screen */
static char last_prompt[80] = "";
int left = 0, right = -1; /* bounds for redraw */
int pad; /* how much to erase at end of line */
int backup; /* how far to backup before fixing */
int new_shift; /* value of shift based on cursor */
int extra; /* adjusts when shift (scroll) happens */
int i;
int new_right = -1; /* alternate right bound, using gl_extent */
int l1, l2;
if (change == -2) { /* reset */
gl_pos = gl_cnt = gl_shift = off_right = off_left = 0;
gl_putc('\r');
gl_puts(prompt);
strcpy(last_prompt, prompt);
change = 0;
gl_width = gl_termw - gl_strlen(prompt);
} else if (strcmp(prompt, last_prompt) != 0) {
l1 = gl_strlen(last_prompt);
l2 = gl_strlen(prompt);
gl_cnt = gl_cnt + l1 - l2;
strcpy(last_prompt, prompt);
gl_putc('\r');
gl_puts(prompt);
gl_pos = gl_shift;
gl_width = gl_termw - l2;
change = 0;
}
pad = (off_right)? gl_width - 1 : gl_cnt - gl_shift; /* old length */
backup = gl_pos - gl_shift;
if (change >= 0) {
gl_cnt = strlen(gl_buf);
if (change > gl_cnt)
change = gl_cnt;
}
if (cursor > gl_cnt) {
if (cursor != BUF_SIZE) /* BUF_SIZE means end of line */
gl_putc('\007');
cursor = gl_cnt;
}
if (cursor < 0) {
gl_putc('\007');
cursor = 0;
}
if (off_right || (off_left && cursor < gl_shift + gl_width - gl_scroll / 2))
extra = 2; /* shift the scrolling boundary */
else
extra = 0;
new_shift = cursor + extra + gl_scroll - gl_width;
if (new_shift > 0) {
new_shift /= gl_scroll;
new_shift *= gl_scroll;
} else
new_shift = 0;
if (new_shift != gl_shift) { /* scroll occurs */
gl_shift = new_shift;
off_left = (gl_shift)? 1 : 0;
off_right = (gl_cnt > gl_shift + gl_width - 1)? 1 : 0;
left = gl_shift;
new_right = right = (off_right)? gl_shift + gl_width - 2 : gl_cnt;
} else if (change >= 0) { /* no scroll, but text changed */
if (change < gl_shift + off_left) {
left = gl_shift;
} else {
left = change;
backup = gl_pos - change;
}
off_right = (gl_cnt > gl_shift + gl_width - 1)? 1 : 0;
right = (off_right)? gl_shift + gl_width - 2 : gl_cnt;
new_right = (gl_extent && (right > left + gl_extent))?
left + gl_extent : right;
}
pad -= (off_right)? gl_width - 1 : gl_cnt - gl_shift;
pad = (pad < 0)? 0 : pad;
if (left <= right) { /* clean up screen */
for (i=0; i < backup; i++)
gl_putc('\b');
if (left == gl_shift && off_left) {
gl_putc('$');
left++;
}
for (i=left; i < new_right; i++)
gl_putc(gl_buf[i]);
gl_pos = new_right;
if (off_right && new_right == right) {
gl_putc('$');
gl_pos++;
} else {
for (i=0; i < pad; i++) /* erase remains of prev line */
gl_putc(' ');
gl_pos += pad;
}
}
i = gl_pos - cursor; /* move to final cursor location */
if (i > 0) {
while (i--)
gl_putc('\b');
} else {
for (i=gl_pos; i < cursor; i++)
gl_putc(gl_buf[i]);
}
gl_pos = cursor;
}
static int
gl_tab(buf, offset, loc)
char *buf;
int offset;
int *loc;
/* default tab handler, acts like tabstops every 8 cols */
{
int i, count, len;
len = strlen(buf);
count = 8 - (offset + *loc) % 8;
for (i=len; i >= *loc; i--)
buf[i+count] = buf[i];
for (i=0; i < count; i++)
buf[*loc+i] = ' ';
i = *loc;
*loc = i + count;
return i;
}
/******************* strlen stuff **************************************/
void gl_strwidth(func)
size_t (*func)();
{
if (func != 0) {
gl_strlen = func;
}
}
/******************* History stuff **************************************/
#ifndef HIST_SIZE
#define HIST_SIZE 100
#endif
static int hist_pos = 0, hist_last = 0;
static char *hist_buf[HIST_SIZE];
void hist_init() {
int i;
hist_buf[0] = "";
for (i=1; i < HIST_SIZE; i++)
hist_buf[i] = (char *)0;
}
void
gl_histadd(buf)
char *buf;
{
static char *prev = 0;
char *p = buf;
int len;
/* in case we call gl_histadd() before we call getline() */
if (gl_init_done < 0) { /* -1 only on startup */
hist_init();
gl_init_done = 0;
}
while (*p == ' ' || *p == '\t' || *p == '\n')
p++;
if (*p) {
len = strlen(buf);
if (strchr(p, '\n')) /* previously line already has NL stripped */
len--;
if (prev == 0 || strlen(prev) != len ||
strncmp(prev, buf, len) != 0) {
hist_buf[hist_last] = hist_save(buf);
prev = hist_buf[hist_last];
hist_last = (hist_last + 1) % HIST_SIZE;
if (hist_buf[hist_last] && *hist_buf[hist_last]) {
free(hist_buf[hist_last]);
}
hist_buf[hist_last] = "";
}
}
hist_pos = hist_last;
}
static char *
hist_prev()
/* loads previous hist entry into input buffer, sticks on first */
{
char *p = 0;
int next = (hist_pos - 1 + HIST_SIZE) % HIST_SIZE;
if (hist_buf[hist_pos] != 0 && next != hist_last) {
hist_pos = next;
p = hist_buf[hist_pos];
}
if (p == 0) {
p = "";
gl_putc('\007');
}
return p;
}
static char *
hist_next()
/* loads next hist entry into input buffer, clears on last */
{
char *p = 0;
if (hist_pos != hist_last) {
hist_pos = (hist_pos+1) % HIST_SIZE;
p = hist_buf[hist_pos];
}
if (p == 0) {
p = "";
gl_putc('\007');
}
return p;
}
static char *
hist_save(p)
char *p;
/* makes a copy of the string */
{
char *s = 0;
int len = strlen(p);
char *nl = strchr(p, '\n');
if (nl) {
if ((s = malloc(len)) != 0) {
strncpy(s, p, len-1);
s[len-1] = 0;
}
} else {
if ((s = malloc(len+1)) != 0) {
strcpy(s, p);
}
}
if (s == 0)
gl_error("\n*** Error: hist_save() failed on malloc\n");
return s;
}
/******************* Search stuff **************************************/
static char search_prompt[101]; /* prompt includes search string */
static char search_string[100];
static int search_pos = 0; /* current location in search_string */
static int search_forw_flg = 0; /* search direction flag */
static int search_last = 0; /* last match found */
static void
search_update(c)
int c;
{
if (c == 0) {
search_pos = 0;
search_string[0] = 0;
search_prompt[0] = '?';
search_prompt[1] = ' ';
search_prompt[2] = 0;
} else if (c > 0) {
search_string[search_pos] = c;
search_string[search_pos+1] = 0;
search_prompt[search_pos] = c;
search_prompt[search_pos+1] = '?';
search_prompt[search_pos+2] = ' ';
search_prompt[search_pos+3] = 0;
search_pos++;
} else {
if (search_pos > 0) {
search_pos--;
search_string[search_pos] = 0;
search_prompt[search_pos] = '?';
search_prompt[search_pos+1] = ' ';
search_prompt[search_pos+2] = 0;
} else {
gl_putc('\007');
hist_pos = hist_last;
}
}
}
static void
search_addchar(c)
int c;
{
char *loc;
search_update(c);
if (c < 0) {
if (search_pos > 0) {
hist_pos = search_last;
} else {
gl_buf[0] = 0;
hist_pos = hist_last;
}
strcpy(gl_buf, hist_buf[hist_pos]);
}
if ((loc = strstr(gl_buf, search_string)) != 0) {
gl_fixup(search_prompt, 0, loc - gl_buf);
} else if (search_pos > 0) {
if (search_forw_flg) {
search_forw(0);
} else {
search_back(0);
}
} else {
gl_fixup(search_prompt, 0, 0);
}
}
static void
search_term()
{
gl_search_mode = 0;
if (gl_buf[0] == 0) /* not found, reset hist list */
hist_pos = hist_last;
if (gl_in_hook)
gl_in_hook(gl_buf);
gl_fixup(gl_prompt, 0, gl_pos);
}
static void
search_back(new_search)
int new_search;
{
int found = 0;
char *p, *loc;
search_forw_flg = 0;
if (gl_search_mode == 0) {
search_last = hist_pos = hist_last;
search_update(0);
gl_search_mode = 1;
gl_buf[0] = 0;
gl_fixup(search_prompt, 0, 0);
} else if (search_pos > 0) {
while (!found) {
p = hist_prev();
if (*p == 0) { /* not found, done looking */
gl_buf[0] = 0;
gl_fixup(search_prompt, 0, 0);
found = 1;
} else if ((loc = strstr(p, search_string)) != 0) {
strcpy(gl_buf, p);
gl_fixup(search_prompt, 0, loc - p);
if (new_search)
search_last = hist_pos;
found = 1;
}
}
} else {
gl_putc('\007');
}
}
static void
search_forw(new_search)
int new_search;
{
int found = 0;
char *p, *loc;
search_forw_flg = 1;
if (gl_search_mode == 0) {
search_last = hist_pos = hist_last;
search_update(0);
gl_search_mode = 1;
gl_buf[0] = 0;
gl_fixup(search_prompt, 0, 0);
} else if (search_pos > 0) {
while (!found) {
p = hist_next();
if (*p == 0) { /* not found, done looking */
gl_buf[0] = 0;
gl_fixup(search_prompt, 0, 0);
found = 1;
} else if ((loc = strstr(p, search_string)) != 0) {
strcpy(gl_buf, p);
gl_fixup(search_prompt, 0, loc - p);
if (new_search)
search_last = hist_pos;
found = 1;
}
}
} else {
gl_putc('\007');
}
}
libreadline-java-0.8.0.1+dfsg/src/native/Makefile 0000644 0001750 0001750 00000007003 07606524213 020212 0 ustar moon moon #**************************************************************************
#* Makefile for libJava*.so -- load library for JNI wrapper of
#* of GNU readline
#*
#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
#*
#* This program is free software; you can redistribute it and/or modify
#* it under the terms of the GNU Library General Public License as published
#* by the Free Software Foundation; either version 2 of the License or
#* (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful, but
#* WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU Library General Public License for more details.
#*
#* You should have received a copy of the GNU Library General Public License
#* along with this program; see the file COPYING.LIB. If not, write to
#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
#* Boston, MA 02111-1307 USA
#***************************************************************************
#
# Makefile for JNI-library libJava*.so
#
# $Author: bablokb $
# $Revision: 1.13 $
#
export
.PHONY: org_gnu_readline_Readline.o
ROOTDIR=../..
BUILDDIR=$(ROOTDIR)/build
ifeq (MSC,$(WIN32))
INCLUDES = -I "c:/Programme/DevStudio/VC/include" \
-I $(JAVAINCLUDE) -I $(JAVANATINC)
LIB = "c:/Programme/DevStudio/VC/lib"
CC = cl
OBJ_EXT := obj
LIB_PRE :=
LIB_EXT := dll
CFLAGS=-DWIN32=$(WIN32) -D__IBMC__
else
INCLUDES = -I $(JAVAINCLUDE) -I $(JAVANATINC)
LIBPATH = -L/usr/lib/termcap
JavaReadline_LIBS = -lreadline -ltermcap -lhistory
JavaEditline_LIBS = -ledit -ltermcap
ifeq (cygwin,$(WIN32))
JavaGetline_LIBS = -lcygwin
endif
CC = gcc
OBJ_EXT := o
LIB_PRE := lib
LIB_EXT := so
CFLAGS=-fPIC -DPOSIX
endif
OBJECTS := org_gnu_readline_Readline.$(OBJ_EXT)
ifeq ($(TG),JavaGetline)
OBJECTS += getline.$(OBJ_EXT)
endif
all: $(T_LIBS)
lib: $(ROOTDIR)/$(LIB_PRE)$(TG).$(LIB_EXT)
JavaReadline:
make TG=$@ lib
JavaEditline:
make TG=$@ lib
JavaGetline:
make TG=$@ lib
$(ROOTDIR)/$(LIB_PRE)$(TG).$(LIB_EXT): $(OBJECTS)
ifeq (MSC,$(WIN32))
$(CC) $(INCLUDES) -LD $(OBJECTS) -Fe$@
else
ifeq (CYGWIN,$(WIN32))
$(CC) -s -W1,--base-file,$(ROOTDIR)/lib$(TG).base -o $@ \
$(OBJECTS) -W1,-e,_readline_init@12
dlltool --base-file $(ROOTDIR)/lib$(TG).base \
--def $(ROOTDIR)/lib$(TG).def \
--output-exp $(ROOTDIR)/lib$(TG).exp \
--dllname $(ROOTDIR)/lib$(TG).dll
$(CC) -s -W1,--base-file $(ROOTDIR)/lib$(TG).base,$(ROOTDIR)/lib$(TG).exp \
-o $@ $(OBJECTS) -W1,-e,_readline_init@12
dlltool --base-file $(ROOTDIR)/lib$(TG).base \
--def $(ROOTDIR)/lib$(TG).def \
--output-exp $(ROOTDIR)/lib$(TG).exp \
--dllname $(ROOTDIR)/lib$(TG).dll
$(CC) -W1,$(ROOTDIR)/lib$(TG).exp -o $@ \
$(OBJECTS) -W1,-e,_readline_init@12
else
$(CC) -shared $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@
endif
endif
getline.$(OBJ_EXT): getline.c
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -D$(TG) -c getline.c
org_gnu_readline_Readline.$(OBJ_EXT): org_gnu_readline_Readline.h \
org_gnu_readline_Readline.c
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -D$(TG) \
-c org_gnu_readline_Readline.c
org_gnu_readline_Readline.h: $(BUILDDIR)/org/gnu/readline/Readline.class
javah -classpath $(BUILDDIR) -jni org.gnu.readline.Readline
touch org_gnu_readline_Readline.h
clean:
-rm -f org_gnu_readline_Readline.h \
org_gnu_readline_Readline.$(OBJ_EXT) getline.$(OBJ_EXT)
libreadline-java-0.8.0.1+dfsg/src/native/org_gnu_readline_Readline.c 0000644 0001750 0001750 00000102573 07717130263 024035 0 ustar moon moon /**************************************************************************
* gnu_readline_Readline.c -- implementation of the Java wrapper
* of GNU readline.
*
* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
*
* This program is free software; you can redistribute it and or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program; see the file COPYING.LIB. If not, write to
* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307 USA
**************************************************************************/
/*
* This file implements the native method interface for class
* gnu.readline.Readline
*
* $Revision: 1.17 $
* $Author: bablokb $
*/
#ifdef WIN32
#include
#endif
#include "org_gnu_readline_Readline.h"
#ifdef JavaReadline
#include
#include
#endif
#ifdef JavaEditline
#include
#endif
#ifdef JavaGetline
#include "getline.h"
#endif
#include
#include
#include
#include
#ifndef WIN32
#include
#endif
/* -------------------------------------------------------------------------- */
/* Internal status variables of the backing implementation. The functions */
/* [sg]etVar\(String\|Int\)Impl() use these arrays. Since the functions use */
/* index-based access, it is important that the variables are in sync with */
/* the constants in Readline.java. */
/* Also, some of the variables are actually read-only. You should check the */
/* documentation/source before using setVar */
/* */
/* TODO: redirect all variables marked as const in globalStringInternals to */
/* static buffers, so that free() works in setVarStringImpl */
/* -------------------------------------------------------------------------- */
static int undefinedInternalInt = 0;
static char* undefinedInternalString = NULL;
static char undefinedInternalChar = '0';
#ifdef JavaReadline
static int* globalIntegerInternals[] = {
&rl_readline_version,
&rl_gnu_readline_p,
&rl_readline_state,
&rl_editing_mode,
&rl_insert_mode,
&rl_point,
&rl_end,
&rl_mark,
&rl_done,
&rl_pending_input,
&rl_dispatching,
&rl_explicit_arg,
&rl_numeric_arg,
&rl_erase_empty_line,
&rl_already_prompted,
&rl_num_chars_to_read,
&rl_catch_signals,
&rl_catch_sigwinch,
&rl_filename_completion_desired,
&rl_filename_quoting_desired,
&rl_attempted_completion_over,
&rl_completion_type,
&rl_completion_append_character,
&rl_completion_suppress_append,
&rl_completion_query_items,
&rl_completion_mark_symlink_dirs,
&rl_ignore_completion_duplicates,
&rl_inhibit_completion,
&history_base,
&history_length,
&history_max_entries,
&history_quotes_inhibit_expansion, /* index: 31 */
NULL
};
static char** globalStringInternals[] = {
/* const */ &rl_library_version,
/* const */ &rl_readline_name,
&rl_prompt,
&rl_line_buffer,
/* const */ &rl_terminal_name,
&rl_executing_macro,
/* const */ &rl_basic_word_break_characters,
/* const */ &rl_completer_word_break_characters,
/* const */ &rl_completer_quote_characters,
/* const */ &rl_basic_quote_characters,
/* const */ &rl_filename_quote_characters,
/* const */ &rl_special_prefixes,
&history_word_delimiters,
&history_no_expand_chars,
&history_search_delimiter_chars, /* index: 14 */
NULL
};
/* unused: needs [sg]etVarCharImpl */
static char* globalCharInternals[] = {
&history_expansion_char,
&history_subst_char,
&history_comment_char,
NULL
};
#endif
#ifdef JavaEditline
static int* globalIntegerInternals[] = {
&undefinedInternalInt, /* &rl_readline_version, */
&undefinedInternalInt, /* &rl_gnu_readline_p, */
&undefinedInternalInt, /* &rl_readline_state, */
&undefinedInternalInt, /* &rl_editing_mode, */
&undefinedInternalInt, /* &rl_insert_mode, */
&undefinedInternalInt, /* &rl_point, */
&undefinedInternalInt, /* &rl_end, */
&undefinedInternalInt, /* &rl_mark, */
&undefinedInternalInt, /* &rl_done, */
&undefinedInternalInt, /* &rl_pending_input, */
&undefinedInternalInt, /* &rl_dispatching, */
&undefinedInternalInt, /* &rl_explicit_arg, */
&undefinedInternalInt, /* &rl_numeric_arg, */
&undefinedInternalInt, /* &rl_erase_empty_line, */
&undefinedInternalInt, /* &rl_already_prompted, */
&undefinedInternalInt, /* &rl_num_chars_to_read, */
&undefinedInternalInt, /* &rl_catch_signals, */
&undefinedInternalInt, /* &rl_catch_sigwinch, */
&undefinedInternalInt, /* &rl_filename_completion_desired, */
&undefinedInternalInt, /* &rl_filename_quoting_desired, */
&undefinedInternalInt, /* &rl_attempted_completion_over, */
&undefinedInternalInt, /* &rl_completion_type, */
&undefinedInternalInt, /* &rl_completion_append_character, */
&undefinedInternalInt, /* &rl_completion_suppress_append, */
&undefinedInternalInt, /* &rl_completion_query_items, */
&undefinedInternalInt, /* &rl_completion_mark_symlink_dirs, */
&undefinedInternalInt, /* &rl_ignore_completion_duplicates, */
&undefinedInternalInt, /* &rl_inhibit_completion, */
&undefinedInternalInt, /* &history_base, */
&undefinedInternalInt, /* &history_length, */
&undefinedInternalInt, /* &history_max_entries, */
&undefinedInternalInt, /* &history_quotes_inhibit_expansion, */
NULL
};
static char** globalStringInternals[] = {
&undefinedInternalString, /* const &rl_library_version, */
&undefinedInternalString, /* const &rl_readline_name, */
&undefinedInternalString, /* &rl_prompt, */
&undefinedInternalString, /* &rl_line_buffer, */
&undefinedInternalString, /* const &rl_terminal_name, */
&undefinedInternalString, /* &rl_executing_macro, */
&undefinedInternalString, /* const &rl_basic_word_break_characters, */
&undefinedInternalString, /* const &rl_completer_word_break_characters, */
&undefinedInternalString, /* const &rl_completer_quote_characters, */
&undefinedInternalString, /* const &rl_basic_quote_characters, */
&undefinedInternalString, /* const &rl_filename_quote_characters, */
&undefinedInternalString, /* const &rl_special_prefixes, */
&undefinedInternalString, /* &history_word_delimiters, */
&undefinedInternalString, /* &history_no_expand_chars, */
&undefinedInternalString, /* &history_search_delimiter_chars */
};
/* unused: needs [sg]etVarCharImpl */
static char* globalCharInternals[] = {
&undefinedInternalChar, /* &history_expansion_char, */
&undefinedInternalChar, /* &history_subst_char, */
&undefinedInternalChar, /* &history_comment_char */
};
#endif
#ifdef JavaGetline
static int* globalIntegerInternals[] = {
&undefinedInternalInt, /* &rl_readline_version, */
&undefinedInternalInt, /* &rl_gnu_readline_p, */
&undefinedInternalInt, /* &rl_readline_state, */
&undefinedInternalInt, /* &rl_editing_mode, */
&undefinedInternalInt, /* &rl_insert_mode, */
&undefinedInternalInt, /* &rl_point, */
&undefinedInternalInt, /* &rl_end, */
&undefinedInternalInt, /* &rl_mark, */
&undefinedInternalInt, /* &rl_done, */
&undefinedInternalInt, /* &rl_pending_input, */
&undefinedInternalInt, /* &rl_dispatching, */
&undefinedInternalInt, /* &rl_explicit_arg, */
&undefinedInternalInt, /* &rl_numeric_arg, */
&undefinedInternalInt, /* &rl_erase_empty_line, */
&undefinedInternalInt, /* &rl_already_prompted, */
&undefinedInternalInt, /* &rl_num_chars_to_read, */
&undefinedInternalInt, /* &rl_catch_signals, */
&undefinedInternalInt, /* &rl_catch_sigwinch, */
&undefinedInternalInt, /* &rl_filename_completion_desired, */
&undefinedInternalInt, /* &rl_filename_quoting_desired, */
&undefinedInternalInt, /* &rl_attempted_completion_over, */
&undefinedInternalInt, /* &rl_completion_type, */
&undefinedInternalInt, /* &rl_completion_append_character, */
&undefinedInternalInt, /* &rl_completion_suppress_append, */
&undefinedInternalInt, /* &rl_completion_query_items, */
&undefinedInternalInt, /* &rl_completion_mark_symlink_dirs, */
&undefinedInternalInt, /* &rl_ignore_completion_duplicates, */
&undefinedInternalInt, /* &rl_inhibit_completion, */
&undefinedInternalInt, /* &history_base, */
&undefinedInternalInt, /* &history_length, */
&undefinedInternalInt, /* &history_max_entries, */
&undefinedInternalInt, /* &history_quotes_inhibit_expansion, */
NULL
};
static char** globalStringInternals[] = {
&undefinedInternalString, /* const &rl_library_version, */
&undefinedInternalString, /* const &rl_readline_name, */
&undefinedInternalString, /* &rl_prompt, */
&undefinedInternalString, /* &rl_line_buffer, */
&undefinedInternalString, /* const &rl_terminal_name, */
&undefinedInternalString, /* &rl_executing_macro, */
&undefinedInternalString, /* const &rl_basic_word_break_characters, */
&undefinedInternalString, /* const &rl_completer_word_break_characters, */
&undefinedInternalString, /* const &rl_completer_quote_characters, */
&undefinedInternalString, /* const &rl_basic_quote_characters, */
&undefinedInternalString, /* const &rl_filename_quote_characters, */
&undefinedInternalString, /* const &rl_special_prefixes, */
&undefinedInternalString, /* &history_word_delimiters, */
&undefinedInternalString, /* &history_no_expand_chars, */
&undefinedInternalString, /* &history_search_delimiter_chars */
};
/* unused: needs [sg]etVarCharImpl */
static char* globalCharInternals[] = {
&undefinedInternalChar, /* &history_expansion_char, */
&undefinedInternalChar, /* &history_subst_char, */
&undefinedInternalChar, /* &history_comment_char */
};
#endif
/* -------------------------------------------------------------------------- */
/* Global buffer. The buffer is allocated when needed and grows in steps of */
/* 1024. It is never freed, but this is not a problem since in realistic */
/* environments it should never be larger than a few KB. This strategy will */
/* prevent constant malloc/free-cycles and keeps the code clean. */
/* */
/* TODO: buffer is changed by utf82ucs and ucs2utf8, but this is not really */
/* transparent. Add some additional comments. */
/* Change the variable name buffer to globalBuffer. */
/* -------------------------------------------------------------------------- */
static char* buffer = NULL;
static size_t bufLength = 0;
static char* word_break_buffer = NULL;
static char* utf2ucs(const char *utf8);
static char* ucs2utf(const char *ucs);
static int allocBuffer(size_t n);
static jobject jniObject;
static jmethodID jniMethodId;
static jclass jniClass;
static JNIEnv* jniEnv;
/* -------------------------------------------------------------------------- */
/* Initialize readline and history. Set application name. */
/* -------------------------------------------------------------------------- */
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_initReadlineImpl
(JNIEnv *env, jclass theClass, jstring jappName) {
const char *appName;
jboolean is_copy;
appName = (*env)->GetStringUTFChars(env,jappName,&is_copy);
if (appName && strlen(appName))
rl_readline_name = strdup(appName);
else
rl_readline_name = strdup("JAVA");
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env, jappName, appName);
#ifdef JavaReadline
rl_catch_signals = 0; // don't install signal handlers in JNI code.
#endif
#ifndef JavaGetline
rl_initialize();
#endif
using_history();
}
/* -------------------------------------------------------------------------- */
/* Reset readline's internal states and terminal.
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_cleanupReadlineImpl
(JNIEnv *env, jclass theClass) {
#ifdef JavaReadline
rl_free_line_state();
rl_cleanup_after_signal();
#endif
}
#endif
/* -------------------------------------------------------------------------- */
/* Report, if we have a terminal
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT jboolean JNICALL Java_org_gnu_readline_Readline_hasTerminalImpl
(JNIEnv *env, jclass theClass) {
return (jboolean) (isatty( STDIN_FILENO ) ? JNI_TRUE : JNI_FALSE);
}
#endif
/* -------------------------------------------------------------------------- */
/* Add line to history */
/* -------------------------------------------------------------------------- */
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_addToHistoryImpl
(JNIEnv *env, jclass theClass, jstring jline) {
const char *line;
jboolean is_copy;
line = (*env)->GetStringUTFChars(env,jline,&is_copy);
if (!utf2ucs(line)) {
jclass newExcCls;
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env, jline, line);
newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return;
}
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env, jline, line);
add_history(buffer);
return;
}
/* -------------------------------------------------------------------------- */
/* Prompt for input. "Main" readline function. . */
/* -------------------------------------------------------------------------- */
JNIEXPORT jstring JNICALL Java_org_gnu_readline_Readline_readlineImpl
(JNIEnv *env, jclass theClass, jstring jprompt) {
const char *prompt;
char *input;
jboolean is_copy;
/* retrieve prompt argument and convert to ucs ---------------------------- */
prompt = (*env)->GetStringUTFChars(env,jprompt,&is_copy);
if (!utf2ucs(prompt)) {
jclass newExcCls;
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env, jprompt, prompt);
newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return NULL;
}
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env, jprompt, prompt);
/* use gnu-readline, convert string to utf8 ------------------------------- */
input = readline(buffer);
if (input == NULL) {
jclass newExcCls;
newExcCls = (*env)->FindClass(env,"java/io/EOFException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return NULL;
} else if (*input) {
ucs2utf(input);
return (*env)->NewStringUTF(env,buffer);
} else
return NULL;
}
/* -------------------------------------------------------------------------- */
/* Get current history buffer */
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_getHistoryImpl
(JNIEnv *env, jclass theClass, jobject jcoll) {
jclass cls;
jmethodID mid;
jstring jline;
#ifdef JavaReadline
HIST_ENTRY **hist;
#endif
#ifdef JavaEditline
HIST_ENTRY *histSingle;
int pos;
#endif
cls = (*env)->GetObjectClass(env,jcoll);
mid = (*env)->GetMethodID(env,cls,"add","(Ljava/lang/Object;)Z");
#ifdef JavaReadline
hist = history_list();
if (hist != NULL) {
while (*hist != NULL) {
jline = (*env)->NewStringUTF(env,(*hist)->line);
(*env)->CallBooleanMethod(env,jcoll,mid,jline);
hist++;
}
}
#endif
#ifdef JavaEditline
for (pos = 0; pos < history_length; pos++) {
histSingle = history_get(pos + 1);
if (histSingle) {
ucs2utf(histSingle->line);
jline = (*env)->NewStringUTF(env,buffer);
(*env)->CallBooleanMethod(env,jcoll,mid,jline);
}
}
#endif
}
#endif
/* -------------------------------------------------------------------------- */
/* Clear the current history buffer */
/* -------------------------------------------------------------------------- */
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_clearHistoryImpl
(JNIEnv *env, jclass theClass) {
clear_history();
}
/* -------------------------------------------------------------------------- */
/* Get nth entry from history file */
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT jstring JNICALL Java_org_gnu_readline_Readline_getHistoryLineImpl
(JNIEnv *env, jclass theClass, jint i) {
HIST_ENTRY *hist = NULL;
if ((hist = history_get ((int) (i + 1))) != NULL) {
ucs2utf(hist->line);
return (*env)->NewStringUTF(env,buffer);
}
return NULL;
}
#endif
/* -------------------------------------------------------------------------- */
/* Get the size of the history buffer. */
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT jint JNICALL Java_org_gnu_readline_Readline_getHistorySizeImpl
(JNIEnv *env, jclass theClass) {
return (jint) history_length;
}
#endif
/* -------------------------------------------------------------------------- */
/* Read keybindings from file. */
/* -------------------------------------------------------------------------- */
#ifdef JavaReadline
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_readInitFileImpl
(JNIEnv *env, jclass theClass, jstring jfilename) {
const char *filename;
jboolean is_copy;
/* retrieve filename argument and convert to ucs -------------------------- */
filename = (*env)->GetStringUTFChars(env,jfilename,&is_copy);
if (!utf2ucs(filename)) {
jclass newExcCls;
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jfilename,filename);
newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return;
}
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jfilename,filename);
/* pass to readline function ---------------------------------------------- */
if (rl_read_init_file(buffer)) {
jclass newExcCls;
newExcCls = (*env)->FindClass(env,"java/io/IOException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,strerror(errno));
return;
}
}
#endif
/* -------------------------------------------------------------------------- */
/* Read keybinding from string. */
/* -------------------------------------------------------------------------- */
#ifdef JavaReadline
JNIEXPORT jboolean JNICALL Java_org_gnu_readline_Readline_parseAndBindImpl
(JNIEnv *env, jclass theClass, jstring jline) {
const char *line;
jboolean is_copy;
/* retrieve line argument and convert to ucs -------------------------- */
line = (*env)->GetStringUTFChars(env,jline,&is_copy);
if (!utf2ucs(line)) {
jclass newExcCls;
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jline,line);
newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return (jboolean) JNI_FALSE;
}
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jline,line);
/* pass to readline function ---------------------------------------------- */
if (rl_parse_and_bind(buffer))
return (jboolean) JNI_FALSE;
else
return (jboolean) JNI_TRUE;
}
#endif
/* -------------------------------------------------------------------------- */
/* Read history file */
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_readHistoryFileImpl
(JNIEnv *env, jclass theClass, jstring jfilename) {
const char *filename;
jboolean is_copy;
/* retrieve filename argument and convert to ucs -------------------------- */
filename = (*env)->GetStringUTFChars(env,jfilename,&is_copy);
if (!utf2ucs(filename)) {
jclass newExcCls;
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jfilename,filename);
newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return;
}
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jfilename,filename);
/* pass to history function ----------------------------------------------- */
read_history(buffer);
}
#endif
/* -------------------------------------------------------------------------- */
/* Write history file */
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_writeHistoryFileImpl
(JNIEnv *env, jclass theClass, jstring jfilename) {
const char *filename;
jboolean is_copy;
/* retrieve filename argument and convert to ucs -------------------------- */
filename = (*env)->GetStringUTFChars(env,jfilename,&is_copy);
if (!utf2ucs(filename)) {
jclass newExcCls;
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jfilename,filename);
newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return;
}
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jfilename,filename);
/* pass to history function ----------------------------------------------- */
write_history(buffer);
}
#endif
/* -------------------------------------------------------------------------- */
/* Completer function, visible to the readline library */
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
const char *java_completer(char *text, int state) {
jstring jtext;
jstring completion;
const char *line;
jboolean is_copy;
jtext = (*jniEnv)->NewStringUTF(jniEnv,text);
if (jniMethodId == 0) {
return;
}
completion = (*jniEnv)->CallObjectMethod(jniEnv, jniObject,
jniMethodId, jtext, state);
if (!completion) {
return ((const char *)NULL);
}
line = (*jniEnv)->GetStringUTFChars(jniEnv,completion,&is_copy);
return line;
}
#endif
/* -------------------------------------------------------------------------- */
/* Install completer object */
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_setCompleterImpl
(JNIEnv *env, jclass class, jobject obj) {
/* completer_cls = (*env)->GetObjectClass(env, compl); */
/* completer_cls = (*env)->NewGlobalRef(env, completer_cls); */
/* completer = (*env)->GetMethodID(env, completer_cls, */
/* "completer", */
/* "(Ljava/lang/String;I)Ljava/lang/String;"); */
/* (*env)->CallVoidMethod(env, completer_cls, completer, "test", 1); */
if (obj != NULL) {
jniEnv = env;
jniObject = obj;
jniClass = (*jniEnv)->GetObjectClass(jniEnv, jniObject);
jniClass = (*env)->NewGlobalRef(env, jniClass);
jniObject = (*env)->NewGlobalRef(env, jniObject);
jniMethodId = (*jniEnv)->GetMethodID(jniEnv, jniClass, "completer",
"(Ljava/lang/String;I)Ljava/lang/String;");
if (jniMethodId == 0) {
rl_completion_entry_function = NULL;
return;
}
#ifdef JavaEditline
rl_completion_entry_function = (CPFunction *) java_completer;
#else
rl_completion_entry_function = (rl_compentry_func_t *) java_completer;
#endif
}
else {
rl_completion_entry_function = NULL;
}
}
#endif
/* -------------------------------------------------------------------------- */
/* Returns rl_line_buffer
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT jstring JNICALL
Java_org_gnu_readline_Readline_getLineBufferImpl
(JNIEnv * env, jclass class) {
jniEnv = env;
return (*jniEnv)->NewStringUTF(jniEnv, rl_line_buffer);
}
#endif
/* -------------------------------------------------------------------------- */
/* Returns rl_completer_word_break_characters */
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT jstring JNICALL
Java_org_gnu_readline_Readline_getWordBreakCharactersImpl
(JNIEnv * env, jclass class) {
jstring word_break_characters;
jniEnv = env;
if (rl_completer_word_break_characters == 0) {
word_break_characters =
(*jniEnv)->NewStringUTF(jniEnv, rl_basic_word_break_characters);
} else {
word_break_characters =
(*jniEnv)->NewStringUTF(jniEnv, rl_completer_word_break_characters);
}
return word_break_characters;
}
#endif
/* -------------------------------------------------------------------------- */
/* Sets rl_completer_word_break_characters */
/* You should not use this function, since rl_completer_word_break_characters */
/* is const char* !!! */
/* -------------------------------------------------------------------------- */
#ifndef JavaGetline
JNIEXPORT void JNICALL
Java_org_gnu_readline_Readline_setWordBreakCharactersImpl
(JNIEnv * env, jclass class, jstring jword_break_chars) {
const char * word_break_chars;
jboolean is_copy;
word_break_chars = (*env)->GetStringUTFChars(env,jword_break_chars,&is_copy);
if (!utf2ucs(word_break_chars)) {
jclass newExcCls;
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jword_break_chars,word_break_chars);
newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return;
}
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jword_break_chars,word_break_chars);
if (word_break_buffer)
free(word_break_buffer);
word_break_buffer = strdup(buffer);
if (!word_break_buffer) {
jclass newExcCls;
newExcCls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return;
}
rl_completer_word_break_characters = word_break_buffer;
}
#endif
/* -------------------------------------------------------------------------- */
/* Sets an internal integer variable */
/* -------------------------------------------------------------------------- */
JNIEXPORT jint JNICALL
Java_org_gnu_readline_Readline_setVarIntImpl(JNIEnv *env, jclass class,
jint jindex, jint jvalue) {
int oldValue;
oldValue = *(globalIntegerInternals[(int) jindex]);
*(globalIntegerInternals[(int) jindex]) = (int) jvalue;
return (jint) oldValue;
}
/* -------------------------------------------------------------------------- */
/* Queries an internal integer variable */
/* -------------------------------------------------------------------------- */
JNIEXPORT jint JNICALL
Java_org_gnu_readline_Readline_getVarIntImpl(JNIEnv *env, jclass class,
jint jindex) {
return (jint) *(globalIntegerInternals[(int) jindex]);
}
/* -------------------------------------------------------------------------- */
/* Sets an internal string variable */
/* -------------------------------------------------------------------------- */
JNIEXPORT jstring JNICALL
Java_org_gnu_readline_Readline_setVarStringImpl(JNIEnv *env, jclass class,
jint jindex, jstring jvalue) {
char *oldValue;
char **value;
const char *newValue;
jboolean is_copy;
/* save old value */
oldValue = strdup(*(globalStringInternals[(int) jindex]));
if (!oldValue) {
jclass newExcCls;
newExcCls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return;
}
/* read new value from argument */
newValue = (*env)->GetStringUTFChars(env,jvalue,&is_copy);
if (!utf2ucs(newValue)) {
jclass newExcCls;
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jvalue,newValue);
newExcCls = (*env)->FindClass(env,"java/io/UnsupportedEncodingException");
if (newExcCls != NULL)
(*env)->ThrowNew(env,newExcCls,"");
return;
}
if (is_copy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env,jvalue,newValue);
/* set new value */
value = globalStringInternals[(int) jindex];
// TODO: currently a memory-leak, but otherwise it crashes
// free(*value);
*value = strdup(buffer);
/* return old value */
ucs2utf(oldValue);
free(oldValue);
return (*env)->NewStringUTF(env,buffer);
}
/* -------------------------------------------------------------------------- */
/* Queries an internal string variable */
/* -------------------------------------------------------------------------- */
JNIEXPORT jstring JNICALL
Java_org_gnu_readline_Readline_getVarStringImpl(JNIEnv *env, jclass class,
jint jindex) {
char *value;
value = *(globalStringInternals[(int) jindex]);
if (value) {
ucs2utf(value);
return (*env)->NewStringUTF(env,buffer);
}
return NULL;
}
/* -------------------------------------------------------------------------- */
/* Convert utf8-string to ucs1-string . */
/* -------------------------------------------------------------------------- */
char* utf2ucs(const char *utf8) {
const char *pin;
char *pout, *ucs;
unsigned char current, next;
int i;
size_t n;
n = strlen(utf8);
if (2*n > bufLength) {
if (allocBuffer(2*n))
return NULL;
}
for (i=0,pin=utf8,pout=buffer; i= 0xE0) { /* we support only two-byte utf8 */
return NULL;
} else if ((current & 0x80) == 0) /* one-byte utf8 */
*pout = current;
else { /* two-byte utf8 */
next = *(++pin);
if (next >= 0xC0) { /* illegal coding */
return NULL;
}
*pout = ((current & 3) << 6) + /* first two bits of first byte */
(next & 63); /* last six bits of second byte */
}
}
if (i bufLength) {
if (allocBuffer(2*n))
return NULL;
}
for (i=0,pin=ucs,pout=buffer; i>6); /* first two bits */
pout++, i++; /* examine second byte */
if (i>=bufLength) { /* cannot convert last byte */
*(--pout) = '\0';
return buffer;
}
*pout = 0x80 + (current & 63); /* last six bits */
}
}
if (i= bufLength);
newSize = (newSize/1024 + 1) * 1024;
buffer = realloc(buffer,newSize);
if (buffer == NULL)
return 1;
bufLength = newSize;
return 0;
}
#ifdef WIN32
int WINAPI
readline_init(HANDLE h, DWORD reason, void *foo) {
return 1;
}
#endif
libreadline-java-0.8.0.1+dfsg/src/native/getline.h 0000644 0001750 0001750 00000002237 07606524213 020356 0 ustar moon moon #ifndef GETLINE_H
#define GETLINE_H
/* unix systems can #define POSIX to use termios, otherwise
* the bsd or sysv interface will be used
*/
/* readline compatibility stuff */
extern char* rl_readline_name; /* unused by getline */
#define add_history(buffer) gl_histadd(buffer)
#define readline(buffer) getline(buffer)
#define clear_history() hist_init()
#define using_history() hist_init()
#if __STDC__ > 0
#include
typedef size_t (*gl_strwidth_proc)(char *);
char *getline(char *); /* read a line of input */
void gl_setwidth(int); /* specify width of screen */
void gl_histadd(char *); /* adds entries to hist */
void gl_strwidth(gl_strwidth_proc); /* to bind gl_strlen */
void hist_init();
extern int (*gl_in_hook)(char *);
extern int (*gl_out_hook)(char *);
extern int (*gl_tab_hook)(char *, int, int *);
#else /* not __STDC__ */
char *getline();
void gl_setwidth();
void gl_histadd();
void gl_strwidth();
extern int (*gl_in_hook)();
extern int (*gl_out_hook)();
extern int (*gl_tab_hook)();
#endif /* __STDC__ */
#endif /* GETLINE_H */
libreadline-java-0.8.0.1+dfsg/src/Makefile 0000644 0001750 0001750 00000000450 07606524213 016723 0 ustar moon moon #
#
BUILD=../build
all : java native
java: always $(BUILD)
$(JAVAC) $(JC_FLAGS) -d $(BUILD) `find . -name "*.java"`
native: always
cd native ; $(MAKE) T_LIBS="$(T_LIBS)" JAVAINCLUDE="$(JAVAINCLUDE)" \
JAVANATINC="$(JAVANATINC)" all
$(BUILD):
mkdir $@
always:
libreadline-java-0.8.0.1+dfsg/src/org/ 0000755 0001750 0001750 00000000000 07606524213 016053 5 ustar moon moon libreadline-java-0.8.0.1+dfsg/src/org/gnu/ 0000755 0001750 0001750 00000000000 07606524213 016644 5 ustar moon moon libreadline-java-0.8.0.1+dfsg/src/org/gnu/readline/ 0000755 0001750 0001750 00000000000 07720733346 020435 5 ustar moon moon libreadline-java-0.8.0.1+dfsg/src/org/gnu/readline/Readline.java 0000644 0001750 0001750 00000130415 07717130232 023016 0 ustar moon moon /**************************************************************************
/* Readline.java -- Java wrapper of GNU readline
/*
/* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
/*
/* This program is free software; you can redistribute it and/or modify
/* it under the terms of the GNU Library General Public License as published
/* by the Free Software Foundation; either version 2 of the License or
/* (at your option) any later version.
/*
/* This program is distributed in the hope that it will be useful, but
/* WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* GNU Library General Public License for more details.
/*
/* You should have received a copy of the GNU Library General Public License
/* along with this program; see the file COPYING.LIB. If not, write to
/* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
/* Boston, MA 02111-1307 USA
/**************************************************************************/
package org.gnu.readline;
import java.io.*;
import java.util.*;
/**
This class implements basic functionality of the GNU-readline interface. It
uses native method calls if available, otherwise it defaults to normal
I/O using a BufferedReader.
A typical implementation could look like:
try {
Readline.load(ReadlineLibrary.GnuReadline);
}
catch (UnsatisfiedLinkError ignore_me) {
System.err.println("couldn't load readline lib. Using simple stdin.");
}
Readline.initReadline("myapp");
Runtime.getRuntime() // if your version supports
.addShutdownHook(new Thread() { // addShutdownHook (since 1.3)
public void run() {
Readline.cleanup();
}
});
while (true) {
try {
line = Readline.readline("myprompt> ");
if (line == null)
System.out.println("no input");
else
processLine();
}
catch (EOFException e) {
break;
}
catch (Exception e) {
doSomething();
}
}
Readline.cleanup(); // see note above about addShutdownHook
@version $Revision: 1.29 $
@author $Author: bablokb $
*/
public class Readline {
/**
Constant to access rl_library_version using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_LIBRARY_VERSION =
new ReadlineConstString(0, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_readline_name using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_READLINE_NAME =
new ReadlineConstString(1, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_prompt using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_PROMPT =
new ReadlineConstString(2, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_line_buffer using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_LINE_BUFFER =
new ReadlineConstString(3, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_terminal_name using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_TERMINAL_NAME =
new ReadlineConstString(4, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_executing_macro using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_EXECUTING_MACRO =
new ReadlineConstString(5, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_basic_word_break_characters using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_BASIC_WORD_BREAK_CHARACTERS =
new ReadlineConstString(6, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_completer_word_break_characters using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_COMPLETER_WORD_BREAK_CHARACTERS =
new ReadlineConstString(7, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_completer_quote_characters using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_COMPLETER_QUOTE_CHARACTERS =
new ReadlineConstString(8, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_basic_quote_characters using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_BASIC_QUOTE_CHARACTERS =
new ReadlineConstString(9, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_filename_quote_characters using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_FILENAME_QUOTE_CHARACTERS =
new ReadlineConstString(10, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_special_prefixes using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString RL_SPECIAL_PREFIXES =
new ReadlineConstString(11, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access history_word_delimiters using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString HISTORY_WORD_DELIMITERS =
new ReadlineConstString(12, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access history_no_expand_chars using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString HISTORY_NO_EXPAND_CHARS =
new ReadlineConstString(13, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access history_search_delimiter_chars using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstString HISTORY_SEARCH_DELIMITERS =
new ReadlineConstString(14, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_readline_version using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_READLINE_VERSION =
new ReadlineConstInt(0, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_gnu_readline_p using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_GNU_READLINE_P =
new ReadlineConstInt(1, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_readline_state using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_READLINE_STATE =
new ReadlineConstInt(2, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_editing_mode using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_EDITING_MODE =
new ReadlineConstInt(3, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_insert_mode using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_INSERT_MODE =
new ReadlineConstInt(4, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_point using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_POINT =
new ReadlineConstInt(5, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_end using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_END =
new ReadlineConstInt(6, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_mark using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_MARK =
new ReadlineConstInt(7, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_done using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_DONE =
new ReadlineConstInt(8, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_pending_input using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_PENDING_INPUT =
new ReadlineConstInt(9, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_dispatching using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_DISPATCHING =
new ReadlineConstInt(10, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_explicit_arg using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_EXPLICIT_ARG =
new ReadlineConstInt(11, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_numeric_arg using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_NUMERIC_ARG =
new ReadlineConstInt(12, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_erase_empty_line using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_ERASE_EMPTY_LINE =
new ReadlineConstInt(13, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_already_prompted using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_ALREADY_PROMPTED =
new ReadlineConstInt(14, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_num_chars_to_read using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_NUM_CHARS_TO_READ =
new ReadlineConstInt(15, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_catch_signals using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_CATCH_SIGNALS =
new ReadlineConstInt(16, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_catch_sigwinch using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_CATCH_SIGWINCH =
new ReadlineConstInt(17, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_filename_completion_desired using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_FILENAME_COMPLETION_DESIRED =
new ReadlineConstInt(18, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_filename_quoting_desired using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_FILENAME_QUOTING_DESIRED =
new ReadlineConstInt(19, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_attempted_completion_over using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_ATTEMPTED_COMPLETION_OVER =
new ReadlineConstInt(20, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_completion_type using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_COMPLETION_TYPE =
new ReadlineConstInt(21, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_completion_append_character using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_COMPLETION_APPEND_CHARACTER =
new ReadlineConstInt(22, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_completion_suppress_append using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_COMPLETION_SUPPRESS_APPEND =
new ReadlineConstInt(23, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_completion_query_items using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_COMPLETION_QUERY_ITEMS =
new ReadlineConstInt(24, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_completion_mark_symlink_dirs using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_COMPLETION_MARK_SYMLINK_DIRS =
new ReadlineConstInt(25, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_ignore_completion_duplicates using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_IGNORE_COMPLETION_DUPLICATES =
new ReadlineConstInt(26, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access rl_inhibit_completion using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt RL_INHIBIT_COMPLETION =
new ReadlineConstInt(27, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access history_base using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt HISTORY_BASE =
new ReadlineConstInt(28, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access history_length using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt HISTORY_LENGTH =
new ReadlineConstInt(29, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access history_max_entries using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt HISTORY_MAX_ENTRIES =
new ReadlineConstInt(30, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/**
Constant to access history_quotes_inhibit_expansion using
getVar()
or setVar()
.
Supporting implementations:
*/
public final static ReadlineConstInt HISTORY_QUOTES_EXPANSION =
new ReadlineConstInt(31, new ReadlineLibrary[]
{ReadlineLibrary.GnuReadline});
/* ----------------------------------------------------------------------- */
/**
The currently defined ReadlineCompleter.
*/
private static ReadlineCompleter iCompleter = null;
/**
The currently implementing backing library.
*/
private static ReadlineLibrary iLib = ReadlineLibrary.PureJava;
/**
The BufferedReader for the fallback solution.
*/
private static BufferedReader iReader = null;
/**
The current encoding of the BufferedReader. The default is the
value of the property readline.encoding. If this
property is unset, the default is null, so the BufferedReader
will use the default encoding.
*/
private static String iEncoding =
System.getProperty("readline.encoding", null);
/**
Configuration flag: throw an UnsupportedOperationException, if true.
This value defaults to false.
*/
private static boolean iThrowException = false;
/////////////////////////////////////////////////////////////////////////////
/**
Load an implementing backing library. This method might throw an
UnsatisfiedLinkError in case the native libary is not found in the
library path. If you want to have a portable program, just catch and
ignore that error. JavaReadline will then just use the pure Java fallback
solution.
@param lib An object (constant) of type ReadlineLibrary
@throws UnsatisfiedLinkError if the shared library could not be
found. Add it to your LD_LIBRARY_PATH.
@see org.gnu.readline.ReadlineLibrary
*/
public static final void load(ReadlineLibrary lib) throws UnsatisfiedLinkError {
if (lib == iLib) // ok, since objects are immutable
return;
if (lib == ReadlineLibrary.PureJava) {
iLib = lib;
return;
}
System.loadLibrary(lib.getName()); // might throw UnsatisfiedLinkError
iLib = lib;
}
/////////////////////////////////////////////////////////////////////////////
/**
Initialize the GNU-Readline library. This will also set the
application name, which can be used in the initialization files of
Readline (usually /etc/inputrc and ~/.inputrc) to define application
specific keys. See the file ReadlineTest.java int the test subdir of
the distribution for an example.
Supporting implementations:
- GNU-Readline
- Editline
- Getline
@param applicationName Name of application in initialization file
*/
public static void initReadline(String applicationName) {
if (iLib == ReadlineLibrary.GnuReadline ||
iLib == ReadlineLibrary.Editline ||
iLib == ReadlineLibrary.Getline)
initReadlineImpl(applicationName);
}
/////////////////////////////////////////////////////////////////////////////
/**
Display a prompt on standard output and read a string from standard
input. This method returns 'null', if there has been an empty input
(user pressed just [RETURN]) and throws an EOFException on end-of-file
(C-d). This versino of readline() automatically adds the line
to the in-memory history; use the other version of readline()
if you want explicit control over that feature.
Supporting implementations:
- GNU-Readline
- Editline
- Getline
- PureJava
@param prompt Prompt to display
@return The string the user entered or 'null' if there was no input.
@throws EOFException on end-of-file, i.e. CTRL-d input.
@see #readline(String,boolean)
@see #addHistory()
*/
public static String readline(String prompt) throws EOFException,
IOException, UnsupportedEncodingException {
return readline(prompt,true);
}
/**
Display a prompt on standard output and read a string from
standard input. This method returns 'null', if there has
been an empty input (user pressed just [RETURN]) and throws
an EOFException on end-of-file (C-d).
@param prompt Prompt to display
@param addToHist true to add the line to the history
automatically; false to refrain from
adding the line to the history. (You can manually
add the line to the history by calling
addHistory().)
@return The string the user entered or 'null' if there was no input.
@throws EOFException on end-of-file, i.e. CTRL-d input.
@see #readline(String)
@see #addHistory()
*/
public static String readline(String prompt, boolean addToHist)
throws EOFException, IOException, UnsupportedEncodingException {
if (iLib != ReadlineLibrary.PureJava) {
String line = readlineImpl(prompt);
if ((line != null) && (addToHist))
addToHistory(line);
return line;
} else {
System.out.print(prompt);
if (iReader == null) {
if (iEncoding == null)
iReader = new BufferedReader(new InputStreamReader(System.in));
else
iReader = new BufferedReader(
new InputStreamReader(System.in, iEncoding));
}
String line = iReader.readLine();
if (line == null)
throw new EOFException("EOF");
if (line.length() == 0)
line = null;
return line;
}
}
/////////////////////////////////////////////////////////////////////////////
/**
Add a line to the in-memory history.
Supporting implementations:
- GNU-Readline
- Editline
- Getline
@param line The line to add to the history
@throws UnsupportOperationException if underlying library doesn't support
a history
*/
public static void addToHistory(String line) {
if (iLib == ReadlineLibrary.GnuReadline ||
iLib == ReadlineLibrary.Editline ||
iLib == ReadlineLibrary.Getline)
addToHistoryImpl(line);
else if (iThrowException)
throw new UnsupportedOperationException();
}
/////////////////////////////////////////////////////////////////////////////
/**
Get the history buffer in a supplied Collection.
Supporting implementations:
@param collection where to store the history
@throws UnsupportOperationException if underlying library doesn't support
a history
*/
public static void getHistory(Collection collection) {
if (iLib == ReadlineLibrary.GnuReadline ||
iLib == ReadlineLibrary.Editline)
getHistoryImpl(collection);
else if (iThrowException)
throw new UnsupportedOperationException();
}
/////////////////////////////////////////////////////////////////////////////
/**
Get the size, in elements (lines), of the history buffer.
Supporting implementations:
@return the number of lines in the history buffer
*/
public static int getHistorySize() {
int result = 0;
if (iLib == ReadlineLibrary.GnuReadline ||
iLib == ReadlineLibrary.Editline)
result = getHistorySizeImpl();
else if (iThrowException)
throw new UnsupportedOperationException();
return result;
}
/////////////////////////////////////////////////////////////////////////////
/**
Clear the history buffer.
Supporting implementations:
*/
public static void clearHistory() {
if (iLib == ReadlineLibrary.GnuReadline ||
iLib == ReadlineLibrary.Editline)
clearHistoryImpl();
else if (iThrowException)
throw new UnsupportedOperationException();
}
/////////////////////////////////////////////////////////////////////////////
/**
Get the specified entry from the history buffer. History buffer entries
are numbered from 0 through (getHistorySize() - 1), with the
oldest entry at index 0.
Supporting implementations:
@param i the index of the entry to return
@return the line at the specified index in the history buffer
@throws ArrayIndexOutOfBoundsException index out of range
*/
public static String getHistoryLine(int i) {
String s = null;
if (iLib == ReadlineLibrary.GnuReadline ||
iLib == ReadlineLibrary.Editline) {
if ((i < 0) || i >= getHistorySize())
throw new ArrayIndexOutOfBoundsException(i);
s = getHistoryLineImpl(i);
}
else if (iThrowException)
throw new UnsupportedOperationException();
return s;
}
/////////////////////////////////////////////////////////////////////////////
/**
Read keybindings and variable assignments from a file. This method is a
wrapper to rl_read_init_file(char *filename). Throws IOException if
something goes wrong.
Supporting implementations:
@param filename Name of file to read bindings from
@return void
*/
public static void readInitFile(String filename) throws IOException {
if (iLib == ReadlineLibrary.GnuReadline)
readInitFileImpl(filename);
else if (iThrowException)
throw new UnsupportedOperationException();
}
/////////////////////////////////////////////////////////////////////////////
/**
Parse argument string as if it had been read from `inputrc' file
and perform key bindings and variable assignments found.
Supporting implementations:
@param line Simulated line from inputrc file
@return boolean False in case of error
*/
public static boolean parseAndBind(String line) {
if (iLib == ReadlineLibrary.GnuReadline)
return parseAndBindImpl(line);
else if (iThrowException)
throw new UnsupportedOperationException();
else
return true;
}
/////////////////////////////////////////////////////////////////////////////
/**
Reads a history file into memory
Supporting implementations:
@param filename Name of history file to read
*/
public static void readHistoryFile(String filename)
throws EOFException, UnsupportedEncodingException {
if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
readHistoryFileImpl(filename);
else if (iThrowException)
throw new UnsupportedOperationException();
}
/////////////////////////////////////////////////////////////////////////////
/**
Writes a history file to disc
Supporting implementations:
@param filename Name of history file to write
*/
public static void writeHistoryFile(String filename)
throws EOFException, UnsupportedEncodingException {
if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
writeHistoryFileImpl(filename);
else if (iThrowException)
throw new UnsupportedOperationException();
}
/////////////////////////////////////////////////////////////////////////////
/**
Set your completer implementation. Setting this to null
will result in the default behaviour of readline which is filename
completion.
Supporting implementations:
@param rlc An object implementing the ReadlineCompleter interface
*/
public static void setCompleter(ReadlineCompleter rlc) {
iCompleter = rlc;
if (iLib == ReadlineLibrary.GnuReadline ||
iLib == ReadlineLibrary.Editline) {
setCompleterImpl(iCompleter);
} else if (iThrowException)
throw new UnsupportedOperationException();
}
/////////////////////////////////////////////////////////////////////////////
/**
Query current completer function.
@return Current ReadlineCompleter object
*/
public static ReadlineCompleter getCompleter() {
return iCompleter;
}
/////////////////////////////////////////////////////////////////////////////
/**
Reset the readline library and with it, the terminal.
Supporting implementations:
*/
public static void cleanup() {
if (iLib == ReadlineLibrary.GnuReadline ||
iLib == ReadlineLibrary.Editline) {
cleanupReadlineImpl();
}
}
/////////////////////////////////////////////////////////////////////////////
/**
Return if we have a terminal. This requires, that any of the native
libraries have been loaded yet
(so call Readline.{@link #load(ReadlineLibrary)}())
first, otherwise this will always return true.
Supporting implementations:
*/
public static boolean hasTerminal() {
if (iLib == ReadlineLibrary.GnuReadline ||
iLib == ReadlineLibrary.Editline) {
return hasTerminalImpl();
}
return true;
}
/////////////////////////////////////////////////////////////////////////////
/**
Set word break characters.
Supporting implementations:
@param wordBreakCharacters A string of word break characters
*/
public static void
setWordBreakCharacters(String wordBreakCharacters)
throws UnsupportedEncodingException {
if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
setWordBreakCharactersImpl(wordBreakCharacters);
else if (iThrowException)
throw new UnsupportedOperationException();
}
/////////////////////////////////////////////////////////////////////////////
/**
Query word break characters.
Supporting implementations:
*/
public static String getWordBreakCharacters() {
if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
return getWordBreakCharactersImpl();
else if (iThrowException)
throw new UnsupportedOperationException();
else
return null;
}
/////////////////////////////////////////////////////////////////////////////
/**
Query the current line buffer. This returns the current content of
the internal line buffer. You might need this in a
{@link ReadlineCompleter} implementation to access the full text
given so far.
Supporting implementations:
*/
public static String getLineBuffer() {
if (iLib == ReadlineLibrary.GnuReadline || iLib == ReadlineLibrary.Editline)
return getLineBufferImpl();
else if (iThrowException)
throw new UnsupportedOperationException();
else
return null;
}
/////////////////////////////////////////////////////////////////////////////
/**
Configure behavior in case an unsupported method is called. If argument
is true, unsupported methods throw an UnsupportedOperationException.
@param flag configuration flag
*/
public static void setThrowExceptionOnUnsupportedMethod(boolean flag) {
iThrowException = flag;
}
/////////////////////////////////////////////////////////////////////////////
/**
Query behavior in case an unsupported method is called.
@return configuration flag
*/
public static boolean getThrowExceptionOnUnsupportedMethod() {
return iThrowException;
}
/////////////////////////////////////////////////////////////////////////////
/**
Set current encoding of fallback BufferedReader.
@param encoding encoding to use
*/
public static void setEncoding(String encoding) {
iEncoding = encoding;
}
/////////////////////////////////////////////////////////////////////////////
/**
Query current encoding of fallback BufferedReader.
@return current encoding
*/
public static String getEncoding() {
return iEncoding;
}
/////////////////////////////////////////////////////////////////////////////
/**
Set integer readline-variable.
@param c symbolic constant of readline-variable
@param value new value of readline-variable
@return old value of readline-variable
*/
public static int setVar(ReadlineConstInt c, int value) {
if (c.isSupported(iLib))
return setVarIntImpl(c.getNumber(),value);
else if (iThrowException)
throw new UnsupportedOperationException();
else
return Integer.MIN_VALUE;
}
/////////////////////////////////////////////////////////////////////////////
/**
Query integer readline-variable.
@param c symbolic constant of readline-variable
@return value of variable
*/
public static int getVar(ReadlineConstInt c) {
if (c.isSupported(iLib))
return getVarIntImpl(c.getNumber());
else if (iThrowException)
throw new UnsupportedOperationException();
else
return Integer.MIN_VALUE;
}
/////////////////////////////////////////////////////////////////////////////
/**
Set string readline-variable.
@param c symbolic constant of readline-variable
@param value new value of readline-variable
@return old value of readline-variable
*/
public static String setVar(ReadlineConstString c, String value) throws
UnsupportedEncodingException {
if (c.isSupported(iLib))
return setVarStringImpl(c.getNumber(),value);
else if (iThrowException)
throw new UnsupportedOperationException();
else
return null;
}
/////////////////////////////////////////////////////////////////////////////
/**
Query string readline-variable.
@param c symbolic constant of readline-variable
@return value of variable
*/
public static String getVar(ReadlineConstString c) throws
UnsupportedEncodingException {
if (c.isSupported(iLib))
return getVarStringImpl(c.getNumber());
else if (iThrowException)
throw new UnsupportedOperationException();
else
return null;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of initReadline()
@see org.gnu.readline.Readline#initReadline(String applicationName)
*/
private native static void initReadlineImpl(String applicationName);
/////////////////////////////////////////////////////////////////////////////
/**
cleanup readline; reset terminal.
*/
private native static void cleanupReadlineImpl();
/////////////////////////////////////////////////////////////////////////////
/**
native implementation of isatty();
*/
private native static boolean hasTerminalImpl();
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of readline()
@see org.gnu.readline.Readline#readline(String prompt)
*/
private native static String readlineImpl(String prompt)
throws EOFException, UnsupportedEncodingException;
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of addToHistory
@see org.gnu.readline.Readline#addToHistory(String line)
*/
private native static void addToHistoryImpl(String line);
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of getHistory
@see org.gnu.readline.Readline#getHistory()
*/
private native static void getHistoryImpl(Collection collection);
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of getHistorySize
@see org.gnu.readline.Readline#getHistorySize()
*/
private native static int getHistorySizeImpl();
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of getHistoryLine
@see org.gnu.readline.Readline#getHistoryLine()
*/
private native static String getHistoryLineImpl(int i);
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of clearHistory
@see org.gnu.readline.Readline#clearHistory()
*/
private native static void clearHistoryImpl();
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of readInitFile(String filename)
@see org.gnu.readline.Readline#readInitFile(String filename)
*/
private native static void readInitFileImpl(String filename)
throws IOException;
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of getLineBuffer()
@see org.gnu.readline.Readline#getLineBuffer()
*/
private native static String getLineBufferImpl();
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of parseAndBind(String line)
@see org.gnu.readline.Readline#parseAndBind(String line)
*/
private native static boolean parseAndBindImpl(String line);
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of readHistoryFile(String filename)
@see org.gnu.readline.Readline#readHistoryFile(String filename)
*/
private native static void readHistoryFileImpl(String filename)
throws EOFException, UnsupportedEncodingException;
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of writeHistoryFile(String filename)
@see org.gnu.readline.Readline#writeHistoryFile(String filename)
*/
private native static void writeHistoryFileImpl(String filename)
throws EOFException, UnsupportedEncodingException;
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of setCompleter(ReadlineCompleter rlc)
@see org.gnu.readline.Readline#setCompleter(ReadlineCompleter rlc)
*/
private native static void setCompleterImpl(ReadlineCompleter rlc);
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of getWordBreakCharacters()
@see org.gnu.readline.Readline#getWordBreakCharacters()
*/
private native static String getWordBreakCharactersImpl();
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of setWordBreakCharacters()
@see
org.gnu.readline.Readline#setWordBreakCharacters(String wordBreakCharacters)
*/
private native static void
setWordBreakCharactersImpl(String wordBreakCharacters)
throws UnsupportedEncodingException;
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of setVar(ReadlineConstInt,int)
@see
org.gnu.readline.Readline#setVar(ReadlineConstInt,int)
*/
private native static int setVarIntImpl(int number,int value);
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of getVar(ReadlineConstInt)
@see
org.gnu.readline.Readline#getVar(ReadlineConstInt)
*/
private native static int getVarIntImpl(int number);
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of setVar(ReadlineConstString,String)
@see
org.gnu.readline.Readline#setVar(ReadlineConstString,String)
*/
private native static String setVarStringImpl(int number,String value)
throws UnsupportedEncodingException;
/////////////////////////////////////////////////////////////////////////////
/**
Native implementation of getVar(ReadlineConstString)
@see
org.gnu.readline.Readline#getVar(ReadlineConstString)
*/
private native static String getVarStringImpl(int number)
throws UnsupportedEncodingException;
}
libreadline-java-0.8.0.1+dfsg/src/org/gnu/readline/ReadlineCompleter.java 0000644 0001750 0001750 00000007476 07606524213 024706 0 ustar moon moon // File: ReadlineCompleter.java
// Created: 2001-02-22 15:50:22, erik
// By:
// Time-stamp: <2001-02-23 11:19:11, erik>
//
// $Id: ReadlineCompleter.java,v 1.1 2001/12/27 11:08:05 Bablokb Exp $
//
// Description:
package org.gnu.readline;
/**
* Callback interface that implements completion. You've to implement this
* interface in order to provide completion in your application. The default
* completion mode of the Readline library would otherwise be simple
* filename completion.
*/
public interface ReadlineCompleter {
/**
* A generator function for filename completion in the general case.
* Note that completion in Bash is a little different because of all
* the pathnames that must be followed when looking up completions
* for a command. The Bash source is a useful reference for writing
* custom completion functions.
*
* The completer method is called with the current text to be
* expanded (that is: the string of characters after the last
* {@link Readline#getWordBreakCharacters() word break character}) and
* an integer. The integer is zero to indicate, that the user just requested
* completion (usually by pressing the TAB-key). The completeter method now
* can return one possible choice or null to indicate that there is no
* choice. If the completer returned a non-null value it is called back by
* the readline library with increasing state
variable until
* it returns null.
*
*
Depending on the state and the return value, the readline library
* reacts differently.
*
* - if the completer returns
null
for state=0, then
* the readline library will beep to indicate that there is no
* known completion.
* - if the completer returns a value for state=0 and
*
null
for state=1, then there was exactly one
* possible completion, that is immediately expanded on the command line.
* - if the completer returns choices for states >= 1, then these
* choices are displayed to the user to choose from.
*
*
* Example
* Consider you have a sorted set (like a TreeSet) of commands:
*
* SortedSet commandSet; // SortedSet<String>
* ...
* commandSet = new TreeSet();
* commandSet.add("copy");
* commandSet.add("copyme");
* commandSet.add("load");
* commandSet.add("list");
* ...
*
* now, you could write a completion method that provides completion for these
* commands:
*
* private Iterator possibleValues; // iterator for subsequent calls.
*
* public String completer(String text, int state) {
* if (state == 0) {
* // first call to completer(): initialize our choices-iterator
* possibleValues = commandSet.tailSet(text).iterator();
* }
* if (possibleValues.hasNext()) {
* String nextKey = (String) possibleValues.next();
* if (nextKey.startsWith(text))
* return nextKey;
* }
* return null; // we reached the last choice.
* }
*
*
* @param text start of completion text. This is the text since the last
* word break character.
* @param state 0 or positive int. This state is zero on the first call
* for a completion request and increments for each subsequent
* call until the end of choices is reached.
*
* @return String with a completion choice or null
, if there
* are no more choices.
*
* @see Readline#getWordBreakCharacters()
* @see test.TestCompleter
*/
public String completer(String text, int state);
}
/*
* Local variables:
* c-basic-offset: 2
* End:
*/
libreadline-java-0.8.0.1+dfsg/src/org/gnu/readline/ReadlineLibrary.java 0000644 0001750 0001750 00000005273 07606524213 024351 0 ustar moon moon /**************************************************************************
/* ReadlineLibrary.java -- A typesafe enum class
/*
/* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
/*
/* This program is free software; you can redistribute it and/or modify
/* it under the terms of the GNU Library General Public License as published
/* by the Free Software Foundation; either version 2 of the License or
/* (at your option) any later version.
/*
/* This program is distributed in the hope that it will be useful, but
/* WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* GNU Library General Public License for more details.
/*
/* You should have received a copy of the GNU Library General Public License
/* along with this program; see the file COPYING.LIB. If not, write to
/* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
/* Boston, MA 02111-1307 USA
/**************************************************************************/
package org.gnu.readline;
/**
This class implements a typesafe enumeration of the backing libraries.
@version $Revision: 1.4 $
@author $Author: bablokb $
*/
public final class ReadlineLibrary {
/**
Constant for fallback, pure Java implementation.
*/
public static final ReadlineLibrary PureJava =
new ReadlineLibrary("PureJava");
/**
Constant for GNU-Readline implementation.
*/
public static final ReadlineLibrary GnuReadline =
new ReadlineLibrary("JavaReadline");
/**
Constant for Editline implementation.
*/
public static final ReadlineLibrary Editline =
new ReadlineLibrary("JavaEditline");
/**
Constant for Getline implementation.
*/
public static final ReadlineLibrary Getline =
new ReadlineLibrary("JavaGetline");
/**
The name of the backing native library.
*/
private String iName;
/**
Constructor. The constructor is private, so only the predefined
constants are available.
*/
private ReadlineLibrary(String name) {
iName = name;
}
/**
Query name of backing library.
@return Name of backing library, or "PureJava", in case fallback
implementation is used.
*/
public String getName() {
return iName;
}
/**
Return ReadlineLibrary-object with given name.
@return one of the predefined constants
*/
public static ReadlineLibrary byName(String name) {
if (name.equals("GnuReadline"))
return GnuReadline;
else if (name.equals("Editline"))
return Editline;
else if (name.equals("Getline"))
return Getline;
else if (name.equals("PureJava"))
return PureJava;
return null;
}
}
libreadline-java-0.8.0.1+dfsg/src/org/gnu/readline/ReadlineReader.java 0000644 0001750 0001750 00000007525 07606524213 024151 0 ustar moon moon package org.gnu.readline;
import java.io.File;
import java.io.Reader;
import java.io.IOException;
import java.io.EOFException;
import java.io.UnsupportedEncodingException;
/**
* A Reader
wrapper for the Readline classes. This seems
* to work fine in conjunction with such classes as BufferedReader,
* but it hasn't been tested well enough to see if this will work well
* in all cases.
*
* This was implemented to make it easier to supplant Readline's
* functionality [shrug] anywhere and everywhere, but specifically in
* BeanShell.
*
* @version $Revision: 1.2 $
* @author Shane Celis
**/
public class ReadlineReader extends Reader {
public static final String DEFAULT_PROMPT = "";
private StringBuffer iBuff;
private String iLineSeparator;
private String iPrompt;
private File iHistoryFile;
/**
* Constructs a ReadlineReader object with the given prompt.
**/
public ReadlineReader(String prompt,ReadlineLibrary lib) {
iBuff = new StringBuffer();
setPrompt(prompt);
Readline.load(lib);
Readline.initReadline("ReadlineReader");
iLineSeparator = System.getProperty("line.separator", "\n");
}
/**
* Constructs a ReadlineReader object with the default prompt.
**/
public ReadlineReader(ReadlineLibrary lib) {
this(DEFAULT_PROMPT,lib);
}
/**
* Constructs a ReadlineReader object with an associated history
* file.
**/
public ReadlineReader(File history,ReadlineLibrary lib) throws IOException {
this(DEFAULT_PROMPT,lib);
Readline.readHistoryFile(history.getAbsolutePath());
iHistoryFile = history; // only set this if we can read the file
}
/**
* Constructs a ReadlineReader object with an associated history
* file and prompt.
**/
public ReadlineReader(String prompt, File history,ReadlineLibrary lib)
throws IOException {
this(history,lib);
setPrompt(prompt);
}
/**
* Returns the current prompt.
**/
public String getPrompt() {
return iPrompt;
}
/**
* Sets the prompt to the given value.
**/
public void setPrompt(String prompt) {
iPrompt = prompt;
}
/**
* Reads what's given from readline()
into a buffer.
* When that buffer is emptied, readline()
is called
* again to replenish that buffer. This seems to work fine in
* conjunction with such classes as BufferedReader, but it hasn't
* been tested well enough to see if this will work well in all
* cases.
**/
public int read(char[] cbuf, int off, int len)
throws IOException {
try {
if (iBuff.length() == 0) {
String line = Readline.readline(iPrompt);
iBuff.append((line == null ? "" : line) + iLineSeparator);
}
if (len > iBuff.length())
len = iBuff.length();
if (len == 0)
return 0;
char[] sbuf = iBuff.substring(0, len).toCharArray();
System.arraycopy(sbuf, 0, cbuf, off, len);
iBuff.delete(0, len);
return len;
} catch (EOFException eof) {
throw eof;
} catch (UnsupportedEncodingException uee) {
throw uee;
}
}
/**
* Nullifies all buffers and writes history file if one was given
* at construction time.
**/
public void close()
throws IOException {
iBuff = null;
iPrompt = null;
if (iHistoryFile != null) {
Readline.writeHistoryFile(iHistoryFile.getAbsolutePath());
iHistoryFile = null;
}
}
public static void main(String[] args) throws Exception {
java.io.BufferedReader rd =
new java.io.BufferedReader(new
ReadlineReader("hmm ", new File("test"),ReadlineLibrary.GnuReadline));
String line;
try {
while ((line = rd.readLine()) != null) {
System.out.println("got: " + line);
}
} finally {
rd.close();
}
}
}
libreadline-java-0.8.0.1+dfsg/src/org/gnu/readline/ReadlineConstBase.java 0000644 0001750 0001750 00000004563 07707563010 024627 0 ustar moon moon /**************************************************************************
/* ReadlineConstBase.java -- The base class for constants for Readline
/* variables
/*
/* Java Wrapper Copyright (c) 1998-2003 by Bernhard Bablok (mail@bablokb.de)
/*
/* This program is free software; you can redistribute it and/or modify
/* it under the terms of the GNU Library General Public License as published
/* by the Free Software Foundation; either version 2 of the License or
/* (at your option) any later version.
/*
/* This program is distributed in the hope that it will be useful, but
/* WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* GNU Library General Public License for more details.
/*
/* You should have received a copy of the GNU Library General Public License
/* along with this program; see the file COPYING.LIB. If not, write to
/* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
/* Boston, MA 02111-1307 USA
/**************************************************************************/
package org.gnu.readline;
/**
This class is the base class for constants for Readline variables.
The constants are used to access internal variables of the
underlying implementation.
@version $Revision: 1.1 $
@author $Author: bablokb $
*/
class ReadlineConstBase {
/**
Numeric number of readline-variable. In the native implementation,
this number serves as an index into an array of variables. This
number can only be set once during initialization.
*/
private int iNumber;
/**
Supporting implementations (not every implementation supports all
variables).
*/
private ReadlineLibrary[] iSupport;
/**
Constructor. The constructor is protected, since the class should not
be used outside of the package.
*/
protected ReadlineConstBase(int number, ReadlineLibrary[] support) {
iNumber = number;
iSupport = support;
}
/**
Query number.
@return number of readline-variable.
*/
protected int getNumber() {
return iNumber;
}
/**
Check if this readline-variable is supported.
@return true if supported
*/
protected boolean isSupported(ReadlineLibrary lib) {
for (int i=0; i < iSupport.length; ++i) {
if (iSupport[i] == lib)
return true;
}
return false;
}
}
libreadline-java-0.8.0.1+dfsg/src/org/gnu/readline/ReadlineConstInt.java 0000644 0001750 0001750 00000003336 07707563010 024504 0 ustar moon moon /**************************************************************************
/* ReadlineConstInt.java -- The class for constants for integer Readline
/* variables
/*
/* Java Wrapper Copyright (c) 1998-2003 by Bernhard Bablok (mail@bablokb.de)
/*
/* This program is free software; you can redistribute it and/or modify
/* it under the terms of the GNU Library General Public License as published
/* by the Free Software Foundation; either version 2 of the License or
/* (at your option) any later version.
/*
/* This program is distributed in the hope that it will be useful, but
/* WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* GNU Library General Public License for more details.
/*
/* You should have received a copy of the GNU Library General Public License
/* along with this program; see the file COPYING.LIB. If not, write to
/* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
/* Boston, MA 02111-1307 USA
/**************************************************************************/
package org.gnu.readline;
/**
This class implements constants for integer Readline variables.
The constants are used to access internal variables of the
underlying implementation.
Note that the class does not add additional functionality, it
is used only for method-overloading.
@version $Revision: 1.1 $
@author $Author: bablokb $
*/
class ReadlineConstInt extends ReadlineConstBase {
/**
Constructor. The constructor is protected, since the class should not
be used outside of the package.
*/
protected ReadlineConstInt(int number, ReadlineLibrary[] support) {
super(number,support);
}
}
libreadline-java-0.8.0.1+dfsg/src/org/gnu/readline/ReadlineConstString.java 0000644 0001750 0001750 00000003344 07707563010 025217 0 ustar moon moon /**************************************************************************
/* ReadlineConstString.java -- The class for constants for string Readline
/* variables
/*
/* Java Wrapper Copyright (c) 1998-2003 by Bernhard Bablok (mail@bablokb.de)
/*
/* This program is free software; you can redistribute it and/or modify
/* it under the terms of the GNU Library General Public License as published
/* by the Free Software Foundation; either version 2 of the License or
/* (at your option) any later version.
/*
/* This program is distributed in the hope that it will be useful, but
/* WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* GNU Library General Public License for more details.
/*
/* You should have received a copy of the GNU Library General Public License
/* along with this program; see the file COPYING.LIB. If not, write to
/* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
/* Boston, MA 02111-1307 USA
/**************************************************************************/
package org.gnu.readline;
/**
This class implements constants for string Readline variables.
The constants are used to access internal variables of the
underlying implementation.
Note that the class does not add additional functionality, it
is used only for method-overloading.
@version $Revision: 1.1 $
@author $Author: bablokb $
*/
class ReadlineConstString extends ReadlineConstBase {
/**
Constructor. The constructor is protected, since the class should not
be used outside of the package.
*/
protected ReadlineConstString(int number, ReadlineLibrary[] support) {
super(number,support);
}
}
libreadline-java-0.8.0.1+dfsg/src/test/ 0000755 0001750 0001750 00000000000 07606524213 016243 5 ustar moon moon libreadline-java-0.8.0.1+dfsg/src/test/Makefile 0000644 0001750 0001750 00000002404 07606524213 017703 0 ustar moon moon #**************************************************************************
#* Makefile for libJavaReadline.so -- load library for JNI wrapper
#* of GNU readline
#*
#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
#*
#* This program is free software; you can redistribute it and/or modify
#* it under the terms of the GNU Library General Public License as published
#* by the Free Software Foundation; either version 2 of the License or
#* (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful, but
#* WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU Library General Public License for more details.
#*
#* You should have received a copy of the GNU Library General Public License
#* along with this program; see the file COPYING.LIB. If not, write to
#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
#* Boston, MA 02111-1307 USA
#***************************************************************************
#
# $Author: Bablokb $
# $Revision: 1.3 $
#
include $(SRCROOT)/mkrules.inc
$(PACKDIR)/ReadlineTest.class: $(PACKDIR)/TestCompleter.class libreadline-java-0.8.0.1+dfsg/src/test/ReadlineTest.java 0000644 0001750 0001750 00000010744 07717130301 021471 0 ustar moon moon /**************************************************************************
/* ReadlineTest.java -- Test program for the Java wrapper of GNU readline
/*
/* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
/*
/* This sample program is placed into the public domain and can be
/* used or modified without any restriction.
/*
/* This program is distributed in the hope that it will be useful, but
/* WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
/**************************************************************************/
package test;
import java.io.*;
import org.gnu.readline.*;
/**
* ReadlineTest.java
*
* This class shows the usage of the readline wrapper. It will read lines
* from standard input using the GNU-Readline library. You can use the
* standard line editing keys. You can also define application specific
* keys. Put this into your ~/.inputrc (or into whatever file $INPUTRC
* points to) and see what happens if you press function keys F1 to F3:
*
*$if ReadlineTest
*"\e[11~": "linux is great"
*"\e[12~": "jikes is cool"
*"\e[13~": "javac is slow"
*$endif
*
*
* If one argument is given to ReadlineTest, a private initialization file
* is read. If a second argument is given, the appropriate library is
* loaded.
*
* @author $Author: bablokb $
* @version $Revision: 1.19 $
*/
public class ReadlineTest {
public ReadlineTest() {
}
/**
Main entry point. The first argument can be a filename with an
application initialization file.
*/
public static void main(String[] args) {
String line;
// Readline.setThrowExceptionOnUnsupportedMethod(true);
if (args.length > 1)
Readline.load(ReadlineLibrary.byName(args[1]));
else
Readline.load(ReadlineLibrary.GnuReadline);
System.out.println("initializing Readline...");
Readline.initReadline("ReadLineTest"); // init, set app name, read inputrc
System.out.println("... done");
try {
if (args.length > 0)
Readline.readInitFile(args[0]); // read private inputrc
} catch (IOException e) { // this deletes any initialization
System.out.println(e.toString()); // from /etc/inputrc and ~/.inputrc
System.exit(0);
}
// read history file, if available
File history = new File(".rltest_history");
try {
if (history.exists())
Readline.readHistoryFile(history.getName());
} catch (Exception e) {
System.err.println("Error reading history file!");
}
// define some additional function keys
Readline.parseAndBind("\"\\e[18~\": \"Function key F7\"");
Readline.parseAndBind("\"\\e[19~\": \"Function key F8\"");
// Set word break characters
try {
String breakChars =
Readline.getVar(Readline.RL_COMPLETER_WORD_BREAK_CHARACTERS);
System.out.println("word-break-chars: " + breakChars);
breakChars =
Readline.setVar(Readline.RL_COMPLETER_WORD_BREAK_CHARACTERS,"abc");
System.out.println("word-break-chars: " + breakChars);
breakChars =
Readline.getVar(Readline.RL_COMPLETER_WORD_BREAK_CHARACTERS);
System.out.println("word-break-chars: " + breakChars);
Readline.setWordBreakCharacters(" \t;");
breakChars =
Readline.getVar(Readline.RL_COMPLETER_WORD_BREAK_CHARACTERS);
System.out.println("word-break-chars: " + breakChars);
} catch (UnsupportedEncodingException enc) {
System.err.println("Could not set word break characters");
System.exit(0);
}
// query version
try {
String version = Readline.getVar(Readline.RL_LIBRARY_VERSION);
System.out.println("Readline-Version: " + version);
} catch (UnsupportedEncodingException enc) {
System.err.println("Could not query libarary version");
System.exit(0);
}
// set test completer
Readline.setCompleter(new TestCompleter());
// main input loop
while (true) {
try {
line = Readline.readline("linux> ");
if (line == null)
System.out.println("no input");
else
System.out.println("line = >" + line + "<");
} catch (UnsupportedEncodingException enc) {
System.err.println("caught UnsupportedEncodingException");
break;
} catch (IOException eof) {
break;
}
}
try {
Readline.writeHistoryFile(history.getName());
} catch (Exception e) {
System.err.println("Error writing history file!");
}
System.out.println();
Readline.cleanup();
System.exit(0);
}
}
libreadline-java-0.8.0.1+dfsg/src/test/TestCompleter.java 0000644 0001750 0001750 00000002765 07606524213 021712 0 ustar moon moon /**************************************************************************
/* TestCompleter.java -- Sample custom completer
/*
/* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
/*
/* This sample program is placed into the public domain and can be
/* used or modified without any restriction.
/*
/* This program is distributed in the hope that it will be useful, but
/* WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
/**************************************************************************/
package test;
import org.gnu.readline.*;
/**
* This class is a sample custom completer. If you press the TAB-key at
* the readline prompt, you will see the two possible completions ("Linux"
* and "Tux"). Once you have entered a "L" or a "T", you will only see
* the respective single possible completion. In any other case, null is
* returned to signal that no (more) completions are available.
*
* @author $Author: Bablokb $
* @version $Revision: 1.1 $
*/
public class TestCompleter implements ReadlineCompleter {
/**
Default constructor.
*/
public TestCompleter () {
}
/**
Return possible completion. Implements org.gnu.readline.ReadlineCompleter.
*/
public String completer (String t, int s) {
if (s == 0) {
if (t.equals("") || t.equals("L"))
return "Linux";
if (t.equals("T"))
return "Tux";
} else if (s == 1 && t.equals(""))
return "Tux";
return null;
}
}
libreadline-java-0.8.0.1+dfsg/src/test/tinputrc 0000644 0001750 0001750 00000000154 07606524213 020036 0 ustar moon moon $if ReadlineTest
"\e[14~": "Function key F4"
"\e[15~": "Function key F5"
"\e[17~": "Function key F6"
$endif
libreadline-java-0.8.0.1+dfsg/etc/ 0000755 0001750 0001750 00000000000 07606524213 015250 5 ustar moon moon libreadline-java-0.8.0.1+dfsg/etc/libreadline-java.spec 0000644 0001750 0001750 00000001650 07606524213 021317 0 ustar moon moon %define version 0.8.0
Summary: java wrapper for the GNU-readline library
Copyright: GNU Lesser General Public License
Group: Development/Java
Name: libreadline-java
Prefix: /usr
Provides: java_readline
Packager: Henner Zeller
Release: 1
Source: %{name}-%{version}-src.tar.gz
URL: http://java-readline.sourceforge.net/
Version: %{version}
Buildroot: /tmp/javareadline-build
BuildRequires: readline-devel
%description
This is a Java-wrapper for the GNU-Readline using the
Java Native Interface (JNI). It allows to write console Java applications
that provide commandline editing functions like history and TAB-completion.
%prep
%setup -q
%build
%install
rm -fr $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT T_LIBS="JavaReadline" install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%{prefix}/lib/libJavaReadline.so
%{prefix}/share/java/%{name}.jar
%doc NEWS ChangeLog README README.1st VERSION api
libreadline-java-0.8.0.1+dfsg/etc/manifest.stub 0000644 0001750 0001750 00000000064 07606524213 017755 0 ustar moon moon Manifest-Version: 1.0
Main-Class: test.ReadlineTest