Пример #1
0
  public static void createReadline(Ruby runtime) throws IOException {
    ConsoleHolder holder = new ConsoleHolder();
    holder.history = new ReadlineHistory();
    holder.currentCompletor = null;
    COMPLETION_CASE_FOLD = runtime.getNil();

    RubyModule mReadline = runtime.defineModule("Readline");

    mReadline.dataWrapStruct(holder);

    mReadline.defineAnnotatedMethods(Readline.class);
    IRubyObject hist = runtime.getObject().callMethod(runtime.getCurrentContext(), "new");
    mReadline.fastSetConstant("HISTORY", hist);
    hist.getSingletonClass().includeModule(runtime.getEnumerable());
    hist.getSingletonClass().defineAnnotatedMethods(HistoryMethods.class);

    // MRI does similar thing on MacOS X with 'EditLine wrapper'.
    mReadline.fastSetConstant("VERSION", runtime.newString("JLine wrapper"));
  }