face.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include <string>
  3. #include <optional>
  4. #include <map>
  5. #include <memory>
  6. #include "lumacs/color.hpp"
  7. namespace lumacs {
  8. // Font weight
  9. enum class FontWeight {
  10. Normal,
  11. Bold,
  12. Light,
  13. };
  14. // Font slant
  15. enum class FontSlant {
  16. Normal,
  17. Italic,
  18. Oblique
  19. };
  20. struct FaceAttributes {
  21. // GUI-specific attributes (ignored in standard TUI/Ncurses)
  22. std::optional<std::string> family; // e.g., "Fira Code", "Arial"
  23. std::optional<int> height; // 1/10 pt. e.g., 120 = 12pt
  24. // Universal attributes (Supported in TUI via Bold/Italic flags)
  25. std::optional<FontWeight> weight; // Normal vs Bold
  26. std::optional<FontSlant> slant; // Normal vs Italic
  27. std::optional<Color> foreground;
  28. std::optional<Color> background;
  29. std::optional<bool> underline;
  30. std::optional<bool> inverse;
  31. std::optional<std::string> inherit; // Name of face to inherit from
  32. // Merging logic: apply other on top of this
  33. void merge(const FaceAttributes& other) {
  34. if (other.family) family = other.family;
  35. if (other.height) height = other.height;
  36. if (other.weight) weight = other.weight;
  37. if (other.slant) slant = other.slant;
  38. if (other.foreground) foreground = other.foreground;
  39. if (other.background) background = other.background;
  40. if (other.underline) underline = other.underline;
  41. if (other.inverse) inverse = other.inverse;
  42. if (other.inherit) inherit = other.inherit;
  43. }
  44. };
  45. class Face {
  46. public:
  47. Face(std::string name) : name_(std::move(name)) {}
  48. const std::string& name() const { return name_; }
  49. FaceAttributes& attributes() { return attributes_; }
  50. const FaceAttributes& attributes() const { return attributes_; }
  51. private:
  52. std::string name_;
  53. FaceAttributes attributes_;
  54. };
  55. } // namespace lumacs