SF.net SVN: jython:[7150] trunk/jython/Lib/readline.py
[email protected] Sat, 16 Oct 2010 05:12:18 +0000
| Newsgroups | gmane.comp.lang.jython.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 7150
http://jython.svn.sourceforge.net/jython/?rev=7150&view=rev
Author: zyasoft
Date: 2010-10-16 05:12:18 +0000 (Sat, 16 Oct 2010)
Log Message:
-----------
Hardened completion sso it doesn't fail on missing symbols.
Modified Paths:
--------------
trunk/jython/Lib/readline.py
Modified: trunk/jython/Lib/readline.py
===================================================================
--- trunk/jython/Lib/readline.py 2010-10-16 03:07:47 UTC (rev 7149)
+++ trunk/jython/Lib/readline.py 2010-10-16 05:12:18 UTC (rev 7150)
@@ -1,30 +1,17 @@
-""" Emulate module 'readline' from CPython.
-We are using the JavaReadline JNI wrapper for GNU readline.
-
-2004-10-27, [email protected]
-
-"""
-
from __future__ import with_statement
import os.path
import sys
-# XXX move to _jline_readline.py, just like our _gnu_readline.py (which is orphaned)
-# then simply try successive imports to see what is installed
-
-# XXX what's oru character encoding issues here, if any?
-
try:
reader = sys._jy_interpreter.reader
- #from JLine import Completor
except AttributeError:
raise ImportError("Cannot access JLineConsole")
def parse_and_bind(string):
- # XXX this should probably reinitialize the reader, if possible
+ # TODO this should probably reinitialize the reader, if possible
# with any desired settings; this will require some more work to implement
- # most importantly, need to support
+ # most importantly, need to support at least
# readline.parse_and_bind("tab: complete")
# but it's possible we can readily support other aspects of a readline file
pass
@@ -68,33 +55,39 @@
return reader.history.historyList[index]
def remove_history_item(pos):
+ # TODO possible?
raise Exception("not implemented")
def redisplay():
- reader.drawLine() # XXX not certain
+ reader.redrawLine()
def set_startup_hook(function=None):
+ # TODO add
pass
def set_pre_input_hook(function=None):
+ # TODO add
pass
_completion_function = None
def set_completer(function=None):
- # XXX single method interface, http://jline.sourceforge.net/apidocs/jline/Completor.html
- # just need to figure out what's necessary to adapt to Python's convention,
- # but it should be fine :)
+ """set_completer([function]) -> None
+ Set or remove the completer function.
+ The function is called as function(text, state),
+ for state in 0, 1, 2, ..., until it returns a non-string.
+ It should return the next possible completion starting with 'text'."""
- """The completer method is called as completerclass.completer(text, state), for state in 0, 1, 2, ...,
- until it returns a non-string value. It should return the next possible completion starting with text."""
-
_completion_function = function
def complete_handler(buffer, cursor, candidates):
- for state in xrange(100):
- completion = function(buffer[:cursor], state)
+ for state in xrange(100): # TODO arbitrary, what's the number used by gnu readline?
+ completion = None
+ try:
+ completion = function(buffer[:cursor], state)
+ except:
+ pass
if completion:
candidates.add(completion)
else:
@@ -108,9 +101,11 @@
return _completion_function
def get_begidx():
+ # TODO add
pass
def get_endidx():
+ # TODO add
pass
def set_completer_delims(string):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev