Coverage Report

Created: 2025-03-04 07:22

/src/serenity/Userland/Libraries/LibLine/StringMetrics.h
Line
Count
Source (jump to first uncovered line)
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
12
namespace Line {
13
14
struct 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
0
        size_t total_length() const { return length; }
27
    };
28
29
    Vector<LineMetrics> line_metrics;
30
    Vector<size_t> grapheme_breaks {};
31
    size_t total_length { 0 };
32
    size_t max_line_length { 0 };
33
34
    size_t lines_with_addition(StringMetrics const& offset, size_t column_width) const;
35
    size_t offset_with_addition(StringMetrics const& offset, size_t column_width) const;
36
    void reset()
37
0
    {
38
0
        line_metrics.clear();
39
0
        total_length = 0;
40
0
        max_line_length = 0;
41
0
        line_metrics.append({ {}, 0 });
42
0
    }
43
};
44
45
}