ttx 0.1.0
Loading...
Searching...
No Matches
reflow_result.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/container/vector/prelude.h"
4#include "di/reflect/prelude.h"
5#include "di/types/integers.h"
7
8namespace ttx::terminal {
23private:
24 struct ReflowRange {
25 AbsolutePosition position;
26 i64 dr = 0;
27 i32 dc = 0;
28 bool absolute_column { false };
29
30 auto operator==(ReflowRange const&) const -> bool = default;
31
32 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<ReflowRange>) {
33 return di::make_fields<"ReflowRange">(di::field<"position", &ReflowRange::position>,
34 di::field<"dr", &ReflowRange::dr>, di::field<"dc", &ReflowRange::dc>,
35 di::field<"absolute_column", &ReflowRange::absolute_column>);
36 }
37 };
38
39public:
44 void add_offset(AbsolutePosition position, i64 dr, i32 dc, bool absolute_column = false);
45
50 void merge(ReflowResult&& other);
51
53 auto map_position(AbsolutePosition position) const -> AbsolutePosition;
54
55 auto operator==(ReflowResult const&) const -> bool = default;
56
57 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<ReflowResult>) {
58 return di::make_fields<"ReflowResult">(di::field<"ranges", &ReflowResult::m_ranges>);
59 }
60
61private:
62 di::Vector<ReflowRange> m_ranges;
63};
64}
Represents the result of reflowing a RowGroup.
Definition reflow_result.h:22
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< ReflowResult >)
Definition reflow_result.h:57
void merge(ReflowResult &&other)
Merge another reflow result with this one.
Definition reflow_result.cpp:25
auto operator==(ReflowResult const &) const -> bool=default
auto map_position(AbsolutePosition position) const -> AbsolutePosition
Map a provided position into the new coordinate space.
Definition reflow_result.cpp:54
void add_offset(AbsolutePosition position, i64 dr, i32 dc, bool absolute_column=false)
Add an offset for the given position to map to new coordinates.
Definition reflow_result.cpp:8
Definition absolute_position.h:6
Represents a coordinate anywhere in a screen, including scroll back.
Definition absolute_position.h:11