Skip to content
You are viewing documentation for v6.1.2. Switch to latest (main).

ftxui::Screen ​

cpp
#include <ftxui/screen/screen.hpp>

Inherits from: ftxui::Image

Derived classes: ftxui::ScreenInteractive

A rectangular grid of Pixel.

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 (+24 more)

Summary ​

SymbolDescription
SelectionStyle
Screen
ToStringProduce a std::string that can be used to print the Screen on the terminal.
Print
ClearClear all the pixel from the screen.
ResetPositionReturn a string to be printed in order to reset the cursor position to the beginning of the screen.
ApplyShader
cursor
SetCursor
RegisterHyperlink
Hyperlink
GetSelectionStyleReturn the current selection style.
SetSelectionStyleSet the current selection style.
CreateCreate a screen with the given dimension.

Public Types ​

SelectionStyle ​

cpp
using SelectionStyle = std::function< void(Pixel &)>;

Public Member Functions ​

Screen ​

cpp
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 (+24 more)

ToString ​

cpp
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();

Print ​

cpp
void Print() const;

Clear ​

cpp
void Clear();

Clear all the pixel from the screen.

ResetPosition ​

cpp
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.

cpp
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.

ApplyShader ​

cpp
void ApplyShader();

cursor ​

cpp
Cursor cursor() const;

SetCursor ​

cpp
void SetCursor(Cursor cursor);
cpp
uint8_t RegisterHyperlink(const std::string & link);
cpp
const std::string & Hyperlink(uint8_t id) const;

GetSelectionStyle ​

cpp
const SelectionStyle & GetSelectionStyle() const;

Return the current selection style.

See also: SetSelectionStyle

SetSelectionStyle ​

cpp
void SetSelectionStyle(SelectionStyle decorator);

Set the current selection style.

See also: GetSelectionStyle

Static Functions ​

Create ​

cpp
static Screen Create(Dimensions dimension);

Create a screen with the given dimension.

Create ​

cpp
static Screen Create(Dimensions width, Dimensions height);

Create a screen with the given dimension along the x-axis and y-axis.