5#include <portals/detail/pss_compact.hpp>
6#include <portals/style_static.hpp>
13void pssInvalidSyntax(PssError error);
17void pssInvalidSelector(PssError error);
21void pssUnknownProperty(PssError error);
25void pssInvalidValue(PssError error);
29void pssInvalidWidth(PssError error);
33void pssInvalidUtf8(PssError error);
37void pssLimitExceeded(PssError error);
43constexpr void rejectPss(PssError error) {
46 pssUnknownProperty(error);
50 pssInvalidValue(error);
54 pssInvalidWidth(error);
59 pssInvalidUtf8(error);
67 pssInvalidSelector(error);
77 pssLimitExceeded(error);
81 pssInvalidSyntax(error);
91template <PssErrorCode Code>
consteval bool pssReason() {
95 static_assert(Code ==
PssErrorCode::NONE,
"Invalid PSS selector: expected type, ID, class, state, or '*'");
105 static_assert(Code ==
PssErrorCode::NONE,
"Invalid PSS property value: expected RGB color or true/false");
108 "Invalid PSS min-width: expected nonnegative state-independent cell width");
110 static_assert(Code ==
PssErrorCode::NONE,
"Invalid UTF-8 in PSS input or source identity");
112 static_assert(Code ==
PssErrorCode::NONE,
"PSS input or source identity contains NUL");
118 static_assert(Code ==
PssErrorCode::NONE,
"PSS selector classes exceed MAX_CT_PSS_CLASSES");
120 static_assert(Code ==
PssErrorCode::NONE,
"PSS declaration occurrences exceed MAX_CT_PSS_DECLARATIONS");
122 static_assert(Code ==
PssErrorCode::NONE,
"PSS owned text exceeds MAX_CT_PSS_TEXT_BYTES");
124 static_assert(Code ==
PssErrorCode::NONE,
"PSS source identity exceeds MAX_CT_PSS_SOURCE_NAME_BYTES");
126 static_assert(Code ==
PssErrorCode::NONE,
"Expected PSS punctuation: '{', ':', ';', or '}'");
130 static_assert(Code ==
PssErrorCode::NONE,
"Invalid PSS input or owning output capacity");
143template <
PssErrorCode Code, std::size_t Offset, std::size_t Line, std::size_t Column,
144 std::array<char, MAX_PSS_ERROR_SUBJECT_BYTES> Subject>
146 static_assert(pssReason<Code>());
159constexpr std::expected<void, PssError> validateCtPssName(std::string_view name) {
161 return std::unexpected(
165 return portals::detail::validatePssUtf8(name);
172constexpr PssInspection inspectPss(std::string_view bytes, std::string_view sourceName) {
173 auto name = validateCtPssName(sourceName);
176 return {{}, name.error(),
false};
180 auto copied = sink.
text(sourceName.size(), {});
183 return {sink.counts, copied.error(),
false};
189 return {sink.counts, parsed.error(),
false};
192 return {sink.counts, {},
true};
215constexpr PssStaging stagePss(std::string_view bytes, std::string_view sourceName) {
217 auto name = validateCtPssName(sourceName);
220 result.error = name.error();
225 PssCompactSink sink(bytes, result.sheet);
226 auto copied = sink.sourceName(sourceName);
229 result.error = copied.error();
237 result.error = parsed.error();
253 { T{}() } -> std::same_as<std::string_view>;
264template <std::
size_t R, std::
size_t C, std::
size_t D, std::
size_t B>
265consteval auto buildPss(std::string_view bytes, std::string_view sourceName) {
268 auto copied = sink.sourceName(sourceName);
271 rejectPss(copied.error());
277 rejectPss(parsed.error());
289template <std::
size_t N>
constexpr std::string_view
text(
const char (&bytes)[N]) {
290 return {bytes, N - 1};
300template <std::
size_t N>
consteval auto pss(
const char (&bytes)[N], std::string_view sourceName = std::string_view{}) {
301 constexpr auto INPUT_BYTES = N - 1;
306 auto validName = detail::validateCtPssName(sourceName);
309 detail::rejectPss(validName.error());
312 return detail::buildPss<RULE_CAPACITY, CLASS_CAPACITY, DECLARATION_CAPACITY, BYTE_CAPACITY>({bytes, INPUT_BYTES},
324template <detail::PssSourceProv
ider Source, detail::PssSourceProv
ider Origin = detail::AnonymousPssSource>
325consteval auto pss(Source source, Origin origin = {}) {
329 constexpr auto BYTES = Source{}();
330 constexpr auto SOURCE_NAME = Origin{}();
331 constexpr auto STAGING = detail::stagePss(BYTES, SOURCE_NAME);
333 if constexpr (!STAGING.valid) {
334 (void)
sizeof(detail::PssFailure<STAGING.error.code, STAGING.error.location.offset, STAGING.error.location.line,
335 STAGING.error.location.column, STAGING.error.subject>);
337 return CompactSheet<0, 0, 0, 0>{};
339 CompactSheet<STAGING.sheet.
rules().size(), STAGING.sheet.classes().size(), STAGING.sheet.declarations().size(),
340 STAGING.sheet.ownedTextBytes()>
343 auto copied = sink.
copyFrom(STAGING.sheet);
346 detail::rejectPss(copied.error());
361template <std::
size_t R, std::
size_t C, std::
size_t D, std::
size_t B>
365 result.
rules.reserve(description.
rules().size());
367 for (
const auto &
rule : description.
rules()) {
376 for (
const auto &declaration : description.
declarations().subspan(
rule.declarationBegin,
rule.declarationCount)) {
377 portals::detail::assignPssDeclaration(declaration.property, declaration.value, target.
declarations);
381 for (std::size_t index = 0; index <
rule.classCount; ++index) {
385 result.
rules.push_back(target);
399template <std::
size_t R, std::
size_t C, std::
size_t D, std::
size_t B>
410 for (
const auto &
rule : description.
rules()) {
413 origin.
selector = detail::expandPosition(
rule.selector);
417 for (std::size_t index = 0; index <
rule.effectiveDeclaration.size(); ++index) {
420 :
rule.effectiveDeclaration[index];
423 result.
origins.push_back(origin);
426 for (
const auto &declaration : description.
declarations()) {
428 {declaration.ruleIndex, declaration.property, detail::expandPosition(declaration.location), declaration.value});
432 }
catch (
const std::bad_alloc &) {
437 return std::unexpected(error);
468 constexpr std::string_view
type() const noexcept {
473 constexpr std::string_view
id() const noexcept {
478 constexpr std::span<const std::string_view>
classes() const noexcept {
500 std::string_view type_;
501 std::string_view id_;
502 std::span<const std::string_view> classes_;
520 result.type_ = S::TYPE.view() ==
"*" ? std::string_view{} : S::TYPE.view();
521 result.id_ = S::ID.view();
522 result.classes_ = S::CLASS_NAMES;
523 result.state_ = state;
524 result.readOnly_ = readOnly;
525 result.values_ = values;
544 using Type = std::remove_cvref_t<
decltype(std::declval<std::tuple_element_t<Index, Tuple>>().initial)>;
578 std::same_as<typename LeftType::Type, RgbColor> &&
579 std::same_as<typename RightType::Type, RgbColor>;
586template <
class D,
class P>
consteval bool flatDeclarationTypeMatches() {
587 using Expression = std::remove_cvref_t<decltype(std::declval<D>().expression)>;
589 constexpr bool COLOR =
590 D::KIND == Property::FOREGROUND || D::KIND == Property::BACKGROUND || D::KIND == Property::FRAME_LINE_FOREGROUND ||
591 D::KIND == Property::FRAME_LINE_BACKGROUND || D::KIND == Property::FRAME_TITLE_FOREGROUND ||
592 D::KIND == Property::FRAME_TITLE_BACKGROUND || D::KIND == Property::FRAME_ENDS_FOREGROUND ||
593 D::KIND == Property::FRAME_ENDS_BACKGROUND || D::KIND == Property::SCROLLBAR_TRACK_FOREGROUND ||
594 D::KIND == Property::SCROLLBAR_TRACK_BACKGROUND || D::KIND == Property::SCROLLBAR_THUMB_START_FOREGROUND ||
595 D::KIND == Property::SCROLLBAR_THUMB_START_BACKGROUND || D::KIND == Property::SCROLLBAR_THUMB_BODY_FOREGROUND ||
596 D::KIND == Property::SCROLLBAR_THUMB_BODY_BACKGROUND || D::KIND == Property::SCROLLBAR_THUMB_END_FOREGROUND ||
597 D::KIND == Property::SCROLLBAR_THUMB_END_BACKGROUND || D::KIND == Property::SCROLLBAR_THUMB_SINGLE_FOREGROUND ||
598 D::KIND == Property::SCROLLBAR_THUMB_SINGLE_BACKGROUND || D::KIND == Property::SCROLLBAR_THUMB_FOREGROUND ||
599 D::KIND == Property::SCROLLBAR_THUMB_BACKGROUND || D::KIND == Property::SCROLLBAR_ENDS_FOREGROUND ||
600 D::KIND == Property::SCROLLBAR_ENDS_BACKGROUND || D::KIND == Property::SCROLLBAR_ARROWS_FOREGROUND ||
601 D::KIND == Property::SCROLLBAR_ARROWS_BACKGROUND || D::KIND == Property::SCROLLBAR_CORNER_FOREGROUND ||
602 D::KIND == Property::SCROLLBAR_CORNER_BACKGROUND || D::KIND == Property::SLIDER_TRACK_FOREGROUND ||
603 D::KIND == Property::SLIDER_TRACK_BACKGROUND || D::KIND == Property::SLIDER_FILL_FOREGROUND ||
604 D::KIND == Property::SLIDER_FILL_BACKGROUND || D::KIND == Property::SLIDER_THUMB_FOREGROUND ||
605 D::KIND == Property::SLIDER_THUMB_BACKGROUND;
606 constexpr bool METRIC = D::KIND == Property::MIN_WIDTH;
607 using Expected = std::conditional_t<
615 std::conditional_t<D::KIND == Property::GLYPH_FALLBACK,
GlyphFallback,
616 std::conditional_t<COLOR, RgbColor, std::conditional_t<METRIC, std::int32_t, bool>>>>>>>;
618 return std::same_as<Actual, Expected>;
624template <
class S>
consteval bool validFlatSelector() {
625 if (!S::TYPE.view().empty() && S::TYPE.view() !=
"*" && !portals::detail::isPssIdentifier(S::TYPE.view())) {
629 if (!S::ID.view().empty() && !portals::detail::isPssIdentifier(S::ID.view())) {
633 for (
const auto name : S::CLASS_NAMES) {
634 if (!portals::detail::isPssIdentifier(name)) {
646constexpr bool pssPropertyPresent(
PssProperty property,
const StyleDeclarations &value) {
649 return value.foreground.has_value();
651 return value.background.has_value();
653 return value.bold.has_value();
655 return value.italic.has_value();
657 return value.underline.has_value();
659 return value.frameLine.foreground.has_value();
661 return value.frameLine.background.has_value();
663 return value.frameLine.bold.has_value();
665 return value.frameLine.italic.has_value();
667 return value.frameLine.underline.has_value();
669 return value.frameTitle.foreground.has_value();
671 return value.frameTitle.background.has_value();
673 return value.frameTitle.bold.has_value();
675 return value.frameTitle.italic.has_value();
677 return value.frameTitle.underline.has_value();
679 return value.frameEnds.foreground.has_value();
681 return value.frameEnds.background.has_value();
683 return value.frameEnds.bold.has_value();
685 return value.frameEnds.italic.has_value();
687 return value.frameEnds.underline.has_value();
689 return value.scrollbarTrack.foreground.has_value();
691 return value.scrollbarTrack.background.has_value();
693 return value.scrollbarTrack.bold.has_value();
695 return value.scrollbarTrack.italic.has_value();
697 return value.scrollbarTrack.underline.has_value();
699 return value.scrollbarThumb.foreground.has_value();
701 return value.scrollbarThumb.background.has_value();
703 return value.scrollbarThumb.bold.has_value();
705 return value.scrollbarThumb.italic.has_value();
707 return value.scrollbarThumb.underline.has_value();
709 return value.scrollbarThumbStart.foreground.has_value();
711 return value.scrollbarThumbStart.background.has_value();
713 return value.scrollbarThumbStart.bold.has_value();
715 return value.scrollbarThumbStart.italic.has_value();
717 return value.scrollbarThumbStart.underline.has_value();
719 return value.scrollbarThumbBody.foreground.has_value();
721 return value.scrollbarThumbBody.background.has_value();
723 return value.scrollbarThumbBody.bold.has_value();
725 return value.scrollbarThumbBody.italic.has_value();
727 return value.scrollbarThumbBody.underline.has_value();
729 return value.scrollbarThumbEnd.foreground.has_value();
731 return value.scrollbarThumbEnd.background.has_value();
733 return value.scrollbarThumbEnd.bold.has_value();
735 return value.scrollbarThumbEnd.italic.has_value();
737 return value.scrollbarThumbEnd.underline.has_value();
739 return value.scrollbarThumbSingle.foreground.has_value();
741 return value.scrollbarThumbSingle.background.has_value();
743 return value.scrollbarThumbSingle.bold.has_value();
745 return value.scrollbarThumbSingle.italic.has_value();
747 return value.scrollbarThumbSingle.underline.has_value();
749 return value.scrollbarEnds.foreground.has_value();
751 return value.scrollbarEnds.background.has_value();
753 return value.scrollbarEnds.bold.has_value();
755 return value.scrollbarEnds.italic.has_value();
757 return value.scrollbarEnds.underline.has_value();
759 return value.scrollbarArrows.foreground.has_value();
761 return value.scrollbarArrows.background.has_value();
763 return value.scrollbarArrows.bold.has_value();
765 return value.scrollbarArrows.italic.has_value();
767 return value.scrollbarArrows.underline.has_value();
769 return value.scrollbarCorner.foreground.has_value();
771 return value.scrollbarCorner.background.has_value();
773 return value.scrollbarCorner.bold.has_value();
775 return value.scrollbarCorner.italic.has_value();
777 return value.scrollbarCorner.underline.has_value();
779 return value.scrollbarTrackPattern.has_value();
781 return value.scrollbarThumbPattern.has_value();
783 return value.scrollbarArrowPattern.has_value();
785 return value.sliderTrack.foreground.has_value();
787 return value.sliderTrack.background.has_value();
789 return value.sliderTrack.bold.has_value();
791 return value.sliderTrack.italic.has_value();
793 return value.sliderTrack.underline.has_value();
795 return value.sliderFill.foreground.has_value();
797 return value.sliderFill.background.has_value();
799 return value.sliderFill.bold.has_value();
801 return value.sliderFill.italic.has_value();
803 return value.sliderFill.underline.has_value();
805 return value.sliderThumb.foreground.has_value();
807 return value.sliderThumb.background.has_value();
809 return value.sliderThumb.bold.has_value();
811 return value.sliderThumb.italic.has_value();
813 return value.sliderThumb.underline.has_value();
815 return value.glyphProfile.has_value();
817 return value.glyphFallback.has_value();
819 return value.minWidth.has_value();
840 result.color = *value.foreground;
844 result.color = *value.background;
848 result.boolean = *value.bold;
852 result.boolean = *value.italic;
856 result.boolean = *value.underline;
860 result.color = *value.frameLine.foreground;
864 result.color = *value.frameLine.background;
868 result.boolean = *value.frameLine.bold;
872 result.boolean = *value.frameLine.italic;
876 result.boolean = *value.frameLine.underline;
880 result.color = *value.frameTitle.foreground;
884 result.color = *value.frameTitle.background;
888 result.boolean = *value.frameTitle.bold;
892 result.boolean = *value.frameTitle.italic;
896 result.boolean = *value.frameTitle.underline;
900 result.color = *value.frameEnds.foreground;
904 result.color = *value.frameEnds.background;
908 result.boolean = *value.frameEnds.bold;
912 result.boolean = *value.frameEnds.italic;
916 result.boolean = *value.frameEnds.underline;
920 result.color = *value.scrollbarTrack.foreground;
924 result.color = *value.scrollbarTrack.background;
928 result.boolean = *value.scrollbarTrack.bold;
932 result.boolean = *value.scrollbarTrack.italic;
936 result.boolean = *value.scrollbarTrack.underline;
940 result.color = *value.scrollbarThumb.foreground;
944 result.color = *value.scrollbarThumb.background;
948 result.boolean = *value.scrollbarThumb.bold;
952 result.boolean = *value.scrollbarThumb.italic;
956 result.boolean = *value.scrollbarThumb.underline;
960 result.color = *value.scrollbarThumbStart.foreground;
964 result.color = *value.scrollbarThumbStart.background;
968 result.boolean = *value.scrollbarThumbStart.bold;
972 result.boolean = *value.scrollbarThumbStart.italic;
976 result.boolean = *value.scrollbarThumbStart.underline;
980 result.color = *value.scrollbarThumbBody.foreground;
984 result.color = *value.scrollbarThumbBody.background;
988 result.boolean = *value.scrollbarThumbBody.bold;
992 result.boolean = *value.scrollbarThumbBody.italic;
996 result.boolean = *value.scrollbarThumbBody.underline;
1000 result.color = *value.scrollbarThumbEnd.foreground;
1004 result.color = *value.scrollbarThumbEnd.background;
1008 result.boolean = *value.scrollbarThumbEnd.bold;
1012 result.boolean = *value.scrollbarThumbEnd.italic;
1016 result.boolean = *value.scrollbarThumbEnd.underline;
1020 result.color = *value.scrollbarThumbSingle.foreground;
1024 result.color = *value.scrollbarThumbSingle.background;
1028 result.boolean = *value.scrollbarThumbSingle.bold;
1032 result.boolean = *value.scrollbarThumbSingle.italic;
1036 result.boolean = *value.scrollbarThumbSingle.underline;
1040 result.color = *value.scrollbarEnds.foreground;
1044 result.color = *value.scrollbarEnds.background;
1048 result.boolean = *value.scrollbarEnds.bold;
1052 result.boolean = *value.scrollbarEnds.italic;
1056 result.boolean = *value.scrollbarEnds.underline;
1060 result.color = *value.scrollbarArrows.foreground;
1064 result.color = *value.scrollbarArrows.background;
1068 result.boolean = *value.scrollbarArrows.bold;
1072 result.boolean = *value.scrollbarArrows.italic;
1076 result.boolean = *value.scrollbarArrows.underline;
1080 result.color = *value.scrollbarCorner.foreground;
1084 result.color = *value.scrollbarCorner.background;
1088 result.boolean = *value.scrollbarCorner.bold;
1092 result.boolean = *value.scrollbarCorner.italic;
1096 result.boolean = *value.scrollbarCorner.underline;
1100 result.pattern =
static_cast<std::int32_t
>(*value.scrollbarTrackPattern);
1104 result.pattern =
static_cast<std::int32_t
>(*value.scrollbarThumbPattern);
1108 result.pattern =
static_cast<std::int32_t
>(*value.scrollbarArrowPattern);
1112 result.color = *value.sliderTrack.foreground;
1116 result.color = *value.sliderTrack.background;
1120 result.boolean = *value.sliderTrack.bold;
1124 result.boolean = *value.sliderTrack.italic;
1128 result.boolean = *value.sliderTrack.underline;
1132 result.color = *value.sliderFill.foreground;
1136 result.color = *value.sliderFill.background;
1140 result.boolean = *value.sliderFill.bold;
1144 result.boolean = *value.sliderFill.italic;
1148 result.boolean = *value.sliderFill.underline;
1152 result.color = *value.sliderThumb.foreground;
1156 result.color = *value.sliderThumb.background;
1160 result.boolean = *value.sliderThumb.bold;
1164 result.boolean = *value.sliderThumb.italic;
1168 result.boolean = *value.sliderThumb.underline;
1172 result.pattern =
static_cast<std::int32_t
>(*value.glyphProfile);
1176 result.pattern =
static_cast<std::int32_t
>(*value.glyphFallback);
1180 result.width = *value.minWidth;
1210template <
class... P,
class S,
class... D>
1214 "Flat style parameter names must be unique and nonempty");
1215 static_assert(detail::validFlatSelector<S>(),
"Flat style selector requires PSS ASCII identifiers");
1220 Definitions>::TOKENS_KNOWN &&
1222 constexpr bool MIX_TYPES_VALID =
1224 Definitions>::MIX_TYPES_VALID &&
1226 constexpr bool TYPES_MATCH = (detail::flatDeclarationTypeMatches<D, Definitions>() && ...);
1229 if constexpr (!TOKENS_KNOWN) {
1230 static_assert(TOKENS_KNOWN,
"Static style token requires a known parameter");
1233 }
else if constexpr (!MIX_TYPES_VALID) {
1234 static_assert(MIX_TYPES_VALID,
"Static style mix requires color expressions");
1237 }
else if constexpr (!TYPES_MATCH) {
1238 static_assert(TYPES_MATCH,
"Static style declaration value type mismatch");
1244 detail::validateRule(
rule, definitions);
1247 selector.state, detail::declarations(
rule, definitions, definitions.defaults()),
selector.readOnly);
1257template <
class S,
class... D>
1258 requires(detail::IsPssSelector<S>::value && (detail::IsDeclaration<D>::value && ...))
1271template <std::
size_t N>
1272consteval auto compactSheet(
const std::array<FlatRule, N> &rules, std::string_view sourceName = std::string_view{}) {
1273 static_assert(N <=
MAX_CT_PSS_RULES,
"Compact style sheet exceeds the CT rule limit");
1276 auto validName = detail::validateCtPssName(sourceName);
1279 detail::rejectPss(validName.error());
1282 CompactSheet<RULE_CAPACITY, MAX_CT_PSS_CLASSES, DECLARATION_CAPACITY, MAX_CT_PSS_TEXT_BYTES> result;
1283 detail::PssCompactSink sink({}, result);
1287 const auto admit = [](std::expected<void, PssError> admitted) {
1289 detail::rejectPss(admitted.error());
1293 admit(sink.sourceName(sourceName));
1295 for (std::size_t index = 0; index < rules.size(); ++index) {
1296 const auto &
rule = rules[index];
1297 const PssLocation location{index, index + 1, 1};
1299 admit(sink.beginRule(location));
1300 admit(sink.typeName(
rule.type(), location));
1301 admit(sink.idName(
rule.id(), location));
1302 admit(sink.state(
rule.state()));
1303 if (
rule.readOnly()) {
1304 admit(sink.readOnly());
1307 for (
const auto name :
rule.classes()) {
1308 admit(sink.classBytes(name, location));
1312 const auto property =
static_cast<PssProperty>(propertyIndex);
1314 if (detail::pssPropertyPresent(property,
rule.values())) {
1315 admit(sink.declaration(property, detail::pssScalar(property,
rule.values()),
1316 {propertyIndex, index + 1, propertyIndex + 1}));
1320 admit(sink.endRule());
Immutable owning scalar stylesheet; its public type contains only numeric capacities.
Definition pss_compact.hpp:220
constexpr std::span< const detail::PssText > classes() const noexcept
Definition pss_compact.hpp:235
constexpr std::string_view sourceName() const noexcept
Definition pss_compact.hpp:256
constexpr std::span< const detail::PssCompactDeclaration > declarations() const noexcept
Definition pss_compact.hpp:240
constexpr std::span< const detail::PssCompactRule > rules() const noexcept
Definition pss_compact.hpp:230
constexpr std::string_view text(detail::PssText range) const noexcept
Definition pss_compact.hpp:247
constexpr PssOriginKind originKind() const noexcept
Definition pss_compact.hpp:261
Nongeneric typed scalar rule for bounded array construction. Selector views refer exclusively to stat...
Definition style_pss.hpp:462
constexpr std::string_view id() const noexcept
Definition style_pss.hpp:473
constexpr const StyleDeclarations & values() const noexcept
Definition style_pss.hpp:493
constexpr StyleState state() const noexcept
Definition style_pss.hpp:483
constexpr std::span< const std::string_view > classes() const noexcept
Definition style_pss.hpp:478
constexpr std::string_view type() const noexcept
Definition style_pss.hpp:468
constexpr FlatRule()=default
Construct a universal empty rule without borrowed names.
constexpr bool readOnly() const noexcept
Definition style_pss.hpp:488
Allocation-free storing sink writing one bounded owning descriptor.
Definition pss_compact.hpp:292
constexpr std::expected< void, PssError > copyFrom(const CompactSheet< SourceR, SourceC, SourceD, SourceB > &source)
Definition pss_compact.hpp:468
constexpr PssParser(std::string_view source, Sink &sink, PssPolicy policy, std::size_t maxBytes=MAX_PSS_BYTES, std::size_t maxRules=MAX_STYLE_RULES)
Definition pss_parser.hpp:376
Captureless provider retaining an explicit byte length.
Definition style_pss.hpp:252
Owning compile-time PSS v0 snapshots using the existing runtime cascade.
Definition pss_compact.hpp:8
StyleSheet materialize(const CompactSheet< R, C, D, B > &description)
Definition style_pss.hpp:362
std::expected< PssDocument, PssError > materializeDocument(const CompactSheet< R, C, D, B > &description)
Definition style_pss.hpp:400
consteval FlatRule flatRule(detail::Parameters< P... > definitions, S selector, D... declarations)
Evaluate one typed rule into nongeneric scalar data before array construction.
Definition style_pss.hpp:1212
consteval auto parameters(P... entries)
Definition style_static.hpp:804
consteval auto pss(const char(&bytes)[N], std::string_view sourceName=std::string_view{})
Convenient strict PSS literal snapshot, with bounded numeric public capacities.
Definition style_pss.hpp:300
consteval auto compactSheet(const std::array< FlatRule, N > &rules, std::string_view sourceName=std::string_view{})
Construct a bounded owning stylesheet from nongeneric typed rules.
Definition style_pss.hpp:1272
consteval auto selector(StyleState state=StyleState::ANY, bool readOnly=false)
Definition style_static.hpp:844
consteval auto rule(S target, D... declarations)
Definition style_static.hpp:1366
constexpr std::size_t MAX_CT_PSS_SOURCE_NAME_BYTES
Maximum caller-supplied compile-time UTF-8 source identity bytes.
Definition pss_compact.hpp:20
constexpr std::string_view text(const char(&bytes)[N])
Preserve the complete extent of a literal for rich compile-time diagnostics.
Definition style_pss.hpp:289
constexpr std::size_t MAX_CT_PSS_BYTES
Maximum compile-time source bytes, independently of the larger runtime budget.
Definition pss_compact.hpp:10
constexpr std::size_t MAX_CT_PSS_TEXT_BYTES
Maximum shared owning selector and source-identity text bytes.
Definition pss_compact.hpp:18
constexpr std::size_t MAX_CT_PSS_CLASSES
Maximum compile-time class predicates across the whole sheet.
Definition pss_compact.hpp:14
constexpr std::size_t MAX_CT_PSS_DECLARATIONS
Maximum compile-time declaration occurrences, including overwritten duplicates.
Definition pss_compact.hpp:16
constexpr std::size_t MAX_CT_PSS_RULES
Maximum compile-time source-order rules.
Definition pss_compact.hpp:12
constexpr std::size_t NO_PSS_DECLARATION
Marker for an absent effective declaration occurrence.
Definition pss_data.hpp:138
ScrollbarThumbPattern
Independent thumb source; all choices are opt-in.
Definition scrollbar_skin.hpp:24
PssProperty
PSS v0 declaration identities in metadata and compact descriptions.
Definition pss_data.hpp:13
@ UNDERLINE
Explicit underline flag.
Definition pss_data.hpp:18
@ SCROLLBAR_ARROWS_UNDERLINE
Scrollbar arrows underline.
Definition pss_data.hpp:54
@ SCROLLBAR_TRACK_PATTERN
Independent scrollbar source.
Definition pss_data.hpp:60
@ SCROLLBAR_TRACK_BOLD
Scrollbar track bold.
Definition pss_data.hpp:37
@ FRAME_LINE_FOREGROUND
Frame part frameLine.foreground.
Definition pss_data.hpp:20
@ SCROLLBAR_ARROWS_FOREGROUND
Scrollbar arrows foreground.
Definition pss_data.hpp:50
@ SCROLLBAR_THUMB_SINGLE_UNDERLINE
Thumb single underline.
Definition pss_data.hpp:82
@ SCROLLBAR_THUMB_START_BACKGROUND
Thumb start background.
Definition pss_data.hpp:64
@ ITALIC
Explicit italic flag.
Definition pss_data.hpp:17
@ BOLD
Explicit bold flag.
Definition pss_data.hpp:16
@ FRAME_ENDS_BACKGROUND
Frame part frameEnds.background.
Definition pss_data.hpp:31
@ SCROLLBAR_THUMB_FOREGROUND
Scrollbar thumb foreground.
Definition pss_data.hpp:40
@ SCROLLBAR_THUMB_START_UNDERLINE
Thumb start underline.
Definition pss_data.hpp:67
@ FRAME_ENDS_FOREGROUND
Frame part frameEnds.foreground.
Definition pss_data.hpp:30
@ SCROLLBAR_CORNER_FOREGROUND
Scrollbar corner foreground.
Definition pss_data.hpp:55
@ SCROLLBAR_THUMB_SINGLE_ITALIC
Thumb single italic.
Definition pss_data.hpp:81
@ SLIDER_THUMB_UNDERLINE
Slider thumb underline.
Definition pss_data.hpp:97
@ ROLE_ITALIC
Runtime named semantic role italic.
Definition pss_data.hpp:129
@ SLIDER_TRACK_BOLD
Slider track bold.
Definition pss_data.hpp:85
@ SLIDER_TRACK_ITALIC
Slider track italic.
Definition pss_data.hpp:86
@ FRAME_TITLE_BOLD
Frame part frameTitle.bold.
Definition pss_data.hpp:27
@ FRAME_LINE_BOLD
Frame part frameLine.bold.
Definition pss_data.hpp:22
@ SLIDER_FILL_UNDERLINE
Slider fill underline.
Definition pss_data.hpp:92
@ WIDTH
Runtime state-independent horizontal mode or exact extent.
Definition pss_data.hpp:121
@ MAX_WIDTH
Runtime state-independent hard column cap.
Definition pss_data.hpp:123
@ MIN_WIDTH
State-independent cell minimum.
Definition pss_data.hpp:19
@ SLIDER_FILL_BACKGROUND
Slider fill background.
Definition pss_data.hpp:89
@ SCROLLBAR_THUMB_BOLD
Scrollbar thumb bold.
Definition pss_data.hpp:42
@ SCROLLBAR_THUMB_BODY_BOLD
Thumb body bold.
Definition pss_data.hpp:70
@ FRAME_TITLE_UNDERLINE
Frame part frameTitle.underline.
Definition pss_data.hpp:29
@ FRAME_ENDS_ITALIC
Frame part frameEnds.italic.
Definition pss_data.hpp:33
@ FRAME_TITLE_BACKGROUND
Frame part frameTitle.background.
Definition pss_data.hpp:26
@ SCROLLBAR_THUMB_PATTERN
Independent scrollbar source.
Definition pss_data.hpp:61
@ GLYPH_FALLBACK
Portable admission fallback.
Definition pss_data.hpp:99
@ SCROLLBAR_THUMB_BODY_UNDERLINE
Thumb body underline.
Definition pss_data.hpp:72
@ SLIDER_FILL_ITALIC
Slider fill italic.
Definition pss_data.hpp:91
@ SCROLLBAR_ENDS_BOLD
Scrollbar ends bold.
Definition pss_data.hpp:47
@ ROLE_BACKGROUND
Runtime named semantic role background.
Definition pss_data.hpp:127
@ SCROLLBAR_THUMB_SINGLE_FOREGROUND
Thumb single foreground.
Definition pss_data.hpp:78
@ SCROLLBAR_THUMB_SINGLE_BOLD
Thumb single bold.
Definition pss_data.hpp:80
@ SCROLLBAR_THUMB_SINGLE_BACKGROUND
Thumb single background.
Definition pss_data.hpp:79
@ GLYPH_PROFILE
Named base glyph map.
Definition pss_data.hpp:98
@ SCROLLBAR_CORNER_ITALIC
Scrollbar corner italic.
Definition pss_data.hpp:58
@ FRAME_LINE_BACKGROUND
Frame part frameLine.background.
Definition pss_data.hpp:21
@ SCROLLBAR_THUMB_END_FOREGROUND
Thumb end foreground.
Definition pss_data.hpp:73
@ SLIDER_TRACK_FOREGROUND
Slider track foreground.
Definition pss_data.hpp:83
@ SCROLLBAR_THUMB_END_BOLD
Thumb end bold.
Definition pss_data.hpp:75
@ SCROLLBAR_THUMB_START_BOLD
Thumb start bold.
Definition pss_data.hpp:65
@ SCROLLBAR_ARROWS_BOLD
Scrollbar arrows bold.
Definition pss_data.hpp:52
@ SLIDER_TRACK_UNDERLINE
Slider track underline.
Definition pss_data.hpp:87
@ SCROLLBAR_TRACK_BACKGROUND
Scrollbar track background.
Definition pss_data.hpp:36
@ FRAME_LINE_ITALIC
Frame part frameLine.italic.
Definition pss_data.hpp:23
@ SCROLLBAR_CORNER_BOLD
Scrollbar corner bold.
Definition pss_data.hpp:57
@ BACKGROUND
RGB fill color.
Definition pss_data.hpp:15
@ ROLE_UNDERLINE
Runtime named semantic role underline.
Definition pss_data.hpp:130
@ SCROLLBAR_THUMB_UNDERLINE
Scrollbar thumb underline.
Definition pss_data.hpp:44
@ SCROLLBAR_THUMB_END_UNDERLINE
Thumb end underline.
Definition pss_data.hpp:77
@ SLIDER_FILL_BOLD
Slider fill bold.
Definition pss_data.hpp:90
@ SCROLLBAR_THUMB_ITALIC
Scrollbar thumb italic.
Definition pss_data.hpp:43
@ SCROLLBAR_THUMB_BODY_ITALIC
Thumb body italic.
Definition pss_data.hpp:71
@ SCROLLBAR_ENDS_FOREGROUND
Scrollbar ends foreground.
Definition pss_data.hpp:45
@ SCROLLBAR_THUMB_END_BACKGROUND
Thumb end background.
Definition pss_data.hpp:74
@ SCROLLBAR_THUMB_START_ITALIC
Thumb start italic.
Definition pss_data.hpp:66
@ FRAME_ENDS_UNDERLINE
Frame part frameEnds.underline.
Definition pss_data.hpp:34
@ SCROLLBAR_ARROWS_ITALIC
Scrollbar arrows italic.
Definition pss_data.hpp:53
@ SLIDER_FILL_FOREGROUND
Slider fill foreground.
Definition pss_data.hpp:88
@ SLIDER_TRACK_BACKGROUND
Slider track background.
Definition pss_data.hpp:84
@ SLIDER_THUMB_BOLD
Slider thumb bold.
Definition pss_data.hpp:95
@ ROLE_BOLD
Runtime named semantic role bold.
Definition pss_data.hpp:128
@ SCROLLBAR_ARROWS_BACKGROUND
Scrollbar arrows background.
Definition pss_data.hpp:51
@ SCROLLBAR_THUMB_BODY_BACKGROUND
Thumb body background.
Definition pss_data.hpp:69
@ SCROLLBAR_THUMB_START_FOREGROUND
Thumb start foreground.
Definition pss_data.hpp:63
@ SCROLLBAR_ARROW_PATTERN
Independent scrollbar source.
Definition pss_data.hpp:62
@ SLIDER_THUMB_FOREGROUND
Slider thumb foreground.
Definition pss_data.hpp:93
@ SCROLLBAR_TRACK_UNDERLINE
Scrollbar track underline.
Definition pss_data.hpp:39
@ SCROLLBAR_TRACK_FOREGROUND
Scrollbar track foreground.
Definition pss_data.hpp:35
@ SCROLLBAR_THUMB_BACKGROUND
Scrollbar thumb background.
Definition pss_data.hpp:41
@ SCROLLBAR_ENDS_ITALIC
Scrollbar ends italic.
Definition pss_data.hpp:48
@ SCROLLBAR_THUMB_BODY_FOREGROUND
Thumb body foreground.
Definition pss_data.hpp:68
@ SCROLLBAR_CORNER_UNDERLINE
Scrollbar corner underline.
Definition pss_data.hpp:59
@ FRAME_TITLE_FOREGROUND
Frame part frameTitle.foreground.
Definition pss_data.hpp:25
@ HEIGHT
Runtime state-independent vertical mode or exact extent.
Definition pss_data.hpp:122
@ FRAME_ENDS_BOLD
Frame part frameEnds.bold.
Definition pss_data.hpp:32
@ SCROLLBAR_THUMB_END_ITALIC
Thumb end italic.
Definition pss_data.hpp:76
@ SCROLLBAR_ENDS_UNDERLINE
Scrollbar ends underline.
Definition pss_data.hpp:49
@ FOREGROUND
RGB text color.
Definition pss_data.hpp:14
@ SLIDER_THUMB_ITALIC
Slider thumb italic.
Definition pss_data.hpp:96
@ ROLE_FOREGROUND
Runtime named semantic role foreground; name is occurrence metadata.
Definition pss_data.hpp:126
@ SLIDER_THUMB_BACKGROUND
Slider thumb background.
Definition pss_data.hpp:94
@ MAX_HEIGHT
Runtime state-independent hard row cap.
Definition pss_data.hpp:125
@ SCROLLBAR_TRACK_ITALIC
Scrollbar track italic.
Definition pss_data.hpp:38
@ SCROLLBAR_ENDS_BACKGROUND
Scrollbar ends background.
Definition pss_data.hpp:46
@ FRAME_LINE_UNDERLINE
Frame part frameLine.underline.
Definition pss_data.hpp:24
@ SCROLLBAR_CORNER_BACKGROUND
Scrollbar corner background.
Definition pss_data.hpp:56
@ FRAME_TITLE_ITALIC
Frame part frameTitle.italic.
Definition pss_data.hpp:28
@ MIN_HEIGHT
Runtime state-independent hard row minimum.
Definition pss_data.hpp:124
constexpr std::size_t PSS_SCALAR_PROPERTY_COUNT
Scalar-only prefix retained by compile-time PSS descriptors.
Definition pss_data.hpp:136
ScrollbarPattern
Opt-in scrollbar glyph presets; legacy calls retain their original appearance.
Definition scrollbar_skin.hpp:15
GlyphProfile
Explicit glyph map, independent of colors and geometry. NF maps use Nerd Fonts 3 Powerline codepoints...
Definition glyph_profile.hpp:12
GlyphFallback
Portable replacement when the selected map fails one-cell admission.
Definition glyph_profile.hpp:23
StyleState
Presentation states; ANY matches every state without changing behavior.
Definition style.hpp:26
@ ANY
Match all presentation variants.
Definition style.hpp:27
@ SYNTHETIC_TYPED
Ordinals in a typed snapshot; they are not C++ file coordinates.
Definition pss_data.hpp:149
ScrollbarArrowPattern
Independent functional-arrow source; selecting it never enables buttons.
Definition scrollbar_skin.hpp:32
PssErrorCode
Structured PSS errors independent of compiler wording.
Definition pss_data.hpp:153
@ RULE_LIMIT
Source-order rule count exceeds the selected budget.
Definition pss_data.hpp:156
@ INPUT_LIMIT
Input bytes exceed the selected budget.
Definition pss_data.hpp:155
@ UNTERMINATED_COMMENT
Missing comment terminator.
Definition pss_data.hpp:167
@ INVALID_WIDTH
Negative, overflowing, or state-dependent minimum width.
Definition pss_data.hpp:173
@ DOCUMENT_LIMIT
Runtime owning payload exceeds its logical budget.
Definition pss_data.hpp:160
@ UNKNOWN_PROPERTY
Unsupported v0 declaration name.
Definition pss_data.hpp:171
@ EXPECTED_PUNCTUATION
Missing required punctuation.
Definition pss_data.hpp:166
@ EXPECTED_IDENTIFIER
Expected an ASCII name.
Definition pss_data.hpp:165
@ DUPLICATE_STATE
More than one presentation-state predicate.
Definition pss_data.hpp:169
@ DUPLICATE_ID
More than one ID predicate in a selector.
Definition pss_data.hpp:168
@ EXPECTED_SELECTOR
No v0 selector at the current position.
Definition pss_data.hpp:164
@ CLASS_LIMIT
Compact class predicates exceed their budget.
Definition pss_data.hpp:157
@ NUL_BYTE
Embedded NUL in strict input or source identity.
Definition pss_data.hpp:163
@ NONE
Successful admission.
Definition pss_data.hpp:154
@ DECLARATION_LIMIT
Compact declaration occurrences exceed their budget.
Definition pss_data.hpp:158
@ INVALID_UTF8
Invalid UTF-8 sequence anywhere in strict input.
Definition pss_data.hpp:162
@ INVALID_VALUE
Value does not have the property's exact scalar syntax.
Definition pss_data.hpp:172
@ TEXT_LIMIT
Compact owning text exceeds its shared arena.
Definition pss_data.hpp:159
@ UNKNOWN_STATE
Unsupported presentation state.
Definition pss_data.hpp:170
@ ALLOCATION
Runtime allocation or checked ownership transfer failed.
Definition pss_data.hpp:174
@ SOURCE_NAME_LIMIT
Source identity exceeds its byte budget.
Definition pss_data.hpp:161
@ NO_MEMORY
Allocation failed inside the operation boundary.
Definition widget_types.hpp:33
std::variant< TreeError, StyleError, ApplicationError > cause
Unformatted original error; StyleError messages follow their static-storage contract.
Definition managed_diagnostics.hpp:66
Owning parsed declarations and provenance; input bytes need not survive the call. Metadata is not aut...
Definition pss_data.hpp:259
std::vector< PssRuleOrigin > origins
One origin per rule.
Definition pss_data.hpp:266
std::string sourceName
Owned caller-supplied source identity; empty means anonymous.
Definition pss_data.hpp:265
PssOriginKind originKind
Coordinate interpretation for this document.
Definition pss_data.hpp:264
std::vector< PssDeclarationOrigin > declarations
All occurrences.
Definition pss_data.hpp:267
StyleSheet sheet
Existing source-order runtime declarations, using the existing cascade.
Definition pss_data.hpp:263
Allocation-free error owning its bounded subject; message always has static lifetime.
Definition pss_data.hpp:203
Owning coordinates and occurrence links for one source-order rule.
Definition pss_data.hpp:219
std::size_t declarationBegin
First occurrence index in PssDocument::declarations.
Definition pss_data.hpp:221
PssLocation selector
Start of the complete conjunction selector.
Definition pss_data.hpp:220
std::array< std::size_t, PSS_PROPERTY_COUNT > effectiveDeclaration
Last occurrence for each property, or NO_PSS_DECLARATION.
Definition pss_data.hpp:223
std::size_t declarationCount
Number of occurrences, including overwritten duplicates.
Definition pss_data.hpp:222
Owning RGB color; terminal encoding belongs to the output adapter.
Definition cell_buffer.hpp:20
Typed declarations; absent values preserve less-specific rules or widget defaults.
Definition style.hpp:169
One owned selector/declaration pair in source order.
Definition style.hpp:205
StyleDeclarations declarations
Definition style.hpp:212
StyleSelector selector
Matching and specificity criteria.
Definition style.hpp:211
std::string type
Empty or * means any type.
Definition style.hpp:68
StyleState state
Optional presentation-state predicate.
Definition style.hpp:71
bool readOnly
True requires read-only; false adds no qualifier.
Definition style.hpp:72
std::vector< std::string > classes
Every named class is required.
Definition style.hpp:70
std::string id
Empty means any identity.
Definition style.hpp:69
Owned immutable-at-use rules; constructing typed values may allocate and throw.
Definition style.hpp:233
std::vector< StyleRule > rules
Source-order rules, at most MAX_STYLE_RULES when installed.
Definition style.hpp:239
Small validated scalar payload; avoids constructing six optional fields per parsed occurrence.
Definition pss_parser.hpp:22
Default anonymous provider preserves a zero-byte string_view extent.
Definition style_pss.hpp:196
constexpr std::string_view operator()() const
Definition style_pss.hpp:198
RgbColor Type
Accepted blends always evaluate to the existing RGB scalar.
Definition style_pss.hpp:575
FlatExpressionType< std::remove_cvref_t< Left >, P > LeftType
Existing by-value left operand semantics.
Definition style_pss.hpp:573
static constexpr bool MIX_TYPES_VALID
Exact RGB operands.
Definition style_pss.hpp:577
static constexpr bool TOKENS_KNOWN
Both identities resolved.
Definition style_pss.hpp:576
FlatExpressionType< std::remove_cvref_t< Right >, P > RightType
Existing by-value right operand semantics.
Definition style_pss.hpp:574
static constexpr bool MIX_TYPES_VALID
A token has no blend operands.
Definition style_pss.hpp:564
static constexpr bool TOKENS_KNOWN
Whether the identity belongs to this definition pack.
Definition style_pss.hpp:563
static constexpr auto INDEX
Safe name lookup result.
Definition style_pss.hpp:562
typename FlatParameterType< INDEX, std::tuple< P... >, TOKENS_KNOWN >::Type Type
Scalar or missing marker.
Definition style_pss.hpp:565
Type-only preflight keeps rejected flat expressions out of the existing evaluator.
Definition style_pss.hpp:552
static constexpr bool TOKENS_KNOWN
Definition style_pss.hpp:554
E Type
Direct scalar's exact type, with no implicit conversion.
Definition style_pss.hpp:553
static constexpr bool MIX_TYPES_VALID
Definition style_pss.hpp:555
std::remove_cvref_t< decltype(std::declval< std::tuple_element_t< Index, Tuple > >().initial)> Type
Existing defaults()/evaluate() copy the parameter scalar by value.
Definition style_pss.hpp:544
Safe parameter type lookup; a missing token never instantiates tuple_element out of range.
Definition style_pss.hpp:536
void Type
Missing-token marker, never evaluated as a scalar.
Definition style_pss.hpp:537
Bounded bridge preserving static identity lifetime independently of selector object lifetime.
Definition style_pss.hpp:510
static consteval FlatRule make(StyleState state, StyleDeclarations values, bool readOnly)
Definition style_pss.hpp:517
Recognize internal declaration types.
Definition style_static.hpp:302
Recognize the existing static owning conjunction selector types.
Definition style_pss.hpp:445
Internal acyclic color blend expression.
Definition style_static.hpp:70
Internal owning parameter pack.
Definition style_static.hpp:46
Allocation-free counting sink with the same limits as the storing sink.
Definition pss_compact.hpp:99
constexpr std::expected< void, PssError > text(std::size_t bytes, PssLocation location)
Definition pss_compact.hpp:191
Shared admission counts computed before exact-sized CT construction.
Definition pss_compact.hpp:91
Bounded C++23 diagnostic carrier; compiler formatting of subject bytes differs.
Definition style_pss.hpp:145
Admission counts and first error for a provider, without source ownership.
Definition style_pss.hpp:150
PssCounts counts
Admitted output counts, meaningful only when valid is true.
Definition style_pss.hpp:151
bool valid
Complete strict grammar and output admission succeeded.
Definition style_pss.hpp:153
PssError error
First owning diagnostic.
Definition style_pss.hpp:152
Private bounded owning staging result; no input bytes or template rule pack enter its type.
Definition style_pss.hpp:204
CompactSheet< MAX_CT_PSS_RULES, MAX_CT_PSS_CLASSES, MAX_CT_PSS_DECLARATIONS, MAX_CT_PSS_TEXT_BYTES > sheet
One temporary owning arena used only during immediate evaluation.
Definition style_pss.hpp:205
bool valid
Complete parse succeeded.
Definition style_pss.hpp:208
PssError error
First admission error.
Definition style_pss.hpp:207
Internal owning rule, validated by its containing sheet.
Definition style_static.hpp:283
Internal conjunction selector with static owning byte identities.
Definition style_static.hpp:259
Internal named expression leaf.
Definition style_static.hpp:62
Owning fixed-size bytes usable as a structural template argument.
Definition ui_static.hpp:15