Ejemplo n.º 1
0
 def __init__(self, printUnsupported=False):
     ReadlineWrapper.__init__(self)
     self.printUnsupported=printUnsupported
     self.completeFunc=Readline.getCompleter()
     self.initFunc=None
     Readline.setCompleter(self)
     pass
Ejemplo n.º 2
0
 def __init__(self, printUnsupported=False):
     ReadlineWrapper.__init__(self)
     self.printUnsupported = printUnsupported
     self.completeFunc = Readline.getCompleter()
     self.initFunc = None
     Readline.setCompleter(self)
     pass
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 5
0
 def parse_and_bind(self,string):
     """Parse and execute single line of a readline init file."""
     return Readline.parseAndBind(string)
Ejemplo n.º 6
0
def read_history_file(filename):
    """Load a readline history file. 
    The default filename is '~/.history'.

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

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

    """ 
    Readline.readHistoryFile(filename)
Ejemplo n.º 15
0
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
Ejemplo n.º 16
0
def get_current_history_length():
    """Get the number of lines currently available in history."""
    return Readline.getHistorySize()
Ejemplo n.º 17
0
def get_completer():
    """Get the current completer instance."""
    return Readline.getCompleter()
Ejemplo n.º 18
0
def write_history_file(filename):
    """Save a readline history file. 
    The default filename is '~/.history'.

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

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

    """ 
    Readline.writeHistoryFile(filename)
Ejemplo n.º 34
0
 def get_completer_delims(self):
     """Get the readline word delimiters for tab-completion."""
     return str(Readline.getWordBreakCharacters())
Ejemplo n.º 35
0
def get_completer():
    """Get the current completer instance."""
    return Readline.getCompleter()
Ejemplo n.º 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)
Ejemplo n.º 37
0
def get_completer_delims():
    """Get the readline word delimiters for tab-completion."""
    return Readline.getWordBreakCharacters()
Ejemplo n.º 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.
Ejemplo n.º 39
0
def get_current_history_length():
    """Get the number of lines currently available in history."""
    return Readline.getHistorySize()
Ejemplo n.º 40
0
def parse_and_bind (bindings):
    """Parse and execute single line of a readline init file.\
    
    """
    Readline.parseAndBind(bindings)