TextRange


An immutable text range class, represents a text range from start (inclusive) to end (exclusive). end can be smaller than start and in those cases min and max can be used in order to fetch the values.

Summary

Public companion properties

TextRange
Cmn

Public functions

operator Boolean
contains(offset: Int)

Returns true if the given offset is a part of this range.

Cmn
operator Boolean

Returns true if this range covers including equals with the given range.

Cmn
Boolean

Returns true if the given range has intersection with this range

Cmn
open String
Cmn

Public properties

Boolean

Returns true if the range is collapsed

Cmn
Int
Cmn
Int

Returns the length of the range.

Cmn
Int

The maximum offset of the range.

Cmn
Int

The minimum offset of the range.

Cmn
Boolean

Returns true if the start offset is larger than the end offset.

Cmn
Int
Cmn

Extension functions

TextRange
TextRange.coerceIn(minimumValue: Int, maximumValue: Int)

Ensures that TextRange.start and TextRange.end values lies in the specified range minimumValue and maximumValue.

Cmn

Public companion properties

Zero

val ZeroTextRange

Public functions

contains

operator fun contains(offset: Int): Boolean

Returns true if the given offset is a part of this range.

contains

operator fun contains(other: TextRange): Boolean

Returns true if this range covers including equals with the given range.

intersects

fun intersects(other: TextRange): Boolean

Returns true if the given range has intersection with this range

toString

open fun toString(): String

Public properties

collapsed

val collapsedBoolean

Returns true if the range is collapsed

end

val endInt

length

val lengthInt

Returns the length of the range.

max

val maxInt

The maximum offset of the range.

min

val minInt

The minimum offset of the range.

reversed

val reversedBoolean

Returns true if the start offset is larger than the end offset.

start

val startInt

Extension functions

coerceIn

fun TextRange.coerceIn(minimumValue: Int, maximumValue: Int): TextRange

Ensures that TextRange.start and TextRange.end values lies in the specified range minimumValue and maximumValue. For each TextRange.start and TextRange.end values:

Parameters
minimumValue: Int

the minimum value that TextRange.start or TextRange.end can be.

maximumValue: Int

the exclusive maximum value that TextRange.start or TextRange.end can be.