FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
surface.hpp
Go to the documentation of this file.
1// Copyright 2024 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_SCREEN_SURFACE_HPP
5#define FTXUI_SCREEN_SURFACE_HPP
6
7#include <string> // for string, basic_string, allocator
8#include <vector> // for vector
9
10#include "ftxui/screen/box.hpp" // for Box
11#include "ftxui/screen/cell.hpp" // for Cell
12
13namespace ftxui {
14
15/// @brief A rectangular grid of Cell.
16///
17/// @note This class was previously named Image.
18///
19/// @ingroup screen
20class Surface {
21 public:
22 // Constructors:
23 Surface() = delete;
24 Surface(int dimx, int dimy);
25
26 // Destructor:
27 virtual ~Surface() = default;
28
29 // Access a character in the grid at a given position.
30 std::string& at(int x, int y);
31 const std::string& at(int x, int y) const;
32
33 // Access a cell (Cell) in the grid at a given position.
34 Cell& CellAt(int x, int y);
35 const Cell& CellAt(int x, int y) const;
36
37 // [Deprecated] alias for CellAt.
38 Cell& PixelAt(int x, int y) { return CellAt(x, y); }
39 const Cell& PixelAt(int x, int y) const { return CellAt(x, y); }
40
41 // Get screen dimensions.
42 int dimx() const { return dimx_; }
43 int dimy() const { return dimy_; }
44
45 // Fill the surface with space and default style
46 void Clear();
47
49
50 protected:
51 int dimx_;
52 int dimy_;
53 std::vector<std::vector<Cell>> cells_;
54};
55
56} // namespace ftxui
57
58#endif // FTXUI_SCREEN_SURFACE_HPP
int dimy() const
Definition surface.hpp:43
const Cell & PixelAt(int x, int y) const
Definition surface.hpp:39
std::string & at(int x, int y)
Access a character in a cell at a given position.
Definition surface.cpp:29
Cell & PixelAt(int x, int y)
Definition surface.hpp:38
Cell & CellAt(int x, int y)
Access a cell (Cell) at a given position.
Definition surface.cpp:43
void Clear()
Clear all the cells from the surface.
Definition surface.cpp:55
std::vector< std::vector< Cell > > cells_
Definition surface.hpp:53
virtual ~Surface()=default
int dimx() const
Definition surface.hpp:42
Surface()=delete
A rectangular grid of Cell.
Definition surface.hpp:20
Box is a structure that represents a rectangular area in a 2D space.
Definition box.hpp:16
A Unicode character and its associated style.
Definition cell.hpp:18
The FTXUI ftxui:: namespace.
Definition animation.hpp:10