Skip to content
You are viewing documentation for v0.10. 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_style, dom/color_gallery, dom/color_info_palette256, dom/color_truecolor_HSV, dom/color_truecolor_RGB, dom/dbox, dom/gauge, dom/graph, dom/gridbox, dom/hflow, dom/html_like (+15 more)

Summary ​

SymbolDescription
stencil
Screen
atAccess a character a given position.
PixelAtAccess a Pixel at a given position.
ToStringProduce a std::string that can be used to print the Screen on the terminal. Don't forget to flush stdout. Alternatively, you can use Screen::Print();
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
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_style, dom/color_gallery, dom/color_info_palette256, dom/color_truecolor_HSV, dom/color_truecolor_RGB, dom/dbox, dom/gauge, dom/graph, dom/gridbox, dom/hflow, dom/html_like (+15 more)

at ​

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

Access a character a given position.

Parameters:

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

PixelAt ​

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

Access a Pixel at a given position.

Parameters:

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

ToString ​

cpp
std::string ToString();

Produce a std::string that can be used to print the Screen on the terminal. Don't forget to flush stdout. Alternatively, you can use Screen::Print();

Print ​

cpp
void Print();

dimx ​

cpp
int dimx();

dimy ​

cpp
int dimy();

ResetPosition ​

cpp
std::string ResetPosition(bool clear = false);

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

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.