Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 509c2c77f6a29ac204ae45030e4362fa > files > 22

libreadline-java-0.8.1-1.5mdv2008.1.x86_64.rpm

// Copyright © Corporation for National Research Initiatives
package org.python.util;
import org.python.core.*;
import org.gnu.readline.*;

// Based on CPython-1.5.2's code module

public class ReadlineConsole extends InteractiveConsole {
    public String filename;

    public ReadlineConsole() {
        this(null, "<console>");
    }
    public ReadlineConsole(PyObject locals) {
        this(locals, "<console>");
    }
    public ReadlineConsole(PyObject locals, String filename) {
        super(locals,filename);
	try {
	  Readline.load(ReadlineLibrary.Editline);
	} catch (Exception e) {
	}
	Readline.initReadline("jpython");
    }


    /**
     * Write a prompt and read a line.
     *
     * The returned line does not include the trailing newline.  When the
     * user enters the EOF key sequence, EOFError is raised.
     *
     * This subclass implements the functionality using JavaReadline.
     **/
    public String raw_input(PyObject prompt) {
        try {
           return Readline.readline(prompt==null ? "" : prompt.toString());
        } catch (java.io.EOFException eofe) {
           throw new PyException(Py.EOFError);
        } catch (java.io.IOException ioe) {
           throw new PyException();
        } catch (java.io.UnsupportedEncodingException e) {
           throw new PyException();
        }
    }
}