2

Scala REPLのタブ補完の出力は、新しい行を開始する前に項目を左から右にソートして、行全体を読み取ります。これは私にはぎこちなく感じます。新しい列を開始する前に、上から下に並べ替えられたリストを読むことに慣れています。代わりに、列を読み取るように出力を変更する方法はありますか?

4

1 に答える 1

2

Scala REPL は、適切な補完を行うためにjlineを使用します。jline のコードを見ると、ここにコピー/貼り付けされているCandidateListCompletionHandler.printCandidates(...)呼び出しが表示されます。reader.printColumns(candidates)

ご覧のとおり、行モードではなく列モードで補完候補をソートする方法はありません。おそらく最善の方法は、jline にパッチを適用して scala/lib/ ディレクトリに置き換えることです。

public void printColumns(final Collection stuff) throws IOException {
    if ((stuff == null) || (stuff.size() == 0)) {
        return;
    }

    int width = getTermwidth();
    int maxwidth = 0;

    for (Iterator i = stuff.iterator(); i.hasNext(); maxwidth = Math.max(
            maxwidth, i.next().toString().length())) {
        ;
    }

    StringBuffer line = new StringBuffer();

    int showLines;

    if (usePagination)
        showLines = getTermheight() - 1; // page limit
    else
        showLines = Integer.MAX_VALUE;

    for (Iterator i = stuff.iterator(); i.hasNext();) {
        String cur = (String) i.next();

        if ((line.length() + maxwidth) > width) {
            printString(line.toString().trim());
            printNewline();
            line.setLength(0);
            if (--showLines == 0) { // Overflow
                printString(loc.getString("display-more"));
                flushConsole();
                int c = readVirtualKey();
                if (c == '\r' || c == '\n')
                    showLines = 1; // one step forward
                else if (c != 'q')
                    showLines = getTermheight() - 1; // page forward

                back(loc.getString("display-more").length());
                if (c == 'q')
                    break; // cancel
            }
        }

        pad(cur, maxwidth + 3, line);
    }

    if (line.length() > 0) {
        printString(line.toString().trim());
        printNewline();
        line.setLength(0);
    }
}
于 2011-02-11T09:09:28.380 に答える