Message2297
Below is the patch I recently posted to jython-dev allowing the
use of the TAB key when working in an interactive jython
interpreter with ReadlineConsole. Since python makes active
use of indentation in defining the language, this resolves a
serious usability problem when using jython with readline
support.
This patch works with the current CVS version of java-readline
(to be released as version 0.8.1), though will not have any
negative effects with earlier java-readline versions.
Ben.
diff -ru old/jython-2.1.0/org/python/util/ReadlineConsole.java
jython-2.1.0/org/python/util/ReadlineConsole.java
--- old/jython-2.1.0/org/python/util/ReadlineConsole.java
2003-08-27 13:49:20.000000000 +1000
+++ jython-2.1.0/org/python/util/ReadlineConsole.java
2003-08-27 15:45:11.000000000 +1000
@@ -26,6 +26,24 @@
// Will use a pure java fallback.
}
Readline.initReadline("jpython");
+
+ // Disable readline completion if we have a new enough
Readline
+ // class, so that <TAB> characters can be input directly.
+ try {
+ java.lang.reflect.Field inhibitConstField =
+
Readline.class.getField("RL_INHIBIT_COMPLETION");
+ if (inhibitConstField != null) {
+ Object inhibitConst = inhibitConstField.get(null);
+ Class[] setVarArgTypes = { inhibitConst.getClass(),
+ Integer.TYPE };
+ java.lang.reflect.Method setVar =
Readline.class.getMethod(
+ "setVar", setVarArgTypes);
+ if (setVar != null) {
+ Object[] args = { inhibitConst, new Integer(1) };
+ setVar.invoke(null, args);
+ }
+ }
+ } catch (Exception exc) {}
}
|
|
Date |
User |
Action |
Args |
2008-02-20 17:18:21 | admin | link | issue795831 messages |
2008-02-20 17:18:21 | admin | create | |
|