text_isolated_emoji.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #pragma once
  8. #include "base/variant.h"
  9. #include "ui/emoji_config.h"
  10. namespace Ui::Text {
  11. inline constexpr auto kIsolatedEmojiLimit = 3;
  12. struct IsolatedEmoji {
  13. using Item = std::variant<v::null_t, EmojiPtr, QString>;
  14. using Items = std::array<Item, kIsolatedEmojiLimit>;
  15. Items items = {};
  16. [[nodiscard]] bool empty() const {
  17. return v::is_null(items[0]);
  18. }
  19. [[nodiscard]] explicit operator bool() const {
  20. return !empty();
  21. }
  22. [[nodiscard]] bool operator<(const IsolatedEmoji &other) const {
  23. return items < other.items;
  24. }
  25. [[nodiscard]] bool operator==(const IsolatedEmoji &other) const {
  26. return items == other.items;
  27. }
  28. [[nodiscard]] bool operator>(const IsolatedEmoji &other) const {
  29. return other < *this;
  30. }
  31. [[nodiscard]] bool operator<=(const IsolatedEmoji &other) const {
  32. return !(other < *this);
  33. }
  34. [[nodiscard]] bool operator>=(const IsolatedEmoji &other) const {
  35. return !(*this < other);
  36. }
  37. [[nodiscard]] bool operator!=(const IsolatedEmoji &other) const {
  38. return !(*this == other);
  39. }
  40. };
  41. struct OnlyCustomEmoji {
  42. struct Item {
  43. QString entityData;
  44. int spacesBefore = 0;
  45. };
  46. std::vector<std::vector<Item>> lines;
  47. [[nodiscard]] bool empty() const {
  48. return lines.empty();
  49. }
  50. [[nodiscard]] explicit operator bool() const {
  51. return !empty();
  52. }
  53. };
  54. } // namespace Ui::Text