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