FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
selection.hpp
Go to the documentation of this file.
1// Copyright 2024 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4
5#ifndef FTXUI_DOM_SELECTION_HPP
6#define FTXUI_DOM_SELECTION_HPP
7
8#include <functional>
9
10#include <sstream>
11#include "ftxui/screen/box.hpp" // for Box
12#include "ftxui/screen/cell.hpp" // for Cell
13#include "ftxui/util/export.hpp" // for FTXUI_EXPORT
14
15namespace ftxui {
16
17/// @brief Represents a selection in a terminal user interface.
18///
19/// Selection is a class that represents the two endpoints of a selection in a
20/// terminal user interface.
21///
22/// @ingroup dom
23class FTXUI_EXPORT(DOM) Selection {
24 public:
25 Selection(); // Empty selection.
26 Selection(int start_x, int start_y, int end_x, int end_y);
27
28 const Box& GetBox() const;
29
30 Selection SaturateHorizontal(Box box);
31 Selection SaturateVertical(Box box);
32 bool IsEmpty() const { return empty_; }
33
34 void AddPart(std::string_view part, int y, int left, int right);
35 std::string GetParts() { return parts_.str(); }
36
37 private:
38 Selection(int start_x, int start_y, int end_x, int end_y, Selection* parent);
39
40 const int start_x_ = 0;
41 const int start_y_ = 0;
42 const int end_x_ = 0;
43 const int end_y_ = 0;
44 const Box box_ = {};
45 Selection* const parent_ = this;
46 const bool empty_ = true;
47 std::stringstream parts_;
48
49 // The position of the last inserted part.
50 int x_ = 0;
51 int y_ = 0;
52};
53
54} // namespace ftxui
55
56#endif /* end of include guard: FTXUI_DOM_SELECTION_HPP */
The FTXUI ftxui:: namespace.
Definition animation.hpp:11
std::uint8_t left
Definition screen.cpp:142
std::uint8_t right
Definition screen.cpp:144