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