1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
/*
* Copyright (C) 2018-2021 Miloš Stojanović
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#ifndef TERMINAL_H
#define TERMINAL_H
#include <vector>
#include "Color.h"
#include "TerminalChar.h"
class Terminal {
protected:
unsigned NumberOfRows {0};
unsigned NumberOfColumns {0};
public:
Terminal();
virtual ~Terminal();
unsigned GetNumberOfRows() { return NumberOfRows; }
unsigned GetNumberOfColumns() { return NumberOfColumns; }
virtual void Reset() = 0;
virtual void Draw(unsigned x, unsigned y, const char *mchar, int colorShade) = 0;
virtual void Erase(unsigned x, unsigned y) = 0;
virtual void DrawTitle(unsigned x, unsigned y, wchar_t tchar) = 0;
virtual void Flush() = 0;
};
template <bool F>
class ColorTerminal : public Terminal {
using TCharType = TerminalChar<F>;
std::vector<TCharType> ScreenBuffer;
public:
ColorTerminal<F>(const Color& color, const Color& background_color);
void Reset() final;
void Draw(unsigned x, unsigned y, const char *mchar, int colorShade) final;
void Erase(unsigned x, unsigned y) final;
void DrawTitle(unsigned x, unsigned y, wchar_t tchar) final;
void Flush() final;
};
#endif
|