FTXUI  5.0.0
C++ functional terminal UI.
ScreenInteractive Class Reference
+ Inheritance diagram for ScreenInteractive:

Data Structures

class  Private
 

Public Member Functions

void TrackMouse (bool enable=true)
 Set whether mouse is tracked and events reported. called outside of the main loop. E.g ScreenInteractive::Loop(...). More...
 
void Loop (Component)
 Execute the main loop. More...
 
void Exit ()
 Exit the main loop. More...
 
Closure ExitLoopClosure ()
 Return a function to exit the main loop. More...
 
void Post (Task task)
 Add a task to the main loop. It will be executed later, after every other scheduled tasks. More...
 
void PostEvent (Event event)
 Add an event to the main loop. It will be executed later, after every other scheduled events. More...
 
void RequestAnimationFrame ()
 Add a task to draw the screen one more time, until all the animations are done. More...
 
CapturedMouse CaptureMouse ()
 Try to get the unique lock about behing able to capture the mouse. More...
 
Closure WithRestoredIO (Closure)
 Decorate a function. It executes the same way, but with the currently active screen terminal hooks temporarilly uninstalled during its execution. More...
 
void ForceHandleCtrlC (bool force)
 Force FTXUI to handle or not handle Ctrl-C, even if the component catches the Event::CtrlC. More...
 
void ForceHandleCtrlZ (bool force)
 Force FTXUI to handle or not handle Ctrl-Z, even if the component catches the Event::CtrlZ. More...
 
std::string ToString () const
 
void Print () const
 
void Clear ()
 Clear all the pixel from the screen. More...
 
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. More...
 
void ApplyShader ()
 
Cursor cursor () const
 
void SetCursor (Cursor cursor)
 
uint8_t RegisterHyperlink (const std::string &link)
 
const std::string & Hyperlink (uint8_t id) const
 
std::string & at (int x, int y)
 Access a character in a cell at a given position. More...
 
const std::string & at (int x, int y) const
 Access a character in a cell at a given position. More...
 
PixelPixelAt (int x, int y)
 Access a cell (Pixel) at a given position. More...
 
const PixelPixelAt (int x, int y) const
 Access a cell (Pixel) at a given position. More...
 
int dimx () const
 
int dimy () const
 

Static Public Member Functions

static ScreenInteractive FixedSize (int dimx, int dimy)
 
static ScreenInteractive Fullscreen ()
 
static ScreenInteractive FullscreenPrimaryScreen ()
 
static ScreenInteractive FullscreenAlternateScreen ()
 
static ScreenInteractive FitComponent ()
 
static ScreenInteractive TerminalOutput ()
 
static ScreenInteractiveActive ()
 Return the currently active screen, or null if none. More...
 
static Screen Create (Dimensions dimension)
 Create a screen with the given dimension. More...
 
static Screen Create (Dimensions width, Dimensions height)
 Create a screen with the given dimension along the x-axis and y-axis. More...
 

Data Fields

friend Private
 
Box stencil
 

Protected Attributes

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

Detailed Description

Definition at line 29 of file screen_interactive.hpp.

Member Function Documentation

◆ FixedSize()

ScreenInteractive FixedSize ( int  dimx,
int  dimy 
)
static

Definition at line 359 of file screen_interactive.cpp.

◆ Fullscreen()

◆ FullscreenPrimaryScreen()

ScreenInteractive FullscreenPrimaryScreen ( )
static

Create a ScreenInteractive taking the full terminal size. The primary screen buffer is being used. It means if the terminal is resized, the previous content might mess up with the terminal content.

Definition at line 382 of file screen_interactive.cpp.

◆ FullscreenAlternateScreen()

ScreenInteractive FullscreenAlternateScreen ( )
static

Create a ScreenInteractive taking the full terminal size. This is using the alternate screen buffer to avoid messing with the terminal content.

Definition at line 395 of file screen_interactive.cpp.

◆ FitComponent()

◆ TerminalOutput()

◆ TrackMouse()

void TrackMouse ( bool  enable = true)

Set whether mouse is tracked and events reported. called outside of the main loop. E.g ScreenInteractive::Loop(...).

