Interface TextBuffer

  • All Known Implementing Classes:
    TextBufferImpl

    public interface TextBuffer
    Contents of a TextUnit being edited/populated.

    Consists of text areas. Active text chunk/area could be switched with pushTextArea(TextAreaToken) and popTextArea(). There's default, top-most text area that can't be removed, i.e. one can treat fresh TextBuffer as being initialized like

       TextBuffer tb;
       tb.pushTextArea(defaultAreaToken);
     

    Supports (nested) text markers, see pushMark(). FIXME Perhaps, shall introduce either BinaryBuffer or BinaryArea to support binary (or partly binary) files

    Since:
    3.3
    • Method Detail

      • pushTextArea

        TextBuffer pushTextArea​(@NotNull
                                TextAreaToken areaIdentity)
        Switch active area. FIXME describe whether nested push with the same token is allowed (present impl does allow, is it smth we'd like to use?)
        Parameters:
        areaIdentity - identifies text chunk to become active for output
        Returns:
        this for convenience
      • popTextArea

        TextBuffer popTextArea()
        Revert to previous active area
        Returns:
        this for convenience
      • pushMark

        TextBuffer pushMark()
        Indicate start location of a marker, which is retrieved with popMark() At the moment, as the name (push/pop) indicates, nested marks are supported. Nested means m1 starts, m2 starts, m2 ends, m1 ends. Intersecting marks, m1 starts, m2 starts, m1 ends, m2 ends are not supported, if there's need to, API shall get extended with mark identity.
      • popMark

        @NotNull
        TextMark popMark()
        Returns:
        text location marker within the buffer
      • snapshot

        @NotNull
        BufferSnapshot snapshot​(@NotNull
                                BufferLayout layout)
        Capture actual state of the buffer, text chunks positioned in accordance with supplied layout.
        Parameters:
        layout - describes how text chunks of the buffer shall be ordered.
        Returns:
        snapshot of the text in the buffer. The value is independent from subsequent buffer modifications