Search in sources :

Example 1 with IntsBuilder

use of primal.primitive.adt.Ints.IntsBuilder in project suite by stupidsing.

the class DevMain method text.

private Text text(IRopeList<Character> text) {
    var starts = new IntsBuilder();
    var ends = new IntsBuilder();
    var p0 = IntMutable.of(-1);
    var size = text.size;
    IntSink lf = px -> {
        starts.append(p0.value() + 1);
        ends.append(px);
        p0.update(px);
    };
    for (var p = 0; p < size; p++) {
        var ch = text.get.apply(p);
        if (ch == '\n' || wrapSize < p - p0.value())
            lf.f(p);
    }
    if (1 < size - p0.value())
        lf.f(size);
    return new Text(text, starts.toInts().toArray(), ends.toInts().toArray());
}
Also used : FixieFun6(primal.adt.Fixie_.FixieFun6) LibcJna(suite.ansi.LibcJna) IRopeList(suite.persistent.PerRope.IRopeList) Termios(suite.ansi.Termios) Fail.fail(primal.statics.Fail.fail) Native(com.sun.jna.Native) Predicate(java.util.function.Predicate) Coord(suite.primitive.Coord) Math.min(java.lang.Math.min) IntSink(primal.primitive.IntPrim.IntSink) IntsBuilder(primal.primitive.adt.Ints.IntsBuilder) Sink(primal.fp.Funs.Sink) Streamlet_.forInt(suite.util.Streamlet_.forInt) ReadString(primal.Verbs.ReadString) IntMutable(primal.primitive.adt.IntMutable) Keyboard(suite.ansi.Keyboard) VK(suite.ansi.Keyboard.VK) Math.max(java.lang.Math.max) NewChr(primal.primitive.ChrVerbs.NewChr) FixieFun3(primal.adt.Fixie_.FixieFun3) IntSink(primal.primitive.IntPrim.IntSink) IntsBuilder(primal.primitive.adt.Ints.IntsBuilder)

Aggregations

Native (com.sun.jna.Native)1 Math.max (java.lang.Math.max)1 Math.min (java.lang.Math.min)1 Predicate (java.util.function.Predicate)1 ReadString (primal.Verbs.ReadString)1 FixieFun3 (primal.adt.Fixie_.FixieFun3)1 FixieFun6 (primal.adt.Fixie_.FixieFun6)1 Sink (primal.fp.Funs.Sink)1 NewChr (primal.primitive.ChrVerbs.NewChr)1 IntSink (primal.primitive.IntPrim.IntSink)1 IntMutable (primal.primitive.adt.IntMutable)1 IntsBuilder (primal.primitive.adt.Ints.IntsBuilder)1 Fail.fail (primal.statics.Fail.fail)1 Keyboard (suite.ansi.Keyboard)1 VK (suite.ansi.Keyboard.VK)1 LibcJna (suite.ansi.LibcJna)1 Termios (suite.ansi.Termios)1 IRopeList (suite.persistent.PerRope.IRopeList)1 Coord (suite.primitive.Coord)1 Streamlet_.forInt (suite.util.Streamlet_.forInt)1