2019-01-07 00:10:35 +08:00
|
|
|
#ifndef FTXUI_SCREEN_SCREEN
|
|
|
|
#define FTXUI_SCREEN_SCREEN
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
|
2019-01-07 00:10:35 +08:00
|
|
|
#include "ftxui/screen/color.hpp"
|
2019-01-20 05:06:05 +08:00
|
|
|
#include "ftxui/screen/box.hpp"
|
2018-10-12 15:23:37 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2018-10-10 01:06:03 +08:00
|
|
|
class Node;
|
|
|
|
}
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2019-01-07 00:10:35 +08:00
|
|
|
|
2018-10-10 01:06:03 +08:00
|
|
|
struct Pixel {
|
|
|
|
wchar_t character = U' ';
|
2018-10-21 20:18:11 +08:00
|
|
|
bool blink = false;
|
2018-10-10 01:06:03 +08:00
|
|
|
bool bold = false;
|
2018-10-21 20:18:11 +08:00
|
|
|
bool dim = false;
|
2018-10-10 01:06:03 +08:00
|
|
|
bool inverted = false;
|
|
|
|
bool underlined = false;
|
2018-10-12 15:23:37 +08:00
|
|
|
Color background_color = Color::Default;
|
|
|
|
Color foreground_color = Color::Default;
|
2018-10-10 01:06:03 +08:00
|
|
|
};
|
|
|
|
|
2019-01-27 04:52:55 +08:00
|
|
|
struct Dimension {
|
|
|
|
static Dimension Fixed(int);
|
|
|
|
static Dimension Fit(std::unique_ptr<Node>&);
|
|
|
|
static Dimension Full();
|
|
|
|
|
|
|
|
int dimx;
|
|
|
|
int dimy;
|
|
|
|
};
|
|
|
|
|
2018-10-10 01:06:03 +08:00
|
|
|
class Screen {
|
|
|
|
public:
|
|
|
|
// Constructor.
|
2019-01-27 04:52:55 +08:00
|
|
|
Screen(int dimx, int dimy);
|
|
|
|
static Screen Create(Dimension dimension);
|
|
|
|
static Screen Create(Dimension width, Dimension height);
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
// Node write into the screen using Screen::at.
|
2019-01-27 04:52:55 +08:00
|
|
|
wchar_t& at(int x, int y);
|
|
|
|
Pixel& PixelAt(int x, int y);
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
// Convert the screen into a printable string in the terminal.
|
|
|
|
std::string ToString();
|
|
|
|
|
|
|
|
// Get screen dimensions.
|
2019-01-27 04:52:55 +08:00
|
|
|
int dimx() { return dimx_;}
|
|
|
|
int dimy() { return dimy_;}
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
// Move the terminal cursor n-lines up with n = dimy().
|
|
|
|
std::string ResetPosition();
|
|
|
|
|
|
|
|
// Fill with space.
|
|
|
|
void Clear();
|
|
|
|
|
2019-01-19 07:20:29 +08:00
|
|
|
void ApplyShader();
|
2019-01-20 05:06:05 +08:00
|
|
|
Box stencil;
|
2019-01-19 07:20:29 +08:00
|
|
|
|
2019-01-05 09:03:49 +08:00
|
|
|
protected:
|
2019-01-27 04:52:55 +08:00
|
|
|
int dimx_;
|
|
|
|
int dimy_;
|
2018-10-10 01:06:03 +08:00
|
|
|
std::vector<std::vector<Pixel>> pixels_;
|
|
|
|
};
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
}; // namespace ftxui
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-07 00:10:35 +08:00
|
|
|
#endif /* end of include guard: FTXUI_SCREEN_SCREEN */
|