FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
Screen Class Reference

A rectangular grid of Pixel. More...

#include <screen.hpp>

+ Inheritance diagram for Screen:
+ Collaboration diagram for Screen:

Data Structures

struct  Cursor
 

Public Types

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

Public Member Functions

 Screen (int dimx, int dimy)
 
std::string ToString () const
 
void Print () const
 
void Clear ()
 Clear all the pixel from the screen.
 
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.
 
void ApplyShader ()
 
Cursor cursor () const
 
void SetCursor (Cursor cursor)
 
uint8_t RegisterHyperlink (const std::string &link)
 
const std::string & Hyperlink (uint8_t id) const
 
const SelectionStyleGetSelectionStyle () const
 Return the current selection style.
 
void SetSelectionStyle (SelectionStyle decorator)
 Set the current selection style.
 
std::string & at (int x, int y)
 Access a character in a cell at a given position.
 
const std::string & at (int x, int y) const
 Access a character in a cell at a given position.
 
PixelPixelAt (int x, int y)
 Access a cell (Pixel) at a given position.
 
const PixelPixelAt (int x, int y) const
 Access a cell (Pixel) at a given position.
 
int dimx () const
 
int dimy () const
 

Static Public Member Functions

static Screen Create (Dimensions dimension)
 Create a screen with the given dimension.
 
static Screen Create (Dimensions width, Dimensions height)
 Create a screen with the given dimension along the x-axis and y-axis.
 

Data Fields

Box stencil
 

Protected Attributes

Cursor cursor_
 
std::vector< std::string > hyperlinks_ = {""}
 
SelectionStyle selection_style_
 
int dimx_
 
int dimy_
 
std::vector< std::vector< Pixel > > pixels_
 

Detailed Description

A rectangular grid of Pixel.

Examples
examples/dom/dbox.cpp, examples/dom/gauge.cpp, and examples/dom/gauge_direction.cpp.

Definition at line 27 of file screen.hpp.

Member Typedef Documentation

◆ SelectionStyle

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

Definition at line 72 of file screen.hpp.

Constructor & Destructor Documentation

◆ Screen()

Screen ( int dimx,
int dimy )

Definition at line 398 of file screen.cpp.

Member Function Documentation

◆ Create() [1/2]

Screen Create ( Dimensions dimension)
static

Create a screen with the given dimension.

Definition at line 394 of file screen.cpp.

◆ Create() [2/2]

Screen Create ( Dimensions width,
Dimensions height )
static

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

Definition at line 388 of file screen.cpp.

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

Definition at line 415 of file screen.cpp.

◆ Print()

void Print ( ) const

Definition at line 452 of file screen.cpp.

◆ Clear()

void Clear ( )

Clear all the pixel from the screen.

Definition at line 494 of file screen.cpp.

◆ 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);
}
static Screen Create(Dimensions dimension)
Create a screen with the given dimension.
Definition screen.cpp:394
Dimensions Fit(Element &, bool extend_beyond_screen=false)
Dimensions Full()
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Definition node.cpp:88
Returns
The string to print in order to reset the cursor position to the beginning.

Definition at line 475 of file screen.cpp.

◆ ApplyShader()

void ApplyShader ( )

Definition at line 506 of file screen.cpp.

◆ cursor()

Cursor cursor ( ) const
inline

Definition at line 64 of file screen.hpp.

◆ SetCursor()

void SetCursor ( Cursor cursor)
inline

Definition at line 65 of file screen.hpp.

◆ RegisterHyperlink()

std::uint8_t RegisterHyperlink ( const std::string & link)

Definition at line 533 of file screen.cpp.

◆ Hyperlink()

const std::string & Hyperlink ( uint8_t id) const

Definition at line 546 of file screen.cpp.

◆ GetSelectionStyle()

const Screen::SelectionStyle & GetSelectionStyle ( ) const

Return the current selection style.

See also
SetSelectionStyle

Definition at line 555 of file screen.cpp.

◆ SetSelectionStyle()

void SetSelectionStyle ( SelectionStyle decorator)

Set the current selection style.

See also
GetSelectionStyle

Definition at line 561 of file screen.cpp.

◆ at() [1/2]

std::string & at ( int x,
int y )
inherited

Access a character in a cell at a given position.

Parameters
xThe cell position along the x-axis.
yThe cell position along the y-axis.

Definition at line 29 of file image.cpp.

◆ at() [2/2]

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

Access a character in a cell at a given position.

Parameters
xThe cell position along the x-axis.
yThe cell position along the y-axis.

Definition at line 36 of file image.cpp.

◆ PixelAt() [1/2]

Pixel & PixelAt ( int x,
int y )
inherited

Access a cell (Pixel) at a given position.

Parameters
xThe cell position along the x-axis.
yThe cell position along the y-axis.

Definition at line 43 of file image.cpp.

◆ PixelAt() [2/2]

const Pixel & PixelAt ( int x,
int y ) const
inherited

Access a cell (Pixel) at a given position.

Parameters
xThe cell position along the x-axis.
yThe cell position along the y-axis.

Definition at line 50 of file image.cpp.

◆ dimx()

int dimx ( ) const
inlineinherited

Definition at line 32 of file image.hpp.

◆ dimy()

int dimy ( ) const
inlineinherited

Definition at line 33 of file image.hpp.

Field Documentation

◆ cursor_

Cursor cursor_
protected

Definition at line 77 of file screen.hpp.

◆ hyperlinks_

std::vector<std::string> hyperlinks_ = {""}
protected

Definition at line 78 of file screen.hpp.

◆ selection_style_

SelectionStyle selection_style_
protected
Initial value:
= [](Pixel& pixel) {
pixel.inverted ^= true;
}

Definition at line 81 of file screen.hpp.

◆ stencil

Box stencil
inherited

Definition at line 38 of file image.hpp.

◆ dimx_

int dimx_
protectedinherited

Definition at line 41 of file image.hpp.

◆ dimy_

int dimy_
protectedinherited

Definition at line 42 of file image.hpp.

◆ pixels_

std::vector<std::vector<Pixel> > pixels_
protectedinherited

Definition at line 43 of file image.hpp.


The documentation for this class was generated from the following files: