Loading...
Searching...
No Matches
ScreenInteractive Class Reference
Inheritance diagram for ScreenInteractive:
[legend]

## Data Structures

class | Private

## Public Types

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

## 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(...).
void | Loop (Component)
| Execute the main loop.
void | Exit ()
| Exit the main loop.
Closure | ExitLoopClosure ()
| Return a function to exit the main loop.
void | Post (Task task)
| Add a task to the main loop. It will be executed later, after every other scheduled tasks.
void | PostEvent (Event event)
| Add an event to the main loop. It will be executed later, after every other scheduled events.
void | RequestAnimationFrame ()
| Add a task to draw the screen one more time, until all the animations are done.
CapturedMouse | CaptureMouse ()
| Try to get the unique lock about behing able to capture the mouse.
Closure | WithRestoredIO (Closure)
| Decorate a function. It executes the same way, but with the currently active screen terminal hooks temporarilly uninstalled during its execution.
void | ForceHandleCtrlC (bool force)
| Force FTXUI to handle or not handle Ctrl-C, even if the component catches the Event::CtrlC.
void | ForceHandleCtrlZ (bool force)
| Force FTXUI to handle or not handle Ctrl-Z, even if the component catches the Event::CtrlZ.
std::string | GetSelection ()
| Returns the content of the current selection.
void | SelectionChange (std::function< void()> callback)
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 SelectionStyle & | GetSelectionStyle () 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.
Pixel & | PixelAt (int x, int y)
| Access a cell (Pixel) at a given position.
const Pixel & | PixelAt (int x, int y) const
| Access a cell (Pixel) at a given position.
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 ScreenInteractive * | Active ()
| Return the currently active screen, or null if none.
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

friend | Private
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

Definition at line 30 of file screen_interactive.hpp.

## Member Typedef Documentation

## SelectionStyle

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

inherited

Definition at line 72 of file screen.hpp.

## Member Function Documentation

## FixedSize()

ScreenInteractive FixedSize | ( | int | dimx,
|  | int | dimy )

static

Definition at line 360 of file screen_interactive.cpp.

## Fullscreen()

ScreenInteractive Fullscreen | ( |  | ) |

static

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

Note
  This is the same as ScreenInteractive::FullscreenAlternateScreen()

Examples
  examples/component/button.cpp, examples/component/flexbox_gallery.cpp, examples/component/focus.cpp, examples/component/focus_cursor.cpp, examples/component/homescreen.cpp, examples/component/linear_gradient_gallery.cpp, examples/component/resizable_split.cpp, examples/component/scrollbar.cpp, examples/component/textarea.cpp, examples/component/window.cpp, and examples/component/with_restored_io.cpp.

Definition at line 374 of file screen_interactive.cpp.

## 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 383 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 396 of file screen_interactive.cpp.

## FitComponent()

ScreenInteractive FitComponent | ( |  | ) |

static

Examples
  examples/component/button_animated.cpp, examples/component/button_in_frame.cpp, examples/component/button_style.cpp, examples/component/canvas_animated.cpp, examples/component/checkbox.cpp, examples/component/checkbox_in_frame.cpp, examples/component/collapsible.cpp, examples/component/composition.cpp, examples/component/custom_loop.cpp, examples/component/dropdown.cpp, examples/component/dropdown_custom.cpp, examples/component/gallery.cpp, examples/component/menu_in_frame.cpp, examples/component/menu_in_frame_horizontal.cpp, examples/component/nested_screen.cpp, examples/component/radiobox_in_frame.cpp, and examples/component/renderer.cpp.

Definition at line 416 of file screen_interactive.cpp.

## TerminalOutput()

ScreenInteractive TerminalOutput | ( |  | ) |

static

Examples
  examples/component/input.cpp, examples/component/input_in_frame.cpp, examples/component/input_style.cpp, examples/component/maybe.cpp, examples/component/menu.cpp, examples/component/menu2.cpp, examples/component/menu_entries.cpp, examples/component/menu_entries_animated.cpp, examples/component/menu_multiple.cpp, examples/component/menu_style.cpp, examples/component/menu_underline_animated_gallery.cpp, examples/component/modal_dialog.cpp, examples/component/modal_dialog_custom.cpp, examples/component/print_key_press.cpp, examples/component/radiobox.cpp, examples/component/selection.cpp, examples/component/slider.cpp, examples/component/slider_direction.cpp, examples/component/slider_rgb.cpp, examples/component/tab_horizontal.cpp, examples/component/tab_vertical.cpp, and examples/component/toggle.cpp.

Definition at line 406 of file screen_interactive.cpp.

## 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

  enable | Whether 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

auto screen = ScreenInteractive::TerminalOutput();
screen.TrackMouse(false);
screen.Loop(component);
ftxui::ScreenInteractive::TerminalOutput
static ScreenInteractive TerminalOutput()
Definition screen_interactive.cpp:406

Definition at line 441 of file screen_interactive.cpp.

## Active()

ScreenInteractive * Active | ( |  | ) |

static

Return the currently active screen, or null if none.

Definition at line 594 of file screen_interactive.cpp.

## Loop()

void Loop | ( | Component | component | ) |

Execute the main loop.

Parameters

  component | The component to draw.

Definition at line 495 of file screen_interactive.cpp.

## Exit()

