HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
v1::text_cursor Class Reference

#include <hikogui/text/text_cursor.hpp>

Public Member Functions

constexpr text_cursor (text_cursor const &) noexcept=default
constexpr text_cursor (text_cursor &&) noexcept=default
constexpr text_cursor & operator= (text_cursor const &) noexcept=default
constexpr text_cursor & operator= (text_cursor &&) noexcept=default
constexpr text_cursor & resize (size_t size) &noexcept
 Set the text size.
constexpr text_cursor resize (size_t size) &&noexcept
constexpr text_cursor (size_t index, bool after) noexcept
 Create a new text cursor.
constexpr text_cursor neighbor (size_t size) const noexcept
 Return the neighbor cursor.
constexpr text_cursor after_neighbor (size_t size) const noexcept
constexpr text_cursor before_neighbor (size_t size) const noexcept
constexpr bool start_of_text () const noexcept
constexpr bool end_of_text (size_t size) const noexcept
constexpr size_t index () const noexcept
constexpr bool after () const noexcept
constexpr bool before () const noexcept

Friends

constexpr friend bool operator== (text_cursor const &, text_cursor const &)=default
constexpr friend auto operator<=> (text_cursor const &, text_cursor const &)=default

Detailed Description

A cursor-position in text.

The cursor position takes into account the index of the character and if it is in front or behind this character. This allows for more detailed positioning inside bidirectional text.

Constructor & Destructor Documentation

◆ text_cursor()

v1::text_cursor::text_cursor ( size_t index,
bool after )
inlineconstexprnoexcept

Create a new text cursor.

Parameters
indexThe character where the cursor is.
afterTrue if the cursor is after the character, false if the cursor is before the character

Member Function Documentation

◆ neighbor()

text_cursor v1::text_cursor::neighbor ( size_t size) const
inlinenodiscardconstexprnoexcept

Return the neighbor cursor.

Parameters
sizeThe text size.
Returns
The cursor that is the neighbor of the this cursor. If this cursor is at start-of-text or end-of-text then this cursor is returned.

◆ resize()

text_cursor & v1::text_cursor::resize ( size_t size) &
inlineconstexprnoexcept

Set the text size.

This function will clamp the cursor position inside the actual text. It should be called before the cursor position is used to select characters in a text.

The cursor position after this function will be:

  • In the same position if the character still exists in the text.
  • After the last character in the text if the text is non-empty.
  • Before the first character in the text if the text is empty.
Parameters
sizeThe size of the text string that this cursor points into.

The documentation for this class was generated from the following file: