7#include "../utility/module.hpp"
8#include "../unicode/module.hpp"
13namespace hi::inline
v1 {
24 constexpr text_cursor()
noexcept =
default;
25 constexpr text_cursor(text_cursor
const&)
noexcept =
default;
26 constexpr text_cursor(text_cursor&&)
noexcept =
default;
27 constexpr text_cursor& operator=(text_cursor
const&)
noexcept =
default;
28 constexpr text_cursor& operator=(text_cursor&&)
noexcept =
default;
29 [[nodiscard]]
constexpr friend bool operator==(text_cursor
const&, text_cursor
const&) =
default;
30 [[nodiscard]]
constexpr friend auto operator<=>(text_cursor
const&, text_cursor
const&) =
default;
45 constexpr text_cursor&
resize(
size_t size) &
noexcept
47 inplace_min(_value, max_value(size));
51 constexpr text_cursor resize(
size_t size) &&
noexcept
53 inplace_min(_value, max_value(size));
65 _value = (index << 1) | static_cast<size_t>(after);
74 [[nodiscard]]
constexpr text_cursor
neighbor(
size_t size)
const noexcept
76 auto r = before() ? text_cursor{index() - 1,
true} : text_cursor{index() + 1,
false};
77 return r.resize(size);
80 [[nodiscard]]
constexpr text_cursor after_neighbor(
size_t size)
const noexcept
82 return before() ? neighbor(size) : *this;
85 [[nodiscard]]
constexpr text_cursor before_neighbor(
size_t size)
const noexcept
87 return after() ? neighbor(size) : *this;
90 [[nodiscard]]
constexpr bool start_of_text() const noexcept
95 [[nodiscard]]
constexpr bool end_of_text(
size_t size)
const noexcept
97 return _value >= max_value(size);
100 [[nodiscard]]
constexpr size_t index() const noexcept
105 [[nodiscard]]
constexpr bool after() const noexcept
107 return to_bool(_value & 1);
110 [[nodiscard]]
constexpr bool before() const noexcept
121 [[nodiscard]]
constexpr static size_t max_value(
size_t size)
noexcept
DOXYGEN BUG.
Definition algorithm.hpp:13
A cursor-position in text.
Definition text_cursor.hpp:22
constexpr text_cursor & resize(size_t size) &noexcept
Set the text size.
Definition text_cursor.hpp:45
constexpr text_cursor(size_t index, bool after) noexcept
Create a new text cursor.
Definition text_cursor.hpp:63
constexpr text_cursor neighbor(size_t size) const noexcept
Return the neighbor cursor.
Definition text_cursor.hpp:74