StringMetrics.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2020-2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Types.h>
  8. #include <AK/Vector.h>
  9. namespace Line {
  10. struct StringMetrics {
  11. struct MaskedChar {
  12. size_t position { 0 };
  13. size_t original_length { 0 };
  14. size_t masked_length { 0 };
  15. };
  16. struct LineMetrics {
  17. Vector<MaskedChar> masked_chars;
  18. size_t length { 0 };
  19. size_t visible_length { 0 };
  20. Optional<size_t> bit_length { 0 };
  21. size_t total_length() const { return length; }
  22. };
  23. Vector<LineMetrics> line_metrics;
  24. size_t total_length { 0 };
  25. size_t max_line_length { 0 };
  26. size_t lines_with_addition(StringMetrics const& offset, size_t column_width) const;
  27. size_t offset_with_addition(StringMetrics const& offset, size_t column_width) const;
  28. void reset()
  29. {
  30. line_metrics.clear();
  31. total_length = 0;
  32. max_line_length = 0;
  33. line_metrics.append({ {}, 0 });
  34. }
  35. };
  36. }