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/// @ingroup screen
17class Surface {
18 public:
19 // Constructors:
20 Surface() = delete;
21 Surface(int dimx, int dimy);
22
23 // Destructor:
24 virtual ~Surface() = default;
25
26 // Access a character in the grid at a given position.
27 std::string& at(int x, int y);
28 const std::string& at(int x, int y) const;
29
30 // Access a cell (Cell) in the grid at a given position.
31 Cell& CellAt(int x, int y);
32 const Cell& CellAt(int x, int y) const;
33
34 // [Deprecated] alias for CellAt.
35 Cell& PixelAt(int x, int y) { return CellAt(x, y); }
36 const Cell& PixelAt(int x, int y) const { return CellAt(x, y); }
37
38 // Get screen dimensions.
39 int dimx() const { return dimx_; }
40 int dimy() const { return dimy_; }
41
42 // Fill the surface with space and default style
43 void Clear();
44
46
47 protected:
48 int dimx_;
49 int dimy_;
50 std::vector<std::vector<Cell>> cells_;
51};
52
53} // namespace ftxui
54
55#endif // FTXUI_SCREEN_SURFACE_HPP
int dimy() const
Definition surface.hpp:40
const Cell & PixelAt(int x, int y) const
Definition surface.hpp:36
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:35
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:50
virtual ~Surface()=default
int dimx() const
Definition surface.hpp:39
Surface()=delete
A rectangular grid of Cell.
Definition surface.hpp:17
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:15
The FTXUI ftxui:: namespace.
Definition animation.hpp:10