ftxui::Screen
#include <ftxui/screen/screen.hpp>Inherits from: ftxui::Surface
Derived classes: ftxui::App
A rectangular grid of Cell.
Examples: dom/border, dom/border_colored, dom/border_style, dom/canvas, dom/color_gallery, dom/color_info_palette256, dom/color_truecolor_HSV, dom/color_truecolor_RGB, dom/dbox, dom/gauge, dom/gauge_direction, dom/graph (+25 more)
Summary
| Symbol | Description |
|---|---|
SelectionStyle | |
Screen | |
~Screen | |
operator= | |
ToString | Produce a std::string that can be used to print the Screen on the terminal. |
Print | |
Clear | Clear all the cells from the screen. |
ResetPosition | Return a string to be printed in order to reset the cursor position to the beginning of the screen. |
ApplyShader | |
cursor | |
SetCursor | |
RegisterHyperlink | |
Hyperlink | |
GetSelectionStyle | Return the current selection style. |
SetSelectionStyle | Set the current selection style. |
Create | Create a screen with the given dimension. |
Public Types
SelectionStyle
using SelectionStyle = std::function< void(Cell &)>;Public Member Functions
Screen
Screen(int dimx, int dimy);Examples: dom/border, dom/border_colored, dom/border_style, dom/canvas, dom/color_gallery, dom/color_info_palette256, dom/color_truecolor_HSV, dom/color_truecolor_RGB, dom/dbox, dom/gauge, dom/gauge_direction, dom/graph (+25 more)
~Screen
~Screen();Screen
Examples: dom/border, dom/border_colored, dom/border_style, dom/canvas, dom/color_gallery, dom/color_info_palette256, dom/color_truecolor_HSV, dom/color_truecolor_RGB, dom/dbox, dom/gauge, dom/gauge_direction, dom/graph (+25 more)
operator=
ToString
std::string ToString() const;Produce a std::string that can be used to print the Screen on the terminal.
Note
Don't forget to flush stdout. Alternatively, you can use Screen::Print();
ToString
void ToString(std::string & ss) const;Produce a std::string that can be used to print the Screen on the terminal.
Parameters:
ss: The string to append to.
ToString
Produce a std::string updating the terminal from previous to this Screen. Only the cells that changed are printed.
Parameters:
ss: The string to append to.previous: The Screen currently displayed. The cursor must be at its top-left corner. It ends where ToString() would leave it.
Print
void Print() const;Clear
void Clear();Clear all the cells from the 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.
std::string reset_position;
while(true) {
auto document = render();
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document);
std::cout << reset_position << screen.ToString() << std::flush;
reset_position = screen.ResetPosition();
using namespace std::chrono_literals;
std::this_thread::sleep_for(0.01s);
}Returns: The string to print in order to reset the cursor position to the beginning.
ResetPosition
void ResetPosition(std::string & ss, bool clear = false) const;Append to a string in order to reset the cursor position to the beginning of the screen.
Parameters:
ss: The string to append to.clear: Whether to clear the screen or not.
ApplyShader
void ApplyShader();cursor
Cursor cursor() const;SetCursor
void SetCursor(Cursor cursor);RegisterHyperlink
uint8_t RegisterHyperlink(std::string_view link);Hyperlink
const std::string & Hyperlink(uint8_t id) const;GetSelectionStyle
const SelectionStyle & GetSelectionStyle() const;Return the current selection style.
See also: SetSelectionStyle
SetSelectionStyle
void SetSelectionStyle(SelectionStyle decorator);Set the current selection style.
See also: GetSelectionStyle
Static Functions
Create
static Screen Create(Dimensions dimension);Create a screen with the given dimension.
Create
static Screen Create(Dimensions width, Dimensions height);Create a screen with the given dimension along the x-axis and y-axis.