92 return static_cast<std::size_t
>((format & (Bold | Italic)) |
106 format &=
static_cast<Format>(~VerticalPosition);
107 return static_cast<Format>(format | flag);
118 return (pos < formats.size()) ? formats[pos] :
Format(None);
127Format FormatForInsertionAt(
const wxString &text,
const Formats &formats,
150Formats Reconcile(
const wxString &oldText,
const Formats &oldFormats,
151 const wxString &newText,
bool hasPending =
false,
152 std::size_t pendingPos = 0, Format pendingFormat = None);
171std::vector<Run>
Runs(
const wxString &text,
const Formats &formats,
172 std::size_t start, std::size_t end);
180 std::size_t lineStart, std::size_t lineEnd);
194 wxString *unknownAttributes =
nullptr);
221std::vector<std::pair<std::size_t, std::size_t>>
ParseRanges(
const wxString &ranges);
226std::size_t
CodePointsBefore(
const wxString &text, std::size_t start, std::size_t index);
230 std::size_t codePoints);
std::vector< Run > Runs(const wxString &text, const Formats &formats, std::size_t start, std::size_t end)
Splits [start, end) of text into runs of equally formatted characters.
Definition: TextFormat.cpp:314
std::size_t CodePointsBefore(const wxString &text, std::size_t start, std::size_t index)
How many Unicode code points text[0, index) holds - which differs from index where wxString stores UT...
Definition: TextFormat.cpp:289
std::size_t IndexOfCodePoint(const wxString &text, std::size_t start, std::size_t codePoints)
The wxString index of the codePoints'th code point after start.
Definition: TextFormat.cpp:301
bool IsPlain(const Formats &formats)
Does this formatting vector describe plain text?
Definition: TextFormat.cpp:201
void ReadLine(const wxXmlNode *line, wxString &text, Formats &formats, wxString *unknownAttributes)
Append the text and formatting of a <line> element.
Definition: TextFormat.cpp:398
wxString LineAttributes(const wxString &text, const Formats &formats, std::size_t lineStart, std::size_t lineEnd)
The attributes that store the formatting of [lineStart, lineEnd) of text.
Definition: TextFormat.cpp:330
std::vector< std::pair< std::size_t, std::size_t > > ParseRanges(const wxString &ranges)
Parse a range list like "0-4,10-12" (half-open, in code points).
Definition: TextFormat.cpp:360
void ReadHTML(const wxString &html, wxString &text, Formats &formats)
The text and formatting of an HTML fragment other programs put on the clipboard.
Definition: TextFormat.cpp:584
constexpr std::size_t FontVariants
How many different fonts the WidthAffecting flags can ask for.
Definition: TextFormat.h:87
std::vector< Format > Formats
One Format per character, indexed like the text it belongs to; empty = plain.
Definition: TextFormat.h:111
Format At(const Formats &formats, std::size_t pos)
The format of character pos, None past the end (or for plain text).
Definition: TextFormat.h:117
constexpr Format VerticalPosition
The flags that move a character up or down. A character is never both.
Definition: TextFormat.h:97
constexpr Format WidthAffecting
The flags that change a character's width, and therefore the font it is measured and drawn with....
Definition: TextFormat.h:84
constexpr std::size_t FontIndex(Format format)
A number below FontVariants that tells the fonts the WidthAffecting flags ask for apart.
Definition: TextFormat.h:91
std::uint8_t Format
The formatting of one character: a combination of the flags below.
Definition: TextFormat.h:68
@ Superscript
Smaller, and raised above the baseline.
Definition: TextFormat.h:77
@ Subscript
Smaller, and lowered below the baseline.
Definition: TextFormat.h:79
constexpr Format WithFlag(Format format, Format flag)
The format that results from switching flag on in format.
Definition: TextFormat.h:104
A stretch of text whose characters all have the same format.
Definition: TextFormat.h:155
std::size_t end
The index after its last character.
Definition: TextFormat.h:159
std::size_t start
The index of its first character.
Definition: TextFormat.h:157