def __init__(self, printUnsupported=False):
     ReadlineWrapper.__init__(self)
     self.printUnsupported=printUnsupported
     self.completeFunc=Readline.getCompleter()
     self.initFunc=None
     Readline.setCompleter(self)
     pass
示例#2
0
 def __init__(self, printUnsupported=False):
     ReadlineWrapper.__init__(self)
     self.printUnsupported = printUnsupported
     self.completeFunc = Readline.getCompleter()
     self.initFunc = None
     Readline.setCompleter(self)
     pass
示例#3
0
def set_completer(completionfunction = None):
    """Set or remove the completer instance. If an instance of ReadlineCompleter is specified, 
    it will be used as the new completer; if omitted or None, any completer already installed is removed.

    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. 

    """
    class DerivedCompleter (ReadlineCompleter):
        def __init__ (self, method):
            self.method = method

        def completer (self, text, state):
            return self.method(text, state)

    Readline.setCompleter(DerivedCompleter(completionfunction))
示例#4
0
def set_completer(completionfunction = None):
    """Set or remove the completer instance. If an instance of ReadlineCompleter is specified, 
    it will be used as the new completer; if omitted or None, any completer already installed is removed.

    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. 

    """
    class DerivedCompleter (ReadlineCompleter):
        def __init__ (self, method):
            self.method = method

        def completer (self, text, state):
            return self.method(text, state)

    Readline.setCompleter(DerivedCompleter(completionfunction))
 def parse_and_bind(self,string):
     """Parse and execute single line of a readline init file."""
     return Readline.parseAndBind(string)
示例#6
0
def read_history_file(filename):
    """Load a readline history file. 
    The default filename is '~/.history'.

    """ 
    Readline.readHistoryFile(filename)
示例#7
0
def get_line_buffer():
    """Return the current contents of the line buffer. 
        
    """
    return Readline.getLineBuffer()
示例#8
0
def cleanup():
    Readline.cleanup()
    pass
示例#9
0
 def clear_history(self):
     """Clear the current history. (Note: this function is not available if the installed version of GNU readline doesn’t support it.)"""
     Readline.clearHistory()
     pass
示例#10
0
 def read_history_file(self, filename):
     """Load a readline history file. The     default filename is ~/.history."""
     Readline.readHistoryFile(filename)
     pass
示例#11
0
 def parse_and_bind(self, string):
     """Parse and execute single line of a readline init file."""
     return Readline.parseAndBind(string)
示例#12
0
def read_init_file(filename):
    """Parse a readline initialization file. 
    The default filename is the last filename used. 

    """
    Readline.readInitFile(filename)
示例#13
0
def set_completer_delims(delimiters):
    """Set the readline word delimiters for tab-completion."""
    Readline.setWordBreakCharacters(delimiters)
示例#14
0
def read_history_file(filename):
    """Load a readline history file. 
    The default filename is '~/.history'.

    """ 
    Readline.readHistoryFile(filename)
if sys.registry["python.console"] != "org.python.util.ReadlineConsole":
    raise EnvironmentError("You need to set python.console=org.python.util.ReadlineConsole in your ~/.jython file!")
try:
    from org.gnu.readline import Readline, ReadlineLibrary, ReadlineCompleter
except ImportError:
    raise ImportError("Make sure you have libreadline-java.jar in classpath!")
import __builtin__
import atexit
import keyword
import os
import re

__all__ = ["PyCompleter", "JvCompleter"]

Readline.load(
    getattr(ReadlineLibrary, sys.registry["python.console.readlinelib"], "")
    or DEFAULTLIB)
histfile = os.path.join(os.environ["HOME"], ".jyhist")
try:
    Readline.readHistoryFile(histfile)
except:
    print >> sys.stderr, histfile, "not available!"
atexit.register(Readline.writeHistoryFile, histfile)

