ladybird/Userland/Libraries/LibVT/Attribute.h
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30

69 lines
1.8 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/EnumBits.h>
#include <AK/Noncopyable.h>
#include <AK/Vector.h>
#include <LibVT/Color.h>
#include <LibVT/XtermColors.h>
#ifndef KERNEL
# include <AK/ByteString.h>
#endif
namespace VT {
struct Attribute {
static constexpr Color default_foreground_color = Color::named(Color::ANSIColor::DefaultForeground);
static constexpr Color default_background_color = Color::named(Color::ANSIColor::DefaultBackground);
void reset()
{
foreground_color = default_foreground_color;
background_color = default_background_color;
flags = Flags::NoAttributes;
#ifndef KERNEL
href = {};
href_id = {};
#endif
}
Color foreground_color { default_foreground_color };
Color background_color { default_background_color };
#ifndef KERNEL
ByteString href;
Optional<ByteString> href_id;
#endif
enum class Flags : u8 {
NoAttributes = 0x00,
Bold = 0x01,
Italic = 0x02,
Underline = 0x04,
Negative = 0x08,
Blink = 0x10,
Touched = 0x20,
};
AK_ENUM_BITWISE_FRIEND_OPERATORS(Flags);
constexpr Color effective_background_color() const { return has_flag(flags, Flags::Negative) ? foreground_color : background_color; }
constexpr Color effective_foreground_color() const { return has_flag(flags, Flags::Negative) ? background_color : foreground_color; }
constexpr bool is_untouched() const { return !has_flag(flags, Flags::Touched); }
Flags flags { Flags::NoAttributes };
constexpr bool operator==(Attribute const& other) const
{
return foreground_color == other.foreground_color && background_color == other.background_color && flags == other.flags;
}
};
}