Terminal++ 4.0.1.23
A C++ library for interacting with ANSI terminal windows
Loading...
Searching...
No Matches
attribute.hpp
1#pragma once
2
3#include "terminalpp/colour.hpp"
4#include "terminalpp/effect.hpp"
5
6#include <boost/container_hash/hash.hpp>
7
8#include <iosfwd>
9
10namespace terminalpp {
11
12//* =========================================================================
15//* =========================================================================
16struct TERMINALPP_EXPORT attribute
17{
18 //* =====================================================================
20 //* =====================================================================
21 [[nodiscard]] friend std::size_t hash_value(attribute const &attr) noexcept
22 {
23 std::size_t seed = 0;
24 boost::hash_combine(seed, attr.foreground_colour_);
25 boost::hash_combine(seed, attr.background_colour_);
26 boost::hash_combine(seed, attr.intensity_);
27 boost::hash_combine(seed, attr.underlining_);
28 boost::hash_combine(seed, attr.polarity_);
29 boost::hash_combine(seed, attr.blinking_);
30
31 return seed;
32 }
33
34 //* =====================================================================
36 //* =====================================================================
37 [[nodiscard]] constexpr friend auto operator<=>(
38 attribute const &lhs, attribute const &rhs) noexcept = default;
39
40 // Graphics Attributes
41 colour foreground_colour_;
42 colour background_colour_;
43 intensity intensity_;
44 underlining underlining_;
45 polarity polarity_;
46 blinking blinking_;
47};
48
49//* =========================================================================
52//* =========================================================================
53TERMINALPP_EXPORT
54std::ostream &operator<<(std::ostream &out, attribute const &attr);
55
56} // namespace terminalpp
57
58namespace std {
59
60template <>
61struct hash<terminalpp::attribute>
62{
64 using result_type = std::size_t;
65
66 [[nodiscard]] result_type operator()(
67 argument_type const &attr) const noexcept
68 {
69 return hash_value(attr);
70 }
71};
72
73} // namespace std
A structure that carries around the presentation attributes of an ANSI element.
Definition attribute.hpp:17
constexpr friend auto operator<=>(attribute const &lhs, attribute const &rhs) noexcept=default
Relational operators for attributes.
friend std::size_t hash_value(attribute const &attr) noexcept
Hash function.
Definition attribute.hpp:21
Structure representing a sum type of the available colour styles.
Definition colour.hpp:218