TextCaret

com.alecdorrington.laminarcomponents.TextCaret
See theTextCaret companion object
class TextCaret(aside: String)

Offsets in the text of an element, read from points on the screen and from the page's selection, and where a caret at one stands: what a field drawn over rendered text, or a highlighter, needs to know where the reader is. The text of elements matching aside, such as notes drawn between the words, is no part of the element's own, so it is skipped, a point within it counting as where it stands.

Value parameters

aside

The selector of the elements whose text is skipped.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def lineOf(root: Element, text: String, offset: Int): Int

Finds which line of an element a caret at an offset of its text stands on, its line breaks' boxes standing for its empty lines.

Finds which line of an element a caret at an offset of its text stands on, its line breaks' boxes standing for its empty lines.

Value parameters

offset

The caret's offset in the text.

root

The element.

text

The element's own text.

Attributes

Returns

The line, counted from naught.

def range(root: Element): Option[(Int, Int)]

Reads the page's selection within an element's text, collapsed where the reader last clicked in it.

Reads the page's selection within an element's text, collapsed where the reader last clicked in it.

Value parameters

root

The element.

Attributes

Returns

The offsets where the selection starts and ends, if it lies in the element.

def rects(root: Element, from: Int, until: Int): List[DOMRect]

Finds the boxes on the screen of a span of an element's text.

Finds the boxes on the screen of a span of an element's text.

Value parameters

from

Where the span starts.

root

The element.

until

Where the span ends, exclusive.

Attributes

Returns

The span's boxes, a line or part of one each.

def selection(root: Element): Selection

Reads the page's selection as far as an element's text goes.

Reads the page's selection as far as an element's text goes.

Value parameters

root

The element.

Attributes

Returns

The span selected, a selection collapsed within the text, or one elsewhere.

def spot(root: Element, text: String, offset: Int): Option[Spot]

Finds where a caret at an offset of an element's text stands: before the character there, else after the one before it, so that a caret at a wrap stands at the start of the next line, as a field's does. A line break is drawn at the end of its line, so a caret after the last one stands a line below it.

Finds where a caret at an offset of an element's text stands: before the character there, else after the one before it, so that a caret at a wrap stands at the start of the next line, as a field's does. A line break is drawn at the end of its line, so a caret after the last one stands a line below it.

Value parameters

offset

The caret's offset in the text.

root

The element.

text

The element's own text.

Attributes

Returns

Where the caret stands.

def within(root: Element, x: Double, y: Double): Option[Int]

Finds the offset in an element's text nearest a point on the screen.

Finds the offset in an element's text nearest a point on the screen.

Value parameters

root

The element.

x

The point's distance from the window's left edge, in pixels.

y

The point's distance from the window's top edge, in pixels.

Attributes

Returns

The offset, if the point lies in the element.