PartialGapBuffer

class PartialGapBuffer
kotlin.Any
   ↳ androidx.ui.input.PartialGapBuffer

An editing buffer that uses Gap Buffer only around the cursor location.

Different from the original gap buffer, this gap buffer doesn't convert all given text into mutable buffer. Instead, this gap buffer converts cursor around text into mutable gap buffer for saving construction time and memory space. If text modification outside of the gap buffer is requested, this class flush the buffer and create new String, then start new gap buffer.

Summary

Public constructors

<init>(text: String)

An editing buffer that uses Gap Buffer only around the cursor location.

Public methods

operator Char
get(index: Int)

[] operator for the character at the index.

Unit
replace(start: Int, end: Int, text: String)

Replace the certain region of text with given text

String

Properties

Int

The text length

String

The initial text

Public constructors

<init>

PartialGapBuffer(text: String)

An editing buffer that uses Gap Buffer only around the cursor location.

Different from the original gap buffer, this gap buffer doesn't convert all given text into mutable buffer. Instead, this gap buffer converts cursor around text into mutable gap buffer for saving construction time and memory space. If text modification outside of the gap buffer is requested, this class flush the buffer and create new String, then start new gap buffer.

Parameters
text: String The initial text

Public methods

get

operator fun get(index: Int): Char

[] operator for the character at the index.

replace

fun replace(
    start: Int,
    end: Int,
    text: String
): Unit

Replace the certain region of text with given text

Parameters
start: Int an inclusive start offset for replacement.
end: Int an exclusive end offset for replacement
text: String a text to replace

toString

fun toString(): String

Properties

length

val length: Int

The text length

text

var text: String

The initial text