Parameters
enableWhether to enable mouse event tracking.
Note
This muse be called outside of the main loop. E.g. before calling ScreenInteractive::Loop.
Mouse tracking is enabled by default.
Mouse tracking is only supported on terminals that supports it.

Example

screen.TrackMouse(false);
screen.Loop(component);
static ScreenInteractive TerminalOutput()

Definition at line 440 of file screen_interactive.cpp.

◆ Active()

ScreenInteractive * Active ( )
static

Return the currently active screen, or null if none.

Definition at line 581 of file screen_interactive.cpp.

◆ Loop()

void Loop ( Component  component)

Execute the main loop.

Parameters
componentThe component to draw.
Examples
examples/component/collapsible.cpp.

Definition at line 494 of file screen_interactive.cpp.

◆ Exit()

void Exit ( )

Exit the main loop.

Definition at line 944 of file screen_interactive.cpp.

◆ ExitLoopClosure()

Closure ExitLoopClosure ( )

Return a function to exit the main loop.

Definition at line 938 of file screen_interactive.cpp.

◆ Post()

void Post ( Task  task)

Add a task to the main loop. It will be executed later, after every other scheduled tasks.

Definition at line 447 of file screen_interactive.cpp.

◆ PostEvent()

void PostEvent ( Event  event)

Add an event to the main loop. It will be executed later, after every other scheduled events.

Definition at line 460 of file screen_interactive.cpp.

◆ RequestAnimationFrame()

void RequestAnimationFrame ( )

Add a task to draw the screen one more time, until all the animations are done.

Definition at line 466 of file screen_interactive.cpp.

◆ CaptureMouse()

CapturedMouse CaptureMouse ( )

Try to get the unique lock about behing able to capture the mouse.

Returns
A unique lock if the mouse is not already captured, otherwise a null.

Definition at line 482 of file screen_interactive.cpp.

◆ WithRestoredIO()

Closure WithRestoredIO ( Closure  fn)

Decorate a function. It executes the same way, but with the currently active screen terminal hooks temporarilly uninstalled during its execution.

Parameters
fnThe function to decorate.

Definition at line 559 of file screen_interactive.cpp.

◆ ForceHandleCtrlC()

void ForceHandleCtrlC ( bool  force)

Force FTXUI to handle or not handle Ctrl-C, even if the component catches the Event::CtrlC.

Definition at line 569 of file screen_interactive.cpp.

◆ ForceHandleCtrlZ()

void ForceHandleCtrlZ ( bool  force)

Force FTXUI to handle or not handle Ctrl-Z, even if the component catches the Event::CtrlZ.

Definition at line 575 of file screen_interactive.cpp.

◆ Create() [1/2]

◆ Create() [2/2]

Screen Create ( Dimensions  width,
Dimensions  height 
)
staticinherited

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

Definition at line 382 of file screen.cpp.

◆ ToString()

std::string ToString ( ) const
inherited

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 409 of file screen.cpp.

◆ Print()

void Print ( ) const
inherited

Definition at line 446 of file screen.cpp.

◆ Clear()

void Clear ( )
inherited

Clear all the pixel from the screen.

Definition at line 488 of file screen.cpp.

◆ ResetPosition()

std::string ResetPosition ( bool  clear = false) const
inherited

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:388
Dimensions Fit(Element &, bool extend_beyond_screen=false)
Definition: util.cpp:93
Dimensions Full()
Definition: screen.cpp:376
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Definition: node.cpp:47
Returns
The string to print in order to reset the cursor position to the beginning.

Definition at line 469 of file screen.cpp.

◆ ApplyShader()

void ApplyShader ( )
inherited

Definition at line 500 of file screen.cpp.

◆ cursor()

Cursor cursor ( ) const
inlineinherited

Definition at line 62 of file screen.hpp.

◆ SetCursor()

void SetCursor ( Cursor  cursor)
inlineinherited

Definition at line 63 of file screen.hpp.

◆ RegisterHyperlink()

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

Definition at line 527 of file screen.cpp.

◆ Hyperlink()

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

Definition at line 540 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

◆ Private

friend Private

Definition at line 139 of file screen_interactive.hpp.

◆ cursor_

Cursor cursor_
protectedinherited

Definition at line 71 of file screen.hpp.

◆ hyperlinks_

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

Definition at line 72 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: