Skip to content
You are viewing documentation for v5.0.0. Switch to latest (main).

ftxui::Screen ​

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

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

Summary ​

SymbolDescription
stencil
Screen
atAccess a character in a cell at a given position.
PixelAtAccess a cell (Pixel) at a given position.
ToStringProduce a std::string that can be used to print the Screen on the terminal.
Print
dimx
dimy
ResetPositionReturn a string to be printed in order to reset the cursor position to the beginning of the screen.
ClearClear all the pixel from the screen.
ApplyShader
cursor
SetCursor
RegisterHyperlink
Hyperlink
CreateCreate a screen with the given dimension.

Public Attributes ​

stencil ​

cpp
Box stencil;

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

at ​

cpp
std::string & at(int x, int y);

Access a character in a cell at a given position.

Parameters:

  • x: The cell position along the x-axis.
  • y: The cell position along the y-axis.

at ​

cpp
const std::string & at(int x, int y) const;

Access a character in a cell at a given position.

Parameters:

  • x: The cell position along the x-axis.
  • y: The cell position along the y-axis.

PixelAt ​

cpp
Pixel & PixelAt(int x, int y);

Access a cell (Pixel) at a given position.

Parameters:

  • x: The cell position along the x-axis.
  • y: The cell position along the y-axis.

PixelAt ​

cpp
const Pixel & PixelAt(int x, int y) const;

Access a cell (Pixel) at a given position.

Parameters:

  • x: The cell position along the x-axis.
  • y: The cell position along the y-axis.

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;

dimx ​

cpp
int dimx() const;

dimy ​

cpp
int dimy() const;

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.

Clear ​

cpp
void Clear();

Clear all the pixel from the screen.

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;

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.