Search in sources :

Example 1 with IRopeList

use of suite.immutable.IRope.IRopeList in project suite by stupidsing.

the class DevMain method text.

private Text text(IRopeList<Character> text) {
    IntsBuilder starts = new IntsBuilder();
    IntsBuilder ends = new IntsBuilder();
    IntMutable p0 = IntMutable.of(-1);
    int size = text.size();
    IntSink lf = px -> {
        starts.append(p0.get() + 1);
        ends.append(px);
        p0.update(px);
    };
    for (int p = 0; p < size; p++) {
        char ch = text.get(p);
        if (ch == '\n' || wrapSize < p - p0.get())
            lf.sink(p);
    }
    if (1 < size - p0.get())
        lf.sink(size);
    return new Text(text, starts.toInts().toArray(), ends.toInts().toArray());
}
Also used : LibcJna(suite.ansi.LibcJna) Termios(suite.ansi.Termios) Friends.min(suite.util.Friends.min) Native(com.sun.jna.Native) IntIntPair(suite.primitive.adt.pair.IntIntPair) Predicate(java.util.function.Predicate) IRope(suite.immutable.IRope) Friends.max(suite.util.Friends.max) IntSink(suite.primitive.IntPrimitives.IntSink) Keyboard(suite.ansi.Keyboard) IRopeList(suite.immutable.IRope.IRopeList) FixieFun6(suite.adt.pair.Fixie_.FixieFun6) VK(suite.ansi.Keyboard.VK) FixieFun3(suite.adt.pair.Fixie_.FixieFun3) Sink(suite.util.FunUtil.Sink) FileUtil(suite.os.FileUtil) Chars_(suite.primitive.Chars_) IntsBuilder(suite.primitive.Ints.IntsBuilder) Ints_(suite.primitive.Ints_) IntMutable(suite.primitive.IntMutable) Fail(suite.util.Fail) IntSink(suite.primitive.IntPrimitives.IntSink) IntsBuilder(suite.primitive.Ints.IntsBuilder) IntMutable(suite.primitive.IntMutable)

Aggregations

Native (com.sun.jna.Native)1 Predicate (java.util.function.Predicate)1 FixieFun3 (suite.adt.pair.Fixie_.FixieFun3)1 FixieFun6 (suite.adt.pair.Fixie_.FixieFun6)1 Keyboard (suite.ansi.Keyboard)1 VK (suite.ansi.Keyboard.VK)1 LibcJna (suite.ansi.LibcJna)1 Termios (suite.ansi.Termios)1 IRope (suite.immutable.IRope)1 IRopeList (suite.immutable.IRope.IRopeList)1 FileUtil (suite.os.FileUtil)1 Chars_ (suite.primitive.Chars_)1 IntMutable (suite.primitive.IntMutable)1 IntSink (suite.primitive.IntPrimitives.IntSink)1 IntsBuilder (suite.primitive.Ints.IntsBuilder)1 Ints_ (suite.primitive.Ints_)1 IntIntPair (suite.primitive.adt.pair.IntIntPair)1 Fail (suite.util.Fail)1 Friends.max (suite.util.Friends.max)1 Friends.min (suite.util.Friends.min)1