FTXUI
6.1.9
C++ functional terminal UI.
Toggle main menu visibility
Loading...
Searching...
No Matches
screen.hpp
Go to the documentation of this file.
1
// Copyright 2020 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
#ifndef FTXUI_SCREEN_SCREEN_HPP
5
#define FTXUI_SCREEN_SCREEN_HPP
6
7
#include <cstdint>
// for uint8_t
8
#include <functional>
// for function
9
#include <string>
// for string, basic_string, allocator
10
#include <vector>
// for vector
11
12
#include "
ftxui/screen/image.hpp
"
// for Pixel, Image
13
#include "
ftxui/screen/terminal.hpp
"
// for Dimensions
14
#include "
ftxui/util/autoreset.hpp
"
// for AutoReset
15
16
namespace
ftxui
{
17
18
/// @brief Define how the Screen's dimensions should look like.
19
/// @ingroup screen
20
namespace
Dimension
{
21
Dimensions
Fixed
(
int
);
22
Dimensions
Full
();
23
}
// namespace Dimension
24
25
/// @brief A rectangular grid of Pixel.
26
/// @ingroup screen
27
class
Screen
:
public
Image
{
28
public
:
29
// Constructors:
30
Screen
(
int
dimx
,
int
dimy
);
31
static
Screen
Create
(
Dimensions
dimension);
32
static
Screen
Create
(
Dimensions
width,
Dimensions
height);
33
34
std::string
ToString
()
const
;
35
36
// Print the Screen on to the terminal.
37
void
Print
()
const
;
38
39
// Fill the screen with space and reset any screen state, like hyperlinks, and
40
// cursor
41
void
Clear
();
42
43
// Move the terminal cursor n-lines up with n = dimy().
44
std::string
ResetPosition
(
bool
clear =
false
)
const
;
45
46
void
ApplyShader
();
47
48
struct
Cursor
{
49
int
x
= 0;
50
int
y
= 0;
51
52
enum
Shape
{
53
Hidden
= 0,
54
BlockBlinking
= 1,
55
Block
= 2,
56
UnderlineBlinking
= 3,
57
Underline
= 4,
58
BarBlinking
= 5,
59
Bar
= 6,
60
};
61
Shape
shape
;
62
};
63
64
Cursor
cursor
()
const
{
return
cursor_
; }
65
void
SetCursor
(
Cursor
cursor
) {
cursor_
=
cursor
; }
66
67
// Store an hyperlink in the screen. Return the id of the hyperlink. The id is
68
// used to identify the hyperlink when the user click on it.
69
uint8_t
RegisterHyperlink
(
const
std::string& link);
70
const
std::string&
Hyperlink
(uint8_t
id
)
const
;
71
72
using
SelectionStyle
= std::function<void(
Pixel
&)>;
73
const
SelectionStyle
&
GetSelectionStyle
()
const
;
74
void
SetSelectionStyle
(
SelectionStyle
decorator);
75
76
protected
:
77
Cursor
cursor_
;
78
std::vector<std::string>
hyperlinks_
= {
""
};
79
80
// The current selection style. This is overridden by various dom elements.
81
SelectionStyle
selection_style_
= [](
Pixel
& pixel) {
82
pixel.inverted ^=
true
;
83
};
84
};
85
86
}
// namespace ftxui
87
88
#endif
// FTXUI_SCREEN_SCREEN_HPP
autoreset.hpp
ftxui::Image::dimy
int dimy() const
Definition
image.hpp:33
ftxui::Image::Image
Image()=delete
ftxui::Image::dimx
int dimx() const
Definition
image.hpp:32
ftxui::Screen::SelectionStyle
std::function< void(Pixel &)> SelectionStyle
Definition
screen.hpp:72
ftxui::Screen::ApplyShader
void ApplyShader()
Definition
screen.cpp:506
ftxui::Screen::GetSelectionStyle
const SelectionStyle & GetSelectionStyle() const
Return the current selection style.
Definition
screen.cpp:555
ftxui::Screen::Hyperlink
const std::string & Hyperlink(uint8_t id) const
Definition
screen.cpp:546
ftxui::Screen::ToString
std::string ToString() const
Definition
screen.cpp:415
ftxui::Screen::SetCursor
void SetCursor(Cursor cursor)
Definition
screen.hpp:65
ftxui::Screen::Create
static Screen Create(Dimensions dimension)
Create a screen with the given dimension.
Definition
screen.cpp:394
ftxui::Screen::RegisterHyperlink
uint8_t RegisterHyperlink(const std::string &link)
Definition
screen.cpp:533
ftxui::Screen::Screen
Screen(int dimx, int dimy)
Definition
screen.cpp:398
ftxui::Screen::cursor
Cursor cursor() const
Definition
screen.hpp:64
ftxui::Screen::ResetPosition
std::string ResetPosition(bool clear=false) const
Return a string to be printed in order to reset the cursor position to the beginning of the screen.
Definition
screen.cpp:475
ftxui::Screen::cursor_
Cursor cursor_
Definition
screen.hpp:77
ftxui::Screen::Clear
void Clear()
Clear all the pixel from the screen.
Definition
screen.cpp:494
ftxui::Screen::selection_style_
SelectionStyle selection_style_
Definition
screen.hpp:81
ftxui::Screen::SetSelectionStyle
void SetSelectionStyle(SelectionStyle decorator)
Set the current selection style.
Definition
screen.cpp:561
ftxui::Screen::hyperlinks_
std::vector< std::string > hyperlinks_
Definition
screen.hpp:78
ftxui::Screen::Print
void Print() const
Definition
screen.cpp:452
image.hpp
ftxui::Dimension
Define how the Screen's dimensions should look like.
Definition
elements.hpp:191
ftxui::Dimension::Fixed
Dimensions Fixed(int)
Definition
screen.cpp:375
ftxui::Dimension::Full
Dimensions Full()
Definition
screen.cpp:382
ftxui
Definition
animation.hpp:10
ftxui::Dimensions
Definition
terminal.hpp:8
ftxui::Pixel
A Unicode character and its associated style.
Definition
pixel.hpp:15
ftxui::Screen::Cursor
Definition
screen.hpp:48
ftxui::Screen::Cursor::y
int y
Definition
screen.hpp:50
ftxui::Screen::Cursor::Shape
Shape
Definition
screen.hpp:52
ftxui::Screen::Cursor::BlockBlinking
@ BlockBlinking
Definition
screen.hpp:54
ftxui::Screen::Cursor::Bar
@ Bar
Definition
screen.hpp:59
ftxui::Screen::Cursor::Block
@ Block
Definition
screen.hpp:55
ftxui::Screen::Cursor::Underline
@ Underline
Definition
screen.hpp:57
ftxui::Screen::Cursor::Hidden
@ Hidden
Definition
screen.hpp:53
ftxui::Screen::Cursor::UnderlineBlinking
@ UnderlineBlinking
Definition
screen.hpp:56
ftxui::Screen::Cursor::BarBlinking
@ BarBlinking
Definition
screen.hpp:58
ftxui::Screen::Cursor::x
int x
Definition
screen.hpp:49
ftxui::Screen::Cursor::shape
Shape shape
Definition
screen.hpp:61
terminal.hpp