From: SourceForge.net <no...@so...> - 2003-08-27 06:52:18
|
Patches item #795831, was opened at 2003-08-27 16:52 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312867&aid=795831&group_id=12867 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Ben Burton (bab) Assigned to: Nobody/Anonymous (nobody) Summary: Patch for using TAB with ReadlineConsole Initial Comment: 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) {} } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312867&aid=795831&group_id=12867 |
From: SourceForge.net <no...@so...> - 2003-08-27 06:54:44
|
Patches item #795831, was opened at 2003-08-27 16:52 Message generated for change (Comment added) made by bab You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312867&aid=795831&group_id=12867 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Ben Burton (bab) Assigned to: Nobody/Anonymous (nobody) Summary: Patch for using TAB with ReadlineConsole Initial Comment: 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) {} } ---------------------------------------------------------------------- >Comment By: Ben Burton (bab) Date: 2003-08-27 16:54 Message: Logged In: YES user_id=146613 Hmm, somewhere in the patch submission process the whitespace has been mangled. I'm attaching the patch again as a separate file with whitespace and indenting intact. Ben. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312867&aid=795831&group_id=12867 |