void Exit | ( |  | ) |

Exit the main loop.

Definition at line 1032 of file screen_interactive.cpp.

## ExitLoopClosure()

Closure ExitLoopClosure | ( |  | ) |

Return a function to exit the main loop.

Definition at line 1026 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 448 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 461 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 467 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 483 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

  fn | The function to decorate.

Definition at line 560 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 570 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 576 of file screen_interactive.cpp.

## GetSelection()

std::string GetSelection | ( |  | ) |

Returns the content of the current selection.

Definition at line 581 of file screen_interactive.cpp.

## SelectionChange()

void SelectionChange | ( | std::function< void()> | callback | ) |

Definition at line 588 of file screen_interactive.cpp.

## Create() [1/2]

Screen Create | ( | Dimensions | dimension | ) |

static inherited

Create a screen with the given dimension.

Examples
  examples/dom/border.cpp, examples/dom/border_colored.cpp, examples/dom/border_style.cpp, examples/dom/canvas.cpp, examples/dom/color_gallery.cpp, examples/dom/color_info_palette256.cpp, examples/dom/color_truecolor_HSV.cpp, examples/dom/color_truecolor_RGB.cpp, examples/dom/dbox.cpp, examples/dom/graph.cpp, examples/dom/gridbox.cpp, examples/dom/hflow.cpp, examples/dom/html_like.cpp, examples/dom/linear_gradient.cpp, examples/dom/package_manager.cpp, examples/dom/paragraph.cpp, examples/dom/separator.cpp, examples/dom/separator_style.cpp, examples/dom/size.cpp, examples/dom/spinner.cpp, examples/dom/style_blink.cpp, examples/dom/style_bold.cpp, examples/dom/style_color.cpp, examples/dom/style_dim.cpp, examples/dom/style_gallery.cpp, examples/dom/style_hyperlink.cpp, examples/dom/style_inverted.cpp, examples/dom/style_italic.cpp, examples/dom/style_strikethrough.cpp, examples/dom/style_underlined.cpp, examples/dom/style_underlined_double.cpp, examples/dom/table.cpp, examples/dom/vbox_hbox.cpp, and examples/dom/vflow.cpp.

Definition at line 394 of file screen.cpp.

## Create() [2/2]

Screen Create | ( | Dimensions | width,
|  | Dimensions | height )

static inherited

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

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

## Print()

void Print | ( |  | ) | const

inherited

Definition at line 452 of file screen.cpp.

## Clear()

void Clear | ( |  | ) |

inherited

Clear all the pixel from the screen.

Definition at line 494 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);
}
ftxui::Screen::Create
static Screen Create(Dimensions dimension)
Create a screen with the given dimension.
Definition screen.cpp:394
ftxui::Dimension::Fit
Dimensions Fit(Element &, bool extend_beyond_screen=false)
Definition util.cpp:93
ftxui::Dimension::Full
Dimensions Full()
Definition screen.cpp:382
ftxui::Render
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 | ( |  | ) |

inherited

Definition at line 506 of file screen.cpp.

## cursor()

Cursor cursor | ( |  | ) | const

inline inherited

Definition at line 64 of file screen.hpp.

## SetCursor()

void SetCursor | ( | Cursor | cursor | ) |

inline inherited

Definition at line 65 of file screen.hpp.

## RegisterHyperlink()

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

inherited

Definition at line 533 of file screen.cpp.

## Hyperlink()

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

inherited

Definition at line 546 of file screen.cpp.

## GetSelectionStyle()

const Screen::SelectionStyle & GetSelectionStyle | ( |  | ) | const

inherited

Return the current selection style.

See also
  SetSelectionStyle

Definition at line 555 of file screen.cpp.

## SetSelectionStyle()

void SetSelectionStyle | ( | SelectionStyle | decorator | ) |

inherited

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

  x | The cell position along the x-axis.
  y | The 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

  x | The cell position along the x-axis.
  y | The 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

  x | The cell position along the x-axis.
  y | The 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

  x | The cell position along the x-axis.
  y | The cell position along the y-axis.

Definition at line 50 of file image.cpp.

## dimx()

int dimx | ( |  | ) | const

inline inherited

Definition at line 32 of file image.hpp.

## dimy()

int dimy | ( |  | ) | const

inline inherited

Definition at line 33 of file image.hpp.

## Field Documentation

## Private

friend Private

Definition at line 162 of file screen_interactive.hpp.

## cursor_

Cursor cursor_

protected inherited

Definition at line 77 of file screen.hpp.

## hyperlinks_

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

protected inherited

Definition at line 78 of file screen.hpp.

## selection_style_

SelectionStyle selection_style_

protected inherited

Initial value:
= [](Pixel& pixel) {
pixel.inverted ^= true;
}
ftxui::Pixel
A Unicode character and its associated style.
Definition pixel.hpp:15

Definition at line 81 of file screen.hpp.

## stencil

Box stencil

inherited

Definition at line 38 of file image.hpp.

## dimx_

int dimx_

protected inherited

Definition at line 41 of file image.hpp.

## dimy_

int dimy_

protected inherited

Definition at line 42 of file image.hpp.

## pixels_

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

protected inherited

Definition at line 43 of file image.hpp.

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

- include/ftxui/component/screen_interactive.hpp
- src/ftxui/component/screen_interactive.cpp