class PyCompleter:
    def __init__(self, namespace = None):
        """Create a new completer for the command line.

        PyCompleter([namespace]) -> completer instance.

        If unspecified, the default namespace where completions are performed
示例#16
0
def get_current_history_length():
    """Get the number of lines currently available in history."""
    return Readline.getHistorySize()
示例#17
0
def get_completer():
    """Get the current completer instance."""
    return Readline.getCompleter()
示例#18
0
def write_history_file(filename):
    """Save a readline history file. 
    The default filename is '~/.history'.

    """ 
    Readline.writeHistoryFile(filename)
示例#19
0
def add_history(line):
    """Append a line to the history buffer, as if it was the last line typed."""
    Readline.addToHistory(line)
示例#20
0
 def get_line_buffer(self):
     """Return the current contents of the line buffer."""
     return Readline.getLineBuffer()
示例#21
0
 def read_init_file(self,filename):
     """Parse a readline initialization file."""
     Readline.readInitFile(filename)
     pass
示例#22
0
 def read_history_file(self,filename):
     """Load a readline history file. The     default filename is ~/.history."""
     Readline.readHistoryFile(filename)
     pass
示例#23
0
 def read_init_file(self, filename):
     """Parse a readline initialization file."""
     Readline.readInitFile(filename)
     pass
示例#24
0
 def write_history_file(self,filename):
     """Save a readline history file. The         default filename is ~/.history."""
     Readline.writeHistoryFile(filename)
     pass
示例#25
0
 def write_history_file(self, filename):
     """Save a readline history file. The         default filename is ~/.history."""
     Readline.writeHistoryFile(filename)
     pass
示例#26
0
 def clear_history(self):
     """Clear the current history. (Note: this function is not available if the installed version of GNU readline doesn’t support it.)"""
     Readline.clearHistory()
     pass
示例#27
0
 def get_current_history_length(self):
     """Return the number of lines currently in the history."""
     return Readline.getHistorySize()
示例#28
0
 def get_current_history_length(self):
     """Return the number of lines currently in the history."""
     return Readline.getHistorySize()
示例#29
0
def parse_and_bind (bindings):
    """Parse and execute single line of a readline init file.\
    
    """
    Readline.parseAndBind(bindings)
示例#30
0
def cleanup():
    Readline.cleanup()
    pass
示例#31
0
def read_init_file(filename):
    """Parse a readline initialization file. 
    The default filename is the last filename used. 

    """
    Readline.readInitFile(filename)
示例#32
0
 def set_completer_delims(self,string):
     """Set the readline word delimiters for tab-completion."""
     Readline.setWordBreakCharacters(string)
示例#33
0
def write_history_file(filename):
    """Save a readline history file. 
    The default filename is '~/.history'.

    """ 
    Readline.writeHistoryFile(filename)
示例#34
0
 def get_completer_delims(self):
     """Get the readline word delimiters for tab-completion."""
     return str(Readline.getWordBreakCharacters())
示例#35
0
def get_completer():
    """Get the current completer instance."""
    return Readline.getCompleter()
示例#36
0
 def add_history(self,line):
     """Append a line to the history buffer, as if it was the last line typed."""
     Readline.addToHistory(line)
示例#37
0
def get_completer_delims():
    """Get the readline word delimiters for tab-completion."""
    return Readline.getWordBreakCharacters()
示例#38
0
        "You need to set python.console=org.python.util.ReadlineConsole in your ~/.jython file!"
    )
try:
    from org.gnu.readline import Readline, ReadlineLibrary, ReadlineCompleter
except ImportError:
    raise ImportError("Make sure you have libreadline-java.jar in classpath!")
import __builtin__
import atexit
import keyword
import os
import re

__all__ = ["PyCompleter", "JvCompleter"]

Readline.load(
    getattr(ReadlineLibrary, sys.registry["python.console.readlinelib"], "")
    or DEFAULTLIB)
histfile = os.path.join(os.environ["HOME"], ".jyhist")
try:
    Readline.readHistoryFile(histfile)
except:
    print >> sys.stderr, histfile, "not available!"
atexit.register(Readline.writeHistoryFile, histfile)


class PyCompleter:
    def __init__(self, namespace=None):
        """Create a new completer for the command line.

        PyCompleter([namespace]) -> completer instance.
示例#39
0
def get_current_history_length():
    """Get the number of lines currently available in history."""
    return Readline.getHistorySize()
示例#40
0
def parse_and_bind (bindings):
    """Parse and execute single line of a readline init file.\
    
    """
    Readline.parseAndBind(bindings)