AttributedString¶
A string that allows you to set attributes for text ranges. Attributed strings are commonly used to apply formatting to a string.
Declaration¶
namespace bdn {
class AttributedString
}
Construction¶
To create an instance of AttributedString simply call std::make_shared<AttributedString>(). A special implementation of std::make_shared will create the platform specific version of an AttributedString.
Serializing¶
-
virtual bool fromHTML(const std::string &html)
Replaces the contents of the
AttributedStringwith the givenhtmlmarkup code. -
virtual std::string toHTML() const
Returns the contents as a string containing HTML markup code.
Json¶
-
void fromJSON(const bdn::json& json)
Replaces the contents of the string with the data from
json.HTML form:
{"html" : <html-string>}Raw form:
{"string" : <raw string>, "ranges" : [ { "start" : <int>, "length" : <int>, attributes: { <name> : <value>, ... } }, ... ] } -
bdn::json toJSON() const
Returns the output of
toHTML()wrapped in ajsonobject.
Attributes¶
-
virtual void addAttribute(std::string attributeName, std::any value, Range range)
Adds an attribute to the specified
range. The value is converted using the typesfromAnyfunction.Attribute Name Type foreground-colorColor fontFont linkstd::string baseline-offsetfloat -
virtual void addAttributes(AttributeMap attributes, Range range)
Adds all attributes in
attributesto the specifiedrange.
Types¶
-
CreatorStack
A GlobalStack used to create platform specific versions of
AttributedString.