CArcTextEditing
- Module
- Arc
- Header
#include "Arc/Text/CArcTextEditing.h"- Namespace
Arcf
Constructors
| Signature | Name | Description |
|---|---|---|
CArcTextEditing() = delete | CArcTextEditing |
Public functions
| Returns | Name | Description |
|---|---|---|
int32_t | NextGrapheme | |
int32_t | PrevGrapheme | |
int32_t | SnapToGrapheme | The cluster boundary at or before pos — where a hit test that landed inside a cluster belongs. |
int32_t | CountGraphemes | |
void | GraphemeBoundaries | Byte offset of every cluster start, plus text.size() at the end. |
int32_t | NextWordStart | Ctrl+Right: past the word (or punctuation run) the caret is in, then past the whitespace after it. |
int32_t | PrevWordStart | Ctrl+Left: back over whitespace, then to the start of the word before it. |
void | WordAt | The word, punctuation run or whitespace run under pos — what a double-click selects. |
std::string | ToSingleLine | Line breaks of every flavour (CRLF, CR, LF, U+2028/2029) become one space each: what a paste into a single-line field must do, or a name field turns into a multi-line string. |
std::string | MaskPassword | One mask glyph per grapheme. |
void | SelectionRects | Highlight rectangles, in layout space, for the logical byte range [lo, hi). |
Function details
CArcTextEditing
CArcTextEditing() = deleteNextGrapheme
static int32_t NextGrapheme(const std::string& text, int32_t pos)PrevGrapheme
static int32_t PrevGrapheme(const std::string& text, int32_t pos)SnapToGrapheme
static int32_t SnapToGrapheme(const std::string& text, int32_t pos)The cluster boundary at or before pos — where a hit test that landed inside a cluster belongs.
CountGraphemes
static int32_t CountGraphemes(const std::string& text)GraphemeBoundaries
static void GraphemeBoundaries(const std::string& text, std::vector<int32_t>& outBoundaries)Byte offset of every cluster start, plus text.size() at the end.
NextWordStart
static int32_t NextWordStart(const std::string& text, int32_t pos, EArcWordTailoring tailoring = EArcWordTailoring::DotIsBoundary)Ctrl+Right: past the word (or punctuation run) the caret is in, then past the whitespace after it.
PrevWordStart
static int32_t PrevWordStart(const std::string& text, int32_t pos, EArcWordTailoring tailoring = EArcWordTailoring::DotIsBoundary)Ctrl+Left: back over whitespace, then to the start of the word before it.
WordAt
static void WordAt(const std::string& text, int32_t pos, int32_t& outStart, int32_t& outEnd, EArcWordTailoring tailoring = EArcWordTailoring::DotIsBoundary)The word, punctuation run or whitespace run under pos — what a double-click selects.
ToSingleLine
static std::string ToSingleLine(const std::string& text)Line breaks of every flavour (CRLF, CR, LF, U+2028/2029) become one space each: what a paste into a single-line field must do, or a name field turns into a multi-line string.
MaskPassword
static std::string MaskPassword(const std::string& text, const char* maskUtf8, std::vector<int32_t>& outSourceOffsets)One mask glyph per grapheme. outSourceOffsets gets, for every mask glyph index, the source byte offset it stands for (plus the end), so a hit on the mask maps back to a cluster boundary in the source.
SelectionRects
static void SelectionRects(const CArcTextLayout& layout, uint32_t lo, uint32_t hi, std::vector<ArcRect>& outRects)Highlight rectangles, in layout space, for the logical byte range [lo, hi). Glyphs are visited in visual order and every selected run becomes its own rect, so a selection across a direction change paints the glyphs that are actually selected instead of one span from the first caret to the last.