chromium/third_party/dawn/src/tint/utils/text/text_style.h

// Copyright 2024 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#ifndef SRC_TINT_UTILS_TEXT_TEXT_STYLE_H_
#define SRC_TINT_UTILS_TEXT_TEXT_STYLE_H_

#include <cstdint>
#include <tuple>
#include <type_traits>

// Forward declarations
namespace tint {
template <typename... VALUES>
struct ScopedTextStyle;
}

namespace tint {

/// TextStyle is a styling that can be applied to span of a StyledText.
class TextStyle {};

/// ScopedTextStyle is a span of text, styled with a TextStyle
template <typename... VALUES>
struct ScopedTextStyle {};

template <typename... VALUES>
ScopedTextStyle<VALUES...> TextStyle::operator()(VALUES&&... values) const {}

namespace detail {
template <typename T>
struct IsScopedTextStyle : std::false_type {};
IsScopedTextStyle<ScopedTextStyle<VALUES...>>;
}  // namespace detail

/// Resolves to true iff T is a ScopedTextStyle.
IsScopedTextStyle;

}  // namespace tint

namespace tint::style {

/// Plain renders text without any styling
static constexpr TextStyle Plain =;
/// Bold renders text with a heavy weight
static constexpr TextStyle Bold =;
/// Underlined renders text with an underline
static constexpr TextStyle Underlined =;
/// Code renders without a single quote when printed as plain text.
static constexpr TextStyle NoQuote =;
/// Match renders text with the compare-match style
static constexpr TextStyle Match =;
/// Mismatch renders text with the compare-mismatch style
static constexpr TextStyle Mismatch =;
/// Success renders text with the styling for a successful status
static constexpr TextStyle Success =;
/// Warning renders text with the styling for a warning status
static constexpr TextStyle Warning =;
/// Error renders text with the styling for a error status
static constexpr TextStyle Error =;
/// Fatal renders text with the styling for a fatal status
static constexpr TextStyle Fatal =;
/// Code renders text with a 'code' style
static constexpr TextStyle Code =;
/// Keyword renders text with a 'code' style that represents a 'keyword' token
static constexpr TextStyle Keyword =;
/// Variable renders text with a 'code' style that represents a 'variable' token
static constexpr TextStyle Variable =;
/// Type renders text with a 'code' style that represents a 'type' token
static constexpr TextStyle Type =;
/// Function renders text with a 'code' style that represents a 'function' token
static constexpr TextStyle Function =;
/// Enum renders text with a 'code' style that represents a 'enum' token
static constexpr TextStyle Enum =;
/// Literal renders text with a 'code' style that represents a 'literal' token
static constexpr TextStyle Literal =;
/// Attribute renders text with a 'code' style that represents an 'attribute' token
static constexpr TextStyle Attribute =;
/// Comment renders text with a 'code' style that represents an 'comment' token
static constexpr TextStyle Comment =;
/// Label renders text with a 'code' style that represents an 'label' token
static constexpr TextStyle Label =;
/// Instruction renders text with a 'code' style that represents an 'instruction' token
static constexpr TextStyle Instruction =;
/// Squiggle renders text with a squiggle-highlight style (`^^^^^`)
static constexpr TextStyle Squiggle =;

}  // namespace tint::style

#endif  // SRC_TINT_UTILS_TEXT_TEXT_STYLE_H_