def __init__(self, printUnsupported=False):
     ReadlineWrapper.__init__(self)
     self.printUnsupported=printUnsupported
     self.completeFunc=Readline.getCompleter()
     self.initFunc=None
     Readline.setCompleter(self)
     pass
Example #2
0
 def __init__(self, printUnsupported=False):
     ReadlineWrapper.__init__(self)
     self.printUnsupported = printUnsupported
     self.completeFunc = Readline.getCompleter()
     self.initFunc = None
     Readline.setCompleter(self)
     pass
Example #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))
Example #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)
Example #6
0
def read_history_file(filename):
    """Load a readline history file. 
    The default filename is '~/.history'.

    """ 
    Readline.readHistoryFile(filename)
Example #7
0
def get_line_buffer():
    """Return the current contents of the line buffer. 
        
    """
    return Readline.getLineBuffer()
Example #8
0
def cleanup():
    Readline.cleanup()
    pass
Example #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
Example #10
0
 def read_history_file(self, filename):
     """Load a readline history file. The     default filename is ~/.history."""
     Readline.readHistoryFile(filename)
     pass
Example #11
0
 def parse_and_bind(self, string):
     """Parse and execute single line of a readline init file."""
     return Readline.parseAndBind(string)
Example #12
0
def read_init_file(filename):
    """Parse a readline initialization file. 
    The default filename is the last filename used. 

    """
    Readline.readInitFile(filename)
Example #13
0
def set_completer_delims(delimiters):
    """Set the readline word delimiters for tab-completion."""
    Readline.setWordBreakCharacters(delimiters)
Example #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
Example #16
0
def get_current_history_length():
    """Get the number of lines currently available in history."""
    return Readline.getHistorySize()
Example #17
0
def get_completer():
    """Get the current completer instance."""
    return Readline.getCompleter()
Example #18
0
def write_history_file(filename):
    """Save a readline history file. 
    The default filename is '~/.history'.

    """ 
    Readline.writeHistoryFile(filename)
Example #19
0
def add_history(line):
    """Append a line to the history buffer, as if it was the last line typed."""
    Readline.addToHistory(line)
 def get_line_buffer(self):
     """Return the current contents of the line buffer."""
     return Readline.getLineBuffer()
 def read_init_file(self,filename):
     """Parse a readline initialization file."""
     Readline.readInitFile(filename)
     pass
 def read_history_file(self,filename):
     """Load a readline history file. The     default filename is ~/.history."""
     Readline.readHistoryFile(filename)
     pass
Example #23
0
 def read_init_file(self, filename):
     """Parse a readline initialization file."""
     Readline.readInitFile(filename)
     pass
 def write_history_file(self,filename):
     """Save a readline history file. The         default filename is ~/.history."""
     Readline.writeHistoryFile(filename)
     pass
Example #25
0
 def write_history_file(self, filename):
     """Save a readline history file. The         default filename is ~/.history."""
     Readline.writeHistoryFile(filename)
     pass
 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
Example #27
0
 def get_current_history_length(self):
     """Return the number of lines currently in the history."""
     return Readline.getHistorySize()
 def get_current_history_length(self):
     """Return the number of lines currently in the history."""
     return Readline.getHistorySize()
Example #29
0
def parse_and_bind (bindings):
    """Parse and execute single line of a readline init file.\
    
    """
    Readline.parseAndBind(bindings)
def cleanup():
    Readline.cleanup()
    pass
Example #31
0
def read_init_file(filename):
    """Parse a readline initialization file. 
    The default filename is the last filename used. 

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

    """ 
    Readline.writeHistoryFile(filename)
 def get_completer_delims(self):
     """Get the readline word delimiters for tab-completion."""
     return str(Readline.getWordBreakCharacters())
Example #35
0
def get_completer():
    """Get the current completer instance."""
    return Readline.getCompleter()
 def add_history(self,line):
     """Append a line to the history buffer, as if it was the last line typed."""
     Readline.addToHistory(line)
Example #37
0
def get_completer_delims():
    """Get the readline word delimiters for tab-completion."""
    return Readline.getWordBreakCharacters()
        "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.
Example #39
0
def get_current_history_length():
    """Get the number of lines currently available in history."""
    return Readline.getHistorySize()
Example #40
0
def parse_and_bind (bindings):
    """Parse and execute single line of a readline init file.\
    
    """
    Readline.parseAndBind(bindings)