MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ move()

MAYAFLUX_API void MayaFlux::Portal::Text::move ( EditableText &  s,
int  n 
)

Move the cursor by n codepoints.

Positive n moves toward the end of the text, negative toward the start. Clamps at whichever text boundary is reached first rather than wrapping or erroring on an out-of-range count.

Definition at line 20 of file TextEdit.cpp.

21{
22 if (n > 0) {
23 for (int i = 0; i < n && s.cursor < s.text.size(); ++i)
25 } else {
26 for (int i = 0; i > n && s.cursor > 0; --i)
27 s.cursor = previous_codepoint_offset(s.text, s.cursor);
28 }
29}
size_t next_codepoint_offset(std::string_view text, size_t byte_offset)
Byte offset of the codepoint boundary after byte_offset.

References MayaFlux::Portal::Text::EditableText::cursor, next_codepoint_offset(), previous_codepoint_offset(), and MayaFlux::Portal::Text::EditableText::text.

Referenced by MayaFlux::Portal::Forma::TextField::wire().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: