Skip to content

decouple RichTextFX from string, use CharSequence #282

@Groostav

Description

@Groostav

(CC: @VinnieH)

As a developer writing a tool for which I cannot gaurentee that the text rendered will be a reasonable size, I would like RichTextFX to keep the minimal content in memory necessary, streaming text off the disk rather than loading it into strings, so that I can sleep easy.

Basically I'd like to decouple RichTextFX from Strings in favor of CharSequences so that I might use @fge's largetext library instead of a flat string. This would make your library fairly agnostic to how it gets the data and give me a shim for lazyness.

Note that CharSequence specifies the two most critical parts of String: subSequence and charAt, in addition to fancy-new IntStreams for codePoints() and chars(), meaning there shouldn't be anything you can do with Strings you cant do with CharSequences. The one major gotcha is that CharSequence is not strict about how it implements equality, so you need to be careful when keeping lists or sets of them and calling contains().

Its also worth mentioning that LargeText's current subSequence() implementation does currently pull the specified subsequence into memory, so if the running code doesn't handle those carefully (possibly with SoftReferences in the case of paragraphs?) then the advantage will be nullified.

Sound reasonable? I could do it myself, but this eventing/reactive system is new to me so I'm likely to make some silly mistakes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions