FTXUI
6.1.9
C++ functional terminal UI.
Toggle main menu visibility
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/pixel.hpp
"
// for Pixel
13
14
namespace
ftxui
{
15
16
/// @brief Represent a selection in the terminal.
17
class
Selection
{
18
public
:
19
Selection
();
// Empty selection.
20
Selection
(
int
start_x,
int
start_y,
int
end_x,
int
end_y);
21
22
const
Box
&
GetBox
()
const
;
23
24
Selection
SaturateHorizontal
(
Box
box);
25
Selection
SaturateVertical
(
Box
box);
26
bool
IsEmpty
()
const
{
return
empty_; }
27
28
void
AddPart
(
const
std::string& part,
int
y,
int
left,
int
right);
29
std::string
GetParts
() {
return
parts_.str(); }
30
31
private
:
32
Selection
(
int
start_x,
int
start_y,
int
end_x,
int
end_y,
Selection
* parent);
33
34
const
int
start_x_ = 0;
35
const
int
start_y_ = 0;
36
const
int
end_x_ = 0;
37
const
int
end_y_ = 0;
38
const
Box
box_ = {};
39
Selection
*
const
parent_ =
this
;
40
const
bool
empty_ =
true
;
41
std::stringstream parts_;
42
43
// The position of the last inserted part.
44
int
x_ = 0;
45
int
y_ = 0;
46
};
47
48
}
// namespace ftxui
49
50
#endif
/* end of include guard: FTXUI_DOM_SELECTION_HPP */
box.hpp
ftxui::Selection
Represent a selection in the terminal.
Definition
selection.hpp:17
ftxui::Selection::GetBox
const Box & GetBox() const
Get the box of the selection.
Definition
selection.cpp:67
ftxui::Selection::GetParts
std::string GetParts()
Definition
selection.hpp:29
ftxui::Selection::IsEmpty
bool IsEmpty() const
Definition
selection.hpp:26
ftxui::Selection::AddPart
void AddPart(const std::string &part, int y, int left, int right)
Definition
selection.cpp:146
ftxui::Selection::SaturateVertical
Selection SaturateVertical(Box box)
Saturate the selection to be inside the box. This is called by vbox to propagate the selection to its...
Definition
selection.cpp:113
ftxui::Selection::Selection
Selection()
Create an empty selection.
ftxui::Selection::SaturateHorizontal
Selection SaturateHorizontal(Box box)
Saturate the selection to be inside the box. This is called by hbox to propagate the selection to its...
Definition
selection.cpp:75
ftxui
Definition
animation.hpp:10
pixel.hpp
ftxui::Box
Definition
box.hpp:9