jline.History.getHistoryList()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中jline.History.getHistoryList()方法的一些代码示例,展示了History.getHistoryList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。History.getHistoryList()方法的具体详情如下:
包路径:jline.History
类名称:History
方法名:getHistoryList

History.getHistoryList介绍

暂无

代码示例

代码示例来源:origin: org.apache.jackrabbit.vault/vault-cli

protected void doExecute(ConsoleExecutionContext ctx, CommandLine cl)
    throws Exception {
  // print the history
  Iterator iter = ctx.getConsole().getReader().getHistory().getHistoryList().iterator();
  int i=1;
  while (iter.hasNext()) {
    System.out.println("  " + i + "  " + iter.next());
    i++;
  }
}

代码示例来源:origin: org.netbeans.api/org-jruby

@JRubyMethod(name = "pop")
@SuppressWarnings("unchecked")
public static IRubyObject s_pop(IRubyObject recv) throws Exception {
  Ruby runtime = recv.getRuntime();
  ConsoleHolder holder = getHolder(runtime);
  List histList = holder.history.getHistoryList();
  // TODO: Not fully implemented. We just return the last value,
  // without really popping it.
  String current = (String)histList.get(histList.size() - 1);
  return runtime.newString(current);
}

代码示例来源:origin: org.apache.jackrabbit.vault/vault-cli

try {
  int historyIndex = Integer.valueOf(line.substring(1).trim()).intValue();
  oldLine = (String) reader.getHistory().getHistoryList().get(historyIndex - 1);
} catch (Exception e) {
  System.out.println("  " + line + ": event not found");

代码示例来源:origin: org.netbeans.api/org-jruby

@JRubyMethod(name = "to_a")
public static IRubyObject s_hist_to_a(IRubyObject recv) throws Exception {
  ConsoleHolder holder = getHolder(recv.getRuntime());
  RubyArray histList = recv.getRuntime().newArray();
  for (Iterator i = holder.history.getHistoryList().iterator(); i.hasNext();) {
    histList.append(recv.getRuntime().newString((String) i.next()));
  }
  return histList;
}

代码示例来源:origin: commons-jelly/commons-jelly-tags-interaction

? new ArrayList(consoleHistory.getHistoryList()) : new ArrayList(0);

代码示例来源:origin: org.netbeans.api/org-jruby

@JRubyMethod(name = "each")
  public static IRubyObject s_hist_each(IRubyObject recv, Block block) {
    ConsoleHolder holder = getHolder(recv.getRuntime());
    for (Iterator i = holder.history.getHistoryList().iterator(); i.hasNext();) {
      block.yield(recv.getRuntime().getCurrentContext(), recv.getRuntime().newString((String) i.next()));
    }
    return recv;
  }
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

public Object execute(final CommandContext context) throws Exception {
    assert context != null;
    IO io = context.getIo();

    // HACK: Get at the shell's history from our variables
    History history = context.getVariables().get("gshell.internal.history", History.class);
    assert history != null;

    // noinspection unchecked
    List<String> elements = history.getHistoryList();

    int i = 0;
    for (String element : elements) {
      String index = String.format("%3d", i);
      io.info("  {}  {}", AnsiRenderer.encode(index, AnsiCode.BOLD), element);
      i++;
    }

    return Result.SUCCESS;
  }
}

代码示例来源:origin: org.netbeans.api/org-jruby

@JRubyMethod(name = "[]")
public static IRubyObject s_hist_get(IRubyObject recv, IRubyObject index) {
  Ruby runtime = recv.getRuntime();
  ConsoleHolder holder = getHolder(runtime);
  int i = (int) index.convertToInteger().getLongValue();
  try {
    // TODO: MRI behavior is more complicated than that,
    // there is some magic when dealing with negative indexes.
    return runtime.newString((String) holder.history.getHistoryList().get(i));
  } catch (IndexOutOfBoundsException ioobe) {
    throw runtime.newIndexError("invalid history index: " + i);
  }
}

代码示例来源:origin: org.apache.felix.karaf.shell/org.apache.felix.karaf.shell.commands

@Override
  protected Object doExecute() throws Exception {
    History history = (History) session.get(".jline.history");
    List<String> elements = history.getHistoryList();

    int i = 0;
    for (String element : elements) {
      System.out.println(
          Ansi.ansi()
            .a("  ")
            .a(Ansi.Attribute.INTENSITY_BOLD).render("%3d", i).a(Ansi.Attribute.INTENSITY_BOLD_OFF)
            .a("  ")
            .a(element)
            .toString());
      i++;
    }
    return null;
  }
}

相